Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
DataExchange/StructuredStreamEvents/Name.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7namespace Stroika::Foundation::DataExchange::StructuredStreamEvents {
8
9 /*
10 ********************************************************************************
11 *********************** StructuredStreamEvents::Name ***************************
12 ********************************************************************************
13 */
14 inline Name::Name ([[maybe_unused]] NameType type)
15 : fType{eValue}
16 {
17 Require (type == eValue);
18 }
19 inline Name::Name (const String& localName, NameType type)
20 : fLocalName{localName}
21 , fType{type}
22 {
23 }
24 inline Name::Name (const String& namespaceURI, const String& localName, NameType type)
25 : fNamespaceURI{namespaceURI}
26 , fLocalName{localName}
27 , fType{type}
28 {
29 }
30 inline String Name::ToString () const
31 {
33 if (fType == NameType::eAttribute) {
34 result += "@"sv;
35 }
36 else if (fType == NameType::eValue) {
37 return "{value}"sv;
38 }
39 if (fNamespaceURI) {
40 result += *fNamespaceURI + ":"sv;
41 }
42 result += fLocalName;
43 return result;
44 }
45 inline strong_ordering Name::operator<=> (const Name& rhs) const
46 {
47 return TWC_ (*this, rhs);
48 }
49 inline bool Name::operator== (const Name& rhs) const
50 {
51 return TWC_ (*this, rhs) == 0;
52 }
53 inline strong_ordering Name::TWC_ (const Name& lhs, const Name& rhs)
54 {
55 // Treat EITHER side missing namespace as 'wildcard' matching any namespace
56 if (lhs.fNamespaceURI.has_value () and rhs.fNamespaceURI.has_value ()) {
57 if (auto cmp = *lhs.fNamespaceURI <=> *rhs.fNamespaceURI; cmp != strong_ordering::equal) {
58 return cmp;
59 }
60 }
61 if (auto cmp = lhs.fLocalName <=> rhs.fLocalName; cmp != strong_ordering::equal) {
62 return cmp;
63 }
64 return lhs.fType <=> rhs.fType;
65 }
66
67}
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201