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