|
EpcTools
An event based multi-threaded C++ development framework.
|
A class used to build JSON strings. It maintains a stack of JSON objects which allows you to build a hierarchy of items. New objects are added to the scope of the current object (i.e. the top of the stack). It provides methods to push and pop objects from the stack and helper classes to automatically manage the stack. More...
#include <ejsonbuilder.h>
Classes | |
| class | StackContainer |
| A helper class which pushes/pops items on the builder's object stack based on its lifetime. More... | |
| class | StackValue |
| A helper class which pushes/pops items on the builder's object stack based on its lifetime. More... | |
Public Types | |
| enum | ContainerType { ContainerType::Array, ContainerType::Object } |
| Enumeration for JSON containers types. More... | |
| using | StackString = StackValue< EString > |
| using | StackUInt = StackValue< UInt > |
| using | StackBool = StackValue< Bool > |
| using | StackArray = StackContainer< ContainerType::Array > |
| using | StackObject = StackContainer< ContainerType::Object > |
Public Member Functions | |
| EJsonBuilder () | |
| Constructor. Initializes the document object used to contain all appended JSON objects. More... | |
| ~EJsonBuilder () | |
| Destructor. More... | |
| Void | push (ContainerType type) |
| Pushes a container type object onto the stack. More... | |
| Void | push (const EString &value) |
| Pushes a string object onto the stack. More... | |
| Void | push (const UInt value) |
| Pushes an unsigned integer value onto the stack. More... | |
| Void | pop (const EString &name="") |
| Pops the top object off the stack. More... | |
| cpStr | toString (Bool pretty=false) |
| Returns a string representation of the json objects. More... | |
A class used to build JSON strings. It maintains a stack of JSON objects which allows you to build a hierarchy of items. New objects are added to the scope of the current object (i.e. the top of the stack). It provides methods to push and pop objects from the stack and helper classes to automatically manage the stack.
| using EJsonBuilder::StackBool = StackValue<Bool> |
| using EJsonBuilder::StackString = StackValue<EString> |
| using EJsonBuilder::StackUInt = StackValue<UInt> |
|
strong |
| EJsonBuilder::EJsonBuilder | ( | ) |
Constructor. Initializes the document object used to contain all appended JSON objects.
|
default |
Destructor.
| Void EJsonBuilder::pop | ( | const EString & | name = "" | ) |
Pops the top object off the stack.
| name | the name to use when adding this object to a container object on the stack. If the current container object is an array, then the name shall be empty, otherwise, it is required to be non-empty. |
| EJsonBuilder_EmptyStack | |
| EJsonBuilder_NonEmptyName | |
| EJsonBuilder_EmptyName |
| Void EJsonBuilder::push | ( | ContainerType | type | ) |
Pushes a container type object onto the stack.
| type | the type of container object to push |
| EJsonBuilder_UnrecognizedType |
| Void EJsonBuilder::push | ( | const EString & | value | ) |
Pushes a string object onto the stack.
| value | the value of the string object |
| Void EJsonBuilder::push | ( | const UInt | value | ) |
Pushes an unsigned integer value onto the stack.
| value | the value of the unsigned integer object |
| cpStr EJsonBuilder::toString | ( | Bool | pretty = false | ) |
Returns a string representation of the json objects.
| pretty | controls whether pretty printing is used |
| EJsonBuilder_NonEmptyStack |
1.8.11