コード例 #1
0
ファイル: xml_tree.cpp プロジェクト: JonathanFu/OpenAM-1
XMLElement XMLTree::getRootElement() const {
#ifdef PUGIXML
    return XMLElement(docPtr.first_child());
#else
    return XMLElement(xmlDocGetRootElement(docPtr));
#endif
}
コード例 #2
0
    void XMLNodeList::setElementAtPosition(double index, const XMLNodeList & list)
    {
        if (list.getSize() && list.getRealNode() != parent)
        {
            int pos = (int)index;

            if (index < 1)
            {
                pos = 1;
            }
            else if (index > size)
            {
                pos = size++;
            }
            else if ((int)index != index)
            {
                pos++;
            }

            setElementAtPosition(index, XMLElement(doc, list.getRealNode()));
            for (xmlNode * cur = list.getRealNode()->next; cur; cur = cur->next)
            {
                setElementAtPosition((double)(pos++) + 0.5, XMLElement(doc, cur));
            }
        }
    }
コード例 #3
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement XMLElement::GetParent() const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    return XMLElement(file_, node.parent().internal_object());
}
コード例 #4
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement XMLElement::SelectSingle(const ea::string& query, pugi::xpath_variable_set* variables) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    pugi::xpath_node result = node.select_single_node(query.c_str(), variables);
    return XMLElement(file_, nullptr, &result, 0);
}
コード例 #5
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement XMLElement::SelectSinglePrepared(const XPathQuery& query) const
{
    if (!file_ || (!node_ && !xpathNode_ && !query.GetXPathQuery()))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    pugi::xpath_node result = node.select_single_node(*query.GetXPathQuery());
    return XMLElement(file_, nullptr, &result, 0);
}
コード例 #6
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement XMLElement::CreateChild(const char* name)
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    pugi::xml_node child = const_cast<pugi::xml_node&>(node).append_child(name);
    return XMLElement(file_, child.internal_object());
}
コード例 #7
0
ファイル: XMLElement.cpp プロジェクト: zhzhxtrrk/Urho3D
XMLElement XMLElement::GetChild(const char* name) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    if (!String::CStringLength(name))
        return XMLElement(file_, node.first_child().internal_object());
    else
        return XMLElement(file_, node.child(name).internal_object());
}
コード例 #8
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement XMLElement::GetNext(const char* name) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    if (!CStringLength(name))
        return XMLElement(file_, node.next_sibling().internal_object());
    else
        return XMLElement(file_, node.next_sibling(name).internal_object());
}
コード例 #9
0
ファイル: XMLFile.cpp プロジェクト: CarloMaker/Urho3D
XMLElement XMLFile::GetRoot(const String& name)
{
    pugi::xml_node root = document_->first_child();
    if (root.empty())
        return XMLElement();
    
    if (!name.Empty() && name != root.name())
        return XMLElement();
    else
        return XMLElement(this, root.internal_object());
}
コード例 #10
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement XMLElement::NextResult() const
{
    if (!xpathResultSet_ || !xpathNode_)
        return XMLElement();

    return xpathResultSet_->operator [](++xpathResultIndex_);
}
コード例 #11
0
ファイル: XMLElement.cpp プロジェクト: zhzhxtrrk/Urho3D
XMLElement XPathResultSet::operator[](unsigned index) const
{
    if (!resultSet_)
        LOGERRORF("Could not return result at index: %u. Most probably this is caused by the XPathResultSet not being stored in a lhs variable.", index);

    return resultSet_ && index < Size() ? XMLElement(file_, this, &resultSet_->operator [](index), index) : XMLElement();
}
コード例 #12
0
ファイル: XMLDoc.cpp プロジェクト: Ouaz/freeorion
std::istream& XMLDoc::ReadDoc(std::istream& is)
{
    root_node = XMLElement(); // clear doc contents
    s_element_stack.clear();  // clear this to start a fresh read
    s_curr_parsing_doc = this;  // indicate where to add elements
    std::string parse_str;
    std::string temp_str;
    while (is) {
        getline(is, temp_str);
        parse_str += temp_str + '\n';
    }
    parse(parse_str.c_str(), document);
    s_curr_parsing_doc = 0;
    return is;
}
コード例 #13
0
    void XMLNodeList::setElementAtPosition(double index, const std::string & xmlCode)
    {
        std::string error;
        XMLDocument document = XMLDocument(xmlCode, false, &error);

        if (error.empty())
        {
            setElementAtPosition(index, document);
        }
        else
        {
            xmlNode *n = xmlNewText((xmlChar *) xmlCode.c_str());

            setElementAtPosition(index, XMLElement(doc, n));
        }
    }
コード例 #14
0
ファイル: XMLElement.cpp プロジェクト: ASP1234/Scilabv5.5.2
void XMLElement::setChildren(const std::string & xmlCode) const
{
    std::string error;
    XMLDocument document = XMLDocument(xmlCode, false, &error);

    if (error.empty())
    {
        setChildren(*document.getRoot());
    }
    else
    {
        xmlNode *n = xmlNewText((xmlChar *) xmlCode.c_str());

        setChildren(XMLElement(doc, n));
    }
}
コード例 #15
0
ファイル: xmlelement.cpp プロジェクト: KDE/jovie
XMLElement XMLElement::fromQString(const QString &str) {
    QStringList sections = str.split( ' ');
    QString tagname = sections[0];
    XMLElement e(tagname.latin1());

    sections.pop_front();
    // Loop over the remaining strings which are attributes="values"
    if(sections.count()) {
        const int sectionsCount = sections.count();
        for(int i = 0; i < sectionsCount; ++i) {
            QStringList list = sections[i].split( '=');
            if(list.count() != 2) {
                std::cerr << "XMLElement::fromQString: Cannot convert list: " << list.join("|") << ". `" << str << "' is not in valid format.\n";
                return XMLElement(" ");
            }
            e.setAttribute(list[0], list[1].left(list[1].length() - 1).right(list[1].length() -2));
        }
    }
    return e;
}
コード例 #16
0
ファイル: XMLNode.cpp プロジェクト: oGGy990/ximp
XMLElement XMLNode::toElement() const
{
	return XMLElement(*this);
}
コード例 #17
0
ファイル: XMLFile.cpp プロジェクト: CarloMaker/Urho3D
XMLElement XMLFile::CreateRoot(const String& name)
{
    document_->reset();
    pugi::xml_node root = document_->append_child(name.CString());
    return XMLElement(this, root.internal_object());
}
コード例 #18
0
ファイル: XMLDoc.cpp プロジェクト: Ouaz/freeorion
XMLDoc::XMLDoc(const std::string& root_tag/*= "XMLDoc"*/) :
    root_node(XMLElement(root_tag, true))
{}
コード例 #19
0
ファイル: XMLDoc.cpp プロジェクト: Ouaz/freeorion
XMLDoc::XMLDoc(const std::istream& is) :
    root_node(XMLElement())
{}
コード例 #20
0
ファイル: XMLDoc.cpp プロジェクト: Ouaz/freeorion
void XMLDoc::SetElemName(const char* first, const char* last)
{ s_temp_elem = XMLElement(std::string(first, last)); }
コード例 #21
0
 XMLElement findElementById(svg_string_t const & id)
 {
   std::pair<element_by_id_t::iterator, bool> ins = element_by_id_.insert(element_by_id_t::value_type(id, XMLElement()));
   if (ins.second)
     ins.first->second = FindChildElementById(getRoot(), id);
   return ins.first->second;
 }
コード例 #22
0
ファイル: XMLDoc.cpp プロジェクト: Ouaz/freeorion
void XMLElement::AppendChild(const std::string& tag)
{ m_children.push_back(XMLElement(tag)); }