ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
functions.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_characters of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace characters {
9//==================================================================================================
10/// Converts a character to upper case.
11///
12/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
13/// @param c The character to convert
14/// @return The upper case version of the given character.
15//==================================================================================================
16template<typename TChar>
17TChar ToUpper( TChar c );
18
19//==================================================================================================
20/// Converts a character sequence to upper case.
21///
22/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
23/// @param src Pointer to the character array.
24/// @param length The length of the array.
25//==================================================================================================
26template<typename TChar>
27void ToUpper( TChar* src, integer length );
28
29//==================================================================================================
30/// Converts a character to lower case.
31///
32/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
33/// @param c The character to convert
34/// @return The lower case version of the given character.
35//==================================================================================================
36template<typename TChar>
37TChar ToLower( TChar c );
38
39//==================================================================================================
40/// Converts a character sequence to lower case.
41///
42/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
43/// @param src Pointer to the character array.
44/// @param length The length of the array.
45//==================================================================================================
46template<typename TChar>
47void ToLower( TChar* src, integer length );
48
49//==================================================================================================
50/// Compares two characters of arbitrary types.
51///
52/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
53/// @tparam sensitivity Letter case sensitivity of the comparison.
54/// @tparam TRhs The type of the right-hand side letter to compare.
55/// @param lhs The left-hand side character to compare of class template
56/// type \p{TChar}.
57/// @param rhs The right-hand side character to compare of method template
58/// type \p{TCharRhs} .
59/// @return \c true if the given characters are equal, \c false otherwise.
60//==================================================================================================
61template<typename TChar, lang::Case sensitivity, typename TRhs >
62bool Equal( TChar lhs, TRhs rhs ) {
63 using TLhs= TChar;
64 bool sensitive= (sensitivity == lang::Case::Sensitive);
65
66 if constexpr ( sizeof(TLhs) == sizeof(TRhs) )
67 return sensitive ? lhs == rhs
68 : ToUpper( lhs) == ToUpper( rhs);
69
70 else if constexpr ( sizeof(TLhs) < sizeof(TRhs) )
71 return sensitive ? static_cast<TRhs>(lhs) == rhs
72 : ToUpper( static_cast<TRhs>(lhs)) == ToUpper( rhs);
73
74 else if constexpr ( sizeof(TLhs) > sizeof(TRhs) )
75 return sensitive ? lhs == static_cast<TLhs>(rhs)
76 : ToUpper( lhs ) == ToUpper(static_cast<TLhs>(rhs));
77}
78
79//==================================================================================================
80/// Returns the length of a zero-terminated "c-style" character array.
81///
82/// Note: This method is implemented as an inlined, direct call to \c std::char_traits::length.
83///
84/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
85/// @param cstring Pointer to a zero-terminated character array.
86/// @return The length of the string.
87//==================================================================================================
88template<typename TChar>
89integer Length( const TChar* cstring )
90{ return integer( std::char_traits<TChar>::length(cstring) ); }
91
92//==================================================================================================
93/// Copies the contents of a character array into another, non-overlapping (!) array.
94///
95/// Note: This method is implemented as an inlined, direct call to \c std::char_traits::copy.
96///
97/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
98/// @param src Pointer to the source array.
99/// @param length The length to copy.
100/// @param dest Pointer to the destination array.
101//==================================================================================================
102template<typename TChar>
103void Copy( const TChar* src, integer length, TChar* dest )
104{ std::char_traits<TChar>::copy( dest, src, size_t(length) ); }
105
106//==================================================================================================
107/// Copies the contents of a character array into another, possibly overlapping array.
108///
109/// Note: This method is implemented as an inlined, direct call to \c std::char_traits::move.
110///
111/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
112/// @param src Pointer to the source array.
113/// @param length The length to copy.
114/// @param dest Pointer to the destination array, optionally within source.
115//==================================================================================================
116template<typename TChar>
117void Move( const TChar* src, integer length, TChar* dest )
118{ std::char_traits<TChar>::move( dest, src, size_t(length) ); }
119
120//==================================================================================================
121/// Sets all elements of the given character array to value \p{value}.
122///
123/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
124/// @param dest Pointer to the destination array.
125/// @param length The length to fill.
126/// @param value The value to fill the array with.
127//==================================================================================================
128template<typename TChar>
129void Fill( TChar* dest, integer length, TChar value );
130
131//==================================================================================================
132/// Reverses the order of the characters.
133///
134/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
135/// @param src Pointer to the character array.
136/// @param length The length of the array.
137//==================================================================================================
138template<typename TChar>
139void Reverse( TChar* src, integer length );
140
141//==================================================================================================
142/// Searches the character. Returns a pointer to the location of \p{needle} in \p{haystack},
143/// respectively \c nullptr if not found.
144///
145/// Note: This method is implemented as a direct call to \c std::memchr, respectively
146/// other character versions of it.
147///
148/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
149/// @param haystack Pointer to the start of the string.
150/// @param haystackLength The length of the string or the maximum position to search.
151/// @param needle Character to search.
152///
153/// @return The pointer to the first occurrence of \p{needle} respectively \c nullptr if
154/// not found.
155//==================================================================================================
156template<typename TChar>
157const TChar* Search( const TChar* haystack, integer haystackLength, TChar needle )
158{ return std::char_traits<TChar>::find( haystack, size_t(haystackLength), needle ); }
159
160//==================================================================================================
161/// Returns the index of the first character in \p{haystack} which is included in a given set
162/// of \p{needles}.
163///
164/// This method searches up to a given maximum index. For a search to the end of the
165/// zero-terminated string, use faster method provided with class
166/// \alib{strings;TCString;CString}.
167///
168/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
169/// @param haystack Pointer to the start of the string.
170/// @param haystackLength The length of the string or the maximum position to search.
171/// If -1 is provided, the length is determined using standard library
172/// function \b strlen (which needs haystack to be zero-terminated).
173/// @param needles Pointer to a set of characters to be searched for.
174/// @param needlesLength The length of the string of needles.
175/// If -1 is provided, the length is determined using standard library
176/// function \b strlen (which needs needles to be zero-terminated).
177///
178/// @return The index of the first character found that is included in \p{needles}.
179/// If no character of haystack is included in \p{needles}, \c -1 is returned.
180//==================================================================================================
181template<typename TChar>
182integer IndexOfAnyIncluded( const TChar* haystack, integer haystackLength,
183 const TChar* needles, integer needlesLength );
184
185//==================================================================================================
186/// Same as #IndexOfAnyIncluded(const TChar*,integer,const TChar*,integer) but works on
187/// zero-terminated strings.
188///
189/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
190/// @param haystack Pointer to a zero-terminated character array to search in.
191/// @param needles Pointer to a zero-terminated set of characters to search for.
192///
193/// @return The index of the first character found that is included in \p{needles}.
194/// If no character of haystack is included in \p{needles}, \c -1 is returned.
195//==================================================================================================
196template<typename TChar>
197integer IndexOfAnyIncludedZT( const TChar* haystack, const TChar* needles );
198
199//==================================================================================================
200/// Returns the index of the first character in \p{haystack} which is not included in a given
201/// set of \p{needles}.
202///
203/// This method searches up to a given maximum index. For a search to the end of the
204/// zero-terminated string, use the faster method provided with class
205/// \alib{strings;TCString;CString}.
206///
207/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
208/// @param haystack Pointer to the start of the string.
209/// @param haystackLength The length of the string or the maximum position to search.
210/// If -1 is provided, the length is determined using standard library
211/// function \b strlen (which needs haystack to be zero-terminated).
212/// @param needles Pointer to a set of characters to be searched for.
213/// @param needlesLength The length of the string of needles.
214/// If -1 is provided, the length is determined using standard library
215/// function \b strlen (which needs needles to be zero-terminated).
216///
217/// @return The index of the first character that is not included in \p{needles}.
218/// If all characters of haystack are included in \p{needles}, \c -1 is returned.
219//==================================================================================================
220template<typename TChar>
221integer IndexOfAnyExcluded( const TChar* haystack, integer haystackLength,
222 const TChar* needles, integer needlesLength );
223
224
225//==================================================================================================
226/// Same as #IndexOfAnyExcluded(const TChar*,integer,const TChar*,integer) but works on
227/// zero-terminated strings.
228///
229/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
230/// @param haystack Pointer to a zero-terminated character array to search in.
231/// @param needles Pointer to a zero-terminated set of characters to search for.
232///
233/// @return The index of the first character that is not included in \p{needles}.
234/// If all characters of haystack are included in \p{needles}, \c -1 is returned.
235//==================================================================================================
236template<typename TChar>
237integer IndexOfAnyExcludedZT( const TChar* haystack, const TChar* needles );
238
239//==================================================================================================
240/// Returns the index of the last character in \p{haystack} which is included in a given set
241/// of \p{needles}.
242///
243/// This method searches backwards from the end of the string.
244///
245/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
246/// @param haystack Pointer to the start of the string.
247/// @param startIdx The position to start the search from. This must be smaller than
248/// the length of the string and greater or equal to zero.
249/// @param needles Pointer to a set of characters to be searched for.
250/// @param needlesLength The length of the string of needles.
251/// If -1 is provided, the length is determined using standard library
252/// function \b strlen (which needs needles to be zero-terminated).
253///
254/// @return The index of the first character found which is included in the given set
255/// of characters. If nothing is found, -1 is returned.
256//==================================================================================================
257template<typename TChar>
258integer LastIndexOfAnyInclude( const TChar* haystack, integer startIdx,
259 const TChar* needles, integer needlesLength );
260
261//==================================================================================================
262/// Returns the index of the last character in \p{haystack} which is not included in a given
263/// set of \p{needles}.
264///
265/// This method searches backwards from the end of the string.
266///
267/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
268/// @param haystack Pointer to the start of the string.
269/// @param startIdx The position to start the search from. This must be smaller than
270/// the length of the string and greater or equal to zero.
271/// @param needles Pointer to a set of characters to be searched for.
272/// @param needlesLength The length of the string of needles.
273/// If -1 is provided, the length is determined using standard library
274/// function \b strlen (which needs needles to be zero-terminated).
275///
276/// @return The index of the first character found which is included in the given set
277/// of characters. If nothing is found, -1 is returned.
278//==================================================================================================
279template<typename TChar>
280integer LastIndexOfAnyExclude( const TChar* haystack, integer startIdx,
281 const TChar* needles, integer needlesLength );
282
283//==================================================================================================
284/// Returns the index of the first character which is not equal within two strings.
285/// If \p{haystack} starts with \p{needle}, then the length of \p{needle} is returned.
286///
287/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
288/// @param haystack Pointer to the start of the string.
289/// @param haystackLength The length of the string or the maximum position to search.
290/// If -1 is provided, the length is determined using standard library
291/// function \b strlen (which needs haystack to be zero-terminated).
292/// @param needle Pointer to the start of the string to compare with.
293/// @param needleLength The length of \p{needle}.
294/// If -1 is provided, the length is determined using standard library
295/// function \b strlen (which needs needles to be zero-terminated).
296/// @param sensitivity Denotes whether the comparison should be made case-sensitive
297/// or not.
298///
299/// @return The index of the first character found which is not equal in given strings.
300//==================================================================================================
301template<typename TChar>
302integer IndexOfFirstDifference( const TChar* haystack, integer haystackLength,
303 const TChar* needle, integer needleLength,
304 lang::Case sensitivity );
305
306//==================================================================================================
307/// Searches for a difference in two character arrays of equal length.
308///
309/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
310/// @param lhs The first array to compare.
311/// @param rhs The second array to compare.
312/// @param cmpLength The number of characters to compare.
313///
314/// @return \c true if the string arrays have identical contents, \c false otherwise.
315//==================================================================================================
316template<typename TChar>
317bool Equal( const TChar* lhs, const TChar* rhs, integer cmpLength )
318{ return ::memcmp( lhs, rhs, size_t(cmpLength) * sizeof(TChar) ) == 0; }
319
320//==================================================================================================
321/// Compares up to \p{cmpLength} characters of two character arrays.
322/// Comparison stops if termination character \c '\0' is found in one of the arrays.
323///
324/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
325/// @param lhs The first array to compare.
326/// @param rhs The second array to compare.
327/// @param cmpLength The number of characters to compare.
328///
329/// @return Negative value if lhs appears before rhs in lexicographical order.
330/// \c 0 if lhs and rhs are equal.
331/// Positive value if lhs appears after rhs in lexicographical order.
332//==================================================================================================
333template<typename TChar>
334int Compare( const TChar* lhs, const TChar* rhs, integer cmpLength )
335{ return std::char_traits<TChar>::compare( lhs, rhs, size_t(cmpLength) ); }
336
337//==================================================================================================
338/// Compares two character arrays of equal length ignoring letter case.
339/// @tparam TChar One of the six (overlapping) \ref alib_characters_chars "character types".
340/// @param lhs The first array to compare.
341/// @param rhs The second array to compare.
342/// @param cmpLength The number of characters to compare.
343///
344/// @return Negative value if lhs appears before rhs in lexicographical order.
345/// \c 0 if lhs and rhs are equal.
346/// Positive value if lhs appears after rhs in lexicographical order.
347//==================================================================================================
348template<typename TChar>
349int CompareIgnoreCase( const TChar* lhs, const TChar* rhs, integer cmpLength );
350
351
352
353//! @cond NO_DOX
354//##################################################################################################
355// Narrow character specifics
356//##################################################################################################
357template<> inline void Fill<nchar>( nchar* dest, integer length, nchar c )
358{ memset( dest, c, size_t(length) ); }
359
360template<> inline nchar ToUpper<nchar>(nchar c) { return static_cast<nchar>( toupper(c) ); }
361
362template<> inline nchar ToLower<nchar>(nchar c) { return static_cast<nchar>( tolower(c) ); }
363
364template<> inline void ToUpper<nchar>(nchar* src, integer length) {
365 nchar* end= src + length;
366 while( src != end ) {
367 *src= ToUpper<nchar>( *src );
368 ++src;
369} }
370
371template<> inline void ToLower<nchar>(nchar* src, integer length) {
372 nchar* end= src + length;
373 while( src != end ) {
374 *src= ToLower<nchar>( *src );
375 ++src;
376} }
377
378template<> inline int CompareIgnoreCase<nchar>( const nchar* lhs, const nchar* rhs,
379 integer cmpLength ) {
380 #if defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
381 return ::strncasecmp( lhs, rhs, size_t(cmpLength) );
382 #elif defined ( _WIN32 )
383 return _strnicmp ( lhs, rhs, size_t(cmpLength) );
384 #else
385 #pragma message ( "Unknown Platform in file: " __FILE__ )
386 #endif
387}
388
389template<> inline integer IndexOfAnyIncludedZT <nchar>( const nchar* haystack,
390 const nchar* needles ) {
391 const nchar* result= std::strpbrk(haystack, needles);
392 return result ? result - haystack
393 : -1;
394}
395
396template<> inline integer IndexOfAnyExcludedZT<nchar>( const nchar* haystack, const nchar* needles )
397{ return integer( std::strspn(haystack, needles) ); }
398
399
400
406extern template ALIB_DLL void Reverse <nchar>( nchar*,integer );
407
408
409//##################################################################################################
410// Wide character specifics
411//##################################################################################################
412template<> inline wchar ToUpper<wchar>(wchar c)
413{ return static_cast<wchar>(towupper(static_cast<wint_t>(c))); }
414
415template<> inline wchar ToLower<wchar>(wchar c)
416{ return static_cast<wchar>(towlower(static_cast<wint_t>(c))); }
417
418template<> inline void ToUpper<wchar>(wchar* src, integer length) {
419 wchar* end= src + length;
420 while( src != end ) {
421 *src= ToUpper<wchar>( *src );
422 ++src;
423} }
424
425template<> inline void ToLower<wchar>(wchar* src, integer length) {
426 wchar* end= src + length;
427 while( src != end ) {
428 *src= ToLower<wchar>( *src );
429 ++src;
430} }
431
432#if ALIB_CHARACTERS_NATIVE_WCHAR
433template<> inline void Fill<wchar>( wchar* dest, integer length, wchar c )
434{ wmemset( dest, c, size_t(length) ); }
435
436template<> inline int CompareIgnoreCase<wchar>( const wchar* lhs, const wchar* rhs,
437 integer cmpLength ) {
438 #if defined ( _WIN32 )
439 return _wcsnicmp ( lhs, rhs, size_t(cmpLength) );
440 #elif defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
441 return ::wcsncasecmp( lhs, rhs, size_t(cmpLength) );
442 #else
443 #pragma message ( "Unknown Platform in file: " __FILE__ )
444 #endif
445}
446
447template<> inline integer IndexOfAnyIncludedZT<wchar>(const wchar* haystack, const wchar* needles) {
448 const wchar* result= std::wcspbrk(haystack, needles);
449 return result ? result - haystack
450 : -1;
451}
452template<> inline integer IndexOfAnyExcludedZT<wchar>(const wchar* haystack, const wchar* needles)
453{ return integer( std::wcsspn(haystack, needles) ); }
454
455
456#else
457template<> ALIB_DLL void Fill<wchar>( wchar* dest, integer length, wchar c );
458template<> ALIB_DLL int CompareIgnoreCase <wchar>( const wchar* lhs, const wchar* rhs, integer cmpLength );
459template<> ALIB_DLL integer IndexOfAnyIncludedZT<wchar>( const wchar* haystack, const wchar* needles );
460template<> ALIB_DLL integer IndexOfAnyExcludedZT<wchar>( const wchar* haystack, const wchar* needles );
461#endif
462
463
469extern template ALIB_DLL void Reverse <wchar>( wchar*,integer );
470
471
472
473//##################################################################################################
474// Strange character specifics
475//##################################################################################################
476template<> inline xchar ToUpper<xchar>(xchar c)
477{ return static_cast<xchar>(towupper(static_cast<wint_t>(c))); }
478
479template<> inline xchar ToLower<xchar>(xchar c)
480{ return static_cast<xchar>(towlower(static_cast<wint_t>(c))); }
481
482template<> inline void ToUpper<xchar>(xchar* src, integer length) {
483 xchar* end= src + length;
484 while( src != end ) {
485 *src= ToUpper<xchar>( *src );
486 ++src;
487} }
488
489template<> inline void ToLower<xchar>(xchar* src, integer length) {
490 xchar* end= src + length;
491 while( src != end ) {
492 *src= ToLower<xchar>( *src );
493 ++src;
494} }
495
496#if ALIB_CHARACTERS_NATIVE_WCHAR
497template<> ALIB_DLL void Fill<xchar>( xchar* dest, integer length, xchar c );
498template<> ALIB_DLL int CompareIgnoreCase<xchar>( const xchar* lhs, const xchar* rhs, integer cmpLength );
499template<> ALIB_DLL integer IndexOfAnyIncludedZT<xchar>( const xchar* haystack, const xchar* needles );
500template<> ALIB_DLL integer IndexOfAnyExcludedZT<xchar>( const xchar* haystack, const xchar* needles );
501#else
502template<> inline void Fill<xchar>( xchar* dest, integer length, xchar c )
503{
504 wmemset( dest, c, size_t(length) );
505}
506
507template<> inline int CompareIgnoreCase<xchar>( const xchar* lhs, const xchar* rhs, integer cmpLength )
508{
509 #if defined (__GLIBCXX__)|| defined(_LIBCPP_VERSION) || defined(__APPLE__)
510 return ::wcsncasecmp( lhs, rhs, size_t(cmpLength) );
511 #elif defined ( _WIN32 )
512 return _wcsnicmp ( lhs, rhs, size_t(cmpLength) );
513 #else
514 #pragma message ( "Unknown Platform in file: " __FILE__ )
515 #endif
516}
517
518template<> inline integer IndexOfAnyIncludedZT <xchar>( const xchar* haystack, const xchar* needles )
519{
520 const xchar* result= std::wcspbrk(haystack, needles);
521 return result ? result - haystack
522 : -1;
523}
524template<> inline integer IndexOfAnyExcludedZT<xchar>( const xchar* haystack, const xchar* needles )
525{
526 return integer( std::wcsspn(haystack, needles) );
527}
528#endif
529
535extern template ALIB_DLL void Reverse <xchar>( xchar*,integer );
536//! @endcond
537
538//##################################################################################################
539// struct AlignedCharArray
540//##################################################################################################
541/// Encapsulates a fixed-size character buffer.
542/// The character type and the buffer's length are templated.
543/// Furthermore the buffer, and with it this type, is aligned to \c 8 bytes on 64-bit machines and
544/// to \c 4 bytes on 32-bit hardware.
545/// This supports fast access and compile-time optimizations.
546///
547/// An overloaded constructor and method #Fill allow filling the buffer with a distinct character.
548/// This is provided, as a frequent use-case for this struct is to provide
549/// \alib{strings;TString;String} objects of variable length.
550/// For example, when generating indentation in text files, a <c>std::basic_ostream</c> might be
551/// faster filled with spaces using a local variable of this type than putting character by
552/// character to the stream in a loop.
553///
554/// The type's name uses the word "local" because usually it is used with local (stack allocated)
555/// variables.
556/// @tparam TChar The character type.
557/// Alias names for C++ character types exist with
558/// - \alib{characters;character},
559/// - \alib{characters;nchar},
560/// - \alib{characters;wchar},
561/// - \alib{characters;xchar},
562/// - \alib{characters;complementChar}, and
563/// - \alib{characters;strangeChar}.
564///
565/// Defaults to \alib{characters;character}.
566///
567/// @tparam TLength The length of the local buffer. Defaults to 128 bytes.
568template<typename TChar= character, size_t TLength= 128/sizeof(TChar)>
570 /// The alignment of the field #buffer. Because this is the first (and only) field, this
571 /// struct itself shares this alignment.
572 static constexpr size_t Alignment =
573 std::conditional_t<sizeof(void*) == 8, std::integral_constant<size_t, 64>,
574 std::integral_constant<size_t, 64>>::value;
575
576 /// The buffer.
577 alignas(Alignment) TChar buffer[TLength];
578
579 /// Default constructor. Leaves the characters uninitialized.
580 constexpr AlignedCharArray() noexcept =default;
581
582 /// Constructor taking a character to initialize the buffer with.
583 /// @param fillChar The character to fill this local buffer with.
584 constexpr AlignedCharArray( TChar fillChar ) noexcept { Fill( fillChar ); }
585
586 /// Returns a pointer to the internal buffer.
587 /// @return A mutable pointer to the characters.
588 constexpr TChar* Buffer() noexcept { return buffer; }
589
590 /// Returns a pointer to the internal buffer.
591 /// @return A const pointer to the characters.
592 constexpr const TChar* Buffer() const noexcept { return buffer; }
593
594 /// Returns the number of characters in this buffer.
595 /// @return The value of template parameter \p{TLength}.
596 constexpr integer Length() const noexcept { return TLength; }
597
598 /// Fills the buffer with given \p{fillChar}.
599 /// @param fillChar The character to fill this local buffer with.
600 constexpr void Fill( TChar fillChar ) noexcept
601 { characters::Fill( buffer, TLength, fillChar); }
602};
603
604}
605
606/// Type alias in namespace \b alib.
607/// Note that the original struct has template parameters, which, for technical reasons can
608/// not be defaulted with this alias as they are defaulted in the original.
609/// Therefore, this alias uses explicit defaults (which are not changeable).
611
612} // namespace [alib::character]
#define ALIB_DLL
Definition alib.inl:503
#define ALIB_EXPORT
Definition alib.inl:497
PLATFORM_SPECIFIC wchar
Definition chartypes.inl:38
const TChar * Search(const TChar *haystack, integer haystackLength, TChar needle)
void Copy(const TChar *src, integer length, TChar *dest)
PLATFORM_SPECIFIC character
Definition chartypes.inl:91
integer Length(const TChar *cstring)
Definition functions.inl:89
integer IndexOfFirstDifference(const TChar *haystack, integer haystackLength, const TChar *needle, integer needleLength, lang::Case sensitivity)
integer LastIndexOfAnyExclude(const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength)
void Reverse(TChar *src, integer length)
PLATFORM_SPECIFIC xchar
Definition chartypes.inl:51
TChar ToUpper(TChar c)
integer LastIndexOfAnyInclude(const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength)
int Compare(const TChar *lhs, const TChar *rhs, integer cmpLength)
void Move(const TChar *src, integer length, TChar *dest)
integer IndexOfAnyIncludedZT(const TChar *haystack, const TChar *needles)
void Fill(TChar *dest, integer length, TChar value)
bool Equal(TChar lhs, TRhs rhs)
Definition functions.inl:62
TChar ToLower(TChar c)
integer IndexOfAnyIncluded(const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength)
integer IndexOfAnyExcluded(const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength)
integer IndexOfAnyExcludedZT(const TChar *haystack, const TChar *needles)
int CompareIgnoreCase(const TChar *lhs, const TChar *rhs, integer cmpLength)
Case
Denotes upper and lower case character treatment.
characters::AlignedCharArray<> AlignedCharArray
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
characters::nchar nchar
Type alias in namespace alib.
strings::TFill< character > Fill
Type alias in namespace alib.
Definition format.inl:577
constexpr AlignedCharArray() noexcept=default
Default constructor. Leaves the characters uninitialized.
constexpr integer Length() const noexcept
constexpr TChar * Buffer() noexcept
static constexpr size_t Alignment
constexpr const TChar * Buffer() const noexcept
TChar buffer[TLength]
The buffer.
constexpr void Fill(TChar fillChar) noexcept