diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/xml/init | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/xml/init')
-rw-r--r-- | library/cpp/xml/init/init.cpp | 62 | ||||
-rw-r--r-- | library/cpp/xml/init/init.h | 10 | ||||
-rw-r--r-- | library/cpp/xml/init/ptr.cpp | 2 | ||||
-rw-r--r-- | library/cpp/xml/init/ptr.h | 64 | ||||
-rw-r--r-- | library/cpp/xml/init/ya.make | 28 |
5 files changed, 83 insertions, 83 deletions
diff --git a/library/cpp/xml/init/init.cpp b/library/cpp/xml/init/init.cpp index aa96c2dd31..9ecdb974d8 100644 --- a/library/cpp/xml/init/init.cpp +++ b/library/cpp/xml/init/init.cpp @@ -1,39 +1,39 @@ -#include "init.h" - +#include "init.h" + #include <libxml/xmlIO.h> #include <libxml/parser.h> #include <libxml/parserInternals.h> #include <libxml/tree.h> - + #include <library/cpp/charset/recyr.hh> -#include <util/generic/singleton.h> - -namespace { +#include <util/generic/singleton.h> + +namespace { int CharEncodingInput(unsigned char* out, int* outlen, const unsigned char* in, int* inlen) { - size_t read = 0, written = 0; - RECODE_RESULT r = Recode(CODES_WIN, CODES_UTF8, (const char*)in, (char*)out, (size_t)*inlen, (size_t)*outlen, read, written); - if (r == RECODE_EOOUTPUT) - return -1; - if (r != RECODE_OK) - return -2; - *inlen = (int)read; - *outlen = (int)written; - return (int)written; - } - - class TLibXml2 { - public: - inline TLibXml2() { - xmlInitParser(); + size_t read = 0, written = 0; + RECODE_RESULT r = Recode(CODES_WIN, CODES_UTF8, (const char*)in, (char*)out, (size_t)*inlen, (size_t)*outlen, read, written); + if (r == RECODE_EOOUTPUT) + return -1; + if (r != RECODE_OK) + return -2; + *inlen = (int)read; + *outlen = (int)written; + return (int)written; + } + + class TLibXml2 { + public: + inline TLibXml2() { + xmlInitParser(); xmlNewCharEncodingHandler("windows-1251", CharEncodingInput, nullptr); - } - + } + inline ~TLibXml2() { - xmlCleanupParser(); - } - }; -} - -void NXml::InitEngine() { - Singleton<TLibXml2>(); -} + xmlCleanupParser(); + } + }; +} + +void NXml::InitEngine() { + Singleton<TLibXml2>(); +} diff --git a/library/cpp/xml/init/init.h b/library/cpp/xml/init/init.h index 2cdc46c655..cf3c8bd743 100644 --- a/library/cpp/xml/init/init.h +++ b/library/cpp/xml/init/init.h @@ -1,5 +1,5 @@ -#pragma once - -namespace NXml { - void InitEngine(); -} +#pragma once + +namespace NXml { + void InitEngine(); +} diff --git a/library/cpp/xml/init/ptr.cpp b/library/cpp/xml/init/ptr.cpp index e11a6460c3..54447188ef 100644 --- a/library/cpp/xml/init/ptr.cpp +++ b/library/cpp/xml/init/ptr.cpp @@ -1 +1 @@ -#include "ptr.h" +#include "ptr.h" diff --git a/library/cpp/xml/init/ptr.h b/library/cpp/xml/init/ptr.h index 7387c7cc40..33e433a858 100644 --- a/library/cpp/xml/init/ptr.h +++ b/library/cpp/xml/init/ptr.h @@ -9,7 +9,7 @@ #include <libxml/uri.h> #include <libxml/xmlschemas.h> -template <class T, void (*DestroyFun)(T*)> +template <class T, void (*DestroyFun)(T*)> struct TFunctionDestroy { static inline void Destroy(T* t) noexcept { if (t) @@ -18,49 +18,49 @@ struct TFunctionDestroy { }; namespace NXml { -#define DEF_HOLDER(type, free) typedef THolder<type, TFunctionDestroy<type, free>> T##type##Holder -#define DEF_PTR(type, free) typedef TAutoPtr<type, TFunctionDestroy<type, free>> T##type##Ptr +#define DEF_HOLDER(type, free) typedef THolder<type, TFunctionDestroy<type, free>> T##type##Holder +#define DEF_PTR(type, free) typedef TAutoPtr<type, TFunctionDestroy<type, free>> T##type##Ptr - // define xmlDocPtr -> TxmlDocHolder TxmlDocPtr - DEF_HOLDER(xmlDoc, xmlFreeDoc); - DEF_PTR(xmlDoc, xmlFreeDoc); + // define xmlDocPtr -> TxmlDocHolder TxmlDocPtr + DEF_HOLDER(xmlDoc, xmlFreeDoc); + DEF_PTR(xmlDoc, xmlFreeDoc); - // xmlXPathContextPtr xpathCtx; - DEF_HOLDER(xmlXPathContext, xmlXPathFreeContext); - DEF_PTR(xmlXPathContext, xmlXPathFreeContext); + // xmlXPathContextPtr xpathCtx; + DEF_HOLDER(xmlXPathContext, xmlXPathFreeContext); + DEF_PTR(xmlXPathContext, xmlXPathFreeContext); - // xmlXPathObjectPtr xpathObj; - DEF_HOLDER(xmlXPathObject, xmlXPathFreeObject); - DEF_PTR(xmlXPathObject, xmlXPathFreeObject); + // xmlXPathObjectPtr xpathObj; + DEF_HOLDER(xmlXPathObject, xmlXPathFreeObject); + DEF_PTR(xmlXPathObject, xmlXPathFreeObject); - // xmlNodeSetPtr nodes - DEF_HOLDER(xmlNodeSet, xmlXPathFreeNodeSet); - DEF_PTR(xmlNodeSet, xmlXPathFreeNodeSet); + // xmlNodeSetPtr nodes + DEF_HOLDER(xmlNodeSet, xmlXPathFreeNodeSet); + DEF_PTR(xmlNodeSet, xmlXPathFreeNodeSet); - // xmlSchemaParserCtxtPtr ctxt; + // xmlSchemaParserCtxtPtr ctxt; DEF_HOLDER(xmlSchemaParserCtxt, xmlSchemaFreeParserCtxt); - DEF_PTR(xmlSchemaParserCtxt, xmlSchemaFreeParserCtxt); + DEF_PTR(xmlSchemaParserCtxt, xmlSchemaFreeParserCtxt); - // xmlSchemaPtr schema; + // xmlSchemaPtr schema; DEF_HOLDER(xmlSchema, xmlSchemaFree); - DEF_PTR(xmlSchema, xmlSchemaFree); + DEF_PTR(xmlSchema, xmlSchemaFree); - // xmlSchemaValidCtxt ctxt; + // xmlSchemaValidCtxt ctxt; DEF_HOLDER(xmlSchemaValidCtxt, xmlSchemaFreeValidCtxt); - DEF_PTR(xmlSchemaValidCtxt, xmlSchemaFreeValidCtxt); + DEF_PTR(xmlSchemaValidCtxt, xmlSchemaFreeValidCtxt); - // xmlSaveCtxtPtr - inline void xmlFreeSave(xmlSaveCtxt* c) { - // returns int - xmlSaveClose(c); - } - DEF_HOLDER(xmlSaveCtxt, xmlFreeSave); - DEF_PTR(xmlSaveCtxt, xmlFreeSave); + // xmlSaveCtxtPtr + inline void xmlFreeSave(xmlSaveCtxt* c) { + // returns int + xmlSaveClose(c); + } + DEF_HOLDER(xmlSaveCtxt, xmlFreeSave); + DEF_PTR(xmlSaveCtxt, xmlFreeSave); - DEF_PTR(xmlURI, xmlFreeURI); - DEF_PTR(xmlNode, xmlFreeNode); - DEF_PTR(xmlParserCtxt, xmlFreeParserCtxt); - DEF_PTR(xmlParserInputBuffer, xmlFreeParserInputBuffer); + DEF_PTR(xmlURI, xmlFreeURI); + DEF_PTR(xmlNode, xmlFreeNode); + DEF_PTR(xmlParserCtxt, xmlFreeParserCtxt); + DEF_PTR(xmlParserInputBuffer, xmlFreeParserInputBuffer); DEF_PTR(xmlDtd, xmlFreeDtd); DEF_PTR(xmlValidCtxt, xmlFreeValidCtxt); diff --git a/library/cpp/xml/init/ya.make b/library/cpp/xml/init/ya.make index 5f3883c2c9..64a39af9d5 100644 --- a/library/cpp/xml/init/ya.make +++ b/library/cpp/xml/init/ya.make @@ -1,15 +1,15 @@ -LIBRARY() - -OWNER(pg) - -PEERDIR( - contrib/libs/libxml +LIBRARY() + +OWNER(pg) + +PEERDIR( + contrib/libs/libxml library/cpp/charset -) - -SRCS( - ptr.cpp - init.cpp -) - -END() +) + +SRCS( + ptr.cpp + init.cpp +) + +END() |