diff options
Diffstat (limited to 'src/mongo/rpc/command_reply.cpp')
-rw-r--r-- | src/mongo/rpc/command_reply.cpp | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/src/mongo/rpc/command_reply.cpp b/src/mongo/rpc/command_reply.cpp index dc8e22d8b89..954d6b051d6 100644 --- a/src/mongo/rpc/command_reply.cpp +++ b/src/mongo/rpc/command_reply.cpp @@ -41,48 +41,46 @@ namespace mongo { namespace rpc { - CommandReply::CommandReply(const Message* message) - : _message(message) { - - const char* begin = _message->singleData().data(); - std::size_t length = _message->singleData().dataLen(); - - // This check failing would normally be operation fatal, but we expect it to have been - // done earlier in the network layer, so we make it an invariant. - invariant(length <= MaxMessageSizeBytes); - - const char* messageEnd = begin + length; - ConstDataRangeCursor cur(begin, messageEnd); - - _metadata = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); - _commandReply = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); - _outputDocs = DocumentRange(cur.data(), messageEnd); - } - - const BSONObj& CommandReply::getMetadata() const { - return _metadata; - } - - const BSONObj& CommandReply::getCommandReply() const { - return _commandReply; - } - - DocumentRange CommandReply::getOutputDocs() const { - return _outputDocs; - } - - Protocol CommandReply::getProtocol() const { - return rpc::Protocol::kOpCommandV1; - } - - bool operator==(const CommandReply& lhs, const CommandReply& rhs) { - return std::tie(lhs._metadata, lhs._commandReply, lhs._outputDocs) == - std::tie(rhs._metadata, rhs._commandReply, rhs._outputDocs); - } - - bool operator!=(const CommandReply& lhs, const CommandReply& rhs) { - return !(lhs == rhs); - } +CommandReply::CommandReply(const Message* message) : _message(message) { + const char* begin = _message->singleData().data(); + std::size_t length = _message->singleData().dataLen(); + + // This check failing would normally be operation fatal, but we expect it to have been + // done earlier in the network layer, so we make it an invariant. + invariant(length <= MaxMessageSizeBytes); + + const char* messageEnd = begin + length; + ConstDataRangeCursor cur(begin, messageEnd); + + _metadata = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); + _commandReply = std::move(uassertStatusOK(cur.readAndAdvance<Validated<BSONObj>>()).val); + _outputDocs = DocumentRange(cur.data(), messageEnd); +} + +const BSONObj& CommandReply::getMetadata() const { + return _metadata; +} + +const BSONObj& CommandReply::getCommandReply() const { + return _commandReply; +} + +DocumentRange CommandReply::getOutputDocs() const { + return _outputDocs; +} + +Protocol CommandReply::getProtocol() const { + return rpc::Protocol::kOpCommandV1; +} + +bool operator==(const CommandReply& lhs, const CommandReply& rhs) { + return std::tie(lhs._metadata, lhs._commandReply, lhs._outputDocs) == + std::tie(rhs._metadata, rhs._commandReply, rhs._outputDocs); +} + +bool operator!=(const CommandReply& lhs, const CommandReply& rhs) { + return !(lhs == rhs); +} } // namespace rpc } // namespace mongo |