std::string agocontrol::variantListToJSONString(qpid::types::Variant::List list) { string result; result += "["; for (Variant::List::const_iterator it = list.begin(); it != list.end(); ++it) { std::string tmpstring; switch(it->getType()) { case VAR_MAP: result += variantMapToJSONString(it->asMap()); break; case VAR_LIST: result += variantListToJSONString(it->asList()); break; case VAR_STRING: tmpstring = it->asString(); replaceString(tmpstring, "\"", "\\\""); result += "\"" + tmpstring + "\""; break; default: if (it->asString().size() != 0) { result += it->asString(); } else { result += "null"; } } if ((it != list.end()) && (next(it) != list.end())) result += ","; } result += "]"; return result; }
size_t MessageEncoder::getEncodedSize(const qpid::types::Variant::List& list, bool alwaysUseLargeList) { size_t total(0); for (qpid::types::Variant::List::const_iterator i = list.begin(); i != list.end(); ++i) { total += getEncodedSizeForValue(*i); } //its not just the count that determines whether we can use a small list, but the aggregate size: if (alwaysUseLargeList || list.size()*2 > 255 || total > 255) total += 4/*size*/ + 4/*count*/; else total += 1/*size*/ + 1/*count*/; total += 1 /*code for list itself*/; return total; }
void PnData::readList(qpid::types::Variant::List& value) { size_t count = pn_data_get_list(data); pn_data_enter(data); for (size_t i = 0; i < count && pn_data_next(data); ++i) { qpid::types::Variant e; if (read(e)) value.push_back(e); } pn_data_exit(data); }