diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2018-05-14 10:49:21 -0400 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2018-05-15 13:05:33 -0400 |
commit | df4b551101995817b71a47ec85d58190d069540a (patch) | |
tree | 5adda3290655b19428a6d90813bddae0620f5cf6 /src/mongo/rpc | |
parent | a21671327a148a84c2246437f7f3c3367838855e (diff) | |
download | mongo-df4b551101995817b71a47ec85d58190d069540a.tar.gz |
SERVER-34345 replace ...WITH_VALIDATOR macros to ->withValidator syntax.
metaprogramming compactness
mark unused auto pointer
change is_same value use from {} to ::value
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r-- | src/mongo/rpc/object_check.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/mongo/rpc/object_check.cpp b/src/mongo/rpc/object_check.cpp index 37a8a8c77a6..03067d45591 100644 --- a/src/mongo/rpc/object_check.cpp +++ b/src/mongo/rpc/object_check.cpp @@ -32,30 +32,28 @@ #include "mongo/base/status.h" #include "mongo/bson/bson_depth.h" #include "mongo/db/server_parameters.h" +#include "mongo/platform/compiler.h" #include "mongo/util/stringutils.h" namespace mongo { namespace { -class MaxBSONDepthParameter - : public ExportedServerParameter<std::int32_t, ServerParameterType::kStartupOnly> { -public: - MaxBSONDepthParameter() - : ExportedServerParameter<std::int32_t, ServerParameterType::kStartupOnly>( - ServerParameterSet::getGlobal(), "maxBSONDepth", &BSONDepth::maxAllowableDepth) {} - virtual Status validate(const std::int32_t& potentialNewValue) { - if (potentialNewValue < BSONDepth::kBSONDepthParameterFloor || - potentialNewValue > BSONDepth::kBSONDepthParameterCeiling) { - return Status(ErrorCodes::BadValue, - str::stream() << "maxBSONDepth must be between " - << BSONDepth::kBSONDepthParameterFloor - << " and " - << BSONDepth::kBSONDepthParameterCeiling - << ", inclusive"); - } - return Status::OK(); - } -} maxBSONDepthParameter; +MONGO_COMPILER_VARIABLE_UNUSED auto _exportedMaxBSONDepth = + (new ExportedServerParameter<std::int32_t, ServerParameterType::kStartupOnly>( + ServerParameterSet::getGlobal(), "maxBSONDepth", &BSONDepth::maxAllowableDepth)) + -> withValidator([](const std::int32_t& potentialNewValue) { + if (potentialNewValue < BSONDepth::kBSONDepthParameterFloor || + potentialNewValue > BSONDepth::kBSONDepthParameterCeiling) { + return Status(ErrorCodes::BadValue, + str::stream() << "maxBSONDepth must be between " + << BSONDepth::kBSONDepthParameterFloor + << " and " + << BSONDepth::kBSONDepthParameterCeiling + << ", inclusive"); + } + return Status::OK(); + }); + } // namespace Status Validator<BSONObj>::validateStore(const BSONObj& toStore) { |