Google APIs Client Library for C++
|
Base class template for a JsonCppData object that is an array. More...
#include "client/data/jsoncpp_data.h"
Public Types | |
typedef JsonCppConstIndexIterator< T > | const_iterator |
Public Member Functions | |
JsonCppArray (const Json::Value &value) | |
Standard constructor for an immutable array. | |
JsonCppArray (Json::Value *value) | |
Standard constructor for a mutable array. | |
bool | empty () const |
Determines if array is empty or not. | |
int | size () const |
Determines the number of elements currently in the array. | |
const Json::Value & | as_value (int i) const |
Gets the [immutable] underlying JsonCpp storage for a given array element. | |
Json::Value * | as_mutable_value (int i) |
Gets the [mutable] underlying JsonCpp storage for a given array element. | |
const JsonCppData | as_object (int i) const |
Gets the [immutable] JsonCppData instance wrapping a given array element. | |
JsonCppData | as_mutable_object (int i) |
Gets the [mutable] JsonCppData instance wrapping a given array element. | |
const_iterator | begin () const |
Returns the starting point for iterating over the elements. | |
const_iterator | end () const |
Returns the ending poitn when iterating over the elements. | |
void | set (int i, const T &value) |
Changes the value for the given element. | |
const T | get (int i) const |
Returns the value for the given index. | |
T | mutable_get (int i) |
Returns a mutable value for the given index. | |
const T | operator[] (int i) const |
Provides syntactic sugar for get using [] operator overloading. | |
T | operator[] (int i) |
Provides syntactic sugar for mutable_get using [] operator overloading. | |
void | Import (const vector< T > &array) |
Imports data from a C++ vector into this instance. | |
void | Import (const T *array, int len) |
Imports data from a C++ aray into this instance. | |
void | Export (vector< T > *array) const |
Exports data from this instance into a given C++ vector. | |
bool | Export (int offset, int count, vector< T > *array) const |
Exports a range of data from this instance into a given C++ vector. | |
bool | Export (int offset, int count, T *array) const |
Exports a range of data from this instance into a given C++ array. |
Base class template for a JsonCppData object that is an array.
Arrays currently follow the JsonCpp implementation where they grow on demand. Accessing an element wil create it if it did not already exist.
This class is not thread-safe.
typedef JsonCppConstIndexIterator<T> const_iterator |
JsonCppArray | ( | const Json::Value & | value | ) | [inline, explicit] |
Standard constructor for an immutable array.
[in] | value | Provides the underlying storage for the array. |
JsonCppArray | ( | Json::Value * | value | ) | [inline, explicit] |
Standard constructor for a mutable array.
[in] | value | Provides the underlying storage for the array. |
JsonCppData as_mutable_object | ( | int | i | ) | [inline] |
Gets the [mutable] JsonCppData instance wrapping a given array element.
Json::Value* as_mutable_value | ( | int | i | ) | [inline] |
Gets the [mutable] underlying JsonCpp storage for a given array element.
This method will CHECK fail if the array is not mutable.
const JsonCppData as_object | ( | int | i | ) | const [inline] |
Gets the [immutable] JsonCppData instance wrapping a given array element.
const Json::Value& as_value | ( | int | i | ) | const [inline] |
const_iterator begin | ( | ) | const [inline] |
Returns the starting point for iterating over the elements.
Unfortunately this data model only permits const iterators because of the call-by-value-result nature of the api. We cant modify the elements unless we create a storage iterator that iterates over the storage (which you can already do by saying MutableStorage()->begin/end()
bool empty | ( | ) | const [inline] |
Determines if array is empty or not.
const_iterator end | ( | ) | const [inline] |
Returns the ending poitn when iterating over the elements.
void Export | ( | vector< T > * | array | ) | const [inline] |
Exports data from this instance into a given C++ vector.
This will clear the array before exporting.
bool Export | ( | int | offset, |
int | count, | ||
vector< T > * | array | ||
) | const [inline] |
Exports a range of data from this instance into a given C++ vector.
This will clear the array before exporting.
[in] | offset | The first index in this array to eport |
[in] | count | The number of elements to export |
[out] | array | The array to write to will be cleared before writing. The element at offset will be written into the 0'th element. |
bool Export | ( | int | offset, |
int | count, | ||
T * | array | ||
) | const [inline] |
Exports a range of data from this instance into a given C++ array.
[in] | offset | The first index in this array to eport |
[in] | count | The number of elements to export |
[out] | array | The caller should ensure that there are count elements allocated in the array. |
const T get | ( | int | i | ) | const [inline] |
Returns the value for the given index.
[in] | i | The element index to get. |
void Import | ( | const vector< T > & | array | ) | [inline] |
Imports data from a C++ vector into this instance.
This method will clear the current data before importing the new.
[in] | array | The vector to import from. |
void Import | ( | const T * | array, |
int | len | ||
) | [inline] |
Imports data from a C++ aray into this instance.
This method will clear the current data before importing the new.
[in] | array | The array to import from. |
[in] | len | The number of elements int he array to import. |
T mutable_get | ( | int | i | ) | [inline] |
Returns a mutable value for the given index.
This method will CHECK-fail if the array is not mutable.
T
denotes a JsonCppObject
. For primitive types (and strings) this method will return copy that will not actually mutate the underlying element. const T operator[] | ( | int | i | ) | const [inline] |
Provides syntactic sugar for get using [] operator overloading.
T operator[] | ( | int | i | ) | [inline] |
Provides syntactic sugar for mutable_get using [] operator overloading.
void set | ( | int | i, |
const T & | value | ||
) | [inline] |
Changes the value for the given element.
This method will CHECK-fail if the array is not mutable.
[in] | i | The index to change will be added if it was not present. |
[in] | value | The value to copy. |
int size | ( | ) | const [inline] |
Determines the number of elements currently in the array.