Open Lighting Architecture  0.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:

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 specifed 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

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

Construct a new JsonPointer from a string representing the path.

Parameters
pathA Json Pointer path. The path should either be empty, or start with a /.

Member Function Documentation

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

Check if this pointer is a prefix of another.

Parameters
otherthe JsonPointer to compare to.
Returns
true if this object is a prefix of the parameter.
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.

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

Append a token to the pointer path.

Parameters
tokenThe un-escaped token to add to this JsonPointer.
std::string ola::web::JsonPointer::TokenAt ( unsigned int  i) const
inline

Return the token at the specifed index.

Parameters
ithe index of the token to return.
Returns
the un-encoded representation of the token.
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: