本文整理汇总了C++中AutoBuffer::write_byte方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoBuffer::write_byte方法的具体用法?C++ AutoBuffer::write_byte怎么用?C++ AutoBuffer::write_byte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoBuffer
的用法示例。
在下文中一共展示了AutoBuffer::write_byte方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
char *attribute_to_string(const AttributeType *attr) {
IService *iserv;
AutoBuffer *buf = &strBuffer;
if (attr->is_nil()) {
buf->write_string("None");
} else if (attr->is_int64() || attr->is_uint64()) {
buf->write_uint64(attr->to_uint64());
} else if (attr->is_string()) {
buf->write_string('\'');
buf->write_string(attr->to_string());
buf->write_string('\'');
} else if (attr->is_bool()) {
if (attr->to_bool()) {
buf->write_string("true");
} else {
buf->write_string("false");
}
} else if (attr->is_list()) {
AttributeType list_item;
unsigned list_sz = attr->size();
buf->write_string('[');
for (unsigned i = 0; i < list_sz; i++) {
list_item = (*attr)[i];
attribute_to_string(&list_item);
if (i < (list_sz - 1)) {
buf->write_string(',');
}
}
buf->write_string(']');
} else if (attr->is_dict()) {
AttributeType dict_item;
unsigned dict_sz = attr->size();;
buf->write_string('{');
for (unsigned i = 0; i < dict_sz; i++) {
buf->write_string('\'');
buf->write_string(attr->u_.dict[i].key_.to_string());
buf->write_string('\'');
buf->write_string(':');
const AttributeType &dict_value = (*attr)[i];
attribute_to_string(&dict_value);
if (i < (dict_sz - 1)) {
buf->write_string(',');
}
}
buf->write_string('}');
} else if (attr->is_data()) {
buf->write_string('(');
if (attr->size() > 0) {
for (unsigned n = 0; n < attr->size()-1; n++) {
buf->write_byte((*attr)(n));
buf->write_string(',');
}
buf->write_byte((*attr)(attr->size()-1));
}
buf->write_string(')');
} else if (attr->is_iface()) {
IFace *iface = attr->to_iface();
if (strcmp(iface->getFaceName(), IFACE_SERVICE) == 0) {
iserv = static_cast<IService *>(iface);
buf->write_string('{');
buf->write_string("'Type':'");
buf->write_string(iface->getFaceName());
buf->write_string("','ModuleName':'");
buf->write_string(iserv->getObjName());
buf->write_string("'}");
} else {
RISCV_printf(NULL, LOG_ERROR,
"Not implemented interface to dict. method");
}
}
return buf->getBuffer();
}