mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
Add checkNull and documentation
This commit is contained in:
@@ -29,42 +29,62 @@ namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
class Redis_API Array
|
||||
/// Represents a Redis Array.
|
||||
/// Represents a Redis Array. An Array can contain Integers, Strings,
|
||||
/// Bulk Strings, Errors and other arrays. It can also contain a Null
|
||||
/// value.
|
||||
{
|
||||
public:
|
||||
Array();
|
||||
/// Default constructor. As long as there are no elements added,
|
||||
/// the array will contain a Null value.
|
||||
|
||||
Array(const Array& copy);
|
||||
/// Copy constructor.
|
||||
|
||||
virtual ~Array();
|
||||
/// Destructor.
|
||||
|
||||
void add(Poco::Int64 value);
|
||||
/// Adds an integer element.
|
||||
|
||||
void add(const std::string& value);
|
||||
/// Adds a simple string element (can't contain a newline!).
|
||||
|
||||
void add(const BulkString& value);
|
||||
/// Adds a bulk string element.
|
||||
|
||||
void add();
|
||||
/// Adds a Null bulk string element.
|
||||
|
||||
void add(RedisType::Ptr value);
|
||||
/// Adds a Redis element.
|
||||
|
||||
std::vector<RedisType::Ptr>::const_iterator begin() const;
|
||||
/// Returns an iterator to the start of the array. Note:
|
||||
/// this can throw a NullValueException when this is a Null array.
|
||||
|
||||
void clear();
|
||||
|
||||
std::vector<RedisType::Ptr>::const_iterator end() const;
|
||||
/// Returns an iterator to the end of the array. Note:
|
||||
/// this can throw a NullValueException when this is a Null array.
|
||||
|
||||
bool isNull() const;
|
||||
/// Returns true when this is a Null array.
|
||||
|
||||
std::string toString() const;
|
||||
/// Returns the String representation as specified in the
|
||||
/// Redis Protocol specification.
|
||||
|
||||
size_t size() const;
|
||||
/// Returns the size of the array. Note:
|
||||
/// this can throw a NullValueException when this is a Null array.
|
||||
|
||||
private:
|
||||
|
||||
Nullable<std::vector<RedisType::Ptr> > _elements;
|
||||
|
||||
static std::vector<RedisType::Ptr> _empty;
|
||||
void checkNull();
|
||||
};
|
||||
|
||||
inline std::vector<RedisType::Ptr>::const_iterator Array::begin() const
|
||||
@@ -72,6 +92,12 @@ inline std::vector<RedisType::Ptr>::const_iterator Array::begin() const
|
||||
return _elements.value().begin();
|
||||
}
|
||||
|
||||
inline void Array::checkNull()
|
||||
{
|
||||
std::vector<RedisType::Ptr> v;
|
||||
if ( _elements.isNull() ) _elements.assign(v);
|
||||
}
|
||||
|
||||
inline void Array::clear()
|
||||
{
|
||||
if ( !_elements.isNull() )
|
||||
|
||||
Reference in New Issue
Block a user