/* */ #include "XmlRpcResponse.h" #include #include #include "util.h" namespace aria2 { namespace xmlrpc { static void encodeValue(const BDE& value, std::ostream& o); template static void encodeArray (InputIterator first, InputIterator last, std::ostream& o) { o << "" << ""; for(; first != last; ++first) { encodeValue(*first, o); } o << "" << ""; } template static void encodeStruct (InputIterator first, InputIterator last, std::ostream& o) { o << ""; for(; first != last; ++first) { o << "" << "" << util::htmlEscape((*first).first) << ""; encodeValue((*first).second, o); o << ""; } o << ""; } static void encodeValue(const BDE& value, std::ostream& o) { o << ""; if(value.isString()) { o << "" << util::htmlEscape(value.s()) << ""; } else if(value.isInteger()) { o << "" << value.i() << ""; } else if(value.isList()) { encodeArray(value.listBegin(), value.listEnd(), o); } else if(value.isDict()) { encodeStruct(value.dictBegin(), value.dictEnd(), o); } o << ""; } std::string XmlRpcResponse::toXml() const { std::stringstream o; o << "" << ""; if(_code == 0) { o << "" << ""; encodeValue(_param, o); o << "" << ""; } else { o << ""; encodeValue(_param, o); o << ""; } o << ""; return o.str(); } } // namespace xmlrpc } // namespace aria2