PLCnext API Documentation
22.9.0.33
|
Rsc container class for primitive data type, strings or information about arrays or structs. ArrayInformation and StructInformation are used in combination with RscArrayReader, RscArrayWriter, RscStructReader and RscStructWriter More...
#include <RscVariant.hxx>
Public Types | |
using | ReadElementFunction = std::function< RscType(RscType expectedType, byte *pValue)> |
using | WriteElementFunction = std::function< void(RscType valueType, const byte *pValue)> |
using | Uuid = Arp::System::Commons::Configuration::Uuid |
Public Member Functions | |
RscVariant (RscType type=RscType::None) | |
Creates an empty instance of RscVariant More... | |
template<class T > | |
RscVariant (const T &value) | |
Creates a new instance of RscVariant with value. Gets RscType by type deduction of T. More... | |
RscVariant (const String &value) | |
Creates a new instance of RscVariant with value. RscType is Utf8String. More... | |
RscVariant (const char *value) | |
Creates a new instance of RscVariant with value. RscType is Utf8String. More... | |
RscVariant (const char16 *input, size_t length, RscType type=RscType::Utf8String) | |
Assigns an UTF16 string to this instance. More... | |
template<int N> | |
RscVariant (const RscString< N > &value) | |
Creates a new instance of RscVariant with value. RscType is Utf8String. More... | |
template<int N> | |
RscVariant (const SecureString< N > &value) | |
Creates a new instance of RscVariant with value. RscType is Utf8String. More... | |
RscVariant (size_t arraySize, RscType arrayElementType, size_t dimensions=1, size_t fieldCount=0) | |
Creates a new instance of RscVariant containing an array with arraySize elements of RscType arrayElementType. Instances created with this constructor are used to to initialize RscArrayWriter to write an array. More... | |
RscVariant (size_t arraySize, RscType arrayElementType, ReadElementFunction *pFunction, size_t dimensions=1, size_t fieldCount=0) | |
Creates a new instance of RscVariant containing an array with arraySize elements of RscType arrayElementType. Instances created with this constructor are used to to initialize RscArrayReader in service implementations to write array data. More... | |
RscVariant (size_t arraySize, RscType arrayElementType, WriteElementFunction *pFunction, size_t dimensions=1, size_t fieldCount=0) | |
Creates a new instance of RscVariant containing an array with arraySize elements of RscType arrayElementType. Instances created with this constructor are used to to initialize RscArrayWriter in service implementations to read array data. More... | |
RscVariant (size_t fieldCount, ReadElementFunction *pFunction) | |
For internal use only More... | |
RscVariant (const RscVariant< MaxStringSize > &)=default | |
Copy constructor More... | |
RscVariant (RscVariant &&) noexcept=default | |
Move constructor More... | |
template<class T > | |
RscVariant & | operator= (const T &value) |
RscVariant & | operator= (const String &value) |
RscVariant & | operator= (const char *value) |
template<int N> | |
RscVariant & | operator= (const RscString< N > &value) |
template<int N> | |
RscVariant & | operator= (const SecureString< N > &value) |
RscVariant & | operator= (const RscVariant &value)=default |
RscVariant & | operator= (RscVariant &&) noexcept=default |
bool | operator== (const RscVariant &value) const |
bool | operator!= (const RscVariant &value) const |
RscType | GetType (void) const |
Gets the RscType of the contained element More... | |
RscType | GetValueType (void) const |
Gets the value type as RscType of the contained element More... | |
RscType | GetArrayElementType (void) const |
Gets the RscType of the array elements if RscVariant contains array information. More... | |
size_t | GetArrayDimensions (void) const |
Gets the count of array dimensions (1 for simple array, 2 for array of array etc.). This method is only valid for RscVariants with array information. More... | |
size_t | GetFieldCount (void) const |
Returns field count, if RscVariant contains struct information More... | |
const char * | GetChars (void) const |
Gets pointer to internal string buffer. Operation only valid for Utf8Strings. More... | |
void | SetWriteElementFunction (WriteElementFunction *pFunction) const |
Sets callback for write function to write a single array element. This could only be used for Variants containing an array info. More... | |
const byte * | GetDataAddress (void) const |
Gets a raw pointer to internal data buffer. To read data prefer CopyTo and to write prefer assignment operators because this method doesn't do any validation checks. More... | |
byte * | GetDataAddress (void) |
Get a raw pointer to internal data buffer. To read data prefer CopyTo and to write prefer assignment operators because this method doesn't do any validation checks. More... | |
void | SetType (RscType rscType) |
Forces the internal RscType to be set to another RscType. This Method does no conversion or validation. Prefer using assignment operators, who sets the RscType implicitly. More... | |
template<class T > | |
T | GetValue (void) const |
Converts this value to the given type T. More... | |
template<class T > | |
void | CopyTo (T &value) const |
Copies internal data to memory referenced by value. Only for primtive types. Read Strings with GetChars. More... | |
String | ToString (void) const |
Converts this instance to string if the variant type has a reasonable string representation. More... | |
void | Assign (const char16 *input, size_t length, RscType rscType=RscType::Utf8String) |
Assigns an UTF16 string to this instance. More... | |
template<class T > | |
RscVariant< MaxStringSize > & | operator= (const T &value) |
template<int N> | |
RscVariant< MaxStringSize > & | operator= (const RscString< N > &value) |
template<int N> | |
RscVariant< MaxStringSize > & | operator= (const SecureString< N > &value) |
Static Public Member Functions | |
static RscVariant< MaxStringSize > | CreateStructVariant (size_t fieldCount) |
Creates a new RscVariant initialized with RscStructInformation More... | |
static RscVariant< MaxStringSize > | CreateArrayVariant (size_t arraySize, RscType elementType, size_t dimensions=1, size_t fieldCount=0) |
Creates a new RscVariant initialized with RscArrayInformation More... | |
Rsc container class for primitive data type, strings or information about arrays or structs. ArrayInformation and StructInformation are used in combination with RscArrayReader, RscArrayWriter, RscStructReader and RscStructWriter
MaxStringSize | Sets the maximum amount of characters for included strings. A RscVariant with dafault value 0 cannot contain string values. |
|
inline |
Creates an empty instance of RscVariant
type | Initial RscType |
|
inline |
Creates a new instance of RscVariant with value. Gets RscType by type deduction of T.
|
inline |
Creates a new instance of RscVariant with value. RscType is Utf8String.
value | Reference to Arp::String value |
|
inline |
Creates a new instance of RscVariant with value. RscType is Utf8String.
value | Reference to c-string value |
|
inline |
Assigns an UTF16 string to this instance.
input | The input UTF16 string to assign. |
length | The string length of the input string (number of char16 characters). |
type | The RscType marshalling type. Actually only RscType::Utf8String is supported. |
The input string is converted to an UTF8 string for marshalling.
|
inline |
Creates a new instance of RscVariant with value. RscType is Utf8String.
value | Reference to RscString value |
|
inline |
Creates a new instance of RscVariant with value. RscType is Utf8String.
value | Reference to SecureString value |
|
inline |
Creates a new instance of RscVariant containing an array with arraySize elements of RscType arrayElementType. Instances created with this constructor are used to to initialize RscArrayWriter to write an array.
arraySize | Number of array elements |
arrayElementType | RscType of array elements |
dimsions | Count of array dimensions. |
fieldCount | Count of fields if struct type is used |
|
inline |
Creates a new instance of RscVariant containing an array with arraySize elements of RscType arrayElementType. Instances created with this constructor are used to to initialize RscArrayReader in service implementations to write array data.
arraySize | Number of array elements |
arrayElementType | RscType of array elements |
pFunction | Callback to write an array elements |
dimsions | Count of array dimensions. |
fieldCount | Count of fields if struct type is used |
|
inline |
Creates a new instance of RscVariant containing an array with arraySize elements of RscType arrayElementType. Instances created with this constructor are used to to initialize RscArrayWriter in service implementations to read array data.
arraySize | Number of array elements |
arrayElementType | RscType of array elements |
pFunction | Callback to read an array element |
dimsions | Count of array dimensions. |
fieldCount | Count of fields if struct type is used |
|
inline |
For internal use only
|
default |
Copy constructor
|
defaultnoexcept |
Move constructor
|
inline |
Assigns an UTF16 string to this instance.
input | The input UTF16 string to assign. |
length | The string length of the input string (number of char16 characters). |
type | The RscType marshalling type. Actually only RscType::Utf8String is supported. |
The input string is converted to an UTF8 string for marshalling.
|
inline |
Copies internal data to memory referenced by value. Only for primtive types. Read Strings with GetChars.
value | Reference to memory |
|
inlinestatic |
Creates a new RscVariant initialized with RscArrayInformation
arraySize | Count of array elements |
elementType | Element type of array |
dimensions | Dimensions fo array |
fieldCount | Count of struct fields for struct element types |
|
inlinestatic |
Creates a new RscVariant initialized with RscStructInformation
fieldCount | Count of struct fields |
|
inline |
Gets the count of array dimensions (1 for simple array, 2 for array of array etc.). This method is only valid for RscVariants with array information.
InvalidOperationException | Throws if RscVariant doesn't contain array information |
|
inline |
Gets the RscType of the array elements if RscVariant contains array information.
InvalidOperationException | Throws if RscVariant doesn't contain array information |
|
inline |
Gets pointer to internal string buffer. Operation only valid for Utf8Strings.
byte* Arp::System::Rsc::Services::RscVariant< MaxStringSize >::GetDataAddress | ( | void | ) |
Get a raw pointer to internal data buffer. To read data prefer CopyTo and to write prefer assignment operators because this method doesn't do any validation checks.
|
inline |
Gets a raw pointer to internal data buffer. To read data prefer CopyTo and to write prefer assignment operators because this method doesn't do any validation checks.
|
inline |
Returns field count, if RscVariant contains struct information
InvalidOperationException | Throws if RscVariant doesn't contain struct information |
|
inline |
|
inline |
Converts this value to the given type T.
T | The type to convert this instance to. |
|
inline |
|
inline |
Forces the internal RscType to be set to another RscType. This Method does no conversion or validation. Prefer using assignment operators, who sets the RscType implicitly.
rscType |
|
inline |
Sets callback for write function to write a single array element. This could only be used for Variants containing an array info.
pFunction | Reference to function |
InvalidOperationException | Throws if RscType is not Array |
|
inline |
Converts this instance to string if the variant type has a reasonable string representation.