From patchwork Thu Apr 23 15:44:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39129 From: gprocida@google.com (Giuliano Procida) Date: Thu, 23 Apr 2020 16:44:22 +0100 Subject: [PATCH 02/21] Move libxml bits out of abg-sptr-utils.h. In-Reply-To: <20200423154441.170531-1-gprocida@google.com> References: <20200423154441.170531-1-gprocida@google.com> Message-ID: <20200423154441.170531-3-gprocida@google.com> The header file abg-sptr-utils.h contains generic things relating to shared pointers. It also contains shared pointer typedefs (in the sptr_utils namespace) and template specialisations for XML types. The last of these more naturally belong in abg-libxml-utils.h (and in the xml namespace). This patch moves them. There are no behavioural changes. * include/abg-sptr-utils.h: Remove reader_sptr and xml_char_sptr typedefs, from namespace sptr_utils. (build_sptr): Remove corresponding template function specialisations for these types. * include/abg-libxml-utils.h: Add reader_sptr and xml_char_sptr typedefs, to namespace xml. (build_sptr): Add corresponding template function specialisations for these types. Signed-off-by: Giuliano Procida --- include/abg-libxml-utils.h | 21 +++++++++++++++++++-- include/abg-sptr-utils.h | 17 +---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/abg-libxml-utils.h b/include/abg-libxml-utils.h index 6331bde5..1e46d950 100644 --- a/include/abg-libxml-utils.h +++ b/include/abg-libxml-utils.h @@ -23,7 +23,10 @@ #ifndef __ABG_LIBXML_UTILS_H__ #define __ABG_LIBXML_UTILS_H__ +#include + #include + #include "abg-sptr-utils.h" #include "abg-cxx-compat.h" @@ -36,8 +39,12 @@ namespace xml using sptr_utils::build_sptr; using abg_compat::shared_ptr; -using sptr_utils::reader_sptr; -using sptr_utils::xml_char_sptr; + +/// A convenience typedef for a shared pointer of xmlTextReader. +typedef shared_ptr reader_sptr; + +/// A convenience typedef for a shared pointer of xmlChar. +typedef shared_ptr xml_char_sptr; /// This functor is used to instantiate a shared_ptr for the /// xmlTextReader. @@ -121,5 +128,15 @@ std::string unescape_xml_comment(const std::string& str); }//end namespace xml + +/// Specialization of sptr_utils::build_sptr for xmlTextReader +template<> +xml::reader_sptr +sptr_utils::build_sptr(xmlTextReader *p); + +/// Specialization of build_str for xmlChar. +template<> +xml::xml_char_sptr sptr_utils::build_sptr(xmlChar *p); + }//end namespace abigail #endif //__ABG_LIBXML_UTILS_H__ diff --git a/include/abg-sptr-utils.h b/include/abg-sptr-utils.h index 9737fe5f..2a12707b 100644 --- a/include/abg-sptr-utils.h +++ b/include/abg-sptr-utils.h @@ -26,7 +26,7 @@ #define __ABG_SPTR_UTILS_H__ #include -#include + #include "abg-cxx-compat.h" namespace abigail @@ -63,21 +63,6 @@ template shared_ptr build_sptr(); -/// A convenience typedef for a shared pointer of xmlTextReader. -typedef shared_ptr reader_sptr; - -/// Specialization of sptr_utils::build_sptr for xmlTextReader -template<> -reader_sptr -build_sptr(xmlTextReader *p); - -/// A convenience typedef for a shared pointer of xmlChar. -typedef shared_ptr xml_char_sptr; - -/// Specialization of build_str for xmlChar. -template<> -xml_char_sptr build_sptr(xmlChar *p); - /// A deleter for shared pointers that ... doesn't delete the object /// managed by the shared pointer. struct noop_deleter