UA Server SDK C++ Bundle  1.4.1.271
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UaGenericValue Class Reference

A class that serializes and deserializes data that is described by an UaStructureDefinition. More...

#include <uagenericvalue.h>

Inherits UaAbstractGenericValue.

Public Member Functions

 UaGenericValue ()
 Creates an empty UaGenericValue. More...
 
 UaGenericValue (const UaStructureDefinition &structureDefinition)
 Creates a UaGenericValue with default values for each field. More...
 
 UaGenericValue (const UaGenericValue &other)
 Copy constructor. More...
 
 UaGenericValue (const UaByteString &bsData, Encoding valueEncoding, const UaStructureDefinition &structureDefinition)
 Creates a UaGenericValue. More...
 
virtual ~UaGenericValue ()
 Desctruction.
 
virtual void clear ()
 Clears the UaGenericValue. More...
 
bool operator== (const UaGenericValue &other) const
 Compares the content of two UaGenericValues.
 
bool operator!= (const UaGenericValue &other) const
 Checks if two UaGenericValues are unequal. More...
 
UaGenericValueoperator= (const UaGenericValue &other)
 Assignment operator. More...
 
OpcUa_StatusCode setGenericValue (const UaByteString &bsData, Encoding valueEncoding, const UaStructureDefinition &structureDefinition)
 Sets a UaGenericValue. More...
 
OpcUa_StatusCode setField (const UaString &sFieldName, const UaVariant &value)
 Sets the value for a structure field based on the field name. More...
 
OpcUa_StatusCode setField (int iIndex, const UaVariant &value)
 Sets the value for a structure field based on the field index. More...
 
UaVariant value (const UaString &sFieldName) const
 Returns the value for a structure field based on the field name. More...
 
UaVariant value (int iIndex) const
 Returns the value for a structure field based on the field index. More...
 
UaStructureDefinition definition () const
 Returns the StructureDefinition of the UaGenericValue. More...
 
UaString toString () const
 Returns a string representation of the value. More...
 
void decode (UaAbstractDecoder *pDecoder)
 Deserializing method that is used by the SDK internally. More...
 
void encode (UaAbstractEncoder *pEncoder) const
 Serializing method that is used by the SDK internally. More...
 
- Public Member Functions inherited from UaAbstractGenericValue
void toVariant (UaVariant &variant, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the variant. More...
 
void toVariant (OpcUa_Variant &variant, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the variant. More...
 
void toDataValue (UaDataValue &dataValue, OpcUa_Boolean updateTimeStamps, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the dataValue. More...
 
void toDataValue (OpcUa_DataValue &dataValue, OpcUa_Boolean updateTimeStamps, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the dataValue. More...
 
void toExtensionObject (UaExtensionObject &extensionObject, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the extensionObject. More...
 
void toExtensionObject (OpcUa_ExtensionObject &extensionObject, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the extensionObject. More...
 

Additional Inherited Members

- Public Types inherited from UaAbstractGenericValue
enum  Encoding
 The possible encodings for a UaAbstractGenericValue. More...
 
- Protected Member Functions inherited from UaAbstractGenericValue
UaVariant readField (UaAbstractDecoder *pDecoder, const UaStructureField &field) const
 Deserializes a field. More...
 
void writeField (UaAbstractEncoder *pEncoder, const UaStructureField &field, const UaVariant &value) const
 Serializes a field. More...
 
bool checkValue (const UaStructureField &field, const UaVariant &value) const
 Checks whether value matches the DataType and ValueRank definition of field. More...
 
UaVariant defaultValue (const UaStructureField &field) const
 Returns a value based on the DataType and the ValueRank of the field. More...
 

Detailed Description

A class that serializes and deserializes data that is described by an UaStructureDefinition.

The serialized data can be accessed by index or by field name. The class can be used for DataTypes that are not registered to the stack.

Constructor & Destructor Documentation

UaGenericValue::UaGenericValue ( )

Creates an empty UaGenericValue.

UaGenericValue::UaGenericValue ( const UaStructureDefinition structureDefinition)

Creates a UaGenericValue with default values for each field.

UaGenericValue::UaGenericValue ( const UaGenericValue other)

Copy constructor.

Parameters
otherthe UaGenericValue.
UaGenericValue::UaGenericValue ( const UaByteString bsData,
UaAbstractGenericValue::Encoding  valueEncoding,
const UaStructureDefinition structureDefinition 
)

Creates a UaGenericValue.

Parameters
bsDataThe content that will be serialized.
valueEncodingThe encoding of bsData.
structureDefinitionThe definition that is used for deserializing.

Member Function Documentation

void UaGenericValue::clear ( )
virtual

Clears the UaGenericValue.

Clears all values and sets the StructureDefinition to an invalid definition.

Implements UaAbstractGenericValue.

void UaGenericValue::decode ( UaAbstractDecoder pDecoder)
virtual

Deserializing method that is used by the SDK internally.

Implements UaAbstractGenericValue.

UaStructureDefinition UaGenericValue::definition ( ) const
virtual

Returns the StructureDefinition of the UaGenericValue.

Implements UaAbstractGenericValue.

void UaGenericValue::encode ( UaAbstractEncoder pEncoder) const
virtual

Serializing method that is used by the SDK internally.

Implements UaAbstractGenericValue.

bool UaGenericValue::operator!= ( const UaGenericValue other) const

Checks if two UaGenericValues are unequal.

UaGenericValue & UaGenericValue::operator= ( const UaGenericValue other)

Assignment operator.

OpcUa_StatusCode UaGenericValue::setField ( const UaString sFieldName,
const UaVariant value 
)

Sets the value for a structure field based on the field name.

Parameters
sFieldNameName of the structure field to set.
valueThe new value for the field.
Returns
OpcUa_Good if the value was updated, OpcUa_BadInvalidArgument if the name was invalid, and OpcUa_BadTypeMismatch if the wrong data type is set.
OpcUa_StatusCode UaGenericValue::setField ( int  iIndex,
const UaVariant value 
)

Sets the value for a structure field based on the field index.

Parameters
iIndexIndex of the structure field to set.
valueThe new value for the field.
Returns
OpcUa_Good if the value was updated, OpcUa_BadInvalidArgument if the name was invalid, and OpcUa_BadTypeMismatch if the wrong data type is set.
OpcUa_StatusCode UaGenericValue::setGenericValue ( const UaByteString bsData,
UaAbstractGenericValue::Encoding  valueEncoding,
const UaStructureDefinition structureDefinition 
)

Sets a UaGenericValue.

Parameters
bsDataThe content that will be serialized.
valueEncodingThe encoding of bsData.
structureDefinitionThe definition that is used for deserializing.
UaString UaGenericValue::toString ( ) const

Returns a string representation of the value.

This string can be used for showing in a GUI. There is no method fromString.

UaVariant UaGenericValue::value ( const UaString sFieldName) const

Returns the value for a structure field based on the field name.

Parameters
sFieldNameName of the structure field value to return.
Returns
The value as UaVariant or an empty UaVariant if the name is invalid.
UaVariant UaGenericValue::value ( int  iIndex) const

Returns the value for a structure field based on the field index.

Parameters
iIndexIndex of the structure field value to return.
Returns
The value as UaVariant or an empty UaVariant if the index is invalid.

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