20 #include "mongo/bson/bson_validate.h"
21 #include "mongo/client/constants.h"
23 #include "mongo/util/net/message.h"
24 #include "mongo/util/net/message_port.h"
80 namespace QueryResult {
94 ConstView(
const char* storage) : _storage(storage) {}
96 const char* view2ptr()
const {
97 return storage().view();
101 return storage().view(offsetof(
Layout, msgdata));
104 int64_t getCursorId()
const {
105 return storage().readLE<int64_t>(offsetof(
Layout, cursorId));
108 int32_t getStartingFrom()
const {
109 return storage().readLE<int32_t>(offsetof(
Layout, startingFrom));
112 int32_t getNReturned()
const {
113 return storage().readLE<int32_t>(offsetof(
Layout, nReturned));
116 const char* data()
const {
117 return storage().view(
sizeof(
Layout));
133 using ConstView::view2ptr;
135 return storage().view();
138 using ConstView::msgdata;
140 return storage().view(offsetof(
Layout, msgdata));
143 void setCursorId(int64_t value) {
144 storage().writeLE(value, offsetof(
Layout, cursorId));
147 void setStartingFrom(int32_t value) {
148 storage().writeLE(value, offsetof(
Layout, startingFrom));
151 void setNReturned(int32_t value) {
152 storage().writeLE(value, offsetof(
Layout, nReturned));
155 int32_t getResultFlags() {
156 return DataView(msgdata().data()).readLE<int32_t>();
159 void setResultFlags(int32_t value) {
160 DataView(msgdata().data()).writeLE(value);
163 void setResultFlagsToOk() {
164 setResultFlags(ResultFlag_AwaitCapable);
167 void initializeResultFlags() {
173 return const_cast<char*
>(ConstView::view2ptr());
180 BOOST_STATIC_ASSERT(
sizeof(
Value) ==
sizeof(
Layout));
195 BOOST_STATIC_ASSERT(
sizeof(
int) == 4);
203 bool messageShouldHaveNs()
const {
204 return (_msg.operation() >= dbMsg) & (_msg.operation() <= dbDelete);
216 const char* getns()
const;
217 int getQueryNToReturn()
const;
220 long long pullInt64();
221 const char* getArray(
size_t count)
const;
224 bool moreJSObjs()
const {
225 return _nextjsobj != 0;
230 const Message& msg()
const {
234 const char* markGet()
const {
242 void markReset(
const char* toMark);
246 template <
typename T>
247 void checkRead(
const char* start,
size_t count = 0)
const;
250 template <
typename T>
254 template <
typename T>
260 const char* _nsStart;
261 const char* _nextjsobj;
286 ntoskip = d.pullInt();
287 ntoreturn = d.pullInt();
288 query = d.nextJsObj();
289 if (d.moreJSObjs()) {
290 fields = d.nextJsObj();
292 queryOptions =
DataView(d.msg().header().data()).readLE<int32_t>();
302 std::string exhaustNS;
312 void replyToQuery(
int queryResultFlags,
318 int startingFrom = 0,
319 long long cursorId = 0);
323 void replyToQuery(
int queryResultFlags,
339 void replyToQuery(
int queryResultFlags,
Message& response,
const BSONObj& resultObj);
Definition: message_port.h:34
Definition: message.h:305
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
Definition: dbmessage.h:84
Definition: message.h:193
Definition: data_view.h:30
Definition: dbmessage.h:177
Definition: dbmessage.h:193
Definition: dbmessage.h:271
Definition: encoded_value_storage.h:24
Definition: dbmessage.h:129
Definition: dbmessage.h:92
Definition: message.h:250
A response to a DbMessage.
Definition: dbmessage.h:299
QueryMessage(DbMessage &d)
parses the message into the above fields Warning: constructor mutates DbMessage.
Definition: dbmessage.h:284
Definition: message.h:187
Definition: encoded_value_storage.h:31
Definition: data_view.h:71
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78
int reservedField() const
the 32 bit field before the ns track all bit usage here as its cross op 0: InsertOption_ContinueOnErr...
Definition: dbmessage.h:212