Spinning Topp Logo BlackTopp Studios
inc
xpathnode.h
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 /*
41  *
42  * Software, Files, Libraries and all other items referenced in this clause refers only
43  * to the contents of this file and associated documentation.
44  *
45  * Pugixml parser - version 1.0
46  * --------------------------------------------------------
47  * Copyright © 2006-2012, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
48  * Report bugs and download new versions at http://pugixml.org/
49  *
50  * This library is distributed under the MIT License. See notice at the end
51  * of this file.
52  *
53  * This work is based on the pugxml parser, which is:
54  * Copyright © 2003, by Kristen Wegner (kristen@tima.net)
55  */
56 #ifndef _xmlxpathnode_h
57 #define _xmlxpathnode_h
58 
59 /// @file
60 /// @brief The definition of the @ref Mezzanine::XML::XPathNode
61 #include "datatypes.h"
62 #include "XML/node.h"
63 
64 
65 
66 namespace Mezzanine
67 {
68  namespace XML
69  {
70  /// @brief An XPath node which can store handles to a XML::Node or an XML::Attribute.
71  /// @details Because an XPath node can be either a XML::Node or an XML::Attribute, there is a special type, XPathNode,
72  /// which is a discriminated union of these types. A value of this type contains two node handles, one of XML::Node type,
73  /// and another one of XML::Attribute type; at most one of them can be non-null. The accessors to get these handles are
74  /// available: XPathNode::GetNode() an XPathNode::GetAttribute() . \n \n
75  /// XPath nodes can be null, in which case both accessors return null handles.
77  {
78  private:
79  /// @internal
80  /// @brief The node this refers to.
81  Node TargetNode;
82 
83  /// @internal
84  /// @brief The node if any that this targets.
85  Attribute _attribute;
86 
87  #ifndef SWIG
88  /// @brief Used to convert this to a boolean value in a safe way
89  /// @return Returns true if the internal data is set and false otherwise.
90  /// @note Not available in scripting languages.
91  typedef void (*unspecified_bool_type)(XPathNode***);
92  #endif
93 
94  public:
95  /// @brief Default constructor; constructs empty XPath node
96  XPathNode();
97 
98  /// @brief Construct From a XML::Node.
99  /// @param node The XML::Node this handle should reference.
100  XPathNode(const Node& node);
101 
102  /// @brief Construct From a XML::Attribute.
103  /// @param GetAttribute The XML::Attribute this handle should reference.
104  /// @param GetParent The XML::Node the XML::Attribute is on.
105  XPathNode(const Attribute& GetAttribute, const Node& GetParent);
106 
107  /// @brief Get the XML::Node this is referencing
108  /// @return A valid XML::Node, or a null node if this doesn't reference a an XML::Node.
109  Node GetNode() const;
110 
111  /// @brief Get the XML::Attribute this is referencing
112  /// @return A valid XML::Attribute, or a null node if this doesn't reference a an XML::Attribute.
113  Attribute GetAttribute() const;
114 
115  /// @brief Get the parent of the XML::Node or XML::Attribute this refers to.
116  /// @return A valid XML::Node, or a null node if this doesn't reference a an XML::Node.
117  Node GetParent() const;
118 
119  #ifndef SWIG
120  /// @brief Used to convert this to a boolean value in a safe way
121  /// @return Returns true if the internal data is set and false otherwise.
122  /// @note Not available in scripting languages.
123  operator unspecified_bool_type() const;
124  #endif
125 
126  /// @brief Logical not operator, used a workaround for borland compiler.
127  /// @return A bool that is the opposite of evaluatig this as a bool normally.
128  bool operator!() const;
129 
130  // Comparison operators
131  /// @brief Called when comparing two XPathNode instances for equality.
132  /// @param n The other XML::XPathNode to compare this Node against for equality.
133  /// @return True if this and the other XML::XPathNode are referencing the same item, false otherwise;
134  bool operator==(const XPathNode& n) const;
135 
136  /// @brief Called when comparing two XPathNode instances for inequality.
137  /// @param n The other XML::XPathNode to compare this Node against for inequality.
138  /// @return True if this and the other XML::XPathNode are referencing the same item, false otherwise;
139  bool operator!=(const XPathNode& n) const;
140  };
141  }
142 } // /namespace Mezzanine
143 
144 
145 
146 #endif // Include guard
147 
148 
149 /*
150  *
151  * Software, Files, Libraries and all other items referenced in this clause refers only
152  * to the contents of this file and associated documentation.
153  *
154  * Copyright © 2006-2012 Arseny Kapoulkine
155  *
156  * Permission is hereby granted, free of charge, to any person
157  * obtaining a copy of this software and associated documentation
158  * files (the "Software"), to deal in the Software without
159  * restriction, including without limitation the rights to use,
160  * copy, modify, merge, publish, distribute, sublicense, and/or sell
161  * copies of the Software, and to permit persons to whom the
162  * Software is furnished to do so, subject to the following
163  * conditions:
164  *
165  * The above copyright notice and this permission notice shall be
166  * included in all copies or substantial portions of the Software.
167  *
168  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
169  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
170  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
171  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
172  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
173  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
174  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
175  * OTHER DEALINGS IN THE SOFTWARE.
176  */
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
This defines the Mezzanine::XML::Node one of the central XML classes.
An XPath node which can store handles to a XML::Node or an XML::Attribute.
Definition: xpathnode.h:76
All the definitions for datatypes as well as some basic conversion functions are defined here...
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56