poco/MongoDB/include/Poco/MongoDB/QueryRequest.h

175 lines
4.0 KiB
C
Raw Normal View History

2013-02-02 21:52:49 +01:00
//
// QueryRequest.h
//
// $Id$
//
// Library: MongoDB
// Package: MongoDB
// Module: QueryRequest
//
// Definition of the QueryRequest 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_QueryRequest_included
#define _MongoDB_QueryRequest_included
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
2013-02-13 19:10:57 +01:00
#include "Poco/MongoDB/Document.h"
2013-02-02 21:52:49 +01:00
namespace Poco {
namespace MongoDB {
2013-02-02 21:52:49 +01:00
class MongoDB_API QueryRequest : public RequestMessage
/// Class for creating an OP_QUERY client request. This request
/// is used to query documents from the database.
{
public:
typedef enum
{
QUERY_NONE = 0,
QUERY_TAILABLECURSOR = 2,
QUERY_SLAVE_OK = 4,
//QUERY_OPLOG_REPLAY = 8 (internal replication use only - drivers should not implement)
QUERY_NOCUROSR_TIMEOUT = 16,
QUERY_AWAIT_DATA = 32,
QUERY_EXHAUST = 64,
QUERY_PARTIAL = 128
} Flags;
QueryRequest(const std::string& collectionName, Flags flags = QUERY_NONE);
/// Constructor.
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar".
virtual ~QueryRequest();
/// Destructor
Flags getFlags() const;
2013-02-02 21:52:49 +01:00
/// Returns the flags
void setFlags(Flags flag);
2013-02-02 21:52:49 +01:00
/// Set the flags
2013-02-13 19:10:57 +01:00
Document& query();
2013-02-02 21:52:49 +01:00
/// Returns the query document
2013-02-02 21:52:49 +01:00
2013-02-13 19:10:57 +01:00
Document& returnFieldSelector();
2013-02-02 21:52:49 +01:00
/// Returns the selector document
Int32 getNumberToSkip() const;
2013-02-02 21:52:49 +01:00
/// Returns the number of documents to skip
void setNumberToSkip(Int32 n);
2013-02-02 21:52:49 +01:00
/// Sets the number of documents to skip
Int32 getNumberToReturn() const;
2013-02-02 21:52:49 +01:00
/// Returns the number to return
void setNumberToReturn(Int32 n);
2013-02-02 21:52:49 +01:00
/// Sets the number to return (limit)
protected:
void buildRequest(BinaryWriter& writer);
private:
Flags _flags;
std::string _fullCollectionName;
Int32 _numberToSkip;
Int32 _numberToReturn;
2013-02-13 19:10:57 +01:00
Document _query;
2013-02-02 21:52:49 +01:00
2013-02-13 19:10:57 +01:00
Document _returnFieldSelector;
2013-02-02 21:52:49 +01:00
};
inline QueryRequest::Flags QueryRequest::getFlags() const
2013-02-02 21:52:49 +01:00
{
return _flags;
}
inline void QueryRequest::setFlags(QueryRequest::Flags flags)
2013-02-02 21:52:49 +01:00
{
_flags = flags;
}
2013-02-13 19:10:57 +01:00
inline Document& QueryRequest::query()
2013-02-02 21:52:49 +01:00
{
return _query;
}
2013-02-13 19:10:57 +01:00
inline Document& QueryRequest::returnFieldSelector()
2013-02-02 21:52:49 +01:00
{
return _returnFieldSelector;
}
inline Int32 QueryRequest::getNumberToSkip() const
2013-02-02 21:52:49 +01:00
{
return _numberToSkip;
}
inline void QueryRequest::setNumberToSkip(Int32 n)
2013-02-02 21:52:49 +01:00
{
_numberToSkip = n;
}
inline Int32 QueryRequest::getNumberToReturn() const
2013-02-02 21:52:49 +01:00
{
return _numberToReturn;
}
inline void QueryRequest::setNumberToReturn(Int32 n)
2013-02-02 21:52:49 +01:00
{
_numberToReturn = n;
}
}} // Namespace Poco::MongoDB
#endif //_MongoDB_QueryRequest_included