void parse_buffer(pugi::xml_document& doc, const char *xmlbuf, size_t buflen) { pugi::xml_parse_result result = doc.load_buffer(xmlbuf, buflen); if (result.status != pugi::status_ok) { std::string errmsg = xml_error_string(result); throw ContentError(errmsg); } }
ServiceDescription ServiceDescription::from_xml(const char *xmlbuf, size_t buflen) { pugi::xml_document doc; XML::parse_buffer(doc, xmlbuf, buflen); auto srv = doc.child("service"); if (!srv) { throw ContentError("Arrowhead::XML::parse_service: no <service> tag"); } return XML::service_from_node(srv); }
Content ONCatEntity::getNestedContent(const Content &content, const std::string &path) const { const auto pathTokens = StringTokenizer(path, ".", Mantid::Kernel::StringTokenizer::TOK_TRIM); auto currentNode = content; // Use the path tokens to drill down through the JSON nodes. for (const auto &pathToken : pathTokens) { if (!currentNode.isMember(pathToken)) { throw ContentError(""); } currentNode = currentNode[pathToken]; } return currentNode; }