Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Namespace.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_XML_Namespace_h_
5#define _Stroika_Foundation_DataExchange_XML_Namespace_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Containers/Mapping.h"
11#include "Stroika/Foundation/Containers/Sequence.h"
14
15namespace Stroika::Foundation::DataExchange::XML {
16
17 using Characters::String;
18 using Containers::Mapping;
19 using Containers::Sequence;
20 using IO::Network::URI;
21
22 /**
23 * \brief used to specify default namespace, and any n: prefixes applicable to elements.
24 *
25 * \note default namespace does NOT apply to attributes, only element names...
26 */
28 public:
29 NamespaceDefinitions () = default;
30 NamespaceDefinitions (const optional<URI>& defaultNamespace, const Mapping<String, URI>& prefixedNamespaces = {});
31 NamespaceDefinitions (const Mapping<String, URI>& prefixedNamespaces);
32
33 public:
34 nonvirtual bool operator== (const NamespaceDefinitions&) const = default;
35
36 public:
37 nonvirtual optional<URI> GetDefaultNamespace () const;
38
39 public:
40 nonvirtual Mapping<String, URI> GetPrefixedNamespaces () const;
41
42 public:
43 /**
44 */
45 nonvirtual String ToString () const;
46
47 private:
48 optional<URI> fDefaultNamespace_;
49 Mapping<String, URI> fPrefixedNS_;
50 };
51
52 /**
53 * Note name argument slightly more flexible than just String so double conversion works ("" can be assigned to NameWithNamespace)
54 *
55 * \note similar to NamespaceDefinition, but this refers to elements which may or may not have an associated namespace.
56 */
58 String fName;
59 optional<URI> fNamespace;
60
61 template <Characters::IConvertibleToString NAME_TYPE>
62 NameWithNamespace (NAME_TYPE&& name);
63 NameWithNamespace (const optional<URI>& ns, const String& name);
64
65 bool operator== (const NameWithNamespace& rhs) const = default;
66#if qCompilerAndStdLib_explicitly_defaulted_threeway_warning_Buggy
67 DISABLE_COMPILER_CLANG_WARNING_START ("clang diagnostic ignored \"-Wdefaulted-function-deleted\"")
68#endif
69 auto operator<=> (const NameWithNamespace& rhs) const = default;
70#if qCompilerAndStdLib_explicitly_defaulted_threeway_warning_Buggy
71 DISABLE_COMPILER_CLANG_WARNING_END ("clang diagnostic ignored \"-Wdefaulted-function-deleted\"")
72#endif
73 /**
74 */
75 nonvirtual String ToString () const;
76 };
77
78 /**
79 * Common 'name/namespace' combo used internally in XML.
80 */
81 inline const NameWithNamespace kXMLNS{"http://www.w3.org/2000/xmlns/"sv, "xmlns"sv};
82
83}
84
85/*
86 ********************************************************************************
87 ***************************** Implementation Details ***************************
88 ********************************************************************************
89 */
90#include "Namespace.inl"
91
92#endif /*_Stroika_Foundation_DataExchange_XML_Namespace_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
used to specify default namespace, and any n: prefixes applicable to elements.
Definition Namespace.h:27