Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
DataExchange/StructuredStreamEvents/Name.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_StructuredStreamEvents_Name_h_
5#define _Stroika_Foundation_DataExchange_StructuredStreamEvents_Name_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <compare>
10#include <optional>
11
13
14/**
15 * \file
16 *
17 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
18 *
19 */
20
21namespace Stroika::Foundation::DataExchange::StructuredStreamEvents {
22
23 using Characters::String;
24
25 /**
26 * \note <a href="Design-Overview.md#Comparisons">Comparisons</a>:
27 * o Standard Stroika Comparison support (operator<=>,operator==, etc);
28 *
29 * Treat EITHER side missing namespace as 'wildcard' matching any namespace
30 */
31 struct Name {
32 /**
33 * fNamespaceURI missing treated as 'wildcard' - matching any other URI name, and
34 * empty string ("") means no namespace (to require no namespace as ns="").
35 */
36 optional<String> fNamespaceURI;
37 String fLocalName;
38
39 /**
40 * \note This terminology differences from XML practice. Here ElementType is really like NodeType.
41 * But for now we only have 2 types of nodes (because that so far seems all that will be needed for
42 * what we do).
43 *
44 * \note Value must have an empty string localname and URI, and refers to XML 'mixed' structures, with both
45 * complex fields, and simple data.
46 */
47 enum NameType {
48 eElement,
49 eAttribute,
50 eValue,
51
52 Stroika_Define_Enum_Bounds (eElement, eValue)
53 };
54 NameType fType{eElement};
55
56 /**
57 * The overload with only NameType \pre type == NameType::eValue
58 */
59 Name () = delete;
60 Name (const Name&) = default;
61 Name (NameType type);
62 Name (const String& localName, NameType type = eElement);
63 Name (const String& namespaceURI, const String& localName, NameType type = eElement);
64
65 /**
66 */
67 nonvirtual strong_ordering operator<=> (const Name& rhs) const;
68
69 /**
70 */
71 nonvirtual bool operator== (const Name& rhs) const;
72
73 /**
74 * Purely for debugging / diagnostic purposes. Don't count on this format.
75 */
76 nonvirtual String ToString () const;
77
78 private:
79 static strong_ordering TWC_ (const Name& lhs, const Name& rhs); // utility code share between c++17 and c++20 versions
80 };
81
82}
83
84/*
85 ********************************************************************************
86 ***************************** Implementation Details ***************************
87 ********************************************************************************
88 */
89#include "Name.inl"
90
91#endif /*_Stroika_Foundation_DataExchange_StructuredStreamEvents_Name_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201