Coverage Report

Created: 2025-11-06 06:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poco/XML/include/Poco/XML/Name.h
Line
Count
Source
1
//
2
// Name.h
3
//
4
// Library: XML
5
// Package: XML
6
// Module:  Name
7
//
8
// Definition of the Name class.
9
//
10
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11
// and Contributors.
12
//
13
// SPDX-License-Identifier: BSL-1.0
14
//
15
16
17
#ifndef XML_Name_INCLUDED
18
#define XML_Name_INCLUDED
19
20
21
#include "Poco/XML/XML.h"
22
#include "Poco/XML/XMLString.h"
23
24
25
namespace Poco {
26
namespace XML {
27
28
29
class XML_API Name
30
  /// An XML element or attribute name, consisting of a
31
  /// qualified name, a namespace URI and a local name.
32
{
33
public:
34
  Name();
35
    /// Creates an empty Name.
36
37
  Name(const XMLString& qname);
38
    /// Creates a Name from a qualified name only.
39
40
  Name(const XMLString& qname, const XMLString& namespaceURI);
41
    /// Creates a Name from a qualified name and a namespace URI.
42
    /// The local name is extracted from the qualified name.
43
44
  Name(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
45
    /// Creates a Name from a qualified name, a namespace URI and a local name.
46
47
  Name(const Name& name);
48
    /// Copy constructor.
49
50
  Name(Name&& name) noexcept;
51
    /// Move constructor.
52
53
  ~Name();
54
    /// Destroys the name.
55
56
  Name& operator = (const Name& name);
57
    /// Assignment operator.
58
59
  Name& operator = (Name&& name) noexcept;
60
    /// Move assignment.
61
62
  void swap(Name& name) noexcept;
63
    /// Swaps the name with another one.  
64
    
65
  void assign(const XMLString& qname);
66
    /// Assigns a new value to the name.
67
68
  void assign(const XMLString& qname, const XMLString& namespaceURI);
69
    /// Assigns new values to the name.
70
    /// The local name is extracted from the qualified name.
71
72
  void assign(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
73
    /// Assigns new values to the name.
74
75
  bool equals(const Name& name) const;
76
    /// Returns true if both names are equal.
77
78
  bool equals(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const;
79
    /// Returns true if all the name's components are equal to the given ones.
80
81
  bool equalsWeakly(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const;
82
    /// Returns true if either the qnames are identical or the namespaceURIs and the localNames are identical.
83
84
  const XMLString& qname() const;
85
    /// Returns the qualified name.
86
87
  const XMLString& namespaceURI() const;
88
    /// Returns the namespace URI.
89
90
  const XMLString& localName() const;
91
    /// Returns the local name.
92
93
  XMLString prefix() const;
94
    /// Returns the namespace prefix.
95
96
  static void split(const XMLString& qname, XMLString& prefix, XMLString& localName);
97
    /// Splits the given qualified name into its prefix and localName parts.
98
99
  static XMLString localName(const XMLString& qname);
100
    /// Returns the local name part of the given qualified name.
101
102
  static XMLString prefix(const XMLString& qname);
103
    /// Returns the prefix part of the given qualified name.
104
105
  static const XMLString EMPTY_NAME;
106
107
private:
108
  XMLString _qname;
109
  XMLString _namespaceURI;
110
  XMLString _localName;
111
};
112
113
114
//
115
// inlines
116
//
117
inline const XMLString& Name::qname() const
118
0
{
119
0
  return _qname;
120
0
}
121
122
123
inline const XMLString& Name::namespaceURI() const
124
0
{
125
0
  return _namespaceURI;
126
0
}
127
128
129
inline const XMLString& Name::localName() const
130
0
{
131
0
  return _localName;
132
0
}
133
134
135
inline void swap(Name& n1, Name& n2) noexcept
136
0
{
137
0
  n1.swap(n2);
138
0
}
139
140
141
} } // namespace Poco::XML
142
143
144
#endif // XML_Name_INCLUDED