Poco::JSON

class Array

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

Member Summary

Member Functions: add, begin, end, get, getArray, getElement, getObject, isArray, isNull, isObject, optElement, remove, size, stringify

Types

Ptr

typedef SharedPtr < Array > Ptr;

ValueVec

typedef std::vector < Dynamic::Var > ValueVec;

Constructors

Array

Array();

Default constructor

Array

Array(
    const Array & copy
);

Copy Constructor

Destructor

~Array virtual

virtual ~Array();

Destructor

Member Functions

add inline

void add(
    const Dynamic::Var & value
);

Add the given value to the array

begin inline

ValueVec::const_iterator begin() const;

Returns iterator

end inline

ValueVec::const_iterator end() const;

Returns iterator

get

Dynamic::Var get(
    unsigned int index
) const;

Retrieves an element. Will return an empty value when the element doesn't exist.

getArray

Array::Ptr getArray(
    unsigned int index
) const;

Retrieves an array. When the element is not an array or doesn't exist, an empty SharedPtr is returned.

getElement inline

template < typename T > T getElement(
    unsigned int index
) const;

Retrieves an element and tries to convert it to the template type. The convert<T> method of Dynamic is called which can also throw exceptions for invalid values. Note: This will not work for an array or an object.

getObject

SharedPtr < Object > getObject(
    unsigned int index
) const;

Retrieves an object. When the element is not an object or doesn't exist, an empty SharedPtr is returned.

isArray inline

bool isArray(
    unsigned int index
) const;

Returns true when the element is an array

isNull

bool isNull(
    unsigned int index
) const;

Returns true when the element is null or when the element doesn't exist.

isObject

bool isObject(
    unsigned int index
) const;

Returns true when the element is an object

optElement inline

template < typename T > T optElement(
    unsigned int index,
    const T & def
) const;

Returns the element at the given index. When the element is null, doesn't exist or can't be converted to the given type, the default value will be returned

remove inline

void remove(
    unsigned int index
);

Removes the element on the given index.

size inline

std::size_t size() const;

Returns the size of the array

stringify

void stringify(
    std::ostream & out,
    unsigned int indent
) const;

Prints the array to out. When indent is 0, the array will be printed on one line without indentation.