winIDEA SDK
isys::CValueType Class Reference

Description

This is a wrapper class for iConnect SType and SValue.

Since some languages do not support unions, there are special getter methods for obtaining the value.

Important: If there was an error in evaluation, this class will contain error description instead of the value. Method isError() should be called always when an instance of this class is returned from isystem.connect methods, for example CDataController::evaluate() or CDataController::readValue().

This class is immutable.

#include <CValueType.h>

Public Types

enum  EResultFormat {
  EDecimal , EHex ,
  EChar
}
 Defines format of numerical output. More...
 

Public Member Functions

 CValueType (const SType &type, const SValue &value)
 Initializes new object with type and value.
 
 CValueType (const SType &type, const SValue &value, const std::string &result)
 Initializes new object with type, value, and string result of evaluation.
 
 CValueType (const SType &type, int64_t value)
 This ctor sets 64 bit integer value. More...
 
 CValueType (const SType &type, float value)
 This ctor sets float value. More...
 
 CValueType (const SType &type, double value)
 This ctor sets double value. More...
 
 CValueType (int bitSize, int64_t value)
 This ctor initializes object with signed data. More...
 
 CValueType (int bitSize, uint64_t value)
 This ctor initializes object with signed data. More...
 
 CValueType (float value)
 This ctor sets 32 bit float value as follows: More...
 
 CValueType (double value)
 This ctor sets 64 bit float value as follows: More...
 
 CValueType (const SType &type, const CAddress &address)
 This ctor sets address value. More...
 
 CValueType (const SType &type, const std::string &value)
 This ctor sets numeric values and string value, depending on the type specified. More...
 
 CValueType (const std::string &errorMsg)
 This ctor is used to report error. More...
 
bool isError () const
 Returns true, if the object contains error message instead of value. More...
 
const STypegetType () const
 Returns iConnect type. More...
 
const SValuegetValue () const
 Returns iConnect value. More...
 
const std::string & getResult () const
 Returns string value, which is either the evaluation result or error message if isError() returns true. More...
 
const std::string getResult (EResultFormat format) const
 Returns string value, which is either the evaluation result or error message if isError() returns true. More...
 
bool isTypeUnsigned ()
 Returns true, if the value is of unsigned type.
 
bool isTypeSigned ()
 Returns true, if the value is of signed type.
 
bool isTypeFloat ()
 Returns true, if the value is of float type.
 
bool isTypeAddress ()
 Returns true, if the value is of address type.
 
bool isTypeCompound ()
 Returns true, if the value is of signed type.
 
int getBitSize ()
 Returns size of value in bits.
 
int getInt ()
 Returns integer value for bit sizes 8, 16, and 32. More...
 
long long getLong ()
 Returns long integer value for bit sizes 8, 16, 32, and 64. More...
 
float getFloat ()
 Returns float value. More...
 
double getDouble ()
 Returns double value. More...
 
CAddress getAddress ()
 Returns address. More...
 

Member Enumeration Documentation

◆ EResultFormat

Defines format of numerical output.

Enumerator
EDecimal 

All integers, from 8 to 64-bit, are returned as string in decimal format.

Has no effect for other types like floats or addresses.

EHex 

All integers, from 8 to 64-bit, are returned as string in hexadecimal format.

Has no effect for other types like floats or addresses.

EChar 

8-bit integers in range 32-127 are returned as characters

Constructor & Destructor Documentation

◆ CValueType() [1/10]

isys::CValueType::CValueType ( const SType type,
int64_t  value 
)

This ctor sets 64 bit integer value.

Parameters
typemust be set to tSigned or tUnsigned, bit size must be less than 65.
valuethe value

◆ CValueType() [2/10]

isys::CValueType::CValueType ( const SType type,
float  value 
)

This ctor sets float value.

Parameters
typemust be set to tFloat, bit size must be 32 or 64.
valuethe value

◆ CValueType() [3/10]

isys::CValueType::CValueType ( const SType type,
double  value 
)

This ctor sets double value.

Parameters
typemust be set to tFloat, bit size must be 64.
valuethe value

◆ CValueType() [4/10]

isys::CValueType::CValueType ( int  bitSize,
int64_t  value 
)

This ctor initializes object with signed data.

Parameters
bitSizesize of value in bits
valuethe value

◆ CValueType() [5/10]

isys::CValueType::CValueType ( int  bitSize,
uint64_t  value 
)

This ctor initializes object with signed data.

Parameters
bitSizesize of value in bits
valuethe value

◆ CValueType() [6/10]

isys::CValueType::CValueType ( float  value)

This ctor sets 32 bit float value as follows:

SType.m_byType = tFloat;
SType.m_byBitSize = 32;
Parameters
valuethe value

◆ CValueType() [7/10]

isys::CValueType::CValueType ( double  value)

This ctor sets 64 bit float value as follows:

SType.m_byType = tFloat;
SType.m_byBitSize = 64;
Parameters
valuethe value

◆ CValueType() [8/10]

isys::CValueType::CValueType ( const SType type,
const CAddress address 
)

This ctor sets address value.

Parameters
typemust be set to tAddress
addressthe address

◆ CValueType() [9/10]

isys::CValueType::CValueType ( const SType type,
const std::string &  value 
)

This ctor sets numeric values and string value, depending on the type specified.

It is preferred to use this method from Java for unsigned types.

Parameters
typethe type, no restrictions
valuestring containing integer to be set. Example: "324". Only characters up to first non-digit character are used.

◆ CValueType() [10/10]

isys::CValueType::CValueType ( const std::string &  errorMsg)

This ctor is used to report error.

Used for example wehn reading SFRs, since some SFRs can not be read due to access restrictions, while most of them are read without problems.

Parameters
errorMsgstring containing error description

Member Function Documentation

◆ getAddress()

CAddress isys::CValueType::getAddress ( )

Returns address.

Exceptions
IOExceptionif type is not tAddress.

◆ getDouble()

double isys::CValueType::getDouble ( )

Returns double value.

If the value is of type integer or float, it is converted to double.

Exceptions
IOExceptionif bit size is not 32, or 64, or type is not tSigned, or tUnsigned, or tFloat

◆ getFloat()

float isys::CValueType::getFloat ( )

Returns float value.

If the value is of type integer it is converted to float.

Exceptions
IOExceptionif bit size is not 32, or type is not tSigned, or tUnsigned, or tFloat

◆ getInt()

int isys::CValueType::getInt ( )

Returns integer value for bit sizes 8, 16, and 32.

Exceptions
IOExceptionif bit size given in ctor does not match 8, 16, or 32, or type is not tSigned or tUnsigned.

◆ getLong()

long long isys::CValueType::getLong ( )

Returns long integer value for bit sizes 8, 16, 32, and 64.

Exceptions
IOExceptionif bit size given in ctor does not match 8, 16, 32, or 64, or type is not tSigned or tUnsigned.

◆ getResult() [1/2]

const std::string & isys::CValueType::getResult ( ) const

Returns string value, which is either the evaluation result or error message if isError() returns true.

This method should be used for logging or debugging only. Use other getters to obtain values for further processing. Format of the returned value depends on settings in winIDEA watch window.

◆ getResult() [2/2]

const std::string isys::CValueType::getResult ( EResultFormat  format) const

Returns string value, which is either the evaluation result or error message if isError() returns true.

This method should be used for logging or debugging only. Use other getters to obtain values for further processing.

Parameters
formatresult format has effect only for integer values.

◆ getType()

const SType & isys::CValueType::getType ( ) const

Returns iConnect type.

It is preferred to use one of 'isType...()' and 'getBitSize()' methods instead of this one.

◆ getValue()

const SValue & isys::CValueType::getValue ( ) const

Returns iConnect value.


◆ isError()

bool isys::CValueType::isError ( ) const

Returns true, if the object contains error message instead of value.

Call getResult() to get the error message.