diff options
| author | fippo <[email protected]> | 2022-02-10 16:50:08 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:50:08 +0300 | 
| commit | 7bf72dabd2102d9781c1ec7a754579757baa7b90 (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/xml/document | |
| parent | 3e57c324d47a3a202cb3c5a9648d2f92103d5213 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/xml/document')
| -rw-r--r-- | library/cpp/xml/document/node-attr.h | 30 | ||||
| -rw-r--r-- | library/cpp/xml/document/xml-document-decl.h | 108 | ||||
| -rw-r--r-- | library/cpp/xml/document/xml-document.cpp | 42 | ||||
| -rw-r--r-- | library/cpp/xml/document/xml-document_ut.cpp | 36 | 
4 files changed, 108 insertions, 108 deletions
diff --git a/library/cpp/xml/document/node-attr.h b/library/cpp/xml/document/node-attr.h index baf2812d959..6e74403943c 100644 --- a/library/cpp/xml/document/node-attr.h +++ b/library/cpp/xml/document/node-attr.h @@ -182,28 +182,28 @@ namespace NXml {          return TNode(DocPointer, child);      } -    template <class T>  +    template <class T>      typename std::enable_if<!std::is_convertible_v<T, TStringBuf>, TNode>::type      TNode::AddText(const T& value) { -        TStringStream ss;  -        ss << value;  -        return AddText(ss.Str());  -    }  -  +        TStringStream ss; +        ss << value; +        return AddText(ss.Str()); +    } +      inline TNode TNode::AddText(TStringBuf value) {          if (IsNull()) {              THROW(XmlException, "addChild [value=" << value                                                     << "]: can't add child to null node"); -        }  -  -        xmlNode* child = xmlNewTextLen((xmlChar*)value.data(), value.size());  -        child = xmlAddChild(NodePointer, child);  -  +        } + +        xmlNode* child = xmlNewTextLen((xmlChar*)value.data(), value.size()); +        child = xmlAddChild(NodePointer, child); +          if (!child) {              THROW(XmlException, "addChild [value=" << value                                                     << "]: xmlNewTextChild returned NULL"); -        }  -  -        return TNode(DocPointer, child);  -    }  +        } + +        return TNode(DocPointer, child); +    }  } diff --git a/library/cpp/xml/document/xml-document-decl.h b/library/cpp/xml/document/xml-document-decl.h index af8c31a37b2..bfda1fb7e6e 100644 --- a/library/cpp/xml/document/xml-document-decl.h +++ b/library/cpp/xml/document/xml-document-decl.h @@ -263,13 +263,13 @@ namespace NXml {          TConstNode FirstChild() const;          /** -        * get parent node  -        * throws exception if has no parent  -        */  -        TNode Parent();  -        TConstNode Parent() const;  -  -        /**  +        * get parent node +        * throws exception if has no parent +        */ +        TNode Parent(); +        TConstNode Parent() const; + +        /**          * get node neighbour          * @param name: neighbour name          * @note if name is empty, returns the next sibling node of type "element" @@ -307,17 +307,17 @@ namespace NXml {          TNode AddChild(const TConstNode& node);          /** -        * create text child node  -        * @param name: child name  -        * @param value: node value  -        */  -        template <class T>  +        * create text child node +        * @param name: child name +        * @param value: node value +        */ +        template <class T>          typename std::enable_if<!std::is_convertible_v<T, TStringBuf>, TNode>::type          AddText(const T& value); -  +          TNode AddText(TStringBuf value); -        /**  +        /**          * get node attribute          * @param name: attribute name          * throws exception if attribute not found @@ -398,17 +398,17 @@ namespace NXml {          void DelAttr(TZtStringBuf name);          /** -        * set node application data  -        * @param priv: new application data pointer  -        */  -        void SetPrivate(void* priv);  -  -        /**  -        * @return application data pointer, passed by SetPrivate  -        */  -        void* GetPrivate() const;  -  -        /**  +        * set node application data +        * @param priv: new application data pointer +        */ +        void SetPrivate(void* priv); + +        /** +        * @return application data pointer, passed by SetPrivate +        */ +        void* GetPrivate() const; + +        /**          * get node name          */          TString Name() const; @@ -418,7 +418,7 @@ namespace NXml {          */          TString Path() const; -        /**  +        /**          * get node xml representation          */          TString ToString(TZtStringBuf enc = "") const { @@ -430,16 +430,16 @@ namespace NXml {          void SaveAsHtml(IOutputStream& stream, TZtStringBuf enc = "", bool shouldFormat = false) const;          /** -        * get pointer to internal node  -        */  -        xmlNode* GetPtr();  -        const xmlNode* GetPtr() const;  -  -        /**  -        * check if node is text-only node  -        */  -        bool IsText() const;  -  +        * get pointer to internal node +        */ +        xmlNode* GetPtr(); +        const xmlNode* GetPtr() const; + +        /** +        * check if node is text-only node +        */ +        bool IsText() const; +          /**          * unlink node from parent and free          */ @@ -667,27 +667,27 @@ namespace NXml {          }          /** -        * @return application data pointer, passed by SetPrivate  -        */  +        * @return application data pointer, passed by SetPrivate +        */          void* GetPrivate() const { -            return ActualNode.GetPrivate();  -        }  -  -        /**  -        * get pointer to internal node  -        */  +            return ActualNode.GetPrivate(); +        } + +        /** +        * get pointer to internal node +        */          const xmlNode* GetPtr() const { -            return ActualNode.GetPtr();  -        }  -  -        /**  -        * check if node is text-only node  -        */  +            return ActualNode.GetPtr(); +        } + +        /** +        * check if node is text-only node +        */          bool IsText() const { -            return ActualNode.IsText();  -        }  -  -        /**  +            return ActualNode.IsText(); +        } + +        /**          * get node xpath          */          TString Path() const { diff --git a/library/cpp/xml/document/xml-document.cpp b/library/cpp/xml/document/xml-document.cpp index 93beed31997..18a554d7321 100644 --- a/library/cpp/xml/document/xml-document.cpp +++ b/library/cpp/xml/document/xml-document.cpp @@ -209,15 +209,15 @@ namespace NXml {      TNode TNode::Parent() {          if (nullptr == NodePointer->parent) -            THROW(XmlException, "Parent node not exists");  +            THROW(XmlException, "Parent node not exists"); + +        return TNode(DocPointer, NodePointer->parent); +    } -        return TNode(DocPointer, NodePointer->parent);  -    }  -       TConstNode TNode::Parent() const { -        return const_cast<TNode*>(this)->Parent();  -    }  -  +        return const_cast<TNode*>(this)->Parent(); +    } +      TNode TNode::NextSibling(TZtStringBuf name) {          if (IsNull())              THROW(XmlException, "Node is null"); @@ -255,13 +255,13 @@ namespace NXml {      }      void TNode::SetPrivate(void* priv) { -        NodePointer->_private = priv;  -    }  +        NodePointer->_private = priv; +    }      void* TNode::GetPrivate() const { -        return NodePointer->_private;  -    }  -  +        return NodePointer->_private; +    } +      TNode TNode::Find(xmlNode* start, TZtStringBuf name) {          for (; start; start = start->next)              if (start->type == XML_ELEMENT_NODE && (name.empty() || !xmlStrcmp(start->name, XMLCHAR(name.c_str())))) @@ -286,20 +286,20 @@ namespace NXml {      }      xmlNode* TNode::GetPtr() { -        return NodePointer;  -    }  -  +        return NodePointer; +    } +      const xmlNode* TNode::GetPtr() const { -        return NodePointer;  -    }  -  +        return NodePointer; +    } +      bool TNode::IsText() const {          if (IsNull())              THROW(XmlException, "Node is null"); -        return NodePointer->type == XML_TEXT_NODE;  -    }  -  +        return NodePointer->type == XML_TEXT_NODE; +    } +      void TNode::Remove() {          xmlNode* nodePtr = GetPtr();          xmlUnlinkNode(nodePtr); diff --git a/library/cpp/xml/document/xml-document_ut.cpp b/library/cpp/xml/document/xml-document_ut.cpp index 11f548b8143..9f537b75c4c 100644 --- a/library/cpp/xml/document/xml-document_ut.cpp +++ b/library/cpp/xml/document/xml-document_ut.cpp @@ -92,28 +92,28 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) {          UNIT_ASSERT_EQUAL(root.Node("h:text", false, *ctxt).Value<TString>(), "Некоторый текст");      }      Y_UNIT_TEST(XmlNodes) { -        using namespace NXml;  -        TDocument xml("<?xml version=\"1.0\"?>\n"  -                      "<root>qq<a><b>asdfg</b></a>ww<c></c></root>",  -                      NXml::TDocument::String);  -        TNode root = xml.Root();  +        using namespace NXml; +        TDocument xml("<?xml version=\"1.0\"?>\n" +                      "<root>qq<a><b>asdfg</b></a>ww<c></c></root>", +                      NXml::TDocument::String); +        TNode root = xml.Root();          UNIT_ASSERT_EQUAL(root.Value<TString>(), "qqasdfgww"); -        TConstNode node = root.FirstChild();  -        UNIT_ASSERT_EQUAL(node.IsText(), true);  +        TConstNode node = root.FirstChild(); +        UNIT_ASSERT_EQUAL(node.IsText(), true);          UNIT_ASSERT_EQUAL(node.Value<TString>(), "qq"); -        node = node.NextSibling();  -        UNIT_ASSERT_EQUAL(node.IsText(), false);  -        UNIT_ASSERT_EQUAL(node.Name(), "a");  +        node = node.NextSibling(); +        UNIT_ASSERT_EQUAL(node.IsText(), false); +        UNIT_ASSERT_EQUAL(node.Name(), "a");          UNIT_ASSERT_EQUAL(node.Value<TString>(), "asdfg"); -        node = node.NextSibling();  -        UNIT_ASSERT_EQUAL(node.IsText(), true);  +        node = node.NextSibling(); +        UNIT_ASSERT_EQUAL(node.IsText(), true);          UNIT_ASSERT_EQUAL(node.Value<TString>(), "ww"); -        node = node.NextSibling();  -        UNIT_ASSERT_EQUAL(node.IsText(), false);  -        UNIT_ASSERT_EQUAL(node.Name(), "c");  +        node = node.NextSibling(); +        UNIT_ASSERT_EQUAL(node.IsText(), false); +        UNIT_ASSERT_EQUAL(node.Name(), "c");          UNIT_ASSERT_EQUAL(node.Value<TString>(), ""); -        node = node.NextSibling();  -        UNIT_ASSERT_EQUAL(node.IsNull(), true);  +        node = node.NextSibling(); +        UNIT_ASSERT_EQUAL(node.IsNull(), true);          TStringStream iterLog;          for (const auto& node2 : root.Nodes("/root/*")) {              iterLog << node2.Name() << ';'; @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) {          UNIT_ASSERT_EXCEPTION(node.Name(), yexception);          UNIT_ASSERT_EXCEPTION(node.Value<TString>(), yexception);          UNIT_ASSERT_EXCEPTION(node.IsText(), yexception); -    }  +    }      Y_UNIT_TEST(DefVal) {          using namespace NXml;          TDocument xml("<?xml version=\"1.0\"?>\n"  | 
