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

Class to write a Json file More...

#include <JsonWriter.hpp>

Public Member Functions

 JsonWriter (void)
 Default constructor.
 
 JsonWriter (const JsonWriter &arg)=delete
 
 JsonWriter (JsonWriter &&arg) noexcept
 Default move constructor.
 
JsonWriteroperator= (const JsonWriter &arg)=delete
 
JsonWriteroperator= (JsonWriter &&arg) noexcept
 Default move-assignment operator.
 
 ~JsonWriter (void)
 Default destructor.
 
void SetPrettyPrint (bool state)
 Write json data pretty print More...
 
void SaveDocument (void) const
 Save the json data to a file system More...
 
bool TrySaveDocument (void) const
 Save the json data to a file system More...
 
String SaveToText (void) const
 Save the json data to string More...
 
bool TrySaveToText (String &text) const
 Save the json data to string More...
 
void WriteRootObject (void)
 Create a Json root object More...
 
bool TryWriteRootObject (void)
 Create a Json root object More...
 
void WriteStartObject (const char *objectName)
 Create a Json object More...
 
bool TryWriteStartObject (const char *objectName)
 Create a Json object More...
 
void WriteEndObject (void)
 End of creating Json object More...
 
bool TryWriteEndObject (void)
 End of creating Json object More...
 
void WriteRootComplexArray (void)
 Creating a Json root array of objects More...
 
bool TryWriteRootComplexArray (void)
 Creating a Json root array of objects More...
 
void WriteStartComplexArray (const char *arrayName)
 Creating a Json array of objects More...
 
bool TryWriteStartComplexArray (const char *arrayName)
 Creating a Json array of objects More...
 
void WriteEndComplexArray (void)
 End of Creating a Json array of objects More...
 
bool TryWriteEndComplexArray (void)
 End of creating a Json array of objects More...
 
void WriteStartComplexArrayItem (void)
 Creating of an object array element More...
 
bool TryWriteStartComplexArrayItem (void)
 Creating of an object array element More...
 
void WriteEndComplexArrayItem (void)
 End of creating of an object array element More...
 
bool TryWriteEndComplexArrayItem (void)
 End of creating of an object array element More...
 
void WriteValue (const char *valueName, const bool &value)
 Writes a bool value More...
 
void WriteValue (const char *valueName, const uint8 &value)
 Writes a uint8 value More...
 
void WriteValue (const char *valueName, const int8 &value)
 Writes a int8 value More...
 
void WriteValue (const char *valueName, const uint16 &value)
 Writes a uint16 value More...
 
void WriteValue (const char *valueName, const int16 &value)
 Writes a int16 value More...
 
void WriteValue (const char *valueName, const uint32 &value)
 Writes a uint32 value More...
 
void WriteValue (const char *valueName, const int32 &value)
 Writes a int32 value More...
 
void WriteValue (const char *valueName, const uint64 &value)
 Writes a uint64 value More...
 
void WriteValue (const char *valueName, const int64 &value)
 Writes a int64 value More...
 
void WriteValue (const char *valueName, const float32 &value)
 Writes a float32 value More...
 
void WriteValue (const char *valueName, const float64 &value)
 Writes a float64 value More...
 
void WriteValue (const char *valueName, std::nullptr_t value)
 Writes a null value More...
 
void WriteValue (const char *valueName, const String &value)
 Writes a String value More...
 
void WriteValue (const char *valueName, const char *value)
 Writes from a const char* value, this will be maped to write String More...
 
void WriteValue (const char *valueName, const char *pBuffer, size_t bufferSize)
 Writes from a const char* value More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< bool > &values)
 Writes a simple array of bool More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< String > &values)
 Writes a simple array of String More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< uint8 > &values)
 Writes a simple array of uint8 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< int8 > &values)
 Writes a simple array of int8 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< uint16 > &values)
 Writes a simple array of uint16 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< int16 > &values)
 Writes a simple array of int16 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< uint32 > &values)
 Writes a simple array of uint32 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< int32 > &values)
 Writes a simple array of int32 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< uint64 > &values)
 Writes a simple array of uint64 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< int64 > &values)
 Writes a simple array of int64 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< float32 > &values)
 Writes a simple array of float32 More...
 
void WriteSimpleArray (const char *arrayName, const std::vector< float64 > &values)
 Writes a simple array of float64 More...
 
Impl & GetImpl (void)
 For internal use only.
 
const Impl & GetImpl (void) const
 

Static Public Member Functions

static JsonWriter Create (const String &filename)
 Creates a new Instance of the JsonWriter More...
 
static bool TryCreate (const String &filename, JsonWriter &writer)
 Tries to creates a new Instance of the JsonWriter More...
 

Detailed Description

Class to write a Json file

Member Function Documentation

◆ Create()

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

Creates a new Instance of the JsonWriter

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

◆ SaveDocument()

void Arp::System::Commons::Json::JsonWriter::SaveDocument ( void  ) const

Save the json data to a file system

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ SaveToText()

String Arp::System::Commons::Json::JsonWriter::SaveToText ( void  ) const

Save the json data to string

Returns
Returns the json data

◆ SetPrettyPrint()

void Arp::System::Commons::Json::JsonWriter::SetPrettyPrint ( bool  state)

Write json data pretty print

Parameters
stateIf true, the json data print within pretty print

◆ TryCreate()

bool Arp::System::Commons::Json::JsonWriter::TryCreate ( const String filename,
JsonWriter writer 
)
static

Tries to creates a new Instance of the JsonWriter

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

◆ TrySaveDocument()

bool Arp::System::Commons::Json::JsonWriter::TrySaveDocument ( void  ) const

Save the json data to a file system

Returns
true on success, otherwise false

◆ TrySaveToText()

bool Arp::System::Commons::Json::JsonWriter::TrySaveToText ( String text) const

Save the json data to string

Parameters
textstring result
Returns
true on success, otherwise false

◆ TryWriteEndComplexArray()

bool Arp::System::Commons::Json::JsonWriter::TryWriteEndComplexArray ( void  )

End of creating a Json array of objects

Returns
true on success, otherwise false

◆ TryWriteEndComplexArrayItem()

bool Arp::System::Commons::Json::JsonWriter::TryWriteEndComplexArrayItem ( void  )

End of creating of an object array element

Returns
true on success, otherwise false

◆ TryWriteEndObject()

bool Arp::System::Commons::Json::JsonWriter::TryWriteEndObject ( void  )

End of creating Json object

Returns
true on success, otherwise false

◆ TryWriteRootComplexArray()

bool Arp::System::Commons::Json::JsonWriter::TryWriteRootComplexArray ( void  )

Creating a Json root array of objects

Parameters
arrayNameName of the array
Returns
true on success, otherwise false

◆ TryWriteRootObject()

bool Arp::System::Commons::Json::JsonWriter::TryWriteRootObject ( void  )

Create a Json root object

Parameters
objectNameJson Object name
Returns
true on success, otherwise false

◆ TryWriteStartComplexArray()

bool Arp::System::Commons::Json::JsonWriter::TryWriteStartComplexArray ( const char *  arrayName)

Creating a Json array of objects

Parameters
arrayNameName of the array
Returns
true on success, otherwise false

◆ TryWriteStartComplexArrayItem()

bool Arp::System::Commons::Json::JsonWriter::TryWriteStartComplexArrayItem ( void  )

Creating of an object array element

Returns
true on success, otherwise false

◆ TryWriteStartObject()

bool Arp::System::Commons::Json::JsonWriter::TryWriteStartObject ( const char *  objectName)

Create a Json object

Parameters
objectNameJson Object name
Returns
true on success, otherwise false

◆ WriteEndComplexArray()

void Arp::System::Commons::Json::JsonWriter::WriteEndComplexArray ( void  )

End of Creating a Json array of objects

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ WriteEndComplexArrayItem()

void Arp::System::Commons::Json::JsonWriter::WriteEndComplexArrayItem ( void  )

End of creating of an object array element

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ WriteEndObject()

void Arp::System::Commons::Json::JsonWriter::WriteEndObject ( void  )

End of creating Json object

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ WriteRootComplexArray()

void Arp::System::Commons::Json::JsonWriter::WriteRootComplexArray ( void  )

Creating a Json root array of objects

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

◆ WriteRootObject()

void Arp::System::Commons::Json::JsonWriter::WriteRootObject ( void  )

Create a Json root object

Parameters
objectNameJson object name
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ WriteSimpleArray() [1/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< bool > &  values 
)

Writes a simple array of bool

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [2/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< float32 > &  values 
)

Writes a simple array of float32

Parameters
nameName of the value
valuesArray value to write

◆ WriteSimpleArray() [3/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< float64 > &  values 
)

Writes a simple array of float64

Parameters
nameName of the value
valuesArray value to write

◆ WriteSimpleArray() [4/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< int16 > &  values 
)

Writes a simple array of int16

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [5/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< int32 > &  values 
)

Writes a simple array of int32

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [6/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< int64 > &  values 
)

Writes a simple array of int64

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [7/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< int8 > &  values 
)

Writes a simple array of int8

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [8/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< String > &  values 
)

Writes a simple array of String

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [9/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< uint16 > &  values 
)

Writes a simple array of uint16

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [10/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< uint32 > &  values 
)

Writes a simple array of uint32

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [11/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< uint64 > &  values 
)

Writes a simple array of uint64

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteSimpleArray() [12/12]

void Arp::System::Commons::Json::JsonWriter::WriteSimpleArray ( const char *  arrayName,
const std::vector< uint8 > &  values 
)

Writes a simple array of uint8

Parameters
arrayNameName of the value
valuesArray value to write

◆ WriteStartComplexArray()

void Arp::System::Commons::Json::JsonWriter::WriteStartComplexArray ( const char *  arrayName)

Creating a Json array of objects

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

◆ WriteStartComplexArrayItem()

void Arp::System::Commons::Json::JsonWriter::WriteStartComplexArrayItem ( void  )

Creating of an object array element

Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ WriteStartObject()

void Arp::System::Commons::Json::JsonWriter::WriteStartObject ( const char *  objectName)

Create a Json object

Parameters
objectNameJson object name
Exceptions
JsonExceptionAn exception is thrown if the function cannot be executed

◆ WriteValue() [1/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const bool &  value 
)

Writes a bool value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [2/15]

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

Writes from a const char* value

Parameters
valueNameName of the value
pBufferValue to write
bufferSizeWriting size

◆ WriteValue() [3/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const char *  value 
)

Writes from a const char* value, this will be maped to write String

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [4/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const float32 &  value 
)

Writes a float32 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [5/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const float64 &  value 
)

Writes a float64 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [6/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const int16 &  value 
)

Writes a int16 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [7/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const int32 &  value 
)

Writes a int32 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [8/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const int64 &  value 
)

Writes a int64 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [9/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const int8 &  value 
)

Writes a int8 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [10/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const String value 
)

Writes a String value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [11/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const uint16 &  value 
)

Writes a uint16 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [12/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const uint32 &  value 
)

Writes a uint32 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [13/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const uint64 &  value 
)

Writes a uint64 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [14/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
const uint8 &  value 
)

Writes a uint8 value

Parameters
valueNameName of the value
valueValue to write

◆ WriteValue() [15/15]

void Arp::System::Commons::Json::JsonWriter::WriteValue ( const char *  valueName,
std::nullptr_t  value 
)

Writes a null value

Parameters
valueNameName of the value
valueValue to write

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