CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
UTF8String.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace CYB {
5  namespace API {
6  namespace String {
8  class UTF8 : public Dynamic {
9  private:
10  int FLength;
11  private:
19  int ByteIndexOfChar(const int ACharIndex) const noexcept;
20 
27  void CalculateLength(void) noexcept;
28  public:
36  static bool Validate(const CStyle& AString) noexcept;
37 
38  UTF8() noexcept = default;
39 
46  UTF8(Dynamic&& AData);
55  UTF8(const CStyle& AData);
56  UTF8(const UTF8& ACopy) = default;
57  UTF8(UTF8&& AMove) noexcept = default;
58  UTF8& operator=(UTF8&& AMove) noexcept = default;
59 
68  UTF8 operator+(const UTF8& ARHS) const;
77  UTF8& operator+=(const UTF8& ARHS);
79  UTF8 SubString(const int AIndex, const int ALength) const;
80 
82 
90  template <typename ALambda> void IterateCodepoints(const ALambda AIterator, const bool AReverse) const noexcept(noexcept(AIterator(0U,0)));
91 
99  const char& operator[](const int APosition) const noexcept;
100 
107  void Shrink(const int AMaxChars) noexcept final override;
108 
110  int Length(void) const noexcept final override;
111  };
112  };
113  };
114 };
A variable length UTF-8 string.
Definition: UTF8String.hpp:8
void Shrink(const int AMaxChars) noexceptfinaloverride
Move the null terminator of the string so that the maxumum number of remaining characters is AMaxChar...
static bool Validate(const CStyle &AString) noexcept
Validates if a given string is UTF8.
void IterateCodepoints(const ALambda AIterator, const bool AReverse) const noexcept(noexcept(AIterator(0U, 0)))
Iterate over the code points.
Used for string of allocated variable length.
void CalculateLength(void) noexcept
Sets up the length cache variable. Assumes the string is validated.
A basic char contained string.
Definition: CStyleString.hpp:7
int Length(void) const noexceptfinaloverride
Get the number of characters in the contained string. The definition of character may change in deriv...
int ByteIndexOfChar(const int ACharIndex) const noexcept
Gets the byte index of a given character index.
UTF8 SubString(const int AIndex, const int ALength) const
Get a substring of the contained string. This version will not segment inside of multibyte characters...
int FLength
Length cache.
Definition: UTF8String.hpp:10