Open Lighting Architecture  0.9.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
ola::web::JsonArray Class Reference

Detailed Description

An array of JSON values. Arrays in JSON can contain values of different types.

Inheritance diagram for ola::web::JsonArray:
ola::web::JsonValue

Public Member Functions

JsonValueLookupElementWithIter (JsonPointer::Iterator *iter)
 Lookup the Value referred to by the Iterator.
bool operator== (const JsonValue &other) const
 Equality operator.
bool Equals (const JsonArray &other) const
 Check if this JsonValue equals a JsonArray.
void Append (const std::string &value)
 Append a string value to the array.
void Append (const char *value)
 Append a string value to the array.
void Append (unsigned int i)
 Append an unsigned int value to the array.
void Append (int i)
 Append an int value to the array.
void Append (bool value)
 Append a bool value to the array.
void Append ()
 Append a null value to the array.
void Append (JsonValue *value)
 Append a JsonValue. Takes ownership of the pointer.
void Append (JsonObject *value)
 Append a JsonValue. Takes ownership of the pointer.
JsonObjectAppendObject ()
 Append a JsonObject to the array.
JsonArrayAppendArray ()
 Append a JsonArray to the array.
void AppendValue (JsonValue *value)
 Append a JsonValue to the array.
void AppendRaw (const std::string &value)
 Append a raw value to the array.
bool RemoveElementAt (uint32_t index)
 Remove the JsonValue at the specified index.
bool ReplaceElementAt (uint32_t index, JsonValue *value)
 Replace the JsonValue at the specified index.
bool InsertElementAt (uint32_t index, JsonValue *value)
 Inserts the JsonValue at the specified index.
void Accept (JsonValueVisitorInterface *visitor)
 The Accept method for the visitor pattern.
void Accept (JsonValueConstVisitorInterface *visitor) const
 The Accept (const) method for the visitor pattern.
JsonValueClone () const
 Make a copy of this JsonValue.
bool IsEmpty () const
 Check if there are elements within the array.
unsigned int Size () const
 Return the number of elements in the array.
const JsonValueElementAt (unsigned int i) const
 Return the element at index i.
bool IsComplexType () const
 Return true if this array contains nested arrays or objects.
- Public Member Functions inherited from ola::web::JsonValue
virtual JsonValueLookupElement (const JsonPointer &pointer)
 Locate the JsonValue referred to by the JSON Pointer.
virtual bool operator!= (const JsonValue &other) const
 Not-equals operator.

Member Function Documentation

void ola::web::JsonArray::Accept ( JsonValueVisitorInterface visitor)
inlinevirtual

The Accept method for the visitor pattern.

This can be used to traverse the Json Tree in a type-safe manner.

Implements ola::web::JsonValue.

void ola::web::JsonArray::Accept ( JsonValueConstVisitorInterface visitor) const
inlinevirtual

The Accept (const) method for the visitor pattern.

This can be used to traverse the Json Tree in a type-safe manner.

Implements ola::web::JsonValue.

void ola::web::JsonArray::Append ( const std::string &  value)
inline

Append a string value to the array.

Parameters
valuethe value to append
void ola::web::JsonArray::Append ( const char *  value)
inline

Append a string value to the array.

Parameters
valuethe value to append
void ola::web::JsonArray::Append ( unsigned int  i)
inline

Append an unsigned int value to the array.

Parameters
ithe value to append
void ola::web::JsonArray::Append ( int  i)
inline

Append an int value to the array.

Parameters
ithe value to append
void ola::web::JsonArray::Append ( bool  value)
inline

Append a bool value to the array.

Parameters
valuethe value to append
JsonArray* ola::web::JsonArray::AppendArray ( )
inline

Append a JsonArray to the array.

Returns
the new JsonArray. Ownership is not transferred and the pointer is valid for the lifetime of this JsonArray.
JsonObject* ola::web::JsonArray::AppendObject ( )
inline

Append a JsonObject to the array.

Returns
the new JsonObject. Ownership is not transferred and the pointer is valid for the lifetime of this JsonArray.
void ola::web::JsonArray::AppendValue ( JsonValue value)
inline

Append a JsonValue to the array.

Parameters
valuethe JsonValue to append, ownership is transferred.
const JsonValue * ola::web::JsonArray::ElementAt ( unsigned int  i) const

Return the element at index i.

Returns
The JsonValue at i, of NULL if the index is out of range.
bool ola::web::JsonArray::Equals ( const JsonArray ) const
virtual

Check if this JsonValue equals a JsonArray.

Returns
true if the two values are equal, false otherwise.

Reimplemented from ola::web::JsonValue.

bool ola::web::JsonArray::InsertElementAt ( uint32_t  index,
JsonValue value 
)

Inserts the JsonValue at the specified index.

Parameters
indexthe index to insert at.
valuethe new JsonValue. Ownership is transferred.
Returns
true if the index is within the current array, false otherwise.

Any elements at or above the index are shifted one to the right.

bool ola::web::JsonArray::IsEmpty ( ) const
inline

Check if there are elements within the array.

Returns
true if the array is empty, false if there are elements.
JsonValue * ola::web::JsonArray::LookupElementWithIter ( JsonPointer::Iterator iterator)
virtual

Lookup the Value referred to by the Iterator.

This is used by recursively by JsonValue classes. You should call LookupElement() instead.

Implements ola::web::JsonValue.

bool ola::web::JsonArray::operator== ( const JsonValue other) const
inlinevirtual

Equality operator.

This implements equality as defined in section 3.6 of the JSON Schema Core document.

Implements ola::web::JsonValue.

bool ola::web::JsonArray::RemoveElementAt ( uint32_t  index)

Remove the JsonValue at the specified index.

Parameters
indexthe index of the value to remove
Returns
true if the index is within the current array, false otherwise.
bool ola::web::JsonArray::ReplaceElementAt ( uint32_t  index,
JsonValue value 
)

Replace the JsonValue at the specified index.

Parameters
indexthe index of the value to replace.
valuethe new JsonValue. Ownership is transferred.
Returns
true if the index is within the current array, false otherwise.

The documentation for this class was generated from the following files: