UTF 16 bit string class. More...
Public Member Functions | |
String16 (void) noexcept | |
Creates an empty string. | |
String16 (const String16 &rInput) | |
Initialize a Burger::String16 with a Burger::String16. | |
String16 (const String16 &rInput, uintptr_t uStart, uintptr_t uEnd=UINTPTR_MAX) | |
Initialize a Burger::String16 by using a subsection of a different Burger::String16. | |
String16 (const char *pInput) noexcept | |
Initialize with a UTF8 "C" string. | |
String16 (const char *pInput, uintptr_t uPadding) | |
Initialize with a UTF8 "C" string with padding. | |
String16 (const uint16_t *pInput) | |
Initialize with a UTF16 string. | |
String16 (const uint32_t *pInput) | |
~String16 () | |
Release memory, if any. | |
operator uint16_t * () noexcept | |
Return the pointer to the string. | |
operator const uint16_t * () const noexcept | |
Return the const pointer to the string. | |
const uint16_t * | c_str () const noexcept |
Return the const pointer to the string. | |
uint16_t * | c_str () noexcept |
Return the pointer to the string. | |
const uint16_t * | data (void) const noexcept |
uint16_t * | data (void) noexcept |
operator uint16_t () const noexcept | |
Return the first character of the UTF16 "C" string. | |
uintptr_t | length (void) const noexcept |
Return the length of the "C" string. | |
uint_t | empty (void) const noexcept |
uintptr_t | GetLength (void) const noexcept |
Return the length of the UTF16 "C" string. | |
uint16_t * | GetPtr () noexcept |
Return the pointer to the string. | |
const uint16_t * | GetPtr () const noexcept |
Return the const pointer to the string. | |
eError | assign (const char *pInput) noexcept |
Copy an 8 bit "C" string to a Burger::String16. | |
eError | assign (const uint16_t *pInput) noexcept |
Copy a "C" string to a Burger::String. | |
eError | SetBufferSize (uintptr_t uSize) noexcept |
Force a buffer size. | |
eError | resize (uintptr_t uSize) noexcept |
String16 & | operator= (const String16 &rInput) |
Assign a Burger::String16. | |
String16 & | operator= (const uint16_t *pInput) |
Assign a "C" string to a Burger::String16. | |
String16 & | operator= (const char *pInput) |
Assign a "C" string to a Burger::String16. | |
String16 & | operator= (char cInput) |
Assign a single character length string to this Burger::String. | |
String16 | operator() (uintptr_t uStart, uintptr_t uEnd) const noexcept |
Create a new Burger::String16 from a substring. | |
uint16_t & | operator() (uintptr_t uInput) noexcept |
Return the reference to a location in the string. | |
uint16_t const & | operator() (uintptr_t uInput) const noexcept |
Return the reference to a location in the string. | |
uint16_t & | operator[] (uintptr_t uInput) noexcept |
Return the reference to a location in the string. | |
uint16_t const & | operator[] (uintptr_t uInput) const noexcept |
Return the reference to a location in the string. | |
uint_t | operator! () const noexcept |
Return TRUE if the string is empty. | |
uint_t | is_valid (void) const noexcept |
Return TRUE if the string has characters. | |
void | clear (void) noexcept |
Clear out the data. | |
Static Public Attributes | |
static const uintptr_t | BUFFERSIZE |
Ensures the structure is 128 bytes in size on all platforms. | |
Private Attributes | |
uint16_t * | m_pData |
Pointer to the string. | |
uintptr_t | m_uLength |
Length of the string. | |
uint16_t | m_Raw [BUFFERSIZE] |
Temp preallocated buffer for most strings Structure size is 128 bytes. | |
UTF 16 bit string class.
This commonly used string class was designed for performance in mind. Each instance takes 128 bytes to contain data for the string and a pointer to allocated memory if the internal string buffer is too large. Since most strings rarely exceed 120 bytes in length, this class will be able to allocate and free strings with no calls to a memory manager. Only when the string exceeds the internal buffer will Burger::Alloc() and Burger::Free() be used.
Functions exist to convert UTF8 and UTF32 data into UTF16 format, which this string class uses internally for data storage.
|
inlinenoexcept |
Creates an empty string.
Burger::String16::String16 | ( | const String16 & | rInput | ) |
Initialize a Burger::String16 with a Burger::String16.
rInput | Reference to a Burger::String16 |
Burger::String16::String16 | ( | const String16 & | rInput, |
uintptr_t | uStart, | ||
uintptr_t | uEnd = UINTPTR_MAX ) |
Initialize a Burger::String16 by using a subsection of a different Burger::String16.
Given a starting (inclusive) and ending (exclusive) offset, grab the sub
string and use it to create a new Burger::String16
\note If uEnd is less than or equal to uStart, the resulting string will be
empty.
\param rInput Burger::String16 to receive input from \param uStart Offset to the first character to read from \param uEnd Offset beyond the last character to read from
|
noexcept |
Initialize with a UTF8 "C" string.
Initialize the Burger::String16 with a copy of the passed string. The original string can be discarded after the call returns.
\note This function will perform a conversion from UTF8 to UTF16 \param pInput Pointer to a valid UTF8 "C" string or \ref NULL to create an
empty string
Burger::String16::String16 | ( | const char * | pInput, |
uintptr_t | uPadding ) |
Initialize with a UTF8 "C" string with padding.
Initialize the Burger::String16 with a copy of the passed string. The original string can be discarded after the call returns. Allocate a buffer that can hold the initialization string + the uPadding number of bytes so the programmer can manually append data to the end of the string with Burger::StringCopy() or equivalent
Burger::String16::String16 | ( | const uint16_t * | pInput | ) |
Burger::String16::String16 | ( | const uint32_t * | pInput | ) |
|
inline |
Release memory, if any.
Releases any allocated memory for the string. Under most cases, this performs no operation.
|
noexcept |
Copy an 8 bit "C" string to a Burger::String16.
|
noexcept |
Copy a "C" string to a Burger::String.
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Clear out the data.
Set the string to an empty string
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Return the reference to a location in the string.
Given an offset into the string, return the reference to the character. If the offset exceeds the length of the string, it will be clamped to the terminating zero.
uInput | Offset to the starting character of the new string |
|
inlinenoexcept |
Return the reference to a location in the string.
Given an offset into the string, return the reference to the character. If the offset exceeds the length of the string, it will be clamped to the terminating zero.
uInput | Offset to the starting character of the new string |
|
inlinenoexcept |
Create a new Burger::String16 from a substring.
Given the start and end offsets of a string, create a new string with those offsets and return the resulting string
uStart | Offset to the starting character of the new string |
uEnd | Offset to the character AFTER the last character of the new string |
\sa Burger::String16::String16(const Burger::String16 &,uintptr_t,uintptr_t)
Burger::String16 & Burger::String16::operator= | ( | char | cInput | ) |
Assign a single character length string to this Burger::String.
If the input is zero, the string is empty.
cInput | Single low ASCII character to create a string. |
Burger::String16 & Burger::String16::operator= | ( | const char * | pInput | ) |
Assign a "C" string to a Burger::String16.
Copy the contents of a UTF8 "C" string into this Burger::String16
Burger::String16 & Burger::String16::operator= | ( | const String16 & | rInput | ) |
Assign a Burger::String16.
Copy the contents of a Burger::String16 into this Burger::String16
rInput | Reference to a Burger::String16 to copy from |
Burger::String16 & Burger::String16::operator= | ( | const uint16_t * | pInput | ) |
Assign a "C" string to a Burger::String16.
Copy the contents of a UTF8 "C" string into this Burger::String16
|
inlinenoexcept |
Return the reference to a location in the string.
Given an offset into the string, return the reference to the character. If the offset exceeds the length of the string, it will be clamped to the terminating zero.
uInput | Offset to the starting character of the new string |
|
inlinenoexcept |
Return the reference to a location in the string.
Given an offset into the string, return the reference to the character. If the offset exceeds the length of the string, it will be clamped to the terminating zero.
uInput | Offset to the starting character of the new string |
|
inlinenoexcept |
|
noexcept |
Force a buffer size.
Set the buffer to a specific size while retaining the existing string. If the preexisting string is too long for the new buffer, it will be truncated. The buffer size will be padded to reserve two bytes for the terminating zero.
\note If a buffer of 100 characters is requested, 202 bytes will be
allocated to hold a string up to 100 characters in length with the 101st short being the terminating zero. The output of Burger::StringLength(const uint16_t *) is acceptable as input for a new string.
\param uSize Number of characters to set the buffer to
|
static |
Ensures the structure is 128 bytes in size on all platforms.
|
private |
Pointer to the string.
|
private |
Temp preallocated buffer for most strings Structure size is 128 bytes.
|
private |
Length of the string.