diff --git a/MongoDB/include/Poco/MongoDB/BSONReader.h b/MongoDB/include/Poco/MongoDB/BSONReader.h index 05e5f0553..aa4fcb38e 100644 --- a/MongoDB/include/Poco/MongoDB/BSONReader.h +++ b/MongoDB/include/Poco/MongoDB/BSONReader.h @@ -35,15 +35,19 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_BSONReader_INCLUDED #define MongoDB_BSONReader_INCLUDED + #include "Poco/MongoDB/MongoDB.h" #include "Poco/BinaryReader.h" + namespace Poco { namespace MongoDB { + class MongoDB_API BSONReader /// Class for reading BSON from a Poco::BinaryReader { @@ -85,14 +89,8 @@ inline std::string BSONReader::readCString() _reader >> c; if ( _reader.good() ) { - if (c == 0x00) - { - return val; - } - else - { - val += c; - } + if (c == 0x00) return val; + else val += c; } } return val; diff --git a/MongoDB/include/Poco/MongoDB/BSONWriter.h b/MongoDB/include/Poco/MongoDB/BSONWriter.h index a634b4db4..64e6487e0 100644 --- a/MongoDB/include/Poco/MongoDB/BSONWriter.h +++ b/MongoDB/include/Poco/MongoDB/BSONWriter.h @@ -35,12 +35,15 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_BSONWriter_INCLUDED #define MongoDB_BSONWriter_INCLUDED + #include "Poco/MongoDB/MongoDB.h" #include "Poco/BinaryWriter.h" + namespace Poco { namespace MongoDB { @@ -82,6 +85,7 @@ inline void BSONWriter::writeCString(const std::string& value) _writer << (unsigned char) 0x00; } + } } // namespace Poco::MongoDB diff --git a/MongoDB/include/Poco/MongoDB/Binary.h b/MongoDB/include/Poco/MongoDB/Binary.h index c7d458d37..a54beaaf9 100644 --- a/MongoDB/include/Poco/MongoDB/Binary.h +++ b/MongoDB/include/Poco/MongoDB/Binary.h @@ -35,21 +35,24 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_Binary_INCLUDED #define MongoDB_Binary_INCLUDED + #include "Poco/MongoDB/MongoDB.h" #include "Poco/MongoDB/Element.h" #include "Poco/Base64Encoder.h" #include "Poco/Buffer.h" #include "Poco/StreamCopier.h" #include "Poco/MemoryStream.h" - #include + namespace Poco { namespace MongoDB { + class MongoDB_API Binary /// Implements BSON Binary. It's a wrapper around a Poco::Buffer. { @@ -130,6 +133,7 @@ inline void BSONReader::read(Binary::Ptr& to) _reader.readRaw((char*) to->buffer().begin(), size); } + template<> inline void BSONWriter::write(Binary::Ptr& from) { @@ -140,4 +144,5 @@ inline void BSONWriter::write(Binary::Ptr& from) } } // namespace Poco::MongoDB + #endif // MongoDB_Binary_INCLUDED diff --git a/MongoDB/include/Poco/MongoDB/Database.h b/MongoDB/include/Poco/MongoDB/Database.h index 3ba989ff2..a05253d4d 100644 --- a/MongoDB/include/Poco/MongoDB/Database.h +++ b/MongoDB/include/Poco/MongoDB/Database.h @@ -90,7 +90,14 @@ public: Poco::SharedPtr createUpdateRequest(const std::string& collectionName) const; /// Creates an UpdateRequest. The collectionname must not contain the database name! - Poco::MongoDB::Document::Ptr ensureIndex(Connection& connection, const std::string& collection, const std::string& indexName, Poco::MongoDB::Document::Ptr keys, bool unique = false, bool background = false, int version = 0, int ttl = 0); + Poco::MongoDB::Document::Ptr ensureIndex(Connection& connection, + const std::string& collection, + const std::string& indexName, + Poco::MongoDB::Document::Ptr keys, + bool unique = false, + bool background = false, + int version = 0, + int ttl = 0); /// Creates an index. The document returned is the result of a getLastError call. /// For more info look at the ensureIndex information on the MongoDB website. @@ -114,25 +121,29 @@ inline Poco::SharedPtr Database::createCommand() co } -inline Poco::SharedPtr Database::createDeleteRequest(const std::string& collectionName) const +inline Poco::SharedPtr +Database::createDeleteRequest(const std::string& collectionName) const { return new Poco::MongoDB::DeleteRequest(_dbname + '.' + collectionName); } -inline Poco::SharedPtr Database::createInsertRequest(const std::string& collectionName) const +inline Poco::SharedPtr +Database::createInsertRequest(const std::string& collectionName) const { return new Poco::MongoDB::InsertRequest(_dbname + '.' + collectionName); } -inline Poco::SharedPtr Database::createQueryRequest(const std::string& collectionName) const +inline Poco::SharedPtr +Database::createQueryRequest(const std::string& collectionName) const { return new Poco::MongoDB::QueryRequest(_dbname + '.' + collectionName); } -inline Poco::SharedPtr Database::createUpdateRequest(const std::string& collectionName) const +inline Poco::SharedPtr +Database::createUpdateRequest(const std::string& collectionName) const { return new Poco::MongoDB::UpdateRequest(_dbname + '.' + collectionName); } diff --git a/MongoDB/include/Poco/MongoDB/DeleteRequest.h b/MongoDB/include/Poco/MongoDB/DeleteRequest.h index 9070491e1..791bc4d31 100644 --- a/MongoDB/include/Poco/MongoDB/DeleteRequest.h +++ b/MongoDB/include/Poco/MongoDB/DeleteRequest.h @@ -98,7 +98,7 @@ protected: private: Flags _flags; std::string _fullCollectionName; - Document _selector; + Document _selector; }; @@ -119,6 +119,7 @@ inline Document& DeleteRequest::selector() return _selector; } + } } // namespace Poco::MongoDB diff --git a/MongoDB/include/Poco/MongoDB/Document.h b/MongoDB/include/Poco/MongoDB/Document.h index 57b9cc2e5..1cf41e94f 100644 --- a/MongoDB/include/Poco/MongoDB/Document.h +++ b/MongoDB/include/Poco/MongoDB/Document.h @@ -67,6 +67,7 @@ private: std::string _name; }; + class MongoDB_API Document /// Represents a BSON document { @@ -270,6 +271,7 @@ inline void BSONReader::read(Document::Ptr& to) to->read(_reader); } + template<> inline void BSONWriter::write(Document::Ptr& from) { diff --git a/MongoDB/include/Poco/MongoDB/Element.h b/MongoDB/include/Poco/MongoDB/Element.h index f8e4ae29f..d8e48eb94 100644 --- a/MongoDB/include/Poco/MongoDB/Element.h +++ b/MongoDB/include/Poco/MongoDB/Element.h @@ -35,13 +35,10 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_Element_INCLUDED #define MongoDB_Element_INCLUDED -#include -#include -#include -#include #include "Poco/BinaryReader.h" #include "Poco/BinaryWriter.h" @@ -53,6 +50,11 @@ #include "Poco/MongoDB/MongoDB.h" #include "Poco/MongoDB/BSONReader.h" #include "Poco/MongoDB/BSONWriter.h" +#include +#include +#include +#include + namespace Poco { namespace MongoDB { @@ -129,7 +131,7 @@ struct ElementTraits // BSON UTF-8 string // spec: int32 (byte*) "\x00" -// int32 is the number bytes in byte* + 1 (for trailing "\x00" +// int32 is the number bytes in byte* + 1 (for trailing "\x00") template<> struct ElementTraits { @@ -226,6 +228,7 @@ inline void BSONReader::read(bool& to) to = b != 0; } + template<> inline void BSONWriter::write(bool& from) { diff --git a/MongoDB/include/Poco/MongoDB/GetMoreRequest.h b/MongoDB/include/Poco/MongoDB/GetMoreRequest.h index 0788bbf83..e7a3dac66 100644 --- a/MongoDB/include/Poco/MongoDB/GetMoreRequest.h +++ b/MongoDB/include/Poco/MongoDB/GetMoreRequest.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_GetMoreRequest_INCLUDED #define MongoDB_GetMoreRequest_INCLUDED diff --git a/MongoDB/include/Poco/MongoDB/KillCursorsRequest.h b/MongoDB/include/Poco/MongoDB/KillCursorsRequest.h index d42f58f9c..226b8e4ef 100644 --- a/MongoDB/include/Poco/MongoDB/KillCursorsRequest.h +++ b/MongoDB/include/Poco/MongoDB/KillCursorsRequest.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_KillCursorsRequest_INCLUDED #define MongoDB_KillCursorsRequest_INCLUDED diff --git a/MongoDB/include/Poco/MongoDB/Message.h b/MongoDB/include/Poco/MongoDB/Message.h index d0ccaf60d..67a67b2b7 100644 --- a/MongoDB/include/Poco/MongoDB/Message.h +++ b/MongoDB/include/Poco/MongoDB/Message.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_Message_INCLUDED #define MongoDB_Message_INCLUDED diff --git a/MongoDB/include/Poco/MongoDB/MessageHeader.h b/MongoDB/include/Poco/MongoDB/MessageHeader.h index 584679a8d..ef096ba4f 100644 --- a/MongoDB/include/Poco/MongoDB/MessageHeader.h +++ b/MongoDB/include/Poco/MongoDB/MessageHeader.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_MessageHeader_INCLUDED #define MongoDB_MessageHeader_INCLUDED @@ -43,9 +44,6 @@ #include "Poco/MongoDB/MessageHeader.h" -#define MSG_HEADER_SIZE 16 - - namespace Poco { namespace MongoDB { @@ -55,6 +53,8 @@ class MongoDB_API MessageHeader /// or response of MongoDB { public: + static const unsigned int MSG_HEADER_SIZE = 16; + typedef enum { Reply = 1 diff --git a/MongoDB/include/Poco/MongoDB/ObjectId.h b/MongoDB/include/Poco/MongoDB/ObjectId.h index 9161ca52b..66681111b 100644 --- a/MongoDB/include/Poco/MongoDB/ObjectId.h +++ b/MongoDB/include/Poco/MongoDB/ObjectId.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef MongoDB_ObjectId_INCLUDED #define MongoDB_ObjectId_INCLUDED @@ -47,6 +48,7 @@ namespace Poco { namespace MongoDB { + class MongoDB_API ObjectId /// ObjectId is a 12-byte BSON type, constructed using: /// diff --git a/MongoDB/include/Poco/MongoDB/ResponseMessage.h b/MongoDB/include/Poco/MongoDB/ResponseMessage.h index 477449cd7..462190d9f 100644 --- a/MongoDB/include/Poco/MongoDB/ResponseMessage.h +++ b/MongoDB/include/Poco/MongoDB/ResponseMessage.h @@ -119,6 +119,7 @@ inline bool ResponseMessage::hasDocuments() const return _documents.size() > 0; } + } } // namespace Poco::MongoDB diff --git a/MongoDB/include/Poco/MongoDB/UpdateRequest.h b/MongoDB/include/Poco/MongoDB/UpdateRequest.h index a1293e84e..dbe6d55d3 100644 --- a/MongoDB/include/Poco/MongoDB/UpdateRequest.h +++ b/MongoDB/include/Poco/MongoDB/UpdateRequest.h @@ -88,7 +88,7 @@ public: void flags(Flags flags); /// Sets the flags - + protected: void buildRequest(BinaryWriter& writer); @@ -124,4 +124,5 @@ inline Document& UpdateRequest::update() } } // namespace Poco::MongoDB + #endif //MongoDB_UpdateRequest_INCLUDED diff --git a/MongoDB/src/Array.cpp b/MongoDB/src/Array.cpp index e369ddb1e..f36f454b6 100644 --- a/MongoDB/src/Array.cpp +++ b/MongoDB/src/Array.cpp @@ -34,13 +34,16 @@ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // -#include + #include "Poco/MongoDB/Array.h" +#include + namespace Poco { namespace MongoDB { + Array::Array() : Document() { } diff --git a/MongoDB/src/Binary.cpp b/MongoDB/src/Binary.cpp index 5c174bfb1..e76985b34 100644 --- a/MongoDB/src/Binary.cpp +++ b/MongoDB/src/Binary.cpp @@ -35,8 +35,10 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/Binary.h" + namespace Poco { namespace MongoDB { diff --git a/MongoDB/src/Connection.cpp b/MongoDB/src/Connection.cpp index 13d69ad00..4d83f3347 100644 --- a/MongoDB/src/Connection.cpp +++ b/MongoDB/src/Connection.cpp @@ -34,15 +34,16 @@ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // -#include + #include "Poco/Net/SocketStream.h" #include "Poco/MongoDB/Connection.h" +#include + + +namespace Poco { +namespace MongoDB { -namespace Poco -{ -namespace MongoDB -{ Connection::Connection() : _address(), _socket() { @@ -54,6 +55,7 @@ Connection::Connection(const std::string& hostAndPort) : _address(hostAndPort), connect(); } + Connection::Connection(const std::string& host, int port) : _address(host, port), _socket() { connect(); @@ -90,6 +92,7 @@ void Connection::connect(const std::string& hostAndPort) connect(); } + void Connection::connect(const std::string& host, int port) { _address = Net::SocketAddress(host, port); @@ -103,17 +106,20 @@ void Connection::connect(const Net::SocketAddress& addrs) connect(); } + void Connection::disconnect() { _socket.close(); } + void Connection::sendRequest(RequestMessage& request) { Net::SocketOutputStream sos(_socket); request.send(sos); } + void Connection::sendRequest(RequestMessage& request, ResponseMessage& response) { sendRequest(request); diff --git a/MongoDB/src/Cursor.cpp b/MongoDB/src/Cursor.cpp index 1108f3224..dfac65789 100644 --- a/MongoDB/src/Cursor.cpp +++ b/MongoDB/src/Cursor.cpp @@ -35,14 +35,14 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/Cursor.h" #include "Poco/MongoDB/GetMoreRequest.h" #include "Poco/MongoDB/KillCursorsRequest.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { Cursor::Cursor(const std::string& db, const std::string& collection, QueryRequest::Flags flags) @@ -91,5 +91,5 @@ void Cursor::kill(Connection& connection) _response.clear(); } -} } // Namespace Poco::MongoDB +} } // Namespace Poco::MongoDB diff --git a/MongoDB/src/Database.cpp b/MongoDB/src/Database.cpp index f89befcd6..c51c1114f 100644 --- a/MongoDB/src/Database.cpp +++ b/MongoDB/src/Database.cpp @@ -35,12 +35,12 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/Database.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { Database::Database( const std::string& db) : _dbname(db) @@ -126,6 +126,7 @@ Document::Ptr Database::getLastErrorDoc(Connection& connection) const return errorDoc; } + std::string Database::getLastError(Connection& connection) const { Document::Ptr errorDoc = getLastErrorDoc(connection); diff --git a/MongoDB/src/DeleteRequest.cpp b/MongoDB/src/DeleteRequest.cpp index 583f3a7af..f83561bb6 100644 --- a/MongoDB/src/DeleteRequest.cpp +++ b/MongoDB/src/DeleteRequest.cpp @@ -35,12 +35,12 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/DeleteRequest.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { DeleteRequest::DeleteRequest(const std::string& collectionName, DeleteRequest::Flags flags) @@ -65,6 +65,7 @@ DeleteRequest::~DeleteRequest() { } + void DeleteRequest::buildRequest(BinaryWriter& writer) { writer << 0; // 0 - reserved for future use @@ -74,4 +75,4 @@ void DeleteRequest::buildRequest(BinaryWriter& writer) } -}} // Namespace MongoDB +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/Document.cpp b/MongoDB/src/Document.cpp index a467d41d3..89cc5fa49 100644 --- a/MongoDB/src/Document.cpp +++ b/MongoDB/src/Document.cpp @@ -35,7 +35,6 @@ // DEALINGS IN THE SOFTWARE. // -#include #include "Poco/MongoDB/Document.h" #include "Poco/MongoDB/Binary.h" @@ -43,17 +42,18 @@ #include "Poco/MongoDB/Array.h" #include "Poco/MongoDB/RegularExpression.h" #include "Poco/MongoDB/JavaScriptCode.h" +#include -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { Document::Document() { } + Document::~Document() { } @@ -198,14 +198,14 @@ void Document::write(BinaryWriter& writer) Poco::BinaryWriter tempWriter(sstream); for(ElementSet::iterator it = _elements.begin(); it != _elements.end(); ++it) { - tempWriter << (unsigned char) (*it)->type(); + tempWriter << static_cast((*it)->type()); BSONWriter(tempWriter).writeCString((*it)->name()); Element::Ptr element = *it; element->write(tempWriter); } tempWriter.flush(); - Poco::Int32 len = 5 + sstream.tellp(); /* 5 = sizeof(len) + 0-byte */ + Poco::Int32 len = static_cast(5 + sstream.tellp()); /* 5 = sizeof(len) + 0-byte */ writer << len; writer.writeRaw(sstream.str()); } diff --git a/MongoDB/src/Element.cpp b/MongoDB/src/Element.cpp index df30cc92e..a09e56e51 100644 --- a/MongoDB/src/Element.cpp +++ b/MongoDB/src/Element.cpp @@ -35,17 +35,19 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/Element.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { + Element::Element(const std::string& name) : _name(name) { } + Element::~Element() { } diff --git a/MongoDB/src/GetMoreRequest.cpp b/MongoDB/src/GetMoreRequest.cpp index 1c7a02f65..f1425bea5 100644 --- a/MongoDB/src/GetMoreRequest.cpp +++ b/MongoDB/src/GetMoreRequest.cpp @@ -35,13 +35,13 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/GetMoreRequest.h" #include "Poco/MongoDB/Element.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { GetMoreRequest::GetMoreRequest(const std::string& collectionName, Int64 cursorID) @@ -52,10 +52,12 @@ GetMoreRequest::GetMoreRequest(const std::string& collectionName, Int64 cursorID { } + GetMoreRequest::~GetMoreRequest() { } + void GetMoreRequest::buildRequest(BinaryWriter& writer) { writer << 0; // 0 - reserved for future use @@ -65,4 +67,4 @@ void GetMoreRequest::buildRequest(BinaryWriter& writer) } -}} // Namespace MongoDB +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/InsertRequest.cpp b/MongoDB/src/InsertRequest.cpp index ec2b6f236..c192e798c 100644 --- a/MongoDB/src/InsertRequest.cpp +++ b/MongoDB/src/InsertRequest.cpp @@ -35,12 +35,12 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/InsertRequest.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { InsertRequest::InsertRequest(const std::string& collectionName, Flags flags) @@ -50,10 +50,12 @@ InsertRequest::InsertRequest(const std::string& collectionName, Flags flags) { } + InsertRequest::~InsertRequest() { } + void InsertRequest::buildRequest(BinaryWriter& writer) { //TODO: throw exception when no document is added @@ -67,4 +69,5 @@ void InsertRequest::buildRequest(BinaryWriter& writer) } } -}} // Namespace MongoDB + +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/JavaScriptCode.cpp b/MongoDB/src/JavaScriptCode.cpp index 4b31c124b..21b6cfb6e 100644 --- a/MongoDB/src/JavaScriptCode.cpp +++ b/MongoDB/src/JavaScriptCode.cpp @@ -34,8 +34,11 @@ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // + + #include "Poco/MongoDB/JavaScriptCode.h" + namespace Poco { namespace MongoDB { @@ -45,8 +48,10 @@ JavaScriptCode::JavaScriptCode() } + JavaScriptCode::~JavaScriptCode() { } + } } // namespace Poco::MongoDB diff --git a/MongoDB/src/KillCursorsRequest.cpp b/MongoDB/src/KillCursorsRequest.cpp index 077db5c20..be29d599a 100644 --- a/MongoDB/src/KillCursorsRequest.cpp +++ b/MongoDB/src/KillCursorsRequest.cpp @@ -35,12 +35,12 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/KillCursorsRequest.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { KillCursorsRequest::KillCursorsRequest() @@ -48,10 +48,12 @@ KillCursorsRequest::KillCursorsRequest() { } + KillCursorsRequest::~KillCursorsRequest() { } + void KillCursorsRequest::buildRequest(BinaryWriter& writer) { writer << 0; // 0 - reserved for future use @@ -63,4 +65,4 @@ void KillCursorsRequest::buildRequest(BinaryWriter& writer) } -}} // Namespace MongoDB +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/Message.cpp b/MongoDB/src/Message.cpp index 66c8f177f..0a65280a2 100644 --- a/MongoDB/src/Message.cpp +++ b/MongoDB/src/Message.cpp @@ -35,20 +35,22 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/Message.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { Message::Message(MessageHeader::OpCode opcode) : _header(opcode) { } + Message::~Message() { } -}} // Namespace MongoDB + +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/MessageHeader.cpp b/MongoDB/src/MessageHeader.cpp index 0cd6fe159..386276a09 100644 --- a/MongoDB/src/MessageHeader.cpp +++ b/MongoDB/src/MessageHeader.cpp @@ -34,25 +34,28 @@ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // -#include "Poco/MongoDB/Message.h" + +#include "Poco/MongoDB/Message.h" #include "Poco/Exception.h" #include "Poco/Net/SocketStream.h" #include "Poco/StreamCopier.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { + MessageHeader::MessageHeader(OpCode opCode) : _messageLength(0), _requestID(0), _responseTo(0), _opCode(opCode) { } + MessageHeader::~MessageHeader() { } + void MessageHeader::read(BinaryReader& reader) { reader >> _messageLength; @@ -69,6 +72,7 @@ void MessageHeader::read(BinaryReader& reader) } } + void MessageHeader::write(BinaryWriter& writer) { writer << _messageLength; @@ -77,4 +81,5 @@ void MessageHeader::write(BinaryWriter& writer) writer << (Int32) _opCode; } -}} // Namespace MongoDB + +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/ObjectId.cpp b/MongoDB/src/ObjectId.cpp index fdc61d641..10d706c36 100644 --- a/MongoDB/src/ObjectId.cpp +++ b/MongoDB/src/ObjectId.cpp @@ -35,14 +35,14 @@ // DEALINGS IN THE SOFTWARE. // -#include "Poco/MongoDB/ObjectId.h" +#include "Poco/MongoDB/ObjectId.h" #include "Poco/Format.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { + ObjectId::ObjectId() { diff --git a/MongoDB/src/QueryRequest.cpp b/MongoDB/src/QueryRequest.cpp index 6fb32bf46..d03826a11 100644 --- a/MongoDB/src/QueryRequest.cpp +++ b/MongoDB/src/QueryRequest.cpp @@ -35,12 +35,12 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/QueryRequest.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { QueryRequest::QueryRequest(const std::string& collectionName, QueryRequest::Flags flags) @@ -59,6 +59,7 @@ QueryRequest::~QueryRequest() { } + void QueryRequest::buildRequest(BinaryWriter& writer) { writer << _flags; @@ -74,4 +75,4 @@ void QueryRequest::buildRequest(BinaryWriter& writer) } -}} // Namespace MongoDB +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/RegularExpression.cpp b/MongoDB/src/RegularExpression.cpp index 505343f64..69624625e 100644 --- a/MongoDB/src/RegularExpression.cpp +++ b/MongoDB/src/RegularExpression.cpp @@ -35,9 +35,10 @@ // DEALINGS IN THE SOFTWARE. // -#include #include "Poco/MongoDB/RegularExpression.h" +#include + namespace Poco { namespace MongoDB { @@ -88,4 +89,5 @@ SharedPtr RegularExpression::createRE() const return new Poco::RegularExpression(_pattern, options); } + } } // namespace Poco::MongoDB diff --git a/MongoDB/src/ReplicaSet.cpp b/MongoDB/src/ReplicaSet.cpp index 92c58ba78..8667935ed 100644 --- a/MongoDB/src/ReplicaSet.cpp +++ b/MongoDB/src/ReplicaSet.cpp @@ -34,19 +34,21 @@ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // + + #include "Poco/MongoDB/ReplicaSet.h" #include "Poco/MongoDB/QueryRequest.h" #include "Poco/MongoDB/ResponseMessage.h" -namespace Poco -{ -namespace MongoDB -{ +namespace Poco { +namespace MongoDB { + ReplicaSet::ReplicaSet(const std::vector &addresses) : _addresses(addresses) { } + ReplicaSet::~ReplicaSet() { } @@ -68,6 +70,7 @@ Connection::Ptr ReplicaSet::findMaster() return master; } + Connection::Ptr ReplicaSet::isMaster(const Net::SocketAddress& address) { Connection::Ptr conn = new Connection(); diff --git a/MongoDB/src/RequestMessage.cpp b/MongoDB/src/RequestMessage.cpp index 753dc58c9..2f86a8d9f 100644 --- a/MongoDB/src/RequestMessage.cpp +++ b/MongoDB/src/RequestMessage.cpp @@ -35,20 +35,21 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/RequestMessage.h" #include "Poco/Net/SocketStream.h" #include "Poco/StreamCopier.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { RequestMessage::RequestMessage(MessageHeader::OpCode opcode) : Message(opcode) { } + RequestMessage::~RequestMessage() { } @@ -69,4 +70,5 @@ void RequestMessage::send(std::ostream& ostr) ostr.flush(); } -}} // Namespace MongoDB + +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/ResponseMessage.cpp b/MongoDB/src/ResponseMessage.cpp index f07c00a21..e8b42f484 100644 --- a/MongoDB/src/ResponseMessage.cpp +++ b/MongoDB/src/ResponseMessage.cpp @@ -35,18 +35,20 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/ResponseMessage.h" #include "Poco/Net/SocketStream.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { + ResponseMessage::ResponseMessage() : Message(MessageHeader::Reply), _responseFlags(0), _cursorID(0), _startingFrom(0), _numberReturned(0) { } + ResponseMessage::~ResponseMessage() { } @@ -83,4 +85,5 @@ void ResponseMessage::read(std::istream& istr) } } -}} // Namespace MongoDB + +} } // namespace Poco::MongoDB diff --git a/MongoDB/src/UpdateRequest.cpp b/MongoDB/src/UpdateRequest.cpp index a57ddd162..fda14e2d3 100644 --- a/MongoDB/src/UpdateRequest.cpp +++ b/MongoDB/src/UpdateRequest.cpp @@ -35,12 +35,12 @@ // DEALINGS IN THE SOFTWARE. // + #include "Poco/MongoDB/UpdateRequest.h" -namespace Poco -{ -namespace MongoDB -{ + +namespace Poco { +namespace MongoDB { UpdateRequest::UpdateRequest(const std::string& collectionName, UpdateRequest::Flags flags) @@ -52,10 +52,12 @@ UpdateRequest::UpdateRequest(const std::string& collectionName, UpdateRequest::F { } + UpdateRequest::~UpdateRequest() { } + void UpdateRequest::buildRequest(BinaryWriter& writer) { writer << 0; // 0 - reserved for future use @@ -65,4 +67,5 @@ void UpdateRequest::buildRequest(BinaryWriter& writer) _update.write(writer); } -}} // Namespace MongoDB + +} } // namespace Poco::MongoDB