winIDEA SDK
|
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 SType & | getType () const |
Returns iConnect type. More... | |
const SValue & | getValue () 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... | |
Defines format of numerical output.
isys::CValueType::CValueType | ( | const SType & | type, |
int64_t | value | ||
) |
This ctor sets 64 bit integer value.
type | must be set to tSigned or tUnsigned, bit size must be less than 65. |
value | the value |
isys::CValueType::CValueType | ( | const SType & | type, |
float | value | ||
) |
This ctor sets float value.
type | must be set to tFloat, bit size must be 32 or 64. |
value | the value |
isys::CValueType::CValueType | ( | const SType & | type, |
double | value | ||
) |
This ctor sets double value.
type | must be set to tFloat, bit size must be 64. |
value | the value |
isys::CValueType::CValueType | ( | int | bitSize, |
int64_t | value | ||
) |
This ctor initializes object with signed data.
bitSize | size of value in bits |
value | the value |
isys::CValueType::CValueType | ( | int | bitSize, |
uint64_t | value | ||
) |
This ctor initializes object with signed data.
bitSize | size of value in bits |
value | the value |
isys::CValueType::CValueType | ( | float | value | ) |
This ctor sets 32 bit float value as follows:
SType.m_byType = tFloat; SType.m_byBitSize = 32;
value | the value |
isys::CValueType::CValueType | ( | double | value | ) |
This ctor sets 64 bit float value as follows:
SType.m_byType = tFloat; SType.m_byBitSize = 64;
value | the value |
This ctor sets address value.
type | must be set to tAddress |
address | the address |
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.
type | the type, no restrictions |
value | string containing integer to be set. Example: "324". Only characters up to first non-digit character are used. |
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.
errorMsg | string containing error description |
CAddress isys::CValueType::getAddress | ( | ) |
Returns address.
IOException | if type is not tAddress. |
double isys::CValueType::getDouble | ( | ) |
Returns double value.
If the value is of type integer or float, it is converted to double.
IOException | if bit size is not 32, or 64, or type is not tSigned, or tUnsigned, or tFloat |
float isys::CValueType::getFloat | ( | ) |
Returns float value.
If the value is of type integer it is converted to float.
IOException | if bit size is not 32, or type is not tSigned, or tUnsigned, or tFloat |
int isys::CValueType::getInt | ( | ) |
Returns integer value for bit sizes 8, 16, and 32.
IOException | if bit size given in ctor does not match 8, 16, or 32, or type is not tSigned or tUnsigned. |
long long isys::CValueType::getLong | ( | ) |
Returns long integer value for bit sizes 8, 16, 32, and 64.
IOException | if bit size given in ctor does not match 8, 16, 32, or 64, or type is not tSigned or tUnsigned. |
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.
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.
format | result format has effect only for integer values. |
const SType & isys::CValueType::getType | ( | ) | const |
Returns iConnect type.
It is preferred to use one of 'isType...()' and 'getBitSize()' methods instead of this one.
const SValue & isys::CValueType::getValue | ( | ) | const |
Returns iConnect value.
bool isys::CValueType::isError | ( | ) | const |
Returns true, if the object contains error message instead of value.
Call getResult() to get the error message.