ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
chararraytraits.inl
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_strings of the \aliblong.
4 *
5 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6 * Published under \ref mainpage_license "Boost Software License".
7 **************************************************************************************************/
8#ifndef HPP_ALIB_STRINGS_CHARARRAYTRAITS
9#define HPP_ALIB_STRINGS_CHARARRAYTRAITS 1
10
11#if !defined(HPP_ALIB_STRINGS_STRING)
12# error "ALib sources with ending '.inl' must not be included from outside."
13#endif
14#if !defined(ALIB_DOX)
15
16namespace alib { namespace strings {
17
18
19template<typename TChar> struct T_SuppressAutoCast<TAString<TChar>, characters::ConstructionType::Implicit, TCString<TChar> > : public std::true_type {};
20template<typename TChar> struct T_SuppressAutoCast<TAString<TChar>, characters::ConstructionType::Implicit, TSubstring<TChar> > : public std::true_type {};
21template<typename TChar> struct T_SuppressAutoCast<TCString<TChar>, characters::ConstructionType::Implicit, TSubstring<TChar> > : public std::true_type {};
22
23// #################################################################################################
24// Specializations of T_CharArray for ALib string types
25// #################################################################################################
26} namespace characters {
27
28template<typename TChar> struct T_CharArray<strings::TString<TChar>, TChar>
29{
30 static constexpr AccessType Access = AccessType::Implicit;
31 static constexpr const TChar* Buffer (const strings::TString<TChar>& src) { return src.Buffer(); }
32 static constexpr integer Length (const strings::TString<TChar>& src) { return src.Length(); }
33
35 static constexpr strings::TString<TChar> Construct(const TChar* array, integer length) { return strings::TString<TChar>(array, length); }
36};
37
38template<typename TChar> struct T_CharArray<strings::TSubstring<TChar>, TChar>
39{
40 static constexpr AccessType Access = AccessType::Implicit;
41 static constexpr const TChar* Buffer(const strings::TSubstring<TChar>& src) { return src.Buffer(); }
42 static constexpr integer Length(const strings::TSubstring<TChar>& src) { return src.Length(); }
43
45 static constexpr strings::TSubstring<TChar> Construct(const TChar* array, integer length) { return strings::TSubstring<TChar>(array, length); }
46};
47
48template<typename TChar> struct T_CharArray<strings::TCString<TChar>, TChar>
49{
50 static constexpr AccessType Access = AccessType::Implicit;
51 static constexpr const TChar* Buffer(const strings::TCString<TChar>& src) { return src.Buffer(); }
52 static constexpr integer Length(const strings::TCString<TChar>& src) { return src.Length(); }
53
55 static constexpr strings::TCString<TChar> Construct(const TChar* array, integer length){ return strings::TCString<TChar>(array, length); }
56};
57
58
59template<typename TChar> struct T_CharArray<strings::TAString<TChar>, TChar>
60{
61 static constexpr AccessType Access = AccessType::Implicit;
62 static constexpr const TChar* Buffer(const strings::TAString<TChar>& src) { return src.Buffer(); }
63 static constexpr integer Length(const strings::TAString<TChar>& src) { return src.Length(); }
64
66 static constexpr strings::TAString<TChar> Construct(const TChar* array, integer length){ return strings::TAString<TChar>().Append(array, length); }
67};
68
69template<typename TChar, integer TCapacity>
70struct T_CharArray<strings::TLocalString<TChar,TCapacity>, TChar>
71{
72 static constexpr AccessType Access = AccessType::Implicit;
73 static constexpr const TChar* Buffer(const strings::TLocalString<TChar, TCapacity>& src) { return src.Buffer(); }
74 static constexpr integer Length(const strings::TLocalString<TChar, TCapacity>& src) { return src.Length(); }
75
77};
78
79template<typename TChar> struct T_CharArray<strings::TStringNZT<TChar>, TChar>
80{
81 static constexpr AccessType Access = AccessType::Implicit;
82 static constexpr const TChar* Buffer (const strings::TString<TChar>& src) { return src.Buffer(); }
83 static constexpr integer Length (const strings::TString<TChar>& src) { return src.Length(); }
84
86};
87
88
89// #################################################################################################
90// Specializations of T_ZTCharArray for ALib string types
91// #################################################################################################
92
93template<typename TChar> struct T_ZTCharArray<strings::TString<TChar>, TChar>
94{
95 static constexpr AccessType Access = AccessType::ExplicitOnly;
96 static constexpr const TChar* Buffer(const strings::TString<TChar>& src) { return src.Buffer(); }
97 static constexpr integer Length(const strings::TString<TChar>& src) { return src.Length(); }
98
99 static constexpr ConstructionType Construction = ConstructionType::ExplicitOnly;
100 static constexpr strings::TString<TChar> Construct(const TChar* array, integer length ) { return strings::TString<TChar>(array, length); }
101};
102
103template<typename TChar> struct T_ZTCharArray<strings::TSubstring<TChar>, TChar>
104{
105 static constexpr AccessType Access = AccessType::ExplicitOnly;
106 static constexpr const TChar* Buffer(const strings::TSubstring<TChar>& src) { return src.Buffer(); }
107 static constexpr integer Length(const strings::TSubstring<TChar>& src) { return src.Length(); }
108
109 static constexpr ConstructionType Construction = ConstructionType::ExplicitOnly;
110 static constexpr strings::TSubstring<TChar> Construct(const TChar* array, integer length ) { return strings::TSubstring<TChar>(array, length); }
111};
112
113
114template<typename TChar> struct T_ZTCharArray<strings::TCString<TChar>, TChar>
115{
116 static constexpr AccessType Access = AccessType::Implicit;
117 static constexpr const TChar* Buffer(const strings::TCString<TChar>& src) { return src.Buffer(); }
118 static constexpr integer Length(const strings::TCString<TChar>& src) { return src.Length(); }
119
120 static constexpr ConstructionType Construction = ConstructionType::ExplicitOnly;
121 static constexpr strings::TCString<TChar> Construct(const TChar* array, integer length ) { return strings::TCString<TChar>(array, length); }
122};
123
124
125template<typename TChar> struct T_ZTCharArray<strings::TAString<TChar>, TChar>
126{
127 static constexpr AccessType Access = AccessType::Implicit;
128 static constexpr const TChar* Buffer(const strings::TAString<TChar>& src) { return src.Terminate(); }
129 static constexpr integer Length(const strings::TAString<TChar>& src) { return src.Length(); }
130
131 static constexpr ConstructionType Construction = ConstructionType::ExplicitOnly;
132 static constexpr strings::TAString<TChar> Construct(const TChar* array, integer length ) { return strings::TAString<TChar>().Append(array, length); }
133};
134
135template<typename TChar, integer TCapacity>
136struct T_ZTCharArray<strings::TLocalString<TChar,TCapacity>, TChar>
137{
138 static constexpr AccessType Access = AccessType::Implicit;
139 static constexpr const TChar* Buffer(const strings::TLocalString<TChar, TCapacity>& src) { return src.Terminate(); }
140 static constexpr integer Length(const strings::TLocalString<TChar, TCapacity>& src) { return src.Length(); }
141
142 static constexpr ConstructionType Construction = ConstructionType::NONE;
143};
144
145
146} namespace strings {
147
148
149}} // namespace [alib::strings]
150
151#endif // !defined(ALIB_DOX)
152#endif // HPP_ALIB_STRINGS_CHARARRAYTRAITS
Definition alib.cpp:57
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:286
static const TChar * Buffer(const TString &src)
static constexpr ConstructionType Construction
static TString Construct(const TChar *array, integer length)
static constexpr AccessType Access
static integer Length(const TString &src)
static const TChar * Buffer(const TString &src)
static TString Construct(const TChar *array, integer length)
static integer Length(const TString &src)