本文整理汇总了C++中Datagram::add_float32方法的典型用法代码示例。如果您正苦于以下问题:C++ Datagram::add_float32方法的具体用法?C++ Datagram::add_float32怎么用?C++ Datagram::add_float32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datagram
的用法示例。
在下文中一共展示了Datagram::add_float32方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBException
static void bson2bamboo(const dclass::DistributedType *type,
const BSONElement &element,
Datagram &dg)
{
switch(type->get_type()) {
case dclass::Type::T_INT8: {
dg.add_int8(element.Int());
}
break;
case dclass::Type::T_INT16: {
dg.add_int16(element.Int());
}
break;
case dclass::Type::T_INT32: {
dg.add_int32(element.Int());
}
break;
case dclass::Type::T_INT64: {
dg.add_int64(element.Int());
}
break;
case dclass::Type::T_UINT8: {
dg.add_uint8(element.Int());
}
break;
case dclass::Type::T_UINT16: {
dg.add_uint16(element.Int());
}
break;
case dclass::Type::T_UINT32: {
dg.add_uint32(element.Int());
}
break;
case dclass::Type::T_UINT64: {
dg.add_uint64(element.Int());
}
break;
case dclass::Type::T_CHAR: {
string str = element.String();
if(str.size() != 1) {
throw mongo::DBException("Expected single-length string for char field", 0);
}
dg.add_uint8(str[0]);
}
break;
case dclass::Type::T_FLOAT32: {
dg.add_float32(element.Number());
}
break;
case dclass::Type::T_FLOAT64: {
dg.add_float64(element.Number());
}
break;
case dclass::Type::T_STRING: {
dg.add_data(element.String());
}
break;
case dclass::Type::T_VARSTRING: {
dg.add_string(element.String());
}
break;
case dclass::Type::T_BLOB: {
int len;
const uint8_t *rawdata = (const uint8_t *)element.binData(len);
dg.add_data(rawdata, len);
}
break;
case dclass::Type::T_VARBLOB: {
int len;
const uint8_t *rawdata = (const uint8_t *)element.binData(len);
dg.add_blob(rawdata, len);
}
break;
case dclass::Type::T_ARRAY: {
const dclass::ArrayType *array = type->as_array();
std::vector<BSONElement> data = element.Array();
for(auto it = data.begin(); it != data.end(); ++it) {
bson2bamboo(array->get_element_type(), *it, dg);
}
}
break;
case dclass::Type::T_VARARRAY: {
const dclass::ArrayType *array = type->as_array();
std::vector<BSONElement> data = element.Array();
DatagramPtr newdg = Datagram::create();
for(auto it = data.begin(); it != data.end(); ++it) {
bson2bamboo(array->get_element_type(), *it, *newdg);
}
dg.add_blob(newdg->get_data(), newdg->size());
}
break;
case dclass::Type::T_STRUCT: {
const dclass::Struct *s = type->as_struct();
size_t fields = s->get_num_fields();
for(unsigned int i = 0; i < fields; ++i) {
const dclass::Field *field = s->get_field(i);
//.........这里部分代码省略.........