1
// server_parameters_inline.h
4
* Copyright (C) 2012 10gen Inc.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Affero General Public License, version 3,
8
* as published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include "mongo/util/stringutils.h"
24
inline Status ExportedServerParameter<T>::set( const BSONElement& newValueElement ) {
27
if ( !newValueElement.coerce( &newValue) )
28
return Status( ErrorCodes::BadValue, "can't set value" );
30
return set( newValue );
34
inline Status ExportedServerParameter<T>::set( const T& newValue ) {
36
Status v = validate( newValue );
45
inline Status ExportedServerParameter<int>::setFromString( const string& str ) {
46
return set( atoi(str.c_str() ) );
50
inline Status ExportedServerParameter<double>::setFromString( const string& str ) {
51
const char* start = str.c_str();
53
double d = strtod( str.c_str(), &end );
55
return Status( ErrorCodes::BadValue, "not a double" );
60
inline Status ExportedServerParameter<string>::setFromString( const string& str ) {
65
inline Status ExportedServerParameter<bool>::setFromString( const string& str ) {
69
if ( str == "false" ||
72
return Status( ErrorCodes::BadValue, "can't convert string to bool" );
77
inline Status ExportedServerParameter< vector<string> >::setFromString( const string& str ) {
79
splitStringDelim( str, &v, ',' );