[02/21] Move libxml bits out of abg-sptr-utils.h.

Message ID 20200423154441.170531-3-gprocida@google.com
State Superseded
Headers
Series Simplify regex and suppression parsing. |

Commit Message

Giuliano Procida April 23, 2020, 3:44 p.m. UTC
  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 <gprocida@google.com>
---
 include/abg-libxml-utils.h | 21 +++++++++++++++++++--
 include/abg-sptr-utils.h   | 17 +----------------
 2 files changed, 20 insertions(+), 18 deletions(-)
  

Patch

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 <libxml/xmlreader.h>
+
 #include <istream>
+
 #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<xmlTextReader> reader_sptr;
+
+/// A convenience typedef for a shared pointer of xmlChar.
+typedef shared_ptr<xmlChar> 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>(xmlTextReader *p);
+
+/// Specialization of build_str for xmlChar.
+template<>
+xml::xml_char_sptr sptr_utils::build_sptr<xmlChar>(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 <regex.h>
-#include <libxml/xmlreader.h>
+
 #include "abg-cxx-compat.h"
 
 namespace abigail
@@ -63,21 +63,6 @@  template<class T>
 shared_ptr<T>
 build_sptr();
 
-/// A convenience typedef for a shared pointer of xmlTextReader.
-typedef shared_ptr<xmlTextReader> reader_sptr;
-
-/// Specialization of sptr_utils::build_sptr for xmlTextReader
-template<>
-reader_sptr
-build_sptr<xmlTextReader>(xmlTextReader *p);
-
-/// A convenience typedef for a shared pointer of xmlChar.
-typedef shared_ptr<xmlChar> xml_char_sptr;
-
-/// Specialization of build_str for xmlChar.
-template<>
-xml_char_sptr build_sptr<xmlChar>(xmlChar *p);
-
 /// A deleter for shared pointers that ... doesn't delete the object
 /// managed by the shared pointer.
 struct noop_deleter