Open Lighting Architecture: ola::web::JsonPointer Class Reference

| Open Lighting Architecture 0.10.9

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

## Detailed Description

A JSON pointer (RFC 6901) refers to a possible element in a JSON data structure.

The element referenced by the pointer may or may not exist.

Given the JSON:

{
"foo": {
"bar": 1,
"baz": true
},
"bat": [0, 1, 2]
}

The JSON pointers for each element are:

- ""
- "/foo"
- "/foo/bar"
- "/foo/baz"
- "/bat"
- "/bat/0"
- "/bat/1"
- "/bat/2"

## Classes
class | Iterator
| An iterator for traversing a JsonPointer. More...

## Public Member Functions
| JsonPointer (const JsonPointer &other)
| JsonPointer (const std::string &path)
| Construct a new JsonPointer from a string representing the path.
bool | operator== (const JsonPointer &other) const
| Equality operator.
bool | IsValid () const
| Returns true if this pointer is valid.
Iterator | begin () const
| Return an iterator pointing to the first token in the JsonPointer.
unsigned int | TokenCount () const
| The number of tokens in the Json Pointer.
std::string | TokenAt (unsigned int i) const
| Return the token at the specified index.
void | Push (const std::string &token)
| Append a token to the pointer path.
void | Pop ()
| Pop the last token from the pointer.
std::string | ToString () const
| Returns the string representation of the pointer.
bool | IsPrefixOf (const JsonPointer &other) const
| Check if this pointer is a prefix of another.

## Constructor & Destructor Documentation

## ◆ JsonPointer()

ola::web::JsonPointer::JsonPointer | ( | const std::string & | path | ) |
| explicit

Construct a new JsonPointer from a string representing the path.

Parameters

  path | A Json Pointer path. The path should either be empty, or start with a /.

## Member Function Documentation

## ◆ IsPrefixOf()

bool ola::web::JsonPointer::IsPrefixOf | ( | const JsonPointer & | other | ) | const

Check if this pointer is a prefix of another.

Parameters

  other | the JsonPointer to compare to.

Returns
  true if this object is a prefix of the parameter.

## ◆ IsValid()

bool ola::web::JsonPointer::IsValid | ( |  | ) | const
| inline

Returns true if this pointer is valid.

Invalid pointers are ones that don't start with a /. If the pointer is invalid, the result of all other methods is undefined.

## ◆ Push()

void ola::web::JsonPointer::Push | ( | const std::string & | token | ) |

Append a token to the pointer path.

Parameters

  token | The un-escaped token to add to this JsonPointer.

## ◆ TokenAt()

std::string ola::web::JsonPointer::TokenAt | ( | unsigned int | i | ) | const
| inline

Return the token at the specified index.

Parameters

  i | the index of the token to return.

Returns
  the un-encoded representation of the token.

## ◆ TokenCount()

unsigned int ola::web::JsonPointer::TokenCount | ( |  | ) | const
| inline

The number of tokens in the Json Pointer.

A valid pointer has at least one token (""). The number of tokens is the number of / plus one.

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

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