Move libxml bits out of abg-sptr-utils.h.

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>
This commit is contained in:
Giuliano Procida 2020-04-24 10:21:13 +01:00 committed by Dodji Seketeli
parent ae30e5fa96
commit 0082ee529f
2 changed files with 20 additions and 18 deletions

View File

@ -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__

View File

@ -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