Пример #1
0
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);
    }
}
Пример #2
0
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);
}
Пример #3
0
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;
}