C++ Based OPC UA Client/Server SDK  1.5.3.346
UaGenericStructureValue Class Reference

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

#include <uagenericstructurevalue.h>

Inherits UaAbstractGenericStructureValue.

Public Member Functions

 UaGenericStructureValue ()
 Creates an empty UaGenericValue. More...
 
 UaGenericStructureValue (const UaStructureDefinition &structureDefinition)
 Creates a UaGenericValue with default values for each field. More...
 
 UaGenericStructureValue (const UaGenericStructureValue &other)
 Copy constructor. More...
 
 UaGenericStructureValue (const UaByteString &bsData, Encoding valueEncoding, const UaStructureDefinition &structureDefinition)
 Creates a UaGenericValue. More...
 
 UaGenericStructureValue (const UaExtensionObject &extensionObject, const UaStructureDefinition &structureDefinition)
 Parses a the binary data of an ExtenionObject and stores the data to a new UaGenericStructureValue. More...
 
virtual ~UaGenericStructureValue ()
 Desctruction.
 
virtual void clear ()
 Clears the UaGenericValue. More...
 
bool operator== (const UaGenericStructureValue &other) const
 Compares the content of two UaGenericValues.
 
bool operator!= (const UaGenericStructureValue &other) const
 Checks if two UaGenericValues are unequal. More...
 
UaGenericStructureValueoperator= (const UaGenericStructureValue &other)
 Assignment operator. More...
 
OpcUa_StatusCode setGenericValue (const UaByteString &bsData, Encoding valueEncoding, const UaStructureDefinition &structureDefinition)
 Sets a UaGenericValue. More...
 
OpcUa_StatusCode setGenericValue (const UaExtensionObject &extensionObject, const UaStructureDefinition &structureDefinition)
 Parses a the binary data of an ExtenionObject and stores the data to a new UaGenericStructureValue. More...
 
OpcUa_StatusCode setField (const UaString &sFieldName, UaVariant &value, OpcUa_Boolean bDetach)
 Sets the value for a structure field based on the field name. More...
 
OpcUa_StatusCode setField (int iIndex, UaVariant &value, OpcUa_Boolean bDetach)
 Sets the value for a structure field based on the field index. More...
 
OpcUa_StatusCode setField (const UaString &sFieldName, const UaGenericStructureValue &value)
 Sets the value for a structure field based on the field name. More...
 
OpcUa_StatusCode setField (int iIndex, const UaGenericStructureValue &value)
 Sets the value for a structure field based on the field index. More...
 
OpcUa_StatusCode setField (const UaString &sFieldName, const UaGenericStructureArray &values)
 Sets the value for a structure field based on the field name. More...
 
OpcUa_StatusCode setField (int iIndex, const UaGenericStructureArray &values)
 Sets the value for a structure field based on the field index. More...
 
OpcUa_StatusCode setField (const UaString &sFieldName, const UaGenericUnionValue &value)
 Sets the value for a structure field based on the field name. More...
 
OpcUa_StatusCode setField (int iIndex, const UaGenericUnionValue &value)
 Sets the value for a structure field based on the field index. More...
 
OpcUa_StatusCode setField (const UaString &sFieldName, const UaGenericUnionArray &values)
 Sets the value for a structure field based on the field name. More...
 
OpcUa_StatusCode setField (int iIndex, const UaGenericUnionArray &values)
 Sets the value for a structure field based on the field index. More...
 
UaStructureFieldDataType valueType (int iIndex, OpcUa_StatusCode *status=0) const
 Returns the type of the structure field value.
 
UaVariant value (const UaString &sFieldName, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field name. More...
 
UaVariant value (int iIndex, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field index. More...
 
UaGenericStructureValue genericStructure (const UaString &sFieldName, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field name. More...
 
UaGenericStructureValue genericStructure (int iIndex, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field index. More...
 
UaGenericStructureArray genericStructureArray (const UaString &sFieldName, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field name. More...
 
UaGenericStructureArray genericStructureArray (int iIndex, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field index. More...
 
UaGenericUnionValue genericUnion (const UaString &sFieldName, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field name. More...
 
UaGenericUnionValue genericUnion (int iIndex, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field index. More...
 
UaGenericUnionArray genericUnionArray (const UaString &sFieldName, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field name. More...
 
UaGenericUnionArray genericUnionArray (int iIndex, OpcUa_StatusCode *status=0) const
 Returns the value for a structure field based on the field index. More...
 
bool isFieldSet (const UaString &sFieldName) const
 Checks if a structure field based on a field name is set. More...
 
bool isFieldSet (int iIndex) const
 Checks if a structure field based on the field index is set. More...
 
OpcUa_StatusCode unsetField (const UaString &sFieldName)
 Unsets an optional field based on a field name. More...
 
OpcUa_StatusCode unsetField (int iIndex)
 Unsets an optional field based on a field index. More...
 
UaStructureDefinition definition () const
 Returns the StructureDefinition of the UaGenericValue. More...
 
void setDefinition (const UaStructureDefinition &definition, bool bCreateDefaultValues=false)
 Clears the UaGenericStructureValue and sets the structure definition. 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
virtual void toVariant (UaVariant &variant, Encoding valueEncoding=Encoding_Binary) const
 Serializes the UaGenericValue to the variant. More...
 
virtual 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 UaAbstractGenericStructureValue
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...
 
void setVariantToFieldData (const UaStructureField &field, UaVariant &value, UaStructureFieldData &fieldData) const
 Detaches value.
 
- Protected Member Functions inherited from UaAbstractGenericValue
UaStructureFieldData readField (UaAbstractDecoder *pDecoder, const UaStructureField &field) const
 Deserializes a field. More...
 
void writeField (UaAbstractEncoder *pEncoder, const UaStructureField &field, const UaStructureFieldData &value) const
 Serializes a 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

UaGenericStructureValue::UaGenericStructureValue ( )

Creates an empty UaGenericValue.

UaGenericStructureValue::UaGenericStructureValue ( const UaStructureDefinition structureDefinition)

Creates a UaGenericValue with default values for each field.

UaGenericStructureValue::UaGenericStructureValue ( const UaGenericStructureValue other)

Copy constructor.

Parameters
otherthe UaGenericValue.
UaGenericStructureValue::UaGenericStructureValue ( 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.
UaGenericStructureValue::UaGenericStructureValue ( const UaExtensionObject extensionObject,
const UaStructureDefinition structureDefinition 
)

Parses a the binary data of an ExtenionObject and stores the data to a new UaGenericStructureValue.

If the TypeId of the ExtenionObject does not match the structureDefinition, an empty UaGenericStructureValue will be created.

Parameters
extensionObjectContains the content that will be deserialized.
structureDefinitionThe definition that is used for deserializing.

Member Function Documentation

void UaGenericStructureValue::clear ( )
virtual

Clears the UaGenericValue.

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

Implements UaAbstractGenericValue.

void UaGenericStructureValue::decode ( UaAbstractDecoder pDecoder)
virtual

Deserializing method that is used by the SDK internally.

Implements UaAbstractGenericValue.

UaStructureDefinition UaGenericStructureValue::definition ( ) const
virtual

Returns the StructureDefinition of the UaGenericValue.

Implements UaAbstractGenericStructureValue.

void UaGenericStructureValue::encode ( UaAbstractEncoder pEncoder) const
virtual

Serializing method that is used by the SDK internally.

Implements UaAbstractGenericValue.

UaGenericStructureValue UaGenericStructureValue::genericStructure ( const UaString sFieldName,
OpcUa_StatusCode status = 0 
) const

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

Parameters
sFieldNameName of the structure field value to return.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Scalar. Is set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericValue or an empty UaGenericValue if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericStructureValue UaGenericStructureValue::genericStructure ( int  iIndex,
OpcUa_StatusCode status = 0 
) const

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

Parameters
iIndexIndex of the structure field to set.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Scalar. Is set to OpcUa_BadInvalidArgument if the index is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericValue or an empty UaGenericValue if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericStructureArray UaGenericStructureValue::genericStructureArray ( const UaString sFieldName,
OpcUa_StatusCode status = 0 
) const

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

Parameters
sFieldNameName of the structure field value to return.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Array. Is set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericStructureArray or an empty UaGenericStructureArray if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericStructureArray UaGenericStructureValue::genericStructureArray ( int  iIndex,
OpcUa_StatusCode status = 0 
) const

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

Parameters
iIndexIndex of the structure field to set.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Array. Is set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericStructureArray or an empty UaGenericStructureArray if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericUnionValue UaGenericStructureValue::genericUnion ( const UaString sFieldName,
OpcUa_StatusCode status = 0 
) const

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

Parameters
sFieldNameName of the structure field value to return.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Scalar. Is set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericUnion or an empty UaGenericUnion if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericUnionValue UaGenericStructureValue::genericUnion ( int  iIndex,
OpcUa_StatusCode status = 0 
) const

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

Parameters
iIndexIndex of the structure field to set.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Scalar. Is set to OpcUa_BadInvalidArgument if the index is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericUnion or an empty UaGenericUnion if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericUnionArray UaGenericStructureValue::genericUnionArray ( const UaString sFieldName,
OpcUa_StatusCode status = 0 
) const

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

Parameters
sFieldNameName of the structure field value to return.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not a structured DataType or the array type of the field is not ArrayType_Array. Is set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericUnionArray or an empty UaGenericUnionArray if the name is invalid or the DataType of the field is not a structured DataType.
UaGenericUnionArray UaGenericStructureValue::genericUnionArray ( int  iIndex,
OpcUa_StatusCode status = 0 
) const

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

Parameters
iIndexIndex of the structure field to set.
statusIs set to OpcUa_BadTypeMismatch if the DataType of the field is not the correct union DataType or the array type of the field is not ArrayType_Scalar. Is set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaGenericUnionArray or an empty UaGenericUnionArray if the name is invalid or the DataType of the field is not a structured DataType.
bool UaGenericStructureValue::isFieldSet ( const UaString sFieldName) const

Checks if a structure field based on a field name is set.

Parameters
sFieldNameName of the structure field
Returns
'true' if the field is set. 'false' if the optional field is not set, or sFieldName is invalid
bool UaGenericStructureValue::isFieldSet ( int  iIndex) const

Checks if a structure field based on the field index is set.

Parameters
iIndexIndex of the structure field
Returns
'true' if the field is set. 'false' if the optional field is not set, or iIndex is invalid
bool UaGenericStructureValue::operator!= ( const UaGenericStructureValue other) const

Checks if two UaGenericValues are unequal.

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

Assignment operator.

void UaGenericStructureValue::setDefinition ( const UaStructureDefinition definition,
bool  bCreateDefaultValues = false 
)

Clears the UaGenericStructureValue and sets the structure definition.

Parameters
definitionThe new structure definition
bCreateDefaultValuesIf true, default values for the fields are created. If false, no fields are created. This argument shall only be set to true by decoders. If this argument is set to false, setField methods will fail.
OpcUa_StatusCode UaGenericStructureValue::setField ( const UaString sFieldName,
UaVariant value,
OpcUa_Boolean  bDetach 
)

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.
bDetachIf true the specified field attaches value. If false value is copied to 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 UaGenericStructureValue::setField ( int  iIndex,
UaVariant value,
OpcUa_Boolean  bDetach 
)

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.
bDetachIf true the specified field attaches value. If false value is copied to 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 UaGenericStructureValue::setField ( const UaString sFieldName,
const UaGenericStructureValue 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 or the array type of the field is not ArrayType_Scalar.
OpcUa_StatusCode UaGenericStructureValue::setField ( int  iIndex,
const UaGenericStructureValue 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 or the array type of the field is not ArrayType_Scalar.
OpcUa_StatusCode UaGenericStructureValue::setField ( const UaString sFieldName,
const UaGenericStructureArray values 
)

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

Parameters
sFieldNameName of the structure field to set.
valuesThe 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 or the array type of the field is not ArrayType_Array.
OpcUa_StatusCode UaGenericStructureValue::setField ( int  iIndex,
const UaGenericStructureArray values 
)

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

Parameters
iIndexIndex of the structure field to set.
valuesThe new values 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 or the array type of the field is not ArrayType_Array.
OpcUa_StatusCode UaGenericStructureValue::setField ( const UaString sFieldName,
const UaGenericUnionValue 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 or the array type of the field is not ArrayType_Scalar.
OpcUa_StatusCode UaGenericStructureValue::setField ( int  iIndex,
const UaGenericUnionValue 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 or the array type of the field is not ArrayType_Scalar.
OpcUa_StatusCode UaGenericStructureValue::setField ( const UaString sFieldName,
const UaGenericUnionArray values 
)

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

Parameters
sFieldNameName of the structure field to set.
valuesThe 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 or the array type of the field is not ArrayType_Array.
OpcUa_StatusCode UaGenericStructureValue::setField ( int  iIndex,
const UaGenericUnionArray values 
)

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

Parameters
iIndexIndex of the structure field to set.
valuesThe new values 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 or the array type of the field is not ArrayType_Array.
OpcUa_StatusCode UaGenericStructureValue::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.
OpcUa_StatusCode UaGenericStructureValue::setGenericValue ( const UaExtensionObject extensionObject,
const UaStructureDefinition structureDefinition 
)

Parses a the binary data of an ExtenionObject and stores the data to a new UaGenericStructureValue.

If the TypeId of the ExtenionObject does not match the structureDefinition, the UaGenericStructureValue will not be changed.

Parameters
extensionObjectContains the content that will be deserialized.
structureDefinitionThe definition that is used for deserializing.
UaString UaGenericStructureValue::toString ( ) const

Returns a string representation of the value.

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

OpcUa_StatusCode UaGenericStructureValue::unsetField ( const UaString sFieldName)

Unsets an optional field based on a field name.

Parameters
sFieldNameName of the structure field
Returns
'BadInvalidArgument' if the field is not optional or sFieldName is invalid. 'Good' otherwise.
OpcUa_StatusCode UaGenericStructureValue::unsetField ( int  iIndex)

Unsets an optional field based on a field index.

Parameters
iIndexIndex of the structure field
Returns
'BadInvalidArgument' if the field is not optional or iIndex is invalid. 'Good' otherwise.
UaVariant UaGenericStructureValue::value ( const UaString sFieldName,
OpcUa_StatusCode status = 0 
) const

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

Parameters
sFieldNameName of the structure field value to return.
statusIs set to OpcUa_BadInvalidArgument if the name is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
Returns
The value as UaVariant or an empty UaVariant if the name is invalid.
UaVariant UaGenericStructureValue::value ( int  iIndex,
OpcUa_StatusCode status = 0 
) const

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

Parameters
iIndexIndex of the structure field value to return.
statusIs set to OpcUa_BadInvalidArgument if the index is invalid. Is set to OpcUa_Good otherwise. This argument can be null.
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: