KEYXMLReader.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libetonyek project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef KEYXMLREADER_H_INCLUDED
11 #define KEYXMLREADER_H_INCLUDED
12 
13 #include <boost/function.hpp>
14 
15 class WPXInputStream;
16 
17 namespace libetonyek
18 {
19 
21 {
22  // -Weffc++
23  KEYXMLReader(const KEYXMLReader &other);
24  KEYXMLReader &operator=(const KEYXMLReader &other);
25 
26  struct Impl;
27 
28  enum Type
29  {
30  TYPE_ELEMENT = 0x1,
31  TYPE_TEXT = 0x2
32  };
33 
35  {
36  friend class KEYXMLReader;
37 
38  public:
39  NodeIterator(const KEYXMLReader &reader, int types);
40 
41  bool next();
42 
43  Impl *getImpl() const;
44 
45  private:
46  bool test() const;
47 
48  private:
49  Impl *const m_impl;
50  const int m_types;
51  int m_level;
52  bool m_last;
53  };
54 
55 public:
56 
58  {
59  friend class KEYXMLReader;
60 
61  public:
62  explicit AttributeIterator(const KEYXMLReader &reader);
63 
64  bool next();
65 
66  const char *getName() const;
67  const char *getNamespace() const;
68  const char *getValue() const;
69 
70  int getToken(const char *token) const;
71 
72  private:
73  bool move();
74  void read();
75  bool test();
76 
77  private:
78  Impl *const m_impl;
79  bool m_first;
80  bool m_last;
81  };
82 
84  {
85  public:
86  explicit ElementIterator(const KEYXMLReader &reader);
87 
88  bool next();
89 
90  const char *getName() const;
91  const char *getNamespace() const;
92  const char *getText() const;
93  bool isEmpty() const;
94 
95  int getToken(const char *token) const;
96 
97  const NodeIterator &getNodeIterator() const;
98 
99  private:
101  };
102 
104  {
105  public:
106  explicit MixedIterator(const KEYXMLReader &reader);
107 
108  bool next();
109 
110  bool isElement() const;
111  bool isText() const;
112 
113  const char *getName() const;
114  const char *getNamespace() const;
115  const char *getText() const;
116  bool isEmpty() const;
117 
118  int getToken(const char *token) const;
119 
120  const NodeIterator &getNodeIterator() const;
121 
122  private:
124  };
125 
126  typedef boost::function<int(const char *)> TokenizerFunction_t;
127 
128 public:
129  explicit KEYXMLReader(WPXInputStream *input);
130  KEYXMLReader(WPXInputStream *input, TokenizerFunction_t tokenizer);
131  KEYXMLReader(const ElementIterator &iterator);
132  KEYXMLReader(const MixedIterator &iterator);
133  ~KEYXMLReader();
134 
139  const char *getName() const;
140 
145  const char *getNamespace() const;
146 
147  int getToken(const char *token) const;
148 
149 private:
150  void initialize(WPXInputStream *input);
151 
152 private:
153  Impl *const m_impl;
154  bool m_owner;
155 };
156 
157 int getNameId(const KEYXMLReader::AttributeIterator &attribute);
158 int getNamespaceId(const KEYXMLReader::AttributeIterator &attribute);
159 int getId(const KEYXMLReader::AttributeIterator &attribute);
160 int getValueId(const KEYXMLReader::AttributeIterator &attribute);
161 
166 
167 int getNameId(const KEYXMLReader &reader);
168 int getNamespaceId(const KEYXMLReader &reader);
169 int getId(const KEYXMLReader &reader);
170 
171 }
172 
173 #endif // KEYXMLREADER_H_INCLUDED
174 
175 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
NodeIterator(const KEYXMLReader &reader, int types)
Definition: KEYXMLReader.cpp:100
Definition: KEYXMLReader.h:30
int getToken(const char *token) const
Definition: KEYXMLReader.cpp:268
int getToken(const char *token) const
Definition: KEYXMLReader.cpp:317
ElementIterator(const KEYXMLReader &reader)
Definition: KEYXMLReader.cpp:233
bool isEmpty() const
Definition: KEYXMLReader.cpp:258
NodeIterator m_iterator
Definition: KEYXMLReader.h:100
Definition: KEYXMLReader.h:31
int getToken(const char *token) const
Definition: KEYXMLReader.cpp:227
int getTextId(const KEYXMLReader::ElementIterator &element)
Definition: KEYXMLReader.cpp:445
void initialize(WPXInputStream *input)
Definition: KEYXMLReader.cpp:392
bool isText() const
Definition: KEYXMLReader.cpp:288
int getNamespaceId(const KEYXMLReader::AttributeIterator &attribute)
Definition: KEYXMLReader.cpp:415
Definition: KEY2Token.h:186
int getToken(const char *token) const
Definition: KEYXMLReader.cpp:387
int getNameId(const KEYXMLReader::AttributeIterator &attribute)
Definition: KEYXMLReader.cpp:410
const char * getNamespace() const
Definition: KEYXMLReader.cpp:248
const char * getValue() const
Definition: KEYXMLReader.cpp:222
const NodeIterator & getNodeIterator() const
Definition: KEYXMLReader.cpp:263
const NodeIterator & getNodeIterator() const
Definition: KEYXMLReader.cpp:322
bool next()
Definition: KEYXMLReader.cpp:238
bool test()
Definition: KEYXMLReader.cpp:202
Impl *const m_impl
Definition: KEYXMLReader.h:49
bool test() const
Definition: KEYXMLReader.cpp:146
Definition: KEYXMLReader.h:34
bool next()
Definition: KEYXMLReader.cpp:278
bool m_last
Definition: KEYXMLReader.h:52
Type
Definition: KEYXMLReader.h:28
int getValueId(const KEYXMLReader::AttributeIterator &attribute)
Definition: KEYXMLReader.cpp:425
const char * getNamespace() const
Definition: KEYXMLReader.cpp:217
const char * getName() const
Definition: KEYXMLReader.cpp:212
bool isEmpty() const
Definition: KEYXMLReader.cpp:311
bool m_first
Definition: KEYXMLReader.h:79
bool m_owner
Definition: KEYXMLReader.h:154
Impl * getImpl() const
Definition: KEYXMLReader.cpp:141
int getId(const KEYXMLReader::AttributeIterator &attribute)
Definition: KEYXMLReader.cpp:420
Definition: KEYXMLReader.h:103
int m_level
Definition: KEYXMLReader.h:51
bool isElement() const
Definition: KEYXMLReader.cpp:283
const char * getText() const
Definition: KEYXMLReader.cpp:305
const char * getName() const
Get the local name of the current element.
Definition: KEYXMLReader.cpp:377
const char * getNamespace() const
Definition: KEYXMLReader.cpp:299
const char * getNamespace() const
Get the namespace URI of the current element.
Definition: KEYXMLReader.cpp:382
bool m_last
Definition: KEYXMLReader.h:80
Definition: KEYXMLReader.h:20
~KEYXMLReader()
Definition: KEYXMLReader.cpp:371
KEYXMLReader(const KEYXMLReader &other)
Definition: KEYXMLReader.cpp:72
MixedIterator(const KEYXMLReader &reader)
Definition: KEYXMLReader.cpp:273
NodeIterator m_iterator
Definition: KEYXMLReader.h:123
KEYXMLReader & operator=(const KEYXMLReader &other)
Impl *const m_impl
Definition: KEYXMLReader.h:78
Definition: KEYXMLReader.h:57
const char * getName() const
Definition: KEYXMLReader.cpp:293
const char * getName() const
Definition: KEYXMLReader.cpp:243
bool move()
Definition: KEYXMLReader.cpp:183
Impl *const m_impl
Definition: KEYXMLReader.h:153
const char * getText() const
Definition: KEYXMLReader.cpp:253
bool next()
Definition: KEYXMLReader.cpp:172
boost::function< int(const char *)> TokenizerFunction_t
Definition: KEYXMLReader.h:126
const int m_types
Definition: KEYXMLReader.h:50
AttributeIterator(const KEYXMLReader &reader)
Definition: KEYXMLReader.cpp:158
Definition: KEYXMLReader.h:83
bool next()
Definition: KEYXMLReader.cpp:117

Generated for libetonyek by doxygen 1.8.5