VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
metaFlightXmlReader.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: mtFltXmlReader.h,v $ $Revision: 1.8 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef metaFlightXmlReader_H_
10 #define metaFlightXmlReader_H_
11 
12 //
13 // \file mtFltXmlReader.h
14 // \brief Represents a reader class that interacts with libXml to read a Metaflight file
15 //
16 
17 #include "mtflt/mtfltDefines.h"
18 #include <vlutil/vlString.h>
19 #include <libxml/xmlreader.h>
20 
21 // \brief Represents a reader class that interacts with libXml to read a Metaflight file
22 // A Metaflight file is represented as a n-ary tree document in which the tags contained
23 // inside other tags are represented as parent-child relationships. For example,
24 // \code
25 // <Ellipsoid name="WGS84">
26 // <SemiMajorRadius>6378137</SemiMajorRadius>
27 // <SemiMinorRadius>6356752.31424518</SemiMinorRadius>
28 // </Ellipsoid>
29 // \endcode
30 // is represented as a tree with the Ellipsoid node as the father and SemiMajorRadius and
31 // SemiMinorRadius as children. Both SemiMajorRadius and SemiMinorRadius are considered
32 // atomic nodes since they have no child tags.
33 
35 {
36 public:
37 
38  // Default constructor.
40 
42 
43  // Destructor
44  virtual ~DtMetaFlightXmlReader();
45 
46  // Copy constructor
48 
49  // Assignment operator
50  DtMetaFlightXmlReader& operator=(const DtMetaFlightXmlReader& orig);
51 
52  // Finds the first node whose tag matches the one given by \p nodeName.
53  // \param node Starting node for the search inside the xml document
54  // \param nodeName Name of the node to be searched (e.g. "GridStructure")
55  // \return 0 if no matches are found.
56  virtual xmlNodePtr findNode(xmlNodePtr node, const char* nodeName);
57 
58  // Finds the node named as nodeName and that also has an attribute named
59  // attrName with a value of attrValue. For example,
60  // <tt>findNode(nodeptr, "GridStructure", "name", "abc")</tt> searches for a
61  // node that looks like <br> <br> <tt>
62  // <GridStructure name="abc"> <br>
63  // ... <br>
64  // </GridStructure>
65  // </tt>
66  // \return 0 if no matches are found.
67  virtual xmlNodePtr findNode(xmlNodePtr node, const char* nodeName,
68  const char* attrName, const char *attrValue);
69 
70  // Returns the value of the attribute attrname inside the node. Attributes
71  // are specified inside the node like this <br><br> <tt>
72  // <node \e attrname=\e value ...> <br>
73  // ... <br>
74  // </node>
75  // </tt>
76  // \param node Node to access
77  // \param attrname Name of the attribute to be searched (e.g. "name")
78  // \return The attribute's value if present or an empty DtSring otherwise.
79  virtual DtString getAttrValue(xmlNodePtr node, const char* attrname) const;
80 
81  // Returns the value of an "atomic" node. Atomic nodes are the ones that
82  // have the following structure <tt><tag>value</tag></tt>.
83  // \param node Node to start the search of the atomic node
84  // \param nodeName Name of the atomic node to be searched
85  // \return It returns an empty DtString if the node has the form or <tag></tag>
86  virtual DtString getAtomicNodeValue(xmlNodePtr node, const char* nodeName);
87 
88  // \return the next node which is not a blank text node
89  virtual void nextNode(xmlNodePtr& node);
90 
91  // \return the top root node of this reader
92  virtual xmlNodePtr getRootNode() { return myRootNode; };
93 
94 protected:
95 
96  xmlNodePtr myRootNode;
98 
99  // Returns the value of an "atomic" node. Atomic nodes are the ones that
100  // have the following structure <tag>value</tag>. It returns the empty
101  // string if the node has the form or <tag></tag>
102  virtual DtString getAtomicNodeValue(xmlNodePtr node) const;
103 
104  // Returns a pointer to the first child of the node or NULL if not defined
105  // The reason for this method is because libXml also includes blank text
106  // nodes sometimes, so they need to be filtered out. This function
107  // guarantees you get an actual child node as the first node
108  virtual xmlNodePtr getChildren(xmlNodePtr node) const;
109 
110 };
111 
112 #endif
Definition: metaFlightXmlReader.h:34
DT_DLL_shape DtNetworkNode * findNode(DtVectorNetwork *vecNwk, unsigned int firstNode, DtPoint &p, DtSpecificationID ID)
xmlNode * xmlNodePtr
Definition: DtLightPointTable.h:20
#define DT_DLL_mtflt
Definition: mtfltDefines.h:23
xmlNodePtr myCurNode
Definition: metaFlightXmlReader.h:97

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)