summaryrefslogtreecommitdiff
path: root/src/mongo/util/options_parser/environment.cpp
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-08-18 11:23:55 -0700
committerShaun Verch <shaun.verch@10gen.com>2013-09-05 13:49:33 -0400
commit43e7502572b4a217eb3f57eee479585ae2a2d19e (patch)
tree7db0ce4aec250b4147ec03842c526a194eda64c0 /src/mongo/util/options_parser/environment.cpp
parent4ffd53218fc9d8ad63e34c7cfec4247da2d1bef7 (diff)
downloadmongo-43e7502572b4a217eb3f57eee479585ae2a2d19e.tar.gz
SERVER-8510 Added legacy interface to Environment and Value to ease transition from variables_map
Diffstat (limited to 'src/mongo/util/options_parser/environment.cpp')
-rw-r--r--src/mongo/util/options_parser/environment.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/util/options_parser/environment.cpp b/src/mongo/util/options_parser/environment.cpp
index 0db43abef4a..78524b7e408 100644
--- a/src/mongo/util/options_parser/environment.cpp
+++ b/src/mongo/util/options_parser/environment.cpp
@@ -135,6 +135,29 @@ namespace optionenvironment {
return Status::OK();
}
+ /** Implementation of legacy interface to be consistent with
+ * boost::program_options::variables_map during the transition period
+ *
+ * boost::program_options::variables_map inherits the count function from std::map, which
+ * returns 1 if the value is set, and 0 if it is not set
+ */
+ bool Environment::count(const Key& key) const {
+ Value value;
+ Status ret = get(key, &value);
+ if (ret.isOK()) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ Value Environment::operator[](const Key& key) const {
+ Value value;
+ Status ret = get(key, &value);
+ return value;
+ }
+
/* Debugging */
void Environment::dump() {
std::map<Key, Value>::iterator iter;