mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-30 13:47:10 +01:00
Make it work again
This commit is contained in:
@@ -59,13 +59,20 @@ public:
|
||||
/// Destructor
|
||||
|
||||
};
|
||||
/*
|
||||
|
||||
// BSON Embedded Array
|
||||
// spec: document
|
||||
template<>
|
||||
struct ElementTraits<Array::Ptr>
|
||||
{
|
||||
enum { TypeId = 0x04 };
|
||||
|
||||
static std::string toString(const Array::Ptr& value)
|
||||
{
|
||||
//TODO:
|
||||
return value.isNull() ? "null" : "[]";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -79,7 +86,7 @@ inline void BSONWriter::write<Array::Ptr>(Array::Ptr& from)
|
||||
{
|
||||
from->write(_writer);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#define _MongoDB_BSONReader_included
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/Document.h"
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
@@ -50,7 +49,7 @@ class MongoDB_API BSONReader
|
||||
/// Class for reading BSON from a Poco::BinaryReader
|
||||
{
|
||||
public:
|
||||
BSONReader(Poco::BinaryReader& reader) : _reader(reader)
|
||||
BSONReader(const Poco::BinaryReader& reader) : _reader(reader)
|
||||
/// Constructor
|
||||
{
|
||||
}
|
||||
@@ -60,9 +59,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void read(Document& v);
|
||||
template<typename T>
|
||||
void read(T& t)
|
||||
/// Reads the value from the reader. The default implementation uses the >> operator to
|
||||
/// the given argument. Special types can write their own version.
|
||||
{
|
||||
_reader >> t;
|
||||
}
|
||||
|
||||
std::string readCString();
|
||||
/// Reads a cstring from the reader.
|
||||
|
||||
@@ -38,10 +38,8 @@
|
||||
#ifndef _MongoDB_BSONWriter_included
|
||||
#define _MongoDB_BSONWriter_included
|
||||
|
||||
#include "Poco/BinaryWriter.h"
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/Document.h"
|
||||
#include "Poco/BinaryWriter.h"
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
@@ -53,15 +51,23 @@ class MongoDB_API BSONWriter
|
||||
/// Class for writing BSON to a Poco::BinaryWriter.
|
||||
{
|
||||
public:
|
||||
BSONWriter(Poco::BinaryWriter& writer);
|
||||
BSONWriter(const Poco::BinaryWriter& writer) : _writer(writer)
|
||||
/// Constructor
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~BSONWriter();
|
||||
virtual ~BSONWriter()
|
||||
/// Destructor
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void write(const Document& v);
|
||||
|
||||
template<typename T>
|
||||
void write(T& t)
|
||||
/// Writes the value to the writer. The default implementation uses
|
||||
/// the << operator. Special types can write their own version.
|
||||
{
|
||||
_writer << t;
|
||||
}
|
||||
|
||||
void writeCString(const std::string& value);
|
||||
/// Writes a cstring to the writer. A cstring is a string
|
||||
@@ -72,6 +78,12 @@ private:
|
||||
Poco::BinaryWriter _writer;
|
||||
};
|
||||
|
||||
inline void BSONWriter::writeCString(const std::string& value)
|
||||
{
|
||||
_writer.writeRaw(value);
|
||||
_writer << (unsigned char) 0x00;
|
||||
}
|
||||
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
#endif // _MongoDB_BSONWriter_included
|
||||
|
||||
@@ -39,13 +39,16 @@
|
||||
#define _MongoDB_Binary_included
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/Buffer.h"
|
||||
#include "Poco/MongoDB/Element.h"
|
||||
#include "Poco/Base64Encoder.h"
|
||||
#include "Poco/Buffer.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/MemoryStream.h"
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
namespace MongoDB
|
||||
{
|
||||
#include <sstream>
|
||||
|
||||
namespace Poco {
|
||||
namespace MongoDB {
|
||||
|
||||
class MongoDB_API Binary
|
||||
/// Implements BSON Binary. It's a wrapper around a Poco::Buffer<unsigned char>.
|
||||
@@ -63,14 +66,11 @@ public:
|
||||
|
||||
|
||||
virtual ~Binary();
|
||||
/// Destructor
|
||||
|
||||
|
||||
unsigned char* begin();
|
||||
/// Returns the start of the buffer
|
||||
|
||||
|
||||
Poco::Int32 size() const;
|
||||
/// Returns the size of the buffer
|
||||
Buffer<unsigned char>& buffer();
|
||||
/// Returns a reference to the buffer
|
||||
|
||||
|
||||
unsigned char subtype() const;
|
||||
@@ -81,27 +81,18 @@ public:
|
||||
/// Sets the subtype
|
||||
|
||||
|
||||
void resize(std::size_t newSize);
|
||||
/// Resizes the buffer
|
||||
std::string toString() const;
|
||||
/// Returns the binary encoded in Base64
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Poco::Buffer<unsigned char> _buffer;
|
||||
Buffer<unsigned char> _buffer;
|
||||
|
||||
|
||||
unsigned char _subtype;
|
||||
};
|
||||
|
||||
inline unsigned char* Binary::begin()
|
||||
{
|
||||
return _buffer.begin();
|
||||
}
|
||||
|
||||
inline Poco::Int32 Binary::size() const
|
||||
{
|
||||
return _buffer.size();
|
||||
}
|
||||
|
||||
|
||||
inline unsigned char Binary::subtype() const
|
||||
{
|
||||
@@ -114,13 +105,24 @@ inline void Binary::subtype(unsigned char type)
|
||||
_subtype = type;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
inline Buffer<unsigned char>& Binary::buffer()
|
||||
{
|
||||
return _buffer;
|
||||
}
|
||||
|
||||
|
||||
// BSON Embedded Document
|
||||
// spec: binary
|
||||
template<>
|
||||
struct ElementTraits<Binary::Ptr>
|
||||
{
|
||||
enum { TypeId = 0x05 };
|
||||
|
||||
static std::string toString(const Binary::Ptr& value)
|
||||
{
|
||||
return value.isNull() ? "" : value->toString();
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -129,22 +131,22 @@ inline void BSONReader::read<Binary::Ptr>(Binary::Ptr& to)
|
||||
Poco::Int32 size;
|
||||
_reader >> size;
|
||||
|
||||
to->resize(size);
|
||||
to->buffer().resize(size);
|
||||
|
||||
unsigned char subtype;
|
||||
_reader >> subtype;
|
||||
to->subtype(subtype);
|
||||
|
||||
_reader.readRaw((char*) to->begin(), size);
|
||||
_reader.readRaw((char*) to->buffer().begin(), size);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void BSONWriter::write<Binary::Ptr>(Binary::Ptr& from)
|
||||
{
|
||||
_writer << from->subtype();
|
||||
_writer.writeRaw((char*) from->begin(), from->size());
|
||||
_writer.writeRaw((char*) from->buffer().begin(), from->buffer().size());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
|
||||
69
MongoDB/include/Poco/MongoDB/Database.h
Normal file
69
MongoDB/include/Poco/MongoDB/Database.h
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Database.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: MongoDB
|
||||
// Package: MongoDB
|
||||
// Module: Database
|
||||
//
|
||||
// Definition of the Database class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#ifndef _MongoDB_Database_included
|
||||
#define _MongoDB_Database_included
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/Document.h"
|
||||
#include "Poco/MongoDB/QueryRequest.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace MongoDB {
|
||||
|
||||
|
||||
class MongoDB_API Database
|
||||
{
|
||||
public:
|
||||
Database(const std::string& db);
|
||||
|
||||
|
||||
virtual ~Database();
|
||||
|
||||
|
||||
Poco::SharedPtr<Poco::MongoDB::QueryRequest> createQueryRequest(const std::string& collectionName);
|
||||
|
||||
|
||||
Poco::SharedPtr<Poco::MongoDB::QueryRequest> createCountRequest(const std::string& collectionName);
|
||||
|
||||
|
||||
private:
|
||||
std::string _dbname;
|
||||
};
|
||||
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
#endif // _MongoDB_Database_included
|
||||
@@ -38,18 +38,19 @@
|
||||
#ifndef _MongoDB_Document_included
|
||||
#define _MongoDB_Document_included
|
||||
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "Poco/Dynamic/Struct.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "Poco/BinaryReader.h"
|
||||
#include "Poco/BinaryWriter.h"
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/Element.h"
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
namespace MongoDB
|
||||
{
|
||||
|
||||
typedef Dynamic::Struct<std::string> Document;
|
||||
typedef SharedPtr<Document> DocumentPtr;
|
||||
typedef std::vector<DocumentPtr> Documents;
|
||||
/*
|
||||
class ElementFindByName
|
||||
{
|
||||
public:
|
||||
@@ -184,6 +185,12 @@ template<>
|
||||
struct ElementTraits<Document::Ptr>
|
||||
{
|
||||
enum { TypeId = 0x03 };
|
||||
|
||||
static std::string toString(const Document::Ptr& value)
|
||||
{
|
||||
//TODO
|
||||
return value.isNull() ? "null" : "{}";
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -197,7 +204,7 @@ inline void BSONWriter::write<Document::Ptr>(Document::Ptr& from)
|
||||
{
|
||||
from->write(_writer);
|
||||
}
|
||||
*/
|
||||
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
#endif // _MongoDB_Document_included
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/RegularExpression.h"
|
||||
#include "Poco/Nullable.h"
|
||||
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/BSONReader.h"
|
||||
#include "Poco/MongoDB/BSONWriter.h"
|
||||
@@ -68,6 +69,9 @@ public:
|
||||
virtual ~Element();
|
||||
|
||||
|
||||
virtual std::string toString() const = 0;
|
||||
|
||||
|
||||
virtual int type() const = 0;
|
||||
|
||||
|
||||
@@ -77,11 +81,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// virtual void read(BinaryReader& reader) = 0;
|
||||
virtual void read(BinaryReader& reader) = 0;
|
||||
|
||||
// virtual void write(BinaryWriter& writer) = 0;
|
||||
virtual void write(BinaryWriter& writer) = 0;
|
||||
|
||||
// friend class Document;
|
||||
friend class Document;
|
||||
|
||||
std::string _name;
|
||||
};
|
||||
@@ -116,6 +120,11 @@ template<>
|
||||
struct ElementTraits<double>
|
||||
{
|
||||
enum { TypeId = 0x01 };
|
||||
|
||||
static std::string toString(const double& value)
|
||||
{
|
||||
return Poco::NumberFormatter::format(value);
|
||||
}
|
||||
};
|
||||
|
||||
// BSON UTF-8 string
|
||||
@@ -125,8 +134,13 @@ template<>
|
||||
struct ElementTraits<std::string>
|
||||
{
|
||||
enum { TypeId = 0x02 };
|
||||
|
||||
static std::string toString(const std::string& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
||||
template<>
|
||||
inline void BSONReader::read<std::string>(std::string& to)
|
||||
{
|
||||
@@ -142,7 +156,7 @@ inline void BSONWriter::write<std::string>(std::string& from)
|
||||
_writer << (Poco::Int32) (from.length() + 1);
|
||||
writeCString(from);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// BSON bool
|
||||
@@ -151,8 +165,13 @@ template<>
|
||||
struct ElementTraits<bool>
|
||||
{
|
||||
enum { TypeId = 0x08 };
|
||||
|
||||
static std::string toString(const bool& value)
|
||||
{
|
||||
return value ? "true" : "false";
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
||||
template<>
|
||||
inline void BSONReader::read<bool>(bool& to)
|
||||
{
|
||||
@@ -166,13 +185,19 @@ inline void BSONWriter::write<bool>(bool& from)
|
||||
{
|
||||
_writer << (from ? 0x01 : 0x00);
|
||||
}
|
||||
*/
|
||||
|
||||
// BSON 32-bit integer
|
||||
// spec: int32
|
||||
template<>
|
||||
struct ElementTraits<Int32>
|
||||
{
|
||||
enum { TypeId = 0x10 };
|
||||
|
||||
|
||||
static std::string toString(const Int32& value)
|
||||
{
|
||||
return Poco::NumberFormatter::format(value);
|
||||
}
|
||||
};
|
||||
|
||||
// BSON UTC datetime
|
||||
@@ -181,8 +206,13 @@ template<>
|
||||
struct ElementTraits<Timestamp>
|
||||
{
|
||||
enum { TypeId = 0x09 };
|
||||
|
||||
static std::string toString(const Timestamp& value)
|
||||
{
|
||||
return DateTimeFormatter::format(value, "%Y-%m-%dT%H:%M:%s%z");
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
||||
template<>
|
||||
inline void BSONReader::read<Timestamp>(Timestamp& to)
|
||||
{
|
||||
@@ -197,7 +227,7 @@ inline void BSONWriter::write<Timestamp>(Timestamp& from)
|
||||
{
|
||||
_writer << (from.epochMicroseconds() / 1000);
|
||||
}
|
||||
*/
|
||||
|
||||
typedef Nullable<unsigned char> NullValue;
|
||||
|
||||
// BSON Null Value
|
||||
@@ -206,8 +236,13 @@ template<>
|
||||
struct ElementTraits<NullValue>
|
||||
{
|
||||
enum { TypeId = 0x0A };
|
||||
|
||||
static std::string toString(const NullValue& value)
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
||||
template<>
|
||||
inline void BSONReader::read<NullValue>(NullValue& to)
|
||||
{
|
||||
@@ -217,7 +252,7 @@ template<>
|
||||
inline void BSONWriter::write<NullValue>(NullValue& from)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
class RegularExpression
|
||||
{
|
||||
@@ -318,8 +353,14 @@ template<>
|
||||
struct ElementTraits<RegularExpression::Ptr>
|
||||
{
|
||||
enum { TypeId = 0x0B };
|
||||
|
||||
static std::string toString(const RegularExpression::Ptr& value)
|
||||
{
|
||||
//TODO
|
||||
return "RE: not implemented yet";
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
||||
template<>
|
||||
inline void BSONReader::read<RegularExpression::Ptr>(RegularExpression::Ptr& to)
|
||||
{
|
||||
@@ -335,7 +376,7 @@ inline void BSONWriter::write<RegularExpression::Ptr>(RegularExpression::Ptr& fr
|
||||
writeCString(from->getPattern());
|
||||
writeCString(from->getOptions());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
class JavaScriptCode
|
||||
{
|
||||
@@ -381,8 +422,13 @@ template<>
|
||||
struct ElementTraits<JavaScriptCode::Ptr>
|
||||
{
|
||||
enum { TypeId = 0x0D };
|
||||
|
||||
static std::string toString(const JavaScriptCode::Ptr& value)
|
||||
{
|
||||
return value.isNull() ? "" : value->code();
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
||||
template<>
|
||||
inline void BSONReader::read<JavaScriptCode::Ptr>(JavaScriptCode::Ptr& to)
|
||||
{
|
||||
@@ -398,13 +444,18 @@ inline void BSONWriter::write<JavaScriptCode::Ptr>(JavaScriptCode::Ptr& from)
|
||||
std::string code = from->code();
|
||||
BSONWriter(_writer).write(code);
|
||||
}
|
||||
*/
|
||||
|
||||
// BSON 64-bit integer
|
||||
// spec: int64
|
||||
template<>
|
||||
struct ElementTraits<Int64>
|
||||
{
|
||||
enum { TypeId = 0x12 };
|
||||
|
||||
static std::string toString(const Int64& value)
|
||||
{
|
||||
return NumberFormatter::format(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -423,10 +474,13 @@ public:
|
||||
|
||||
T value() const { return _value; }
|
||||
|
||||
|
||||
std::string toString() const { return ElementTraits<T>::toString(_value); }
|
||||
|
||||
|
||||
int type() const { return ElementTraits<T>::TypeId; }
|
||||
|
||||
/*
|
||||
|
||||
void read(BinaryReader& reader)
|
||||
{
|
||||
BSONReader(reader).read(_value);
|
||||
@@ -436,7 +490,7 @@ public:
|
||||
{
|
||||
BSONWriter(writer).write(_value);
|
||||
}
|
||||
*/
|
||||
|
||||
private:
|
||||
|
||||
T _value;
|
||||
@@ -445,4 +499,3 @@ private:
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
#endif // _MongoDB_Element_included
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
/// Destructor
|
||||
|
||||
|
||||
Documents& documents();
|
||||
Document::Vector& documents();
|
||||
/// Returns the documents to insert into the database
|
||||
|
||||
protected:
|
||||
@@ -85,11 +85,11 @@ private:
|
||||
|
||||
std::string _fullCollectionName;
|
||||
|
||||
Documents _documents;
|
||||
Document::Vector _documents;
|
||||
};
|
||||
|
||||
|
||||
inline Documents& InsertRequest::documents()
|
||||
inline Document::Vector& InsertRequest::documents()
|
||||
{
|
||||
return _documents;
|
||||
}
|
||||
|
||||
@@ -63,14 +63,23 @@ public:
|
||||
|
||||
private:
|
||||
unsigned char _id[12];
|
||||
|
||||
friend class BSONWriter;
|
||||
friend class BSONReader;
|
||||
};
|
||||
/*
|
||||
|
||||
// BSON Embedded Document
|
||||
// spec: ObjectId
|
||||
template<>
|
||||
struct ElementTraits<ObjectId::Ptr>
|
||||
{
|
||||
enum { TypeId = 0x07 };
|
||||
|
||||
|
||||
static std::string toString(const ObjectId::Ptr& id)
|
||||
{
|
||||
return id->toString();
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -84,19 +93,9 @@ inline void BSONWriter::write<ObjectId::Ptr>(ObjectId::Ptr& from)
|
||||
{
|
||||
_writer.writeRaw((char*) from->_id, 12);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}} // Namespace Poco::MongoDB
|
||||
|
||||
namespace Poco {
|
||||
namespace Dynamic {
|
||||
|
||||
template<>
|
||||
class VarHolderImpl<MongoDB::ObjectId>: public VarHolder
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}} // Poco::Dynamic
|
||||
|
||||
#endif //_MongoDB_ObjectId_included
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
namespace MongoDB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
class PoolableObjectFactory<Connection, Connection::Ptr>
|
||||
class PoolableObjectFactory<MongoDB::Connection, MongoDB::Connection::Ptr>
|
||||
{
|
||||
public:
|
||||
PoolableObjectFactory(Net::SocketAddress& address)
|
||||
@@ -26,29 +24,29 @@ public:
|
||||
}
|
||||
|
||||
|
||||
Connection::Ptr createObject()
|
||||
MongoDB::Connection::Ptr createObject()
|
||||
{
|
||||
return new Connection(_address);
|
||||
return new MongoDB::Connection(_address);
|
||||
}
|
||||
|
||||
|
||||
bool validateObject(Connection::Ptr pObject)
|
||||
bool validateObject(MongoDB::Connection::Ptr pObject)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void activateObject(Connection::Ptr pObject)
|
||||
void activateObject(MongoDB::Connection::Ptr pObject)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void deactivateObject(Connection::Ptr pObject)
|
||||
void deactivateObject(MongoDB::Connection::Ptr pObject)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void destroyObject(Connection::Ptr pObject)
|
||||
void destroyObject(MongoDB::Connection::Ptr pObject)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,8 +55,35 @@ private:
|
||||
|
||||
Net::SocketAddress _address;
|
||||
};
|
||||
|
||||
namespace MongoDB
|
||||
{
|
||||
|
||||
|
||||
}} // Poco::MongoDB
|
||||
|
||||
class PooledConnection
|
||||
{
|
||||
public:
|
||||
PooledConnection(Poco::ObjectPool<Connection, Connection::Ptr>& pool) : _pool(pool)
|
||||
{
|
||||
_connection = _pool.borrowObject();
|
||||
}
|
||||
|
||||
virtual ~PooledConnection()
|
||||
{
|
||||
_pool.returnObject(_connection);
|
||||
}
|
||||
|
||||
operator Connection::Ptr () { return _connection; }
|
||||
|
||||
private:
|
||||
Poco::ObjectPool<Connection, Connection::Ptr>& _pool;
|
||||
|
||||
Connection::Ptr _connection;
|
||||
};
|
||||
|
||||
} // MongoDB
|
||||
|
||||
|
||||
} // Poco
|
||||
|
||||
#endif //_MongoDB_PoolableConnectionFactory_included
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/RequestMessage.h"
|
||||
|
||||
#include "Poco/Dynamic/Struct.h"
|
||||
#include "Poco/MongoDB/Document.h"
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
@@ -86,11 +85,11 @@ public:
|
||||
void flags(Flags flag);
|
||||
/// Set the flags
|
||||
|
||||
Dynamic::Struct<std::string>& query();
|
||||
Document& query();
|
||||
/// Returns the query document
|
||||
|
||||
|
||||
Dynamic::Struct<std::string>& returnFieldSelector();
|
||||
Document& returnFieldSelector();
|
||||
/// Returns the selector document
|
||||
|
||||
|
||||
@@ -123,9 +122,9 @@ private:
|
||||
|
||||
Int32 _numberToReturn;
|
||||
|
||||
Dynamic::Struct<std::string> _query;
|
||||
Document _query;
|
||||
|
||||
Dynamic::Struct<std::string> _returnFieldSelector;
|
||||
Document _returnFieldSelector;
|
||||
};
|
||||
|
||||
inline QueryRequest::Flags QueryRequest::flags() const
|
||||
@@ -138,12 +137,12 @@ inline void QueryRequest::flags(QueryRequest::Flags flags)
|
||||
_flags = flags;
|
||||
}
|
||||
|
||||
inline Dynamic::Struct<std::string>& QueryRequest::query()
|
||||
inline Document& QueryRequest::query()
|
||||
{
|
||||
return _query;
|
||||
}
|
||||
|
||||
inline Dynamic::Struct<std::string>& QueryRequest::returnFieldSelector()
|
||||
inline Document& QueryRequest::returnFieldSelector()
|
||||
{
|
||||
return _returnFieldSelector;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
/// Reads the response from the stream
|
||||
|
||||
|
||||
Documents& documents();
|
||||
Document::Vector& documents();
|
||||
/// Returns the retrieved documents
|
||||
|
||||
|
||||
@@ -90,11 +90,11 @@ private:
|
||||
Int32 _numberReturned;
|
||||
|
||||
|
||||
Documents _documents;
|
||||
Document::Vector _documents;
|
||||
};
|
||||
|
||||
|
||||
inline Documents& ResponseMessage::documents()
|
||||
inline Document::Vector& ResponseMessage::documents()
|
||||
{
|
||||
return _documents;
|
||||
}
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
|
||||
#include "Poco/MongoDB/MongoDB.h"
|
||||
#include "Poco/MongoDB/RequestMessage.h"
|
||||
|
||||
#include "Poco/Dynamic/Struct.h"
|
||||
#include "Poco/MongoDB/Document.h"
|
||||
|
||||
namespace Poco
|
||||
{
|
||||
@@ -78,11 +77,11 @@ public:
|
||||
/// Destructor
|
||||
|
||||
|
||||
Dynamic::Struct<std::string>& selector();
|
||||
Document& selector();
|
||||
/// Returns the selector document
|
||||
|
||||
|
||||
Dynamic::Struct<std::string>& update();
|
||||
Document& update();
|
||||
/// The document to update
|
||||
|
||||
|
||||
@@ -105,9 +104,9 @@ private:
|
||||
|
||||
std::string _fullCollectionName;
|
||||
|
||||
Dynamic::Struct<std::string> _selector;
|
||||
Document _selector;
|
||||
|
||||
Dynamic::Struct<std::string> _update;
|
||||
Document _update;
|
||||
};
|
||||
|
||||
|
||||
@@ -121,12 +120,12 @@ inline void UpdateRequest::flags(UpdateRequest::Flags flags)
|
||||
_flags = flags;
|
||||
}
|
||||
|
||||
inline Dynamic::Struct<std::string>& UpdateRequest::selector()
|
||||
inline Document& UpdateRequest::selector()
|
||||
{
|
||||
return _selector;
|
||||
}
|
||||
|
||||
inline Dynamic::Struct<std::string>& UpdateRequest::update()
|
||||
inline Document& UpdateRequest::update()
|
||||
{
|
||||
return _update;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user