Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/OpMsgMessage.h
Description
This class represents a request/response (OP_MSG) to send requests and receive responses to/from MongoDB.
THREAD SAFETY: This class is NOT thread-safe. OpMsgMessage instances must not be accessed concurrently from multiple threads without external synchronization. Each thread should use its own message instances.
Inheritance
Direct Base Classes: Message
All Base Classes: Message
Member Summary
Member Functions: acknowledgedRequest, body, clear, collectionName, commandName, databaseName, documents, flags, read, responseOk, send, setAcknowledgedRequest, setCommandName
Inherited Functions: header, messageLength
Enumerations
Flags
MSG_CHECKSUM_PRESENT = (1 << 0)
MSG_MORE_TO_COME = (1 << 1)
Sender will send another message and is not prepared for overlapping messages
MSG_EXHAUST_ALLOWED = (1 << 16)
Client is prepared for multiple replies (using the moreToCome bit) to this request
Constructors
OpMsgMessage
OpMsgMessage();
Creates an OpMsgMessage for response.
OpMsgMessage
OpMsgMessage(
const std::string & databaseName,
const std::string & collectionName,
UInt32 flags = MSG_FLAGS_DEFAULT
);
Creates an OpMsgMessage for requests.
Destructor
~OpMsgMessage
virtual ~OpMsgMessage();
Member Functions
acknowledgedRequest
[[nodiscard]]
bool acknowledgedRequest() const;
body
Document & body();
Access to body document. Additional query arguments shall be added after setting the command name.
body
[[nodiscard]]
const Document & body() const;
clear
void clear();
Clears the message.
collectionName
[[nodiscard]]
const std::string & collectionName() const;
commandName
[[nodiscard]]
const std::string & commandName() const;
Current command name.
databaseName
[[nodiscard]]
const std::string & databaseName() const;
documents
Document::Vector & documents();
Documents prepared for request or retrieved in response.
documents
[[nodiscard]]
const Document::Vector & documents() const;
Documents prepared for request or retrieved in response.
flags
[[nodiscard]]
UInt32 flags() const;
read
void read(
std::istream & istr
);
Reads the response from the stream.
responseOk
[[nodiscard]]
bool responseOk() const;
Reads "ok" status from the response message.
send
void send(
std::ostream & ostr
);
Writes the request to stream.
setAcknowledgedRequest
void setAcknowledgedRequest(
bool ack
);
Set false to create request that does not return response. It has effect only for commands that write or delete documents. Default is true (request returns acknowledge response).
setCommandName
void setCommandName(
const std::string & command
);
Sets the command name and clears the command document
Variables
CMD_AGGREGATE
static const std::string CMD_AGGREGATE;
CMD_BUILD_INFO
static const std::string CMD_BUILD_INFO;
CMD_COLL_STATS
static const std::string CMD_COLL_STATS;
CMD_COUNT
static const std::string CMD_COUNT;
CMD_CREATE
static const std::string CMD_CREATE;
CMD_CREATE_INDEXES
static const std::string CMD_CREATE_INDEXES;
CMD_DB_STATS
static const std::string CMD_DB_STATS;
CMD_DELETE
static const std::string CMD_DELETE;
CMD_DISTINCT
static const std::string CMD_DISTINCT;
CMD_DROP
static const std::string CMD_DROP;
CMD_DROP_DATABASE
static const std::string CMD_DROP_DATABASE;
CMD_FIND
static const std::string CMD_FIND;
CMD_FIND_AND_MODIFY
static const std::string CMD_FIND_AND_MODIFY;
CMD_HELLO
static const std::string CMD_HELLO;
CMD_HOST_INFO
static const std::string CMD_HOST_INFO;
CMD_INSERT
static const std::string CMD_INSERT;
CMD_KILL_CURSORS
static const std::string CMD_KILL_CURSORS;
CMD_LIST_DATABASES
static const std::string CMD_LIST_DATABASES;
CMD_LIST_INDEXES
static const std::string CMD_LIST_INDEXES;
CMD_MAP_REDUCE
static const std::string CMD_MAP_REDUCE;
CMD_REPL_SET_GET_CONFIG
static const std::string CMD_REPL_SET_GET_CONFIG;
CMD_REPL_SET_GET_STATUS
static const std::string CMD_REPL_SET_GET_STATUS;
CMD_UPDATE
static const std::string CMD_UPDATE;