本文整理汇总了C++中IValue::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ IValue::getValue方法的具体用法?C++ IValue::getValue怎么用?C++ IValue::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValue
的用法示例。
在下文中一共展示了IValue::getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readValue
VALUE IValue::readValue(int offset, KIND type) {
int byte;
VALUE value;
DEBUG_STDOUT("\t"
<< " Reading from IValue object: " << toString());
DEBUG_STDOUT("\t"
<< " Reading for type: " << KIND_ToString(type));
byte = KIND_GetSize(type);
if (offset == 0 && KIND_GetSize(getIPtrValue(index).getType()) == byte) {
//
// trivial reading case
//
DEBUG_STDOUT("\t"
<< "Trivial reading.");
value = getIPtrValue(index).getValue();
} else {
//
// off the shelf reading case
//
DEBUG_STDOUT("\t"
<< "Off the shelf reading.");
unsigned nextIndex;
int totalByte, tocInx, trcInx;
uint8_t* totalContent, *truncContent;
nextIndex = index;
totalByte = 0;
// TODO: review the condition nextIndex < length
while (totalByte < offset + byte && nextIndex < length) {
IValue value;
value = getIPtrValue(nextIndex);
totalByte += KIND_GetSize(value.getType()); // TODO: can the value's type change while iterating?
nextIndex++;
}
//
// totalContent stores the accumulative content from IValue at index
// to IValue at nextIndex-1
//
totalContent = (uint8_t*)malloc(totalByte * sizeof(uint8_t));
tocInx = 0;
for (unsigned i = index; i < nextIndex; i++) {
IValue value;
KIND type;
int size;
VALUE valValue;
uint8_t* valueContent;
value = getIPtrValue(i);
type = value.getType();
size = KIND_GetSize(type); // TODO: can the value's type change while iterating?
valValue = value.getValue();
valueContent = (uint8_t*)&valValue;
for (int j = 0; j < size; j++) {
totalContent[tocInx] = valueContent[j];
tocInx++;
}
}
//
// truncate content from total content
//
truncContent = (uint8_t*)calloc(8, sizeof(uint8_t)); // TODO: magic number 8 is 64/8
trcInx = 0;
for (int i = offset; i < offset + byte; i++) {
truncContent[trcInx] = totalContent[i];
trcInx++;
}
//
// cast truncate content array to an actual value
//
switch (type) {
case FLP32_KIND: {
float* truncValue = (float*)truncContent;
value.as_flp = *truncValue;
break;
}
case FLP64_KIND: {
double* truncValue = (double*)truncContent;
value.as_flp = *truncValue;
break;
}
default: {
int64_t* truncValue = (int64_t*)truncContent;
//.........这里部分代码省略.........