2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
//
|
2013-11-18 18:40:47 +00:00
|
|
|
// scoped_ptr alias for libxml2 objects. Deleters for the objects are also
|
|
|
|
// defined in this file.
|
2014-02-14 23:21:05 +00:00
|
|
|
|
2013-11-18 18:40:47 +00:00
|
|
|
#ifndef MPD_BASE_XML_SCOPED_XML_PTR_H_
|
|
|
|
#define MPD_BASE_XML_SCOPED_XML_PTR_H_
|
|
|
|
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "third_party/libxml/src/include/libxml/tree.h"
|
2013-12-30 23:05:27 +00:00
|
|
|
#include "third_party/libxml/src/include/libxml/xmlschemas.h"
|
2013-11-18 18:40:47 +00:00
|
|
|
|
|
|
|
namespace dash_packager {
|
|
|
|
namespace xml {
|
|
|
|
|
|
|
|
struct XmlDeleter {
|
|
|
|
// Called by scoped_ptr. http://goo.gl/YaLbcS
|
2013-12-30 23:05:27 +00:00
|
|
|
inline void operator()(xmlSchemaParserCtxtPtr ptr) const {
|
|
|
|
xmlSchemaFreeParserCtxt(ptr);
|
|
|
|
}
|
|
|
|
inline void operator()(xmlSchemaValidCtxtPtr ptr) const {
|
|
|
|
xmlSchemaFreeValidCtxt(ptr);
|
|
|
|
}
|
|
|
|
inline void operator()(xmlSchemaPtr ptr) const { xmlSchemaFree(ptr); }
|
2013-11-18 18:40:47 +00:00
|
|
|
inline void operator()(xmlNodePtr ptr) const { xmlFreeNode(ptr); }
|
|
|
|
inline void operator()(xmlDocPtr ptr) const { xmlFreeDoc(ptr); }
|
|
|
|
inline void operator()(xmlChar* ptr) const { xmlFree(ptr); }
|
|
|
|
};
|
|
|
|
|
|
|
|
// C++11 allows template alias but standards before it do not. This struct is
|
|
|
|
// for aliasing scoped_ptr with libxml2 object deleter.
|
|
|
|
template <typename XmlType>
|
|
|
|
struct ScopedXmlPtr {
|
|
|
|
typedef scoped_ptr<XmlType, XmlDeleter> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace xml
|
|
|
|
} // namespace dash_packager
|
|
|
|
#endif // MPD_BASE_XML_SCOPED_XML_PTR_H_
|