本文整理汇总了C++中DatagramIterator::read_int32方法的典型用法代码示例。如果您正苦于以下问题:C++ DatagramIterator::read_int32方法的具体用法?C++ DatagramIterator::read_int32怎么用?C++ DatagramIterator::read_int32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatagramIterator
的用法示例。
在下文中一共展示了DatagramIterator::read_int32方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: str
static BSONObj bamboo2bson(const dclass::DistributedType *type,
DatagramIterator &dgi)
{
// The BSON library's weird data model doesn't allow elements to exist on
// their own; they must be part of an object. Therefore, we always return
// results in a single BSONObj with key "_"
BSONObjBuilder b;
switch(type->get_type()) {
case dclass::Type::T_INT8: {
b << "_" << dgi.read_int8();
}
break;
case dclass::Type::T_INT16: {
b << "_" << dgi.read_int16();
}
break;
case dclass::Type::T_INT32: {
b << "_" << dgi.read_int32();
}
break;
case dclass::Type::T_INT64: {
b.appendIntOrLL("_", dgi.read_int64());
}
break;
case dclass::Type::T_UINT8: {
b << "_" << dgi.read_uint8();
}
break;
case dclass::Type::T_UINT16: {
b << "_" << dgi.read_uint16();
}
break;
case dclass::Type::T_UINT32: {
b << "_" << dgi.read_uint32();
}
break;
case dclass::Type::T_UINT64: {
b.appendIntOrLL("_", dgi.read_uint64());
}
break;
case dclass::Type::T_CHAR: {
unsigned char c = dgi.read_uint8();
string str(c, 1);
b << "_" << str;
}
break;
case dclass::Type::T_FLOAT32: {
b << "_" << dgi.read_float32();
}
break;
case dclass::Type::T_FLOAT64: {
b << "_" << dgi.read_float64();
}
break;
case dclass::Type::T_STRING: {
vector<uint8_t> vec = dgi.read_data(type->get_size());
string str((const char *)vec.data(), vec.size());
b << "_" << str;
}
case dclass::Type::T_VARSTRING: {
b << "_" << dgi.read_string();
}
break;
case dclass::Type::T_BLOB: {
vector<uint8_t> blob = dgi.read_data(type->get_size());
b.appendBinData("_", blob.size(), BinDataGeneral, blob.data());
}
break;
case dclass::Type::T_VARBLOB: {
vector<uint8_t> blob = dgi.read_blob();
b.appendBinData("_", blob.size(), BinDataGeneral, blob.data());
}
break;
case dclass::Type::T_ARRAY: {
const dclass::ArrayType *array = type->as_array();
BSONArrayBuilder ab;
for(size_t i = 0; i < array->get_array_size(); i++) {
ab << bamboo2bson(array->get_element_type(), dgi)["_"];
}
b << "_" << ab.arr();
}
break;
case dclass::Type::T_VARARRAY: {
const dclass::ArrayType *array = type->as_array();
dgsize_t array_length = dgi.read_size();
dgsize_t starting_size = dgi.tell();
BSONArrayBuilder ab;
while(dgi.tell() != starting_size + array_length) {
ab << bamboo2bson(array->get_element_type(), dgi)["_"];
if(dgi.tell() > starting_size + array_length) {
throw mongo::DBException("Discovered corrupt array-length tag!", 0);
}
}
//.........这里部分代码省略.........