From 7ffdcf97d448bb4ff4d1d4c2a2afbcbe22eb8e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Tue, 6 Feb 2024 09:59:38 +0100 Subject: [PATCH] fix: make headers parseable by CppParser/PocoDoc --- Foundation/include/Poco/Any.h | 2 + Foundation/include/Poco/Dynamic/VarVisitor.h | 47 +++++++++++++------ Foundation/include/Poco/MemoryPool.h | 2 + PocoDoc/cfg/mkdoc-poco.xml | 1 + .../include/Poco/Prometheus/AtomicFloat.h | 2 +- XML/include/Poco/XML/XMLStreamParser.h | 10 +++- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/Foundation/include/Poco/Any.h b/Foundation/include/Poco/Any.h index 9927776a1..42b8da0a9 100644 --- a/Foundation/include/Poco/Any.h +++ b/Foundation/include/Poco/Any.h @@ -40,6 +40,7 @@ template class VarHolderImpl; } +#ifndef POCO_DOC template struct TypeSizeLE: std::integral_constant{}; @@ -48,6 +49,7 @@ struct TypeSizeLE: template struct TypeSizeGT: std::integral_constant S)>{}; +#endif template diff --git a/Foundation/include/Poco/Dynamic/VarVisitor.h b/Foundation/include/Poco/Dynamic/VarVisitor.h index e800369a5..b3b3d1ce2 100644 --- a/Foundation/include/Poco/Dynamic/VarVisitor.h +++ b/Foundation/include/Poco/Dynamic/VarVisitor.h @@ -1,6 +1,3 @@ -#ifndef Foundation_VarVisitor_INCLUDED -#define Foundation_VarVisitor_INCLUDED - // // VarVisitor.h // @@ -17,18 +14,28 @@ // +#ifndef Foundation_VarVisitor_INCLUDED +#define Foundation_VarVisitor_INCLUDED + + #include "Poco/Dynamic/Var.h" #include #include + namespace Poco { namespace Details { + +#ifndef POCO_DOC + + struct TypeInfoHash { inline std::size_t operator()(std::type_info const& t) const { return t.hash_code(); } }; + struct EqualRef { template @@ -38,20 +45,28 @@ struct EqualRef } }; -using TypeInfoRef = std::reference_wrapper; +using TypeInfoRef = std::reference_wrapper; using HandlerCaller = std::function; + template -using HandlerPointer = void (*)(const T &); +using HandlerPointer = void (*)(const T&); + template using Handler = std::function; -} // Details + +#endif // POCO_DOC + + +} // Details + namespace Dynamic { + class Foundation_API Visitor /// VarVisitor class. { @@ -62,10 +77,10 @@ class Foundation_API Visitor public: template - bool addHandler(const Details::Handler &f) - /// Add handler for specific type T which holds in Var - /// This method is more safe, because it saves copy of handler : lambda or std::function - /// Returns true if handler was added + bool addHandler(const Details::Handler& f) + /// Add handler for specific type T which holds in Var. + /// This method is more safe, because it saves copy of handler : lambda or std::function. + /// Returns true if handler was added. { auto result = _handlers.emplace(std::ref(typeid(T)), Details::HandlerCaller([handler = f](const Poco::Dynamic::Var& x) @@ -77,9 +92,9 @@ public: template bool addHandler(Details::HandlerPointer f) - /// Add handler for specific type T which holds in Var - /// This method is less safe, because it saves only copy of function pointer - /// Returns true if handler was added + /// Add handler for specific type T which holds in Var. + /// This method is less safe, because it saves only copy of function pointer. + /// Returns true if handler was added. { auto result = _handlers.emplace(std::ref(typeid(T)), Details::HandlerCaller([handlerPointer = f](const Poco::Dynamic::Var& x) @@ -90,10 +105,12 @@ public: } bool visit(const Poco::Dynamic::Var& x) const; - /// Find handler for holded type and if it exists call handler - /// Returns true if hanler was found othrewise returns false + /// Find handler for held type and if it exists call handler. + /// Returns true if hanlder was found othrewise returns false. }; + } } // namespace Poco::Dynamic + #endif // Foundation_VarVisitor_INCLUDED diff --git a/Foundation/include/Poco/MemoryPool.h b/Foundation/include/Poco/MemoryPool.h index b3f424ea4..a68f2dc2f 100644 --- a/Foundation/include/Poco/MemoryPool.h +++ b/Foundation/include/Poco/MemoryPool.h @@ -229,6 +229,7 @@ private: _memory.next = next; } +#ifndef POCO_DOC union /// Memory block storage. /// @@ -242,6 +243,7 @@ private: char buffer[sizeof(T)]; Block* next; } _memory; +#endif private: Block(const Block&); diff --git a/PocoDoc/cfg/mkdoc-poco.xml b/PocoDoc/cfg/mkdoc-poco.xml index e74b2081d..8c729cb55 100644 --- a/PocoDoc/cfg/mkdoc-poco.xml +++ b/PocoDoc/cfg/mkdoc-poco.xml @@ -41,6 +41,7 @@ -C, -DPOCO_NO_WINDOWS_H, -DPOCO_NO_GCC_API_ATTRIBUTE, + -DPOCO_DOC, -xc++ diff --git a/Prometheus/include/Poco/Prometheus/AtomicFloat.h b/Prometheus/include/Poco/Prometheus/AtomicFloat.h index 4e8f9f85f..07c2b19b1 100644 --- a/Prometheus/include/Poco/Prometheus/AtomicFloat.h +++ b/Prometheus/include/Poco/Prometheus/AtomicFloat.h @@ -32,7 +32,7 @@ class AtomicFloat { public: AtomicFloat(): - _value{0} + _value(0.0) { } diff --git a/XML/include/Poco/XML/XMLStreamParser.h b/XML/include/Poco/XML/XMLStreamParser.h index 782f7ffb2..05b8f0469 100644 --- a/XML/include/Poco/XML/XMLStreamParser.h +++ b/XML/include/Poco/XML/XMLStreamParser.h @@ -280,6 +280,7 @@ private: EventType nextBody(); void handleError(); +#ifndef POCO_DOC // If _size is 0, then data is std::istream. Otherwise, it is a buffer. union { @@ -287,6 +288,13 @@ private: const void* buf; } _data; +#endif + + enum ParserState + { + state_next, + state_peek + }; std::size_t _size; const std::string _inputName; @@ -294,7 +302,7 @@ private: XML_Parser _parser; std::size_t _depth; bool _accumulateContent; // Whether we are accumulating character content. - enum { state_next, state_peek } _parserState; + ParserState _parserState; EventType _currentEvent; EventType _queue; QName _qname;