summaryrefslogtreecommitdiff
path: root/src/mongo/util/options_parser/option_description.cpp
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-12-06 03:15:44 -0500
committerShaun Verch <shaun.verch@10gen.com>2013-12-06 12:57:58 -0500
commit6bef7b4fa2b5648e11da5aeb4f44b2f6bae7952d (patch)
tree7ce7c82018c8d926c21d4c86aafe912c3036c92d /src/mongo/util/options_parser/option_description.cpp
parent0f0bd1d058375234a639928f90dab26293a584eb (diff)
downloadmongo-6bef7b4fa2b5648e11da5aeb4f44b2f6bae7952d.tar.gz
SERVER-11143 Added support for specifying that a string option must be of a specified format
Diffstat (limited to 'src/mongo/util/options_parser/option_description.cpp')
-rw-r--r--src/mongo/util/options_parser/option_description.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/util/options_parser/option_description.cpp b/src/mongo/util/options_parser/option_description.cpp
index 6acb0e3371f..c7cba2cc3e2 100644
--- a/src/mongo/util/options_parser/option_description.cpp
+++ b/src/mongo/util/options_parser/option_description.cpp
@@ -225,5 +225,19 @@ namespace optionenvironment {
return addConstraint(new RequiresOtherKeyConstraint(_dottedName, otherDottedName));
}
+ OptionDescription& OptionDescription::format(const std::string& regexFormat,
+ const std::string& displayFormat) {
+ if (_type != String) {
+ StringBuilder sb;
+ sb << "Could not register option \"" << _dottedName << "\": "
+ << "only options registered as a string type can have a required format, "
+ << "but option has type: " << _type;
+ throw DBException(sb.str(), ErrorCodes::InternalError);
+ }
+
+ return addConstraint(new StringFormatKeyConstraint(_dottedName, regexFormat,
+ displayFormat));
+ }
+
} // namespace optionenvironment
} // namespace mongo