mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-02 23:42:29 +02:00
127 lines
3.6 KiB
C++
127 lines
3.6 KiB
C++
//
|
|
// DeleteRequest.h
|
|
//
|
|
// $Id$
|
|
//
|
|
// Library: MongoDB
|
|
// Package: MongoDB
|
|
// Module: DeleteRequest
|
|
//
|
|
// Definition of the DeleteRequest 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_DeleteRequest_INCLUDED
|
|
#define MongoDB_DeleteRequest_INCLUDED
|
|
|
|
|
|
#include "Poco/MongoDB/MongoDB.h"
|
|
#include "Poco/MongoDB/RequestMessage.h"
|
|
#include "Poco/MongoDB/Document.h"
|
|
|
|
|
|
namespace Poco {
|
|
namespace MongoDB {
|
|
|
|
|
|
class MongoDB_API DeleteRequest : public RequestMessage
|
|
/// Class for creating an OP_DELETE client request. This request
|
|
/// is used to delete one ore more documents from a database.
|
|
///
|
|
/// Specific flags for this request
|
|
/// - DELETE_NONE
|
|
/// No flags
|
|
/// - DELETE_SINGLE_REMOVE
|
|
/// Delete only the first document
|
|
{
|
|
public:
|
|
typedef enum
|
|
{
|
|
DELETE_NONE = 0,
|
|
DELETE_SINGLE_REMOVE = 1
|
|
} Flags;
|
|
|
|
DeleteRequest(const std::string& collectionName, Flags flags = DELETE_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".
|
|
|
|
DeleteRequest(const std::string& collectionName, bool justOne);
|
|
/// 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". When justOne is true, only the first matching document will
|
|
/// be removed (the same as using flag DELETE_SINGLE_REMOVE).
|
|
|
|
virtual ~DeleteRequest();
|
|
/// Destructor
|
|
|
|
Flags flags() const;
|
|
/// Returns flags
|
|
|
|
void flags(Flags flag);
|
|
/// Sets flags
|
|
|
|
Document& selector();
|
|
/// Returns the selector document
|
|
|
|
protected:
|
|
void buildRequest(BinaryWriter& writer);
|
|
/// Writes the OP_DELETE request to the writer
|
|
|
|
private:
|
|
Flags _flags;
|
|
std::string _fullCollectionName;
|
|
Document _selector;
|
|
};
|
|
|
|
|
|
inline DeleteRequest::Flags DeleteRequest::flags() const
|
|
{
|
|
return _flags;
|
|
}
|
|
|
|
|
|
inline void DeleteRequest::flags(DeleteRequest::Flags flags)
|
|
{
|
|
_flags = flags;
|
|
}
|
|
|
|
|
|
inline Document& DeleteRequest::selector()
|
|
{
|
|
return _selector;
|
|
}
|
|
|
|
|
|
} } // namespace Poco::MongoDB
|
|
|
|
|
|
#endif //MongoDB_DeleteRequest_INCLUDED
|