]> git.donarmstrong.com Git - flightcrew.git/blob - src/XercesExtensions/QName.h
debian/patches/*: fix quilt-patch-missing-description lintian tag
[flightcrew.git] / src / XercesExtensions / QName.h
1 /************************************************************************\r
2 **\r
3 **  Copyright (C) 2010  Strahinja Markovic\r
4 **\r
5 **  This file is part of FlightCrew.\r
6 **\r
7 **  FlightCrew is free software: you can redistribute it and/or modify\r
8 **  it under the terms of the GNU Lesser General Public License as published\r
9 **  by the Free Software Foundation, either version 3 of the License, or\r
10 **  (at your option) any later version.\r
11 **\r
12 **  FlightCrew is distributed in the hope that it will be useful,\r
13 **  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 **  GNU Lesser General Public License for more details.\r
16 **\r
17 **  You should have received a copy of the GNU Lesser General Public License\r
18 **  along with FlightCrew.  If not, see <http://www.gnu.org/licenses/>.\r
19 **\r
20 *************************************************************************/\r
21 \r
22 #pragma once\r
23 #ifndef QNAME_H\r
24 #define QNAME_H\r
25 \r
26 #include <string>\r
27 \r
28 namespace XercesExt\r
29 {\r
30 \r
31 /**\r
32  * A qualified name of a node/element/attribute in XML.\r
33  */\r
34 struct QName\r
35 {\r
36     /**\r
37      * Constructor.\r
38      *\r
39      * @param new_local_name The local name.\r
40      * @param new_namespace_name The namespace of the local name.\r
41      */\r
42     QName( const std::string &new_local_name, const std::string &new_namespace_name )\r
43         : local_name( new_local_name ), namespace_name ( new_namespace_name ) {};\r
44     \r
45     /**\r
46      * Implements the equality operator.\r
47      * Two QNames are equal if they have the same local and namespace names.\r
48      * The exceptions are names that equal "*", which match any name.\r
49      */\r
50     inline bool operator== ( const QName& other ) const \r
51     { \r
52         return ( local_name == other.local_name || local_name == "*" || other.local_name == "*" ) && \r
53                ( namespace_name == other.namespace_name || namespace_name == "*" || other.namespace_name == "*" );\r
54     };\r
55 \r
56     /**\r
57      * Implements the inequality operator.\r
58      * Merely calls the equality operator and returns its inverted result. \r
59      */\r
60     inline bool operator!= ( const QName& other ) const \r
61     { \r
62         return !operator==( other );\r
63     };\r
64 \r
65     /**\r
66      * The local name of the node.\r
67      */\r
68     std::string local_name;\r
69 \r
70     /**\r
71      * The namespace name the local name is located in.\r
72      */\r
73     std::string namespace_name;\r
74 };\r
75 \r
76 }\r
77 \r
78 #endif // QNAME_H