本文整理汇总了C++中AutoBuffer::write_bin方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoBuffer::write_bin方法的具体用法?C++ AutoBuffer::write_bin怎么用?C++ AutoBuffer::write_bin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoBuffer
的用法示例。
在下文中一共展示了AutoBuffer::write_bin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
const char *string_to_attribute(const char *cfg,
AttributeType *out) {
const char *pcur = skip_special_symbols(cfg);
if (pcur[0] == '\'' || pcur[0] == '"') {
AutoBuffer buf;
uint8_t t1 = pcur[0];
int str_sz = 0;
pcur++;
while (*pcur != t1 && *pcur != '\0') {
pcur++;
str_sz++;
}
buf.write_bin(&cfg[1], str_sz);
pcur++;
out->make_string(buf.getBuffer());
} else if (pcur[0] == '[') {
pcur++;
pcur = skip_special_symbols(pcur);
AttributeType new_item;
out->make_list(0);
while (*pcur != ']' && *pcur != '\0') {
pcur = string_to_attribute(pcur, &new_item);
out->realloc_list(out->size() + 1);
(*out)[out->size() - 1] = new_item;
pcur = skip_special_symbols(pcur);
if (*pcur == ',') {
pcur++;
pcur = skip_special_symbols(pcur);
}
}
pcur++;
pcur = skip_special_symbols(pcur);
} else if (pcur[0] == '{') {
AttributeType new_key;
AttributeType new_value;
out->make_dict();
pcur++;
pcur = skip_special_symbols(pcur);
while (*pcur != '}' && *pcur != '\0') {
pcur = string_to_attribute(pcur, &new_key);
pcur = skip_special_symbols(pcur);
if (*pcur == ':') {
pcur++;
}
pcur = skip_special_symbols(pcur);
pcur = string_to_attribute(pcur, &new_value);
(*out)[new_key.to_string()] = new_value;
pcur = skip_special_symbols(pcur);
if (*pcur == ',') {
pcur++;
pcur = skip_special_symbols(pcur);
}
}
pcur++;
pcur = skip_special_symbols(pcur);
if (out->has_key("Type")) {
if (strcmp((*out)["Type"].to_string(), IFACE_SERVICE) == 0) {
IService *iserv;
iserv = static_cast<IService *>(
RISCV_get_service((*out)["ModuleName"].to_string()));
out->attr_free();
*out = AttributeType(iserv);
} else {
RISCV_printf(NULL, LOG_ERROR,
"Not implemented string to dict. attribute");
}
}
} else if (pcur[0] == '(') {
AutoBuffer buf;
char byte_value;
pcur++;
pcur = skip_special_symbols(pcur);
while (*pcur != ')' && *pcur != '\0') {
byte_value = 0;
for (int n = 0; n < 2; n++) {
if (*pcur >= 'A' && *pcur <= 'F') {
byte_value = (byte_value << 4) | ((*pcur - 'A') + 10);
} else {
byte_value = (byte_value << 4) | (*pcur - '0');
}
pcur++;
}
buf.write_bin(&byte_value, 1);
pcur = skip_special_symbols(pcur);
if (*pcur == ',') {
pcur++;
pcur = skip_special_symbols(pcur);
}
}
out->make_data(buf.size(), buf.getBuffer());
pcur++;
pcur = skip_special_symbols(pcur);
} else {
//.........这里部分代码省略.........