示例#1
0
/*---------------------------------------------------------------------------------
 
 ---------------------------------------------------------------------------------*/
void AttributeValue::writeToCDataWrapper(CDataWrapper& data_wrapper) {
    switch(type) {
        case chaos::DataType::TYPE_BYTEARRAY:{
            switch(sub_type.size()) {
                case 1:
                    data_wrapper.addBinaryValue(name, sub_type[0], (const char *)value_buffer, size);
                    break;
                    
                default:
                    data_wrapper.addBinaryValue(name, (const char *)value_buffer, size);
                    break;
            }
            break;
        }
        case chaos::DataType::TYPE_CLUSTER:{

            data_wrapper.addCSDataValue(name,cdvalue);
            break;
        }
        case chaos::DataType::TYPE_STRING:{
            unsigned long str_len = value_buffer?std::strlen((const char *)value_buffer):0;
            str_len = (str_len>=size?size:str_len);
            data_wrapper.addStringValue(name, (str_len?std::string(static_cast<const char*>(value_buffer), str_len):""));
            break;
        }
            
        case chaos::DataType::TYPE_BOOLEAN:{
            data_wrapper.addBoolValue(name, *getValuePtr<bool>());
            break;
        }
            
        case chaos::DataType::TYPE_DOUBLE:{
            data_wrapper.addDoubleValue(name, *getValuePtr<double>());
            break;
        }
            
        case chaos::DataType::TYPE_INT32:{
            data_wrapper.addInt32Value(name, *getValuePtr<int32_t>());
            break;
        }
            
        case chaos::DataType::TYPE_INT64:{
            data_wrapper.addInt64Value(name, *getValuePtr<int64_t>());
            break;
        }
        default:
            break;
    }
}
示例#2
0
void BoolHealtMetric::addMetricToCD(CDataWrapper& data) {
    data.addBoolValue(name.c_str(), value);
}