Poco::Redis

class Array

File Information

Library: Redis
Package: Redis
Header: Poco/Redis/Array.h

Description

Represents a Redis Array. An Array can contain Integers, Strings, Bulk Strings, Errors and other Arrays. It can also contain a Null value.

Inheritance

Known Derived Classes: Command

Member Summary

Member Functions: add, addRedisType, addSimpleString, begin, clear, end, get, getType, isNull, makeNull, operator <<, size, toString

Types Aliases

const_iterator

using const_iterator = std::vector < RedisType::Ptr >::const_iterator;

Constructors

Array

Array();

Creates an Array. As long as there are no elements added, the array will contain a Null value.

Array

Array(
    const Array & copy
);

Creates an Array by copying another one.

Destructor

~Array virtual

virtual ~Array();

Destroys the Array.

Member Functions

add inline

Array & add();

Adds an Null BulkString.

add inline

template < typename T > Array & add(
    const T & arg
);

Adds an element to the array.

Note: the specialization for std::string will add a BulkString! If you really need a simple string, call addSimpleString.

add

Array & add(
    const char * s
);

Special implementation for const char*.

Note: the specialization creates a BulkString. If you need a simple string, call addSimpleString.

add

Array & add(
    const std::vector < std::string > & strings
);

Special implementation for a vector with strings. All strings will be added as a BulkString.

addRedisType

Array & addRedisType(
    RedisType::Ptr value
);

Adds a Redis element.

addSimpleString inline

Array & addSimpleString(
    const std::string & value
);

Adds a simple string (can't contain newline characters!).

begin inline

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.

clear inline

void clear();

Removes all elements from the array.

end inline

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.

get inline

template < typename T > T get(
    size_t pos
) const;

Returns the element on the given position and tries to convert to the template type. A Poco::BadCastException will be thrown when the the conversion fails. An Poco::InvalidArgumentException will be thrown when the index is out of range. When the array is a Null array a Poco::NullValueException is thrown.

getType

int getType(
    size_t pos
) const;

Returns the type of the element. This can throw a Poco::NullValueException when this array is a Null array. An Poco::InvalidArgumentException will be thrown when the index is out of range.

isNull inline

bool isNull() const;

Returns true when this is a Null array.

makeNull inline

void makeNull();

Turns the array into a Null array. When the array already has some elements, the array will be cleared.

operator << inline

template < typename T > Array & operator << (
    const T & arg
);

Adds the argument to the array.

Note: a std::string will be added as a BulkString because this is commonly used for representing strings in Redis. If you really need a simple string, use addSimpleString().

operator <<

Array & operator << (
    const char * s
);

Special implementation for const char*.

Note: the specialization creates a BulkString. If you need a simple string, call addSimpleString().

operator <<

Array & operator << (
    const std::vector < std::string > & strings
);

Special implementation for a vector with strings. All strings will be added as a BulkString.

size inline

size_t size() const;

Returns the size of the array.

Note: this can throw a NullValueException when this is a Null array.

toString

std::string toString() const;

Returns the String representation as specified in the Redis Protocol specification.