Add some handy "short-cut" functions

This commit is contained in:
fbraem 2013-02-27 18:51:05 +01:00
Родитель 382dbd5637
Коммит 6a8b2c5a48
1 изменённых файлов: 40 добавлений и 10 удалений

Просмотреть файл

@ -60,14 +60,6 @@ public:
/// Destructor /// Destructor
void read(std::istream& istr);
/// Reads the response from the stream
Document::Vector& documents();
/// Returns the retrieved documents
Int64 cursorID() const; Int64 cursorID() const;
/// Returns the cursor id /// Returns the cursor id
@ -75,6 +67,27 @@ public:
void clear(); void clear();
/// Clears the response /// Clears the response
size_t count() const;
/// Returns the number of documents in the response
Document::Vector& documents();
/// Returns the retrieved documents
bool empty() const;
/// Returns true when the response doesn't contain any documents
bool hasDocuments() const;
/// Returns true when there is at least one document
void read(std::istream& istr);
/// Reads the response from the stream
private: private:
Int32 _responseFlags; Int32 _responseFlags;
@ -93,9 +106,15 @@ private:
}; };
inline Document::Vector& ResponseMessage::documents() inline size_t ResponseMessage::count() const
{ {
return _documents; return _documents.size();
}
inline bool ResponseMessage::empty() const
{
return _documents.size() == 0;
} }
@ -105,6 +124,17 @@ inline Int64 ResponseMessage::cursorID() const
} }
inline Document::Vector& ResponseMessage::documents()
{
return _documents;
}
inline bool ResponseMessage::hasDocuments() const
{
return _documents.size() > 0;
}
}} // Namespace Poco::MongoDB }} // Namespace Poco::MongoDB
#endif //_MongoDB_ResponseMessage_included #endif //_MongoDB_ResponseMessage_included