1 | // |
---|---|
2 | // QueryRequest.cpp |
3 | // |
4 | // Library: MongoDB |
5 | // Package: MongoDB |
6 | // Module: QueryRequest |
7 | // |
8 | // Copyright (c) 2012, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/MongoDB/QueryRequest.h" |
16 | |
17 | |
18 | namespace Poco { |
19 | namespace MongoDB { |
20 | |
21 | |
22 | QueryRequest::QueryRequest(const std::string& collectionName, QueryRequest::Flags flags): |
23 | RequestMessage(MessageHeader::OP_QUERY), |
24 | _flags(flags), |
25 | _fullCollectionName(collectionName), |
26 | _numberToSkip(0), |
27 | _numberToReturn(100), |
28 | _selector(), |
29 | _returnFieldSelector() |
30 | { |
31 | } |
32 | |
33 | |
34 | QueryRequest::~QueryRequest() |
35 | { |
36 | } |
37 | |
38 | |
39 | void QueryRequest::buildRequest(BinaryWriter& writer) |
40 | { |
41 | writer << _flags; |
42 | BSONWriter(writer).writeCString(_fullCollectionName); |
43 | writer << _numberToSkip; |
44 | writer << _numberToReturn; |
45 | _selector.write(writer); |
46 | |
47 | if (!_returnFieldSelector.empty()) |
48 | { |
49 | _returnFieldSelector.write(writer); |
50 | } |
51 | } |
52 | |
53 | |
54 | } } // namespace Poco::MongoDB |
55 |