diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/rpc/command_request.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/rpc/command_request.cpp')
-rw-r--r-- | src/mongo/rpc/command_request.cpp | 141 |
1 files changed, 67 insertions, 74 deletions
diff --git a/src/mongo/rpc/command_request.cpp b/src/mongo/rpc/command_request.cpp index d5fd8fa4515..961c4ba7d93 100644 --- a/src/mongo/rpc/command_request.cpp +++ b/src/mongo/rpc/command_request.cpp @@ -47,93 +47,86 @@ namespace mongo { namespace rpc { - namespace { - // None of these include null byte - const std::size_t kMaxDatabaseLength = 63; - const std::size_t kMinDatabaseLength = 1; +namespace { +// None of these include null byte +const std::size_t kMaxDatabaseLength = 63; +const std::size_t kMinDatabaseLength = 1; - const std::size_t kMinCommandNameLength = 1; - const std::size_t kMaxCommandNameLength = 128; +const std::size_t kMinCommandNameLength = 1; +const std::size_t kMaxCommandNameLength = 128; - } // namespace +} // namespace - CommandRequest::CommandRequest(const Message* message) - : _message(message) { - char* begin = _message->singleData().data(); - std::size_t length = _message->singleData().dataLen(); +CommandRequest::CommandRequest(const Message* message) : _message(message) { + char* begin = _message->singleData().data(); + std::size_t length = _message->singleData().dataLen(); - // checked in message_port.cpp - invariant(length <= MaxMessageSizeBytes); + // checked in message_port.cpp + invariant(length <= MaxMessageSizeBytes); - const char* messageEnd = begin + length; + const char* messageEnd = begin + length; - ConstDataRangeCursor cur(begin, messageEnd); + ConstDataRangeCursor cur(begin, messageEnd); - _database = uassertStatusOK(cur.readAndAdvance<Terminated<'\0', StringData>>()); + _database = uassertStatusOK(cur.readAndAdvance<Terminated<'\0', StringData>>()); - uassert(28636, str::stream() << "Database parsed in OP_COMMAND message must be between" - << kMinDatabaseLength << " and " << kMaxDatabaseLength - << " bytes. Got: " << _database, - (_database.size() >= kMinDatabaseLength) && - (_database.size() <= kMaxDatabaseLength)); + uassert(28636, + str::stream() << "Database parsed in OP_COMMAND message must be between" + << kMinDatabaseLength << " and " << kMaxDatabaseLength + << " bytes. Got: " << _database, + (_database.size() >= kMinDatabaseLength) && (_database.size() <= kMaxDatabaseLength)); - uassert(ErrorCodes::InvalidNamespace, - str::stream() << "Invalid database name: '" << _database << "'", - NamespaceString::validDBName(_database)); + uassert(ErrorCodes::InvalidNamespace, + str::stream() << "Invalid database name: '" << _database << "'", + NamespaceString::validDBName(_database)); - _commandName = uassertStatusOK(cur.readAndAdvance<Terminated<'\0', StringData>>()); + _commandName = uassertStatusOK(cur.readAndAdvance<Terminated<'\0', StringData>>()); - uassert(28637, str::stream() << "Command name parsed in OP_COMMAND message must be between" - << kMinCommandNameLength << " and " << kMaxCommandNameLength - << " bytes. Got: " << _database, - (_commandName.size() >= kMinCommandNameLength) && + uassert(28637, + str::stream() << "Command name parsed in OP_COMMAND message must be between" + << kMinCommandNameLength << " and " << kMaxCommandNameLength + << " bytes. Got: " << _database, + (_commandName.size() >= kMinCommandNameLength) && (_commandName.size() <= kMaxCommandNameLength)); - _metadata = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); - _commandArgs = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); - _inputDocs = DocumentRange{cur.data(), messageEnd}; - } - - StringData CommandRequest::getDatabase() const { - return _database; - } - - StringData CommandRequest::getCommandName() const { - return _commandName; - } - - const BSONObj& CommandRequest::getMetadata() const { - return _metadata; - } - - const BSONObj& CommandRequest::getCommandArgs() const { - return _commandArgs; - } - - DocumentRange CommandRequest::getInputDocs() const { - return _inputDocs; - } - - bool operator==(const CommandRequest& lhs, const CommandRequest& rhs) { - return std::tie(lhs._database, - lhs._commandName, - lhs._metadata, - lhs._commandArgs, - lhs._inputDocs) == - std::tie(rhs._database, - rhs._commandName, - rhs._metadata, - rhs._commandArgs, - rhs._inputDocs); - } - - bool operator!=(const CommandRequest& lhs, const CommandRequest& rhs) { - return !(lhs == rhs); - } - - Protocol CommandRequest::getProtocol() const { - return rpc::Protocol::kOpCommandV1; - } + _metadata = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); + _commandArgs = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); + _inputDocs = DocumentRange{cur.data(), messageEnd}; +} + +StringData CommandRequest::getDatabase() const { + return _database; +} + +StringData CommandRequest::getCommandName() const { + return _commandName; +} + +const BSONObj& CommandRequest::getMetadata() const { + return _metadata; +} + +const BSONObj& CommandRequest::getCommandArgs() const { + return _commandArgs; +} + +DocumentRange CommandRequest::getInputDocs() const { + return _inputDocs; +} + +bool operator==(const CommandRequest& lhs, const CommandRequest& rhs) { + return std::tie( + lhs._database, lhs._commandName, lhs._metadata, lhs._commandArgs, lhs._inputDocs) == + std::tie(rhs._database, rhs._commandName, rhs._metadata, rhs._commandArgs, rhs._inputDocs); +} + +bool operator!=(const CommandRequest& lhs, const CommandRequest& rhs) { + return !(lhs == rhs); +} + +Protocol CommandRequest::getProtocol() const { + return rpc::Protocol::kOpCommandV1; +} } // namespace rpc } // namespace mongo |