Actin®  Version 5.2.0
Software for Robotics Simulation and Control
ecXmlReader.h
Go to the documentation of this file.
1 #ifndef ecXmlReader_H_
2 #define ecXmlReader_H_
3 //------------------------------------------------------------------------------
4 // Copyright (c) 2003-2013 Energid Technologies. All rights reserved.
5 //
9 //
10 //------------------------------------------------------------------------------
11 #include <foundCore/ecConfig.h> // Required to be first header.
12 
13 #include "ecBaseXmlFactory.h"
14 #include "ecXmlFileReader.h"
16 
18 {
19 public:
20 
25  {
26  XMLREADER_NO_MODIFIERS = 0x0000,
27  XMLREADER_READ_SIMPLIFIED_SHAPES = 0x0001
28  };
29 
32  {
33  HREF_UNKNOWN,
34  HREF_LOCAL_TEXT_FILE,
35  HREF_LOCAL_GZ_FILE,
36  HREF_URL
37  };
38 
41  (
42  );
43 
46  (
47  const EcString& filename,
48  std::istream& stream,
49  EcInt64 fileSize = -1,
50  EcInt32* pProgress = EcNULL
51  );
52 
54  virtual ~EcXmlReader
55  (
56  );
57 
60  (
61  const EcXmlReader& orig
62  );
63 
65  EcXmlReader& operator=
66  (
67  const EcXmlReader& orig
68  );
69 
71  virtual void open
72  (
73  const EcString& filename,
74  std::istream& stream
75  );
76 
78  virtual EcXmlFileReader::XML_READER_MODE readXml
79  (
80  );
81 
83  virtual EcBoolean versionFlag
84  (
85  ) const;
86 
89  (
90  ) const;
91 
93  virtual const EcToken& element
94  (
95  ) const;
96 
98  virtual const EcToken& attributeName
99  (
100  );
101 
103  virtual const EcToken& attributeName
104  (
105  const EcToken& key
106  );
107 
109  virtual const EcString& attributeValue
110  (
111  );
112 
114  virtual const EcString& attributeValue
115  (
116  const EcToken& key
117  );
118 
120  virtual EcSizeT numOfAttributes
121  (
122  ) const;
123 
125  virtual EcSizeT remainingNumOfAttributes
126  (
127  ) const;
128 
130  virtual const EcString& content
131  (
132  ) const;
133 
135  virtual const EcString& contentByWord
136  (
137  ) const;
138 
140  virtual const EcSizeT contentCount
141  (
142  ) const;
143 
145  virtual EcBoolean isContentAvailable
146  (
147  ) const;
148 
150  virtual void setContentVectorFlag
151  (
152  EcBoolean contentVectorFlag = EcTrue
153  );
154 
157  virtual const char* filename
158  (
159  );
160 
162  virtual EcInt32 lineCountOfFile
163  (
164  ) const;
165 
167  virtual EcBoolean nextMatchingEndTag
168  (
169  );
170 
172 
175  virtual const EcString& getChildrenAsString
176  (
177  );
178 
180  virtual std::istream& stream
181  (
182  ) const;
183 
186  virtual const EcString& getComplexStartTagFast
187  (
188  );
189 
192  virtual const EcString& getSimpleStartTagFast
193  (
194  );
195 
197  virtual const EcString& getAttributeValueFast
198  (
199  );
200 
202  virtual const EcString& getLastAttributeValueFast
203  (
204  );
205 
207  virtual const EcString& getContentByWordFast
208  (
209  );
210 
212  virtual void getEndTagFast
213  (
214  );
215 
217  virtual void setFactoryPointer
218  (
219  EcBaseXmlFactory* pFactory
220  );
221 
223  virtual const EcBaseXmlFactory* factoryPointer
224  (
225  ) const;
226 
229  virtual EcBoolean registerComponentCreator
230  (
231  const EcToken& token,
232  EcXmlObjectCreator creator
233  );
234 
236  virtual EcU32 errorCode
237  (
238  ) const;
239 
241  virtual void setLinkTotal
242  (
243  EcSizeT linkTotal
244  );
245 
247  virtual void resetLinkCount
248  (
249  );
250 
252  virtual void incrementLinkCount
253  (
254  );
255 
257  EcU32 modifierFlags
258  (
259  ) const;
260 
262  void setModifierFlags
263  (
264  const EcU32 flags
265  );
266 
268  template<class InputStreamType>
270  {
271  std::pair< HrefSourceStreamCreatorMap::iterator, bool> result =
272  m_InputStreamMap.insert(
273  std::make_pair(type, InputStreamType::create)
274  );
275 
276  return result.second;
277  }
278 
279 protected:
280 
282  virtual EcBoolean openFileTest
283  (
284  );
285 
287  virtual EcBoolean closeFileTest
288  (
289  );
290 
292  virtual EcU32 parseHref
293  (
294  const EcString& href,
295  const EcString& parse,
296  EcString& sourceAddress
297  );
298 
300  virtual EcBoolean checkVersion
301  (
302  );
303 
305  virtual EcBaseXmlFactory* newFactory
306  (
307  ) const;
308 
312  {
314  (
315  const EcXmlFileReader& reader,
316  boost::shared_ptr<std::istream> streamPtr = boost::shared_ptr<std::istream>()
317  ):
318  xmlReader(reader),
319  istreamPtr(streamPtr)
320  {
321  }
322 
323  EcXmlFileReader xmlReader;
324  boost::shared_ptr<std::istream> istreamPtr;
325  };
326 
328  std::stack<FileReaderElement> m_XmlFileReader;
329 
332 
335 
338 
341 
343 
346 
348  typedef EcInputStreamPtr (*EcInputStreamCreator)();
349  typedef std::map<EcU32, EcInputStreamCreator> HrefSourceStreamCreatorMap;
350 
351  HrefSourceStreamCreatorMap m_InputStreamMap;
352 };
353 
354 #endif // ecXmlReader_H_
EcBaseXmlFactory * m_pFactory
A factory pointer.
Definition: ecXmlReader.h:337
#define EcNULL
a null pointer variable
Definition: ecConstants.h:120
EcU32 m_ReaderModifierFlags
Bit flags that can be used to configure the read operation at runtime.
Definition: ecXmlReader.h:342
boost::uint32_t EcU32
32-bit unsigned integer
Definition: ecTypes.h:53
EcXmlReaderModifierFlags
Definition: ecXmlReader.h:24
Specify some global configuration parameters and values.
EcBoolean m_VersionFlag
Is version valid?
Definition: ecXmlReader.h:334
EcHrefSourceTypes
Supported href source types for including XML content.
Definition: ecXmlReader.h:31
const EcBoolean EcTrue
gives a representation of true
Definition: ecConstants.h:23
EcBoolean m_VersionPerformCheckFlag
Perform version check.
Definition: ecXmlReader.h:331
EcXmlObject *(* EcXmlObjectCreator)()
type definition of an expression element creator function
Definition: ecXmlObject.h:132
std::size_t EcSizeT
unsigned integer type used to represent indices and the sizes of containers
Definition: ecTypes.h:129
An EcString-like class that holds a tag and a namespace.
Definition: ecToken.h:41
boost::int64_t EcInt64
64-bit signed integer
Definition: ecTypes.h:62
std::stack< FileReaderElement > m_XmlFileReader
Pointer to top (i.e., of stack) file reader.
Definition: ecXmlReader.h:328
#define EC_STABLE_XML_DECL
xml directory
Definition: ecConfig.h:207
EcSizeT m_LinkTotal
total number of links
Definition: ecXmlReader.h:339
bool EcBoolean
Boolean (0 or 1)
Definition: ecTypes.h:21
EcInt32 * m_pProgress
file loading progress
Definition: ecXmlReader.h:345
HrefSourceStreamCreatorMap m_InputStreamMap
The input stream map for href sources.
Definition: ecXmlReader.h:351
XML_READER_MODE
XML Reader Mode.
boost::int32_t EcInt32
32-bit signed integer
Definition: ecTypes.h:56
EcBoolean registerInputStream(EcHrefSourceTypes type)
register a supported input stream for reading href sources
Definition: ecXmlReader.h:269
std::basic_string< char > EcString
a character string
Definition: ecTypes.h:116
EcInt64 m_FileSize
file size
Definition: ecXmlReader.h:344
An XML file reader.
Definition: ecXmlReader.h:17
EcSizeT m_LinkCount
Link count.
Definition: ecXmlReader.h:340
An XML parser object that can read a single file.
An abstract base class for XML object factories.
Created by Energid Technologies www.energid.com
Copyright © 2016 Energid. All trademarks mentioned in this document are property of their respective owners.