PLCnext API Documentation 25.0.2.69
|
This class is a base class of template class RscVariant. More...
#include <RscVariantBase.hpp>
Public Types | |
using | ReadFieldFunction = std::function< void(RscType fieldType, RscVariantBase &value)> |
The read field delegate type. | |
using | WriteFieldFunction = std::function< void(RscType fieldType, const RscVariantBase &value)> |
The write field delegate type. | |
using | ReadElementFunction = std::function< void(RscType elementType, RscVariantBase &value)> |
The read element delegate type. | |
using | WriteElementFunction = std::function< void(RscType elementType, const RscVariantBase &value)> |
The write element delegate type. | |
Public Member Functions | |
RscVariantBase (RscType type=RscType::None) | |
The default constructor creates an empty instance of RscVariantBase. More... | |
RscVariantBase (RscType type, byte *pBuffer) | |
Creates a typed instance of RscVariant which refers to an external buffer. More... | |
RscVariantBase (RscType type, char *pBuffer, size_t bufferSize) | |
Creates a typed instance of RscVariant which refers to an external buffer. More... | |
RscVariantBase (const RscStringBase &data) | |
Creates a typed instance of RscVariant which refers to an external buffer. More... | |
RscVariantBase (const RscArrayInfo &arrayInfo) | |
Creates a typed instance of RscVariant which represents an array. More... | |
RscVariantBase (const RscStructInfo &structInfo) | |
Creates a typed instance of RscVariant which represents a struct. More... | |
RscVariantBase (const RscVariantBase &arg) | |
The copy constructor. More... | |
RscVariantBase (RscVariantBase &&arg) noexcept | |
The move constructor. More... | |
RscVariantBase & | operator= (const RscVariantBase &arg) |
The assign operator. More... | |
RscVariantBase & | operator= (RscVariantBase &&arg) noexcept |
The move-assign operator. More... | |
~RscVariantBase (void) | |
The default destructor. | |
RscVariantBase & | operator= (const String &value) |
Assign operator for type String. More... | |
RscVariantBase & | operator= (const char *value) |
Assign operator for type char* . More... | |
RscVariantBase & | operator= (const char8u *value) |
Assign operator for type char8u* . More... | |
template<class T > | |
RscVariantBase & | operator= (const T &value) |
Assign operator for values of arbitrary type. More... | |
template<int N> | |
RscVariantBase & | operator= (const RscString< N > &value) |
Assign operator for values of type RscString. More... | |
template<int N> | |
RscVariantBase & | operator= (const RscSecureString< N > &value) |
Assign operator for values of type SecureString. More... | |
void | SetType (RscType value) |
Forces the internal RscType to be set to another RscType. More... | |
RscType | GetType (void) const |
Gets the RscType of the contained element More... | |
RscType | GetValueType (void) const |
Gets the raw value type as RscType of the contained element. More... | |
bool | IsComplexType (void) const |
Determines if this instance represents a complex type, i.e. an array or a struct. More... | |
bool | IsArray (void) const |
Determines if this instance represents an array. More... | |
bool | IsStruct (void) const |
Determines if this instance represents a struct. More... | |
bool | IsFormattable (void) const |
Determines if this instance is convertible to String using the ToString() operation. More... | |
size_t | GetDataSize (void) const |
Gets the data size of the contained element. More... | |
size_t | GetMaxStringSize (void) const |
Gets the maximal length of strings which are provided by this instance. More... | |
size_t | GetBufferSize (void) const |
Gets the buffer size of this instance. More... | |
RscType | GetArrayElementType (void) const |
Gets the RscType of the array elements, if this instance represents an array. More... | |
size_t | GetArraySize (void) const |
Gets the array size, if this instance represents an array. More... | |
size_t | GetArrayDimensions (void) const |
Gets the count of array dimensions (1 for simple array, 2 for array of array etc.), if this instance represents an array. More... | |
size_t | GetArrayFieldCount (void) const |
Gets the field count of the struct elements, if this instance represents an array of structs. More... | |
size_t | GetFieldCount (void) const |
Gets the field count, if this instance represents a struct. More... | |
byte * | GetDataAddress (void) |
Gets a writable raw pointer to the internal data buffer. More... | |
const byte * | GetDataAddress (void) const |
const char * | GetChars (void) const |
Gets a readable pointer to internal string buffer. More... | |
void | Assign (const char *input, RscType rscType=RscType::String) |
Assigns an UTF8 string to this instance. More... | |
void | Assign (const char *input, size_t length, RscType rscType=RscType::String) |
Assigns an UTF8 string to this instance. More... | |
void | Assign (const char16 *input, size_t length) |
Assigns an UTF16 string to this instance. More... | |
void | Assign (const String &value) |
Assigns the given value of type String . More... | |
void | CopyTo (String &value) const |
Copies the content of this variant to a string. More... | |
String | ToString (void) const |
Converts this instance to String if the variant type has a reasonable string representation. More... | |
void | Clear (bool clearBuffer=false) |
Clears the type and all other infos of this instance. More... | |
bool | Equals (const RscVariantBase &arg) const |
Checks if this instance is equal to arg . More... | |
void | Read (RscReader &reader, bool omitTag) |
Reads this instance from RSC. More... | |
void | Write (RscWriter &writer, bool omitTag) const |
Writes this instance to RSC. More... | |
bool | HasArrayInfo (void) const |
Determines if the array info of this instance was set yet. More... | |
void | SetArrayInfo (const RscArrayInfo &arrayInfo) |
Set the array info of this instance. More... | |
void | SetArrayInfo (size_t size, RscType elementType=RscType::None, size_t dimensions=1, size_t fieldCount=0) |
Sets the array info of this instance. More... | |
RscArrayInfo & | GetArrayInfo (void) |
Gets the array info of this instance. More... | |
const RscArrayInfo & | GetArrayInfo (void) const |
bool | HasStructInfo (void) const |
Determines if the struct info of this instance was set yet. More... | |
void | SetStructInfo (size_t fieldCount) |
Sets the struct info of this instance. More... | |
RscStructInfo & | GetStructInfo (void) |
Gets the struct info of this instance. More... | |
const RscStructInfo & | GetStructInfo (void) const |
bool | HasReadElementFunction (void) const |
Determines if this instance provides an element read function. More... | |
ReadElementFunction | GetReadElementFunction (void) const |
Gets the element read function if available. More... | |
void | SetReadElementFunction (ReadElementFunction &function) |
Sets the element read function. More... | |
bool | HasWriteElementFunction (void) const |
Determines if this instance provides an element write function. More... | |
WriteElementFunction | GetWriteElementFunction (void) const |
Gets the element write function if available. More... | |
void | SetWriteElementFunction (WriteElementFunction &function) const |
Sets the element write function. More... | |
void | ResetComplexTypeInfo (void) |
Clears reader, writer and read/write element functions. | |
template<int N> | |
void | Assign (char value[N]) |
Assigns the given value of type T . More... | |
template<int N> | |
void | Assign (const char value[N]) |
template<int N> | |
void | Assign (const RscString< N > &value) |
Assigns the given value of type RscString . More... | |
template<int N> | |
void | Assign (const RscSecureString< N > &value) |
Assigns the given value of type SecureString . More... | |
template<class T > | |
void | Assign (const T &value) |
Assigns the given value of type T . More... | |
template<class T > | |
void | CopyTo (T &value) const |
Copies the value of this instance to the out parameter value . More... | |
template<class T > | |
T | GetValue (void) const |
Converts this value to the given type T . More... | |
template<class T > | |
T * | GetValueAddress (void) |
Gets the address of the contained value as type T *. More... | |
template<class T > | |
const T * | GetValueAddress (void) const |
Gets the address of the contained value as type const T *. More... | |
Protected Member Functions | |
void | SetBufferInfo (byte *pDataBuffer, size_t dataBufferSize, bool isDynamicString) |
Sets the buffer properties which are provided by super class RscVariant. More... | |
bool | HasReader (void) const |
Determines if this instance has a reader for deserialization. More... | |
bool | HasWriter (void) const |
Determines if this instance has a write for serialization. More... | |
void | SetReader (RscReader &reader) |
Sets the RSC reader, if this instance represents a complex type (array or struct). More... | |
void | SetWriter (RscWriter &writer) const |
Sets the RSC writer, if this instance represents a complex type (array or struct). More... | |
RscReader * | GetReader (void) const |
Gets a reader for deserialization. More... | |
RscWriter * | GetWriter (void) const |
Gets a writer for serialization. More... | |
Protected Attributes | |
RscType | type = RscType::None |
The RSC type of this variant. | |
byte * | pBuffer = nullptr |
The buffer of this variant (usually applied by RscVariant<T>) | |
size_t | bufferSize = 0 |
The size of the applied buffer. | |
bool | providesDynamicString = false |
Determines if this variant supports dynamic strings (see String) | |
String | dynamicString |
The dynamic string storage. | |
ComplexTypeInfo | typeInfo |
The type info of this variant. | |
Friends | |
class | Arp::Base::Rsc::Commons::Internal::RscVariantAccessor |
This class is a base class of template class RscVariant.
This implementation avoids extensive inlining of RscVariant implementation, due to the fact, that all template code has to be inlined.
This class is not intended for direct use.
Arp::Base::Rsc::Commons::RscVariantBase::RscVariantBase | ( | RscType | type = RscType::None | ) |
The default constructor creates an empty instance of RscVariantBase.
type | The type of this variant. |
Arp::Base::Rsc::Commons::RscVariantBase::RscVariantBase | ( | RscType | type, |
byte * | pBuffer | ||
) |
Creates a typed instance of RscVariant which refers to an external buffer.
type | The type of this variant. |
pBuffer | The external buffer |
For internal use only.
Arp::Base::Rsc::Commons::RscVariantBase::RscVariantBase | ( | RscType | type, |
char * | pBuffer, | ||
size_t | bufferSize | ||
) |
Creates a typed instance of RscVariant which refers to an external buffer.
type | The type of this variant. |
pBuffer | The external buffer. |
bufferSize | The buffer size of the external buffer. |
For internal use only.
Arp::Base::Rsc::Commons::RscVariantBase::RscVariantBase | ( | const RscStringBase & | data | ) |
Creates a typed instance of RscVariant which refers to an external buffer.
data | The external string buffer. |
For internal use only.
Arp::Base::Rsc::Commons::RscVariantBase::RscVariantBase | ( | const RscArrayInfo & | arrayInfo | ) |
Creates a typed instance of RscVariant which represents an array.
arrayInfo | The array information. |
Arp::Base::Rsc::Commons::RscVariantBase::RscVariantBase | ( | const RscStructInfo & | structInfo | ) |
Creates a typed instance of RscVariant which represents a struct.
structInfo | The struct information. |
|
default |
The copy constructor.
arg | The argument to copy. |
|
defaultnoexcept |
The move constructor.
arg | The argument to move. |
|
inline |
Assigns the given value of type T .
value | The string to assign. |
void Arp::Base::Rsc::Commons::RscVariantBase::Assign | ( | const char * | str, |
RscType | rscType = RscType::String |
||
) |
Assigns an UTF8 string to this instance.
str | The input UTF8 string to assign. |
rscType | The RscType marshalling type. Actually only RscType::String is supported. |
void Arp::Base::Rsc::Commons::RscVariantBase::Assign | ( | const char * | str, |
size_t | length, | ||
RscType | rscType = RscType::String |
||
) |
Assigns an UTF8 string to this instance.
str | The input UTF8 string to assign. |
length | The string length of the input string. |
rscType | The RscType marshalling type. Actually only RscType::String is supported. |
void Arp::Base::Rsc::Commons::RscVariantBase::Assign | ( | const char16 * | input, |
size_t | length | ||
) |
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). |
The input string is converted to an UTF8 string for marshalling.
|
inline |
Assigns the given value of type SecureString
.
value | The string to assign. |
|
inline |
Assigns the given value of type RscString
.
value | The string to assign. |
void Arp::Base::Rsc::Commons::RscVariantBase::Assign | ( | const String & | value | ) |
Assigns the given value of type String
.
value | The string to assign. |
|
inline |
Assigns the given value of type T .
value | The value to assign. |
T | The type to convert this instance to. |
void Arp::Base::Rsc::Commons::RscVariantBase::Clear | ( | bool | clearBuffer = false | ) |
Clears the type and all other infos of this instance.
clearBuffer | true if the buffer should be zeroed also, otherwise false . |
void Arp::Base::Rsc::Commons::RscVariantBase::CopyTo | ( | String & | value | ) | const |
Copies the content of this variant to a string.
value | The resulting string to copy this content to. |
This operation specializes the generic operation CopyTo<T> for the String type.
|
inline |
Copies the value of this instance to the out parameter value .
value | The resulting value. |
InvalidCastException | If this instance does not match the supplied parameter type T . |
bool Arp::Base::Rsc::Commons::RscVariantBase::Equals | ( | const RscVariantBase & | arg | ) | const |
Checks if this instance is equal to arg .
arg | The argument to check on equality. |
true
if this instance is equal to arg , otherwise false
.size_t Arp::Base::Rsc::Commons::RscVariantBase::GetArrayDimensions | ( | void | ) | const |
Gets the count of array dimensions (1 for simple array, 2 for array of array etc.), if this instance represents an array.
InvalidOperationException | If this instance does not represent an array. |
RscType Arp::Base::Rsc::Commons::RscVariantBase::GetArrayElementType | ( | void | ) | const |
Gets the RscType of the array elements, if this instance represents an array.
InvalidOperationException | If this instance does not represent an array. |
size_t Arp::Base::Rsc::Commons::RscVariantBase::GetArrayFieldCount | ( | void | ) | const |
Gets the field count of the struct elements, if this instance represents an array of structs.
InvalidOperationException | If this instance does not represent an array. |
const RscArrayInfo & Arp::Base::Rsc::Commons::RscVariantBase::GetArrayInfo | ( | void | ) |
Gets the array info of this instance.
InvalidOperationException | If this instance does not represent an array. |
size_t Arp::Base::Rsc::Commons::RscVariantBase::GetArraySize | ( | void | ) | const |
Gets the array size, if this instance represents an array.
InvalidOperationException | If this instance does not represent an array. |
size_t Arp::Base::Rsc::Commons::RscVariantBase::GetBufferSize | ( | void | ) | const |
Gets the buffer size of this instance.
const char * Arp::Base::Rsc::Commons::RscVariantBase::GetChars | ( | void | ) | const |
Gets a readable pointer to internal string buffer.
InvalidCastException | If this instance does not represent a string. |
const byte * Arp::Base::Rsc::Commons::RscVariantBase::GetDataAddress | ( | void | ) |
Gets a writable raw pointer to the internal data buffer.
Gets a readable raw pointer to the internal data buffer.
To obtain data from this instance prefer the use of CopyTo or GetValue operations and to write instance data prefer Assign operations or assign operators, because this operation is not type safe. For internal use only.
size_t Arp::Base::Rsc::Commons::RscVariantBase::GetDataSize | ( | void | ) | const |
Gets the data size of the contained element.
size_t Arp::Base::Rsc::Commons::RscVariantBase::GetFieldCount | ( | void | ) | const |
Gets the field count, if this instance represents a struct.
InvalidOperationException | If this instance does not represent a struct. |
size_t Arp::Base::Rsc::Commons::RscVariantBase::GetMaxStringSize | ( | void | ) | const |
Gets the maximal length of strings which are provided by this instance.
RscVariantBase::ReadElementFunction Arp::Base::Rsc::Commons::RscVariantBase::GetReadElementFunction | ( | void | ) | const |
Gets the element read function if available.
InvalidOperationException | If this instance does not provide an element read function. |
|
protected |
Gets a reader for deserialization.
nullptr
.For internal use only.
const RscStructInfo & Arp::Base::Rsc::Commons::RscVariantBase::GetStructInfo | ( | void | ) |
Gets the struct info of this instance.
InvalidOperationException | If this instance does not represent a struct. |
RscType Arp::Base::Rsc::Commons::RscVariantBase::GetType | ( | void | ) | const |
Gets the RscType of the contained element
|
inline |
Converts this value to the given type T .
T
.T | The type to convert this instance to. |
|
inline |
Gets the address of the contained value as type T *.
T*
.T | The type to convert the value address to. |
|
inline |
Gets the address of the contained value as type const T *.
const T*
.T | The type to convert the value address to. |
RscType Arp::Base::Rsc::Commons::RscVariantBase::GetValueType | ( | void | ) | const |
Gets the raw value type as RscType of the contained element.
Some types like <see cref="RscType::IecTime /> are mapped to its raw value counterpart e.g. <see cref="RscType::Int32 />.
RscVariantBase::WriteElementFunction Arp::Base::Rsc::Commons::RscVariantBase::GetWriteElementFunction | ( | void | ) | const |
Gets the element write function if available.
InvalidOperationException | If this instance does not provide an element write function. |
|
protected |
Gets a writer for serialization.
nullptr
.For internal use only.
bool Arp::Base::Rsc::Commons::RscVariantBase::HasArrayInfo | ( | void | ) | const |
Determines if the array info of this instance was set yet.
true
if the array info was set yet, otherwise false
.bool Arp::Base::Rsc::Commons::RscVariantBase::HasReadElementFunction | ( | void | ) | const |
Determines if this instance provides an element read function.
true
if an element read function is available, otherwise false
.
|
protected |
Determines if this instance has a reader for deserialization.
true
if a reader is available, otherwise false
.For internal use only.
bool Arp::Base::Rsc::Commons::RscVariantBase::HasStructInfo | ( | void | ) | const |
Determines if the struct info of this instance was set yet.
true
if the struct info was set yet, otherwise false
.bool Arp::Base::Rsc::Commons::RscVariantBase::HasWriteElementFunction | ( | void | ) | const |
Determines if this instance provides an element write function.
true
if an element write function is available, otherwise false
.
|
protected |
Determines if this instance has a write for serialization.
true
if a writer is available, otherwise false
.For internal use only.
bool Arp::Base::Rsc::Commons::RscVariantBase::IsArray | ( | void | ) | const |
Determines if this instance represents an array.
true
if this instance represents an array, otherwise false
.bool Arp::Base::Rsc::Commons::RscVariantBase::IsComplexType | ( | void | ) | const |
Determines if this instance represents a complex type, i.e. an array or a struct.
true
if this instance represents an array or a struct, otherwise false
.bool Arp::Base::Rsc::Commons::RscVariantBase::IsFormattable | ( | void | ) | const |
Determines if this instance is convertible to String using the ToString() operation.
true
if this instance has a string representation, otherwise false
.bool Arp::Base::Rsc::Commons::RscVariantBase::IsStruct | ( | void | ) | const |
Determines if this instance represents a struct.
true
if this instance represents a struct, otherwise false
.RscVariantBase & Arp::Base::Rsc::Commons::RscVariantBase::operator= | ( | const char * | value | ) |
Assign operator for type char*
.
value | The string to assign. |
RscVariantBase & Arp::Base::Rsc::Commons::RscVariantBase::operator= | ( | const char8u * | value | ) |
Assign operator for type char8u*
.
value | The string to assign. |
|
inline |
Assign operator for values of type SecureString.
value | The string to assign. |
N | The maximal string length. |
|
inline |
Assign operator for values of type RscString.
value | The string to assign. |
N | The maximal string length. |
|
default |
The assign operator.
arg | The argument to assign. |
RscVariantBase & Arp::Base::Rsc::Commons::RscVariantBase::operator= | ( | const String & | value | ) |
Assign operator for type String.
value | The string to assign. |
|
inline |
Assign operator for values of arbitrary type.
value | The value to assign. |
T | The type of the value. |
|
defaultnoexcept |
The move-assign operator.
arg | The argument to move. |
void Arp::Base::Rsc::Commons::RscVariantBase::Read | ( | RscReader & | reader, |
bool | omitTag | ||
) |
Reads this instance from RSC.
reader | The RSC reader to read from. |
omitTag | true if the data tag should be omitted during read, otherwise false . |
For internal use only.
void Arp::Base::Rsc::Commons::RscVariantBase::SetArrayInfo | ( | const RscArrayInfo & | arrayInfo | ) |
Set the array info of this instance.
arrayInfo | The array info to assign. |
This operation set the type of this instance implicitly to RscType::Array and the array infos accordingly.
void Arp::Base::Rsc::Commons::RscVariantBase::SetArrayInfo | ( | size_t | size, |
RscType | elementType = RscType::None , |
||
size_t | dimensions = 1 , |
||
size_t | fieldCount = 0 |
||
) |
Sets the array info of this instance.
size | The size of the array. |
elementType | The element type of the array. |
dimensions | The array dimensions. |
fieldCount | The field count of the element struct type. |
This operation set the type of this instance implicitly to RscType::Array and the array infos accordingly.
|
protected |
Sets the buffer properties which are provided by super class RscVariant.
pDataBuffer | The data buffer. |
dataBufferSize | The data buffer size. |
isDynamicString | Determines if the buffer belongs to a dynamic string of type String. |
For internal use only.
void Arp::Base::Rsc::Commons::RscVariantBase::SetReadElementFunction | ( | ReadElementFunction & | function | ) |
Sets the element read function.
function | The function to read elements. |
InvalidOperationException | If this instance does not provide an element read function. |
|
protected |
Sets the RSC reader, if this instance represents a complex type (array or struct).
reader | The reader to use for deserialization. |
For internal use only.
void Arp::Base::Rsc::Commons::RscVariantBase::SetStructInfo | ( | size_t | fieldCount | ) |
Sets the struct info of this instance.
fieldCount | The field count of the struct. |
void Arp::Base::Rsc::Commons::RscVariantBase::SetType | ( | RscType | value | ) |
Forces the internal RscType to be set to another RscType.
This method does no conversion or validation. Prefer using assignment operators, which sets the RscType implicitly.
value | The new value to set. |
void Arp::Base::Rsc::Commons::RscVariantBase::SetWriteElementFunction | ( | WriteElementFunction & | function | ) | const |
Sets the element write function.
function | The function to write elements. |
|
protected |
Sets the RSC writer, if this instance represents a complex type (array or struct).
writer | The writer to use for serialization. |
For internal use only.
String Arp::Base::Rsc::Commons::RscVariantBase::ToString | ( | void | ) | const |
Converts this instance to String if the variant type has a reasonable string representation.
void Arp::Base::Rsc::Commons::RscVariantBase::Write | ( | RscWriter & | writer, |
bool | omitTag | ||
) | const |
Writes this instance to RSC.
writer | The RSC writer to write to. |
omitTag | true if the data tag should be omitted during write, otherwise false . |
For internal use only.