1 | // |
---|---|
2 | // ResponseMessage.cpp |
3 | // |
4 | // Library: MongoDB |
5 | // Package: MongoDB |
6 | // Module: ResponseMessage |
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/ResponseMessage.h" |
16 | #include "Poco/Net/SocketStream.h" |
17 | |
18 | |
19 | namespace Poco { |
20 | namespace MongoDB { |
21 | |
22 | |
23 | ResponseMessage::ResponseMessage(): |
24 | Message(MessageHeader::OP_REPLY), |
25 | _responseFlags(0), |
26 | _cursorID(0), |
27 | _startingFrom(0), |
28 | _numberReturned(0) |
29 | { |
30 | } |
31 | |
32 | |
33 | ResponseMessage::~ResponseMessage() |
34 | { |
35 | } |
36 | |
37 | |
38 | void ResponseMessage::clear() |
39 | { |
40 | _responseFlags = 0; |
41 | _startingFrom = 0; |
42 | _cursorID = 0; |
43 | _numberReturned = 0; |
44 | _documents.clear(); |
45 | } |
46 | |
47 | |
48 | void ResponseMessage::read(std::istream& istr) |
49 | { |
50 | clear(); |
51 | |
52 | BinaryReader reader(istr, BinaryReader::LITTLE_ENDIAN_BYTE_ORDER); |
53 | |
54 | _header.read(reader); |
55 | |
56 | reader >> _responseFlags; |
57 | reader >> _cursorID; |
58 | reader >> _startingFrom; |
59 | reader >> _numberReturned; |
60 | |
61 | for (int i = 0; i < _numberReturned; ++i) |
62 | { |
63 | Document::Ptr doc = new Document(); |
64 | doc->read(reader); |
65 | _documents.push_back(doc); |
66 | } |
67 | } |
68 | |
69 | |
70 | } } // namespace Poco::MongoDB |
71 |