summaryrefslogtreecommitdiff
path: root/src/mongo/db/server_parameters.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/server_parameters.cpp')
-rw-r--r--src/mongo/db/server_parameters.cpp142
1 files changed, 69 insertions, 73 deletions
diff --git a/src/mongo/db/server_parameters.cpp b/src/mongo/db/server_parameters.cpp
index 0aeef5b4a42..7c8ade05063 100644
--- a/src/mongo/db/server_parameters.cpp
+++ b/src/mongo/db/server_parameters.cpp
@@ -36,84 +36,80 @@
namespace mongo {
- using std::string;
- using std::vector;
-
- namespace {
- ServerParameterSet* GLOBAL = NULL;
- }
-
- ServerParameter::ServerParameter( ServerParameterSet* sps, const std::string& name,
- bool allowedToChangeAtStartup, bool allowedToChangeAtRuntime )
- : _name( name ),
- _allowedToChangeAtStartup( allowedToChangeAtStartup ),
- _allowedToChangeAtRuntime( allowedToChangeAtRuntime ) {
-
- if ( sps ) {
- sps->add( this );
- }
- }
-
- ServerParameter::ServerParameter( ServerParameterSet* sps, const std::string& name )
- : _name( name ),
- _allowedToChangeAtStartup( true ),
- _allowedToChangeAtRuntime( true ) {
-
- if ( sps ) {
- sps->add( this );
- }
- }
-
- ServerParameter::~ServerParameter() {
+using std::string;
+using std::vector;
+
+namespace {
+ServerParameterSet* GLOBAL = NULL;
+}
+
+ServerParameter::ServerParameter(ServerParameterSet* sps,
+ const std::string& name,
+ bool allowedToChangeAtStartup,
+ bool allowedToChangeAtRuntime)
+ : _name(name),
+ _allowedToChangeAtStartup(allowedToChangeAtStartup),
+ _allowedToChangeAtRuntime(allowedToChangeAtRuntime) {
+ if (sps) {
+ sps->add(this);
}
+}
- ServerParameterSet* ServerParameterSet::getGlobal() {
- if ( !GLOBAL ) {
- GLOBAL = new ServerParameterSet();
- }
- return GLOBAL;
+ServerParameter::ServerParameter(ServerParameterSet* sps, const std::string& name)
+ : _name(name), _allowedToChangeAtStartup(true), _allowedToChangeAtRuntime(true) {
+ if (sps) {
+ sps->add(this);
}
+}
- void ServerParameterSet::add( ServerParameter* sp ) {
- ServerParameter*& x = _map[sp->name()];
- if ( x ) abort();
- x = sp;
- }
-
- template <typename T>
- Status ExportedServerParameter<T>::setFromString( const string& str ) {
- T value;
- Status status = parseNumberFromString( str, &value );
- if ( !status.isOK() )
- return status;
- return set( value );
- }
-
- template Status ExportedServerParameter<int>::setFromString( const string& str );
- template Status ExportedServerParameter<long long>::setFromString( const string& str );
- template Status ExportedServerParameter<double>::setFromString( const string& str );
-
- template<>
- Status ExportedServerParameter<string>::setFromString( const string& str ) {
- return set( str );
- }
-
- template<>
- Status ExportedServerParameter<bool>::setFromString( const string& str ) {
- if ( str == "true" ||
- str == "1" )
- return set(true);
- if ( str == "false" ||
- str == "0" )
- return set(false);
- return Status( ErrorCodes::BadValue, "can't convert string to bool" );
- }
+ServerParameter::~ServerParameter() {}
- template<>
- Status ExportedServerParameter< vector<string> >::setFromString( const string& str ) {
- vector<string> v;
- splitStringDelim( str, &v, ',' );
- return set( v );
+ServerParameterSet* ServerParameterSet::getGlobal() {
+ if (!GLOBAL) {
+ GLOBAL = new ServerParameterSet();
}
+ return GLOBAL;
+}
+
+void ServerParameterSet::add(ServerParameter* sp) {
+ ServerParameter*& x = _map[sp->name()];
+ if (x)
+ abort();
+ x = sp;
+}
+
+template <typename T>
+Status ExportedServerParameter<T>::setFromString(const string& str) {
+ T value;
+ Status status = parseNumberFromString(str, &value);
+ if (!status.isOK())
+ return status;
+ return set(value);
+}
+
+template Status ExportedServerParameter<int>::setFromString(const string& str);
+template Status ExportedServerParameter<long long>::setFromString(const string& str);
+template Status ExportedServerParameter<double>::setFromString(const string& str);
+
+template <>
+Status ExportedServerParameter<string>::setFromString(const string& str) {
+ return set(str);
+}
+
+template <>
+Status ExportedServerParameter<bool>::setFromString(const string& str) {
+ if (str == "true" || str == "1")
+ return set(true);
+ if (str == "false" || str == "0")
+ return set(false);
+ return Status(ErrorCodes::BadValue, "can't convert string to bool");
+}
+
+template <>
+Status ExportedServerParameter<vector<string>>::setFromString(const string& str) {
+ vector<string> v;
+ splitStringDelim(str, &v, ',');
+ return set(v);
+}
} // namespace mongo