diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/coroutine/engine/events.h | 8 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.cpp | 8 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.h | 4 | ||||
-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 |
7 files changed, 118 insertions, 118 deletions
diff --git a/library/cpp/coroutine/engine/events.h b/library/cpp/coroutine/engine/events.h index 07cc4d25e8..b6d767c746 100644 --- a/library/cpp/coroutine/engine/events.h +++ b/library/cpp/coroutine/engine/events.h @@ -102,10 +102,10 @@ public: void BroadCast(size_t number) noexcept { for (size_t i = 0; i < number && !Waiters_.Empty(); ++i) { - Waiters_.PopFront()->Wake(); - } - } - + Waiters_.PopFront()->Wake(); + } + } + private: TIntrusiveList<TWaiter> Waiters_; }; diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 24a5b69eef..b1e42295ac 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -222,14 +222,14 @@ TString MD5::Calc(const TArrayRef<const ui8>& data) { TString MD5::CalcRaw(TStringBuf data) { return CalcRaw(MakeUnsignedArrayRef(data)); -} - +} + TString MD5::CalcRaw(const TArrayRef<const ui8>& data) { TString result; result.ReserveAndResize(16); MD5().Update(data).Final(reinterpret_cast<ui8*>(result.begin())); - return result; -} + return result; +} ui64 MD5::CalcHalfMix(const char* data, size_t len) { return CalcHalfMix(MakeUnsignedArrayRef(data, len)); diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 2c17aa0518..216cf49c3f 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/array_ref.h> -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> class IInputStream; @@ -58,7 +58,7 @@ public: static TString Calc(const TArrayRef<const ui8>& data); // 32-byte hex-encoded static TString CalcRaw(TStringBuf data); // 16-byte raw static TString CalcRaw(const TArrayRef<const ui8>& data); // 16-byte raw - + static ui64 CalcHalfMix(TStringBuf data); static ui64 CalcHalfMix(const TArrayRef<const ui8>& data); static ui64 CalcHalfMix(const char* data, size_t len); diff --git a/library/cpp/xml/document/node-attr.h b/library/cpp/xml/document/node-attr.h index 6e74403943..baf2812d95 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 bfda1fb7e6..af8c31a37b 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 18a554d732..93beed3199 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"); - - return TNode(DocPointer, NodePointer->parent); - } + THROW(XmlException, "Parent node not exists"); + 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 9f537b75c4..11f548b814 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" |