Open Lighting Architecture: ola::JsonArray Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ola::JsonArray Class Reference

## Detailed Description

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

Inheritance diagram for ola::JsonArray:

## Public Member Functions
JsonValue * | LookupElementWithIter (JsonPointer::Iterator *iter)
bool | operator== (const JsonValue &other) const
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.
JsonObject * | AppendObject ()
| Append a JsonObject to the array.
JsonArray * | AppendArray ()
| 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)
void | Accept (JsonValueConstVisitorInterface *visitor) const
JsonValue * | Clone () 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 JsonValue * | ElementAt (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 JsonValue * | LookupElement (const JsonPointer &pointer)
| Locate the JsonValue referred to by the JSON Pointer.
virtual bool | operator== (const JsonValue &other) const =0
| Equality operator.
virtual bool | operator!= (const JsonValue &other) const
| Not-equals operator.
virtual void | Accept (JsonValueVisitorInterface *visitor)=0
| The Accept method for the visitor pattern.
virtual void | Accept (JsonValueConstVisitorInterface *visitor) const =0
| The Accept (const) method for the visitor pattern.

## Member Function Documentation

## ◆ Append() [1/5]

void ola::web::JsonArray::Append | ( | bool | value | ) |
| inline

Append a bool value to the array.

Parameters

  value | the value to append

## ◆ Append() [2/5]

void ola::web::JsonArray::Append | ( | const char * | value | ) |
| inline

Append a string value to the array.

Parameters

  value | the value to append

## ◆ Append() [3/5]

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

Append a string value to the array.

Parameters

  value | the value to append

## ◆ Append() [4/5]

void ola::web::JsonArray::Append | ( | int | i | ) |
| inline

Append an int value to the array.

Parameters

  i | the value to append

## ◆ Append() [5/5]

void ola::web::JsonArray::Append | ( | unsigned int | i | ) |
| inline

Append an unsigned int value to the array.

Parameters

  i | the value to append

## ◆ AppendArray()

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.

## ◆ AppendObject()

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.

## ◆ AppendValue()

void ola::web::JsonArray::AppendValue | ( | JsonValue * | value | ) |
| inline

Append a JsonValue to the array.

Parameters

  value | the JsonValue to append, ownership is transferred.

## ◆ Clone()

JsonValue * ola::web::JsonArray::Clone | ( |  | ) | const
| virtual

Make a copy of this JsonValue.

Implements ola::web::JsonValue.

## ◆ ElementAt()

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.

## ◆ Equals()

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.

## ◆ InsertElementAt()

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

Inserts the JsonValue at the specified index.

Parameters

  index | the index to insert at.
  value | the 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.

## ◆ IsEmpty()

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.

## ◆ RemoveElementAt()

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

Remove the JsonValue at the specified index.

Parameters

  index | the index of the value to remove

Returns
  true if the index is within the current array, false otherwise.

## ◆ ReplaceElementAt()

bool ola::web::JsonArray::ReplaceElementAt | ( | uint32_t | index,
|  | JsonValue * | value )

Replace the JsonValue at the specified index.

Parameters

  index | the index of the value to replace.
  value | the 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:

- include/ola/web/Json.h
- common/web/Json.cpp