PLCnext API Documentation 25.0.2.69
Public Member Functions | Static Public Member Functions | List of all members
Arp::System::Commons::Json::JsonReader Class Reference

Public Member Functions

 JsonReader (void)
 Default constructor.
 
 JsonReader (const JsonReader &arg)=delete
 
 JsonReader (JsonReader &&arg) noexcept
 Default move constructor.
 
JsonReaderoperator= (const JsonReader &arg)=delete
 
JsonReaderoperator= (JsonReader &&arg) noexcept
 Default move-assignment operator.
 
 ~JsonReader (void)
 Default destructor.
 
const StringGetDocumentFileName ()
 Gets the current document filename of this Json reader More...
 
bool HasRootObject (void)
 Returns the root value information More...
 
bool HasRootSimpleArray (void)
 Returns the root value information More...
 
bool HasRootComplexArray (void)
 Returns the root value information More...
 
void ReadRootObject (void)
 Go straight into the root object or root complex array More...
 
bool TryReadRootObject (void)
 Go straight into the root object or root complex array More...
 
void ReadStartObject (const char *objectName)
 Reads a Json object or complex array More...
 
bool TryReadStartObject (const char *objectName)
 Reads a Json object or complex array. More...
 
void ReadEndObject (void)
 End of reading a Json object More...
 
bool TryReadEndObject (void)
 End of reading a Json object More...
 
bool TryReadStartAny (String &name)
 Reads in a loop a Json object or complex array More...
 
void ReadEndAny (void)
 End of reading a loop Json object More...
 
bool TryReadEndAny (void)
 End of reading a loop Json object More...
 
void ReadStartComplexArrayItem (void)
 Reads a Json complex array item More...
 
bool TryReadStartComplexArrayItem (void)
 Reads a complex array item More...
 
void ReadEndComplexArrayItem (void)
 End of reading a complex array item More...
 
bool TryReadEndComplexArrayItem (void)
 End of reading a complex array item More...
 
bool TryReadValue (const char *valueName, bool &result)
 Reads a bool value More...
 
bool TryReadValue (const char *valueName, String &result)
 Reads a String value More...
 
bool TryReadValue (const char *valueName, uint8 &result)
 Reads a uint8 value More...
 
bool TryReadValue (const char *valueName, int8 &result)
 Reads a int8 value More...
 
bool TryReadValue (const char *valueName, uint16 &result)
 Reads a uint16 value More...
 
bool TryReadValue (const char *valueName, int16 &result)
 Reads a int16 value More...
 
bool TryReadValue (const char *valueName, uint32 &result)
 Reads a uint32 value More...
 
bool TryReadValue (const char *valueName, int32 &result)
 Reads a int32 value More...
 
bool TryReadValue (const char *valueName, uint64 &result)
 Reads a uint64 value More...
 
bool TryReadValue (const char *valueName, int64 &result)
 Reads a int64 value More...
 
bool TryReadValue (const char *valueName, float32 &result)
 Reads a float32 value More...
 
bool TryReadValue (const char *valueName, float64 &result)
 Reads a float64 value More...
 
void ReadValue (const char *valueName, char *pBuffer, size_t bufferSize)
 Reads a char* value More...
 
bool TryReadValue (const char *valueName, char *pBuffer, size_t bufferSize)
 Reads a char* value More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< bool > &result)
 Reads a simple array of bool More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< String > &result)
 Reads a simple array of String More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< uint8 > &result)
 Reads a simple array of uint8 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< int8 > &result)
 Reads a simple array of int8 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< uint16 > &result)
 Reads a simple array of uint16 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< int16 > &result)
 Reads a simple array of int16 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< uint32 > &result)
 Reads a simple array of uint32 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< int32 > &result)
 Reads a simple array of int32 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< uint64 > &result)
 Reads a simple array of uint64 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< int64 > &result)
 Reads a simple array of int64 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< float32 > &result)
 Reads a simple array of float64 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< float64 > &result)
 Reads a simple array of float64 More...
 
bool TryReadSimpleArray (const char *arrayName, std::vector< Arp::byte > &result)
 Reads a simple array of std::byte More...
 
JsonValue GetRootValue (void)
 Reads a root JsonValue More...
 
bool TryGetRootValue (JsonValue &jsonValueResult)
 Reads a root JsonValue More...
 
JsonValue GetValue (const char *valueName)
 Reads a JsonValue More...
 
bool TryGetValue (const char *valueName, JsonValue &jsonValueResult)
 Reads a JsonValue More...
 
IEnumerator< constJsonValue & >::Ptr GetValueEnumerator (void)
 List a level in the form of an enumerator More...
 
template<class T >
bool TryReadStartComplexArrayItem (T &arrayObjectResult, JsonSerializationContext &context)
 Convenience function to reade a complex array element More...
 
template<class T >
ReadValue (const char *valueName)
 Reads a value More...
 
template<class T >
std::vector< T > ReadSimpleArray (const char *arrayName)
 Reads a simple array More...
 
template<typename... Args>
JsonException CreateException (const char *message, const Args &... args) const
 
JsonException CreateException (const String &message) const
 
Impl & GetImpl (void)
 For internal use only.
 
const Impl & GetImpl (void) const
 

Static Public Member Functions

static JsonReader Create (const String &filename)
 Creates a new Instance of the JsonReader More...
 
static JsonReader CreateFromText (const String &text)
 Creates a new Instance of the JsonReader More...
 
static bool TryCreate (const String &filename, JsonReader &reader)
 Tries to creates a new Instance of the JsonReader More...
 
static bool TryCreateFromText (const String &text, JsonReader &reader)
 Creates a new Instance of the JsonReader reading from a buffer More...
 

Member Function Documentation

◆ Create()

JsonReader Arp::System::Commons::Json::JsonReader::Create ( const String filename)
static

Creates a new Instance of the JsonReader

Parameters
filenameThe Filename the writer uses to write the Json data
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ CreateFromText()

JsonReader Arp::System::Commons::Json::JsonReader::CreateFromText ( const String text)
static

Creates a new Instance of the JsonReader

Parameters
bufferReference to the buffer to read from
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ GetDocumentFileName()

const String & Arp::System::Commons::Json::JsonReader::GetDocumentFileName ( )

Gets the current document filename of this Json reader

Returns
true on success, otherwise false

◆ GetRootValue()

JsonValue Arp::System::Commons::Json::JsonReader::GetRootValue ( void  )

Reads a root JsonValue

Parameters
valueNameName of the value. An empty value name reads the root
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ GetValue()

JsonValue Arp::System::Commons::Json::JsonReader::GetValue ( const char *  valueName)

Reads a JsonValue

Parameters
valueNameName of the value. An empty value name reads the root
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ GetValueEnumerator()

IEnumerator< constJsonValue & >::Ptr Arp::System::Commons::Json::JsonReader::GetValueEnumerator ( void  )

List a level in the form of an enumerator

Returns
Enumerator of a JsonValue reference

◆ HasRootComplexArray()

bool Arp::System::Commons::Json::JsonReader::HasRootComplexArray ( void  )

Returns the root value information

Returns
Is true, if the root element is an array of objects

◆ HasRootObject()

bool Arp::System::Commons::Json::JsonReader::HasRootObject ( void  )

Returns the root value information

Returns
Is true, if the root element is an object

◆ HasRootSimpleArray()

bool Arp::System::Commons::Json::JsonReader::HasRootSimpleArray ( void  )

Returns the root value information

Returns
Is true, if the root element is an array of simple data types

◆ ReadEndAny()

void Arp::System::Commons::Json::JsonReader::ReadEndAny ( void  )

End of reading a loop Json object

Parameters
nameJson object or complex array name
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed</

◆ ReadEndComplexArrayItem()

void Arp::System::Commons::Json::JsonReader::ReadEndComplexArrayItem ( void  )

End of reading a complex array item

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadEndObject()

void Arp::System::Commons::Json::JsonReader::ReadEndObject ( void  )

End of reading a Json object

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadRootObject()

void Arp::System::Commons::Json::JsonReader::ReadRootObject ( void  )

Go straight into the root object or root complex array

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadSimpleArray()

template<class T >
std::vector< T > Arp::System::Commons::Json::JsonReader::ReadSimpleArray ( const char *  arrayName)
inline

Reads a simple array

Parameters
arrayNameName of the array
Returns
Array of values
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadStartComplexArrayItem()

void Arp::System::Commons::Json::JsonReader::ReadStartComplexArrayItem ( void  )

Reads a Json complex array item

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadStartObject()

void Arp::System::Commons::Json::JsonReader::ReadStartObject ( const char *  objectName)

Reads a Json object or complex array

Parameters
objectNameJson Object name. An empty object name reads the root object or complex array
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadValue() [1/2]

template<class T >
T Arp::System::Commons::Json::JsonReader::ReadValue ( const char *  valueName)
inline

Reads a value

Parameters
valueNameName of the value
Returns
Value
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ ReadValue() [2/2]

void Arp::System::Commons::Json::JsonReader::ReadValue ( const char *  valueName,
char *  pBuffer,
size_t  bufferSize 
)

Reads a char* value

Parameters
valueNameName of the value
pBufferPointer to the memory
bufferSizeMax buffer size from the pBuffer
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ TryCreate()

bool Arp::System::Commons::Json::JsonReader::TryCreate ( const String filename,
JsonReader reader 
)
static

Tries to creates a new Instance of the JsonReader

Parameters
filenameThe Filename the writer uses to write the Json data
Returns
true on success, otherwise false

◆ TryCreateFromText()

bool Arp::System::Commons::Json::JsonReader::TryCreateFromText ( const String text,
JsonReader reader 
)
static

Creates a new Instance of the JsonReader reading from a buffer

Parameters
bufferReference to the buffer to read from
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ TryGetRootValue()

bool Arp::System::Commons::Json::JsonReader::TryGetRootValue ( JsonValue &  jsonValueResult)

Reads a root JsonValue

Parameters
valueNameName of the value. An empty value name reads the root
resultResult of a JsonValue
Returns
true on success, otherwise false

◆ TryGetValue()

bool Arp::System::Commons::Json::JsonReader::TryGetValue ( const char *  valueName,
JsonValue &  jsonValueResult 
)

Reads a JsonValue

Parameters
valueNameName of the value. An empty value name reads the root
resultResult of a JsonValue
Returns
true on success, otherwise false

◆ TryReadEndAny()

bool Arp::System::Commons::Json::JsonReader::TryReadEndAny ( void  )

End of reading a loop Json object

Parameters
nameJson object or complex array name
Returns
true on success, otherwise false

◆ TryReadEndComplexArrayItem()

bool Arp::System::Commons::Json::JsonReader::TryReadEndComplexArrayItem ( void  )

End of reading a complex array item

Returns
true on success, otherwise false

◆ TryReadEndObject()

bool Arp::System::Commons::Json::JsonReader::TryReadEndObject ( void  )

End of reading a Json object

Returns
true on success, otherwise false

◆ TryReadRootObject()

bool Arp::System::Commons::Json::JsonReader::TryReadRootObject ( void  )

Go straight into the root object or root complex array

Returns
true on success, otherwise false

◆ TryReadSimpleArray() [1/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< Arp::byte > &  result 
)

Reads a simple array of std::byte

Parameters
arrayNameName of the value
resultArray value
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [2/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< bool > &  result 
)

Reads a simple array of bool

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [3/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< float32 > &  result 
)

Reads a simple array of float64

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [4/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< float64 > &  result 
)

Reads a simple array of float64

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [5/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< int16 > &  result 
)

Reads a simple array of int16

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [6/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< int32 > &  result 
)

Reads a simple array of int32

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [7/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< int64 > &  result 
)

Reads a simple array of int64

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [8/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< int8 > &  result 
)

Reads a simple array of int8

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [9/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< String > &  result 
)

Reads a simple array of String

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [10/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< uint16 > &  result 
)

Reads a simple array of uint16

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [11/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< uint32 > &  result 
)

Reads a simple array of uint32

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [12/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< uint64 > &  result 
)

Reads a simple array of uint64

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadSimpleArray() [13/13]

bool Arp::System::Commons::Json::JsonReader::TryReadSimpleArray ( const char *  arrayName,
std::vector< uint8 > &  result 
)

Reads a simple array of uint8

Parameters
arrayNameName of the value
resultArray value to read
Returns
true on success, otherwise false

◆ TryReadStartAny()

bool Arp::System::Commons::Json::JsonReader::TryReadStartAny ( String name)

Reads in a loop a Json object or complex array

Parameters
nameReturn of a Json object or complex array name
Returns
true on success, otherwise false

◆ TryReadStartComplexArrayItem() [1/2]

template<class T >
bool Arp::System::Commons::Json::JsonReader::TryReadStartComplexArrayItem ( T &  arrayObjectResult,
JsonSerializationContext context 
)
inline

Convenience function to reade a complex array element

Parameters
arryObjectResultComplex array element
contextContext of the Json Serialization
Returns
true on success, otherwise false

◆ TryReadStartComplexArrayItem() [2/2]

bool Arp::System::Commons::Json::JsonReader::TryReadStartComplexArrayItem ( void  )

Reads a complex array item

Returns
true on success, otherwise false

◆ TryReadStartObject()

bool Arp::System::Commons::Json::JsonReader::TryReadStartObject ( const char *  objectName)

Reads a Json object or complex array.

Parameters
objectNameJson Object name. An empty object name reads the root object or complex array
Returns
true on success, otherwise false

◆ TryReadValue() [1/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
bool &  result 
)

Reads a bool value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [2/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
char *  pBuffer,
size_t  bufferSize 
)

Reads a char* value

Parameters
valueNameName of the value
pBufferPointer to the memory
bufferSizeMax buffer size from the pBuffer
Returns
true on success, otherwise false

◆ TryReadValue() [3/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
float32 &  result 
)

Reads a float32 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [4/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
float64 &  result 
)

Reads a float64 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [5/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
int16 &  result 
)

Reads a int16 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [6/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
int32 &  result 
)

Reads a int32 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [7/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
int64 &  result 
)

Reads a int64 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [8/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
int8 &  result 
)

Reads a int8 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [9/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
String result 
)

Reads a String value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [10/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
uint16 &  result 
)

Reads a uint16 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [11/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
uint32 &  result 
)

Reads a uint32 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [12/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
uint64 &  result 
)

Reads a uint64 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

◆ TryReadValue() [13/13]

bool Arp::System::Commons::Json::JsonReader::TryReadValue ( const char *  valueName,
uint8 &  result 
)

Reads a uint8 value

Parameters
valueNameName of the value
resultValue to read
Returns
true on success, otherwise false

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