Nemiver  0.3
nmv-libxml-utils.h
Go to the documentation of this file.
1 /* -*- Mode: C++; indent-tabs-mode:nil; c-basic-offset:4; -*- */
2 
3 /*Copyright (c) 2005-2006 Dodji Seketeli
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6  * software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute,
9  * sublicense, and/or sell copies of the Software, and to permit
10  * persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies
14  * or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS",
17  * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE
19  * WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE
21  * AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23  * HOLDERS BE LIABLE FOR ANY CLAIM,
24  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25  * CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
27  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28  *
29  */
30 #ifndef __NMV_LIBXML_UTILS_H__
31 #define __NMV_LIBXML_UTILS_H__
32 
33 #include "nmv-api-macros.h"
34 #include <libxml/xmlreader.h>
35 #include <libxml/xpath.h>
36 #include <libxml/xmlmemory.h>
37 #include "nmv-safe-ptr-utils.h"
38 #include "nmv-i-input-stream.h"
39 
40 namespace nemiver {
41 namespace common {
42 namespace libxmlutils {
43 
45 
46  void
47  operator () (xmlTextReader* a_ptr) {if (a_ptr){}}
48 
49 };//end XMLReaderRef
50 
52 
53  bool
54  operator () (xmlTextReader* a_ptr)
55  {
56  if (a_ptr) {
57  xmlFreeTextReader (a_ptr);
58  }
59  return true;
60  }
61 
62 };//end XMLReaderRef
63 
65  void
66  operator () (xmlXPathContext *a_ptr) {if (a_ptr){}}
67 };//end XPathContextRef
68 
70  bool
71  operator () (xmlXPathContext *a_ptr)
72  {
73  if (a_ptr) {
74  xmlXPathFreeContext (a_ptr);
75  }
76  return true;
77  }
78 };//end XPathContextRef
79 
81  void
82  operator () (xmlXPathObject *a_ptr) {if (a_ptr) {}}
83 };//end XMLXPathObjectRef
84 
86  bool
87  operator () (xmlXPathObject *a_ptr)
88  {
89  if (a_ptr) {
90  xmlXPathFreeObject (a_ptr);
91  }
92  return true;
93  }
94 };//end XMLXPathObjectRef
95 
96 struct XMLCharRef {
97  void
98  operator () (xmlChar *a_ptr) {if (a_ptr) {}}
99 };//end XMLCharRef
100 
101 struct XMLCharUnref {
102  bool
103  operator () (xmlChar *a_ptr)
104  {
105  if (a_ptr) {
106  xmlFree (a_ptr);
107  }
108  return true;
109  }
110 };//end XMLCharRef
111 
114 
115 typedef SafePtr<xmlXPathContext, XMLXPathContextRef,
117 
120 
122 
123 //****************************************************
124 //helpers to use xmlTextReader with our own IO system
125 //*****************************************************
126 
129 
131  m_istream (a_istream)
132  {}
133 };
134 
135 int NEMIVER_API reader_io_read_callback (ReaderIOContext *a_read_context,
136  char * a_buf,
137  int a_len);
138 
139 int NEMIVER_API reader_io_close_callback (ReaderIOContext *a_read_context);
140 
142 
144  const char* a_element_name);
145 
147  const char *a_element_name);
148 
150 
152  xmlReaderTypes a_node_type_to_be);
153 
155 
156 }//end namespace libxmlutils
157 }//end namespace common
158 }//end namespace nemiver
159 
160 #endif //__NMV_LIBXML_SAFE_PTR_H__
161 
nemiver::common::libxmlutils::XMLXPathContextRef::operator()
void operator()(xmlXPathContext *a_ptr)
Definition: nmv-libxml-utils.h:66
nmv-safe-ptr-utils.h
nemiver::common::libxmlutils::ReaderIOContext::m_istream
IInputStream & m_istream
Definition: nmv-libxml-utils.h:128
nemiver::common::libxmlutils::XMLCharUnref
Definition: nmv-libxml-utils.h:101
nemiver::common::libxmlutils::XMLTextReaderSafePtr
SafePtr< xmlTextReader, XMLTextReaderRef, XMLTextReaderUnref > XMLTextReaderSafePtr
Definition: nmv-libxml-utils.h:113
nemiver::common::libxmlutils::XMLCharRef
Definition: nmv-libxml-utils.h:96
nemiver::common::libxmlutils::XMLXPathContextSafePtr
SafePtr< xmlXPathContext, XMLXPathContextRef, XMLXPathContextUnref > XMLXPathContextSafePtr
Definition: nmv-libxml-utils.h:116
nemiver
Definition: nmv-address.h:31
NEMIVER_API
#define NEMIVER_API
Definition: nmv-api-macros.h:53
nemiver::common::libxmlutils::read_next_and_check_node
bool read_next_and_check_node(XMLTextReaderSafePtr &a_reader, xmlReaderTypes a_node_type_to_be)
nemiver::common::libxmlutils::XMLXPathObjectUnref
Definition: nmv-libxml-utils.h:85
nemiver::common::libxmlutils::XMLXPathObjectUnref::operator()
bool operator()(xmlXPathObject *a_ptr)
Definition: nmv-libxml-utils.h:87
nmv-api-macros.h
nemiver::common::libxmlutils::XMLCharSafePtr
SafePtr< xmlChar, XMLCharRef, XMLCharUnref > XMLCharSafePtr
Definition: nmv-libxml-utils.h:121
nemiver::common::libxmlutils::XMLXPathContextUnref::operator()
bool operator()(xmlXPathContext *a_ptr)
Definition: nmv-libxml-utils.h:71
nemiver::common::libxmlutils::XMLXPathObjectSafePtr
SafePtr< xmlXPathObject, XMLXPathObjectRef, XMLXPathObjectUnref > XMLXPathObjectSafePtr
Definition: nmv-libxml-utils.h:119
nemiver::common::libxmlutils::XMLTextReaderRef::operator()
void operator()(xmlTextReader *a_ptr)
Definition: nmv-libxml-utils.h:47
nmv-i-input-stream.h
nemiver::common::libxmlutils::ReaderIOContext::ReaderIOContext
ReaderIOContext(IInputStream &a_istream)
Definition: nmv-libxml-utils.h:130
nemiver::common::libxmlutils::goto_next_element_node
bool goto_next_element_node(XMLTextReaderSafePtr &a_reader)
nemiver::common::libxmlutils::reader_io_close_callback
int reader_io_close_callback(ReaderIOContext *a_read_context)
nemiver::common::libxmlutils::goto_next_element_node_and_check
bool goto_next_element_node_and_check(XMLTextReaderSafePtr &a_reader, const char *a_element_name)
nemiver::common::libxmlutils::XMLTextReaderUnref
Definition: nmv-libxml-utils.h:51
nemiver::common::libxmlutils::goto_next_text_node
bool goto_next_text_node(XMLTextReaderSafePtr &a_reader)
nemiver::common::libxmlutils::search_next_element_node
bool search_next_element_node(XMLTextReaderSafePtr &a_reader, const char *a_element_name)
nemiver::common::libxmlutils::reader_io_read_callback
int reader_io_read_callback(ReaderIOContext *a_read_context, char *a_buf, int a_len)
nemiver::common::IInputStream
Definition: nmv-i-input-stream.h:38
nemiver::common::libxmlutils::XMLCharUnref::operator()
bool operator()(xmlChar *a_ptr)
Definition: nmv-libxml-utils.h:103
nemiver::common::libxmlutils::is_empty_element
bool is_empty_element(XMLTextReaderSafePtr &a_reader)
nemiver::common::libxmlutils::XMLTextReaderRef
Definition: nmv-libxml-utils.h:44
nemiver::common::libxmlutils::XMLXPathContextRef
Definition: nmv-libxml-utils.h:64
nemiver::common::libxmlutils::XMLCharRef::operator()
void operator()(xmlChar *a_ptr)
Definition: nmv-libxml-utils.h:98
nemiver::common::libxmlutils::XMLXPathContextUnref
Definition: nmv-libxml-utils.h:69
nemiver::common::SafePtr
Definition: nmv-safe-ptr.h:71
nemiver::common::libxmlutils::ReaderIOContext
Definition: nmv-libxml-utils.h:127
nemiver::common::libxmlutils::XMLXPathObjectRef
Definition: nmv-libxml-utils.h:80
nemiver::common::libxmlutils::XMLXPathObjectRef::operator()
void operator()(xmlXPathObject *a_ptr)
Definition: nmv-libxml-utils.h:82
nemiver::common::libxmlutils::XMLTextReaderUnref::operator()
bool operator()(xmlTextReader *a_ptr)
Definition: nmv-libxml-utils.h:54
common
Definition: nmv-proc-list-dialog.h:32