LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::UTF8String Class Reference

Container class for UTF-8 encoded strings. More...

#include <UTF8String.h>

Public Types

using value_type = char
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = value_type&
using const_reference = const value_type&
using pointer = value_type*
using const_pointer = const value_type*
using iterator = value_type*
using const_iterator = const value_type*
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>

Public Member Functions

 UTF8String ()
 Initialize an empty string.
 UTF8String (const UTF8String &rhs)
 Initializes the UTF-8 string with a copy of the specified string.
 UTF8String (UTF8String &&rhs)
 Takes the ownership of the specified UTF-8 string.
 UTF8String (const StringView &str)
 Initializes the UTF-8 string with a copy of the specified string view.
 UTF8String (const WStringView &str)
 Initializes the UTF-8 string with a UTF-8 encoded conversion of the specified wide string view.
 UTF8String (const char *str)
 Initializes the UTF-8 string with a copy of the specified null-terminated string.
 UTF8String (const wchar_t *str)
 Initializes the UTF-8 string with a UTF-8 encoded conversion of the specified null-terminated wide string.
template<template< class, class, class > class TString, class TChar, class Traits, class Allocator>
 UTF8String (const TString< TChar, Traits, Allocator > &str)
 Initializes the UTF-8 string with a copy of another templated string class. This would usually be std::basic_string.
 UTF8String (SmallVector< char > &&data)
 Initializes the UTF-8 string by moving the ownership of the internal data container.
bool empty () const noexcept
size_type size () const noexcept
size_type length () const noexcept
size_type capacity () const noexcept
const_pointer data () const noexcept
const_pointer c_str () const noexcept
const_reference at (size_type pos) const
const_reference front () const
const_reference back () const
const_iterator begin () const noexcept
const_iterator cbegin () const noexcept
const_reverse_iterator rbegin () const
const_reverse_iterator crbegin () const
const_iterator end () const noexcept
const_iterator cend () const noexcept
const_reverse_iterator rend () const
const_reverse_iterator crend () const
void clear ()
int compare (const StringView &str) const
int compare (size_type pos1, size_type count1, const StringView &str) const
int compare (size_type pos1, size_type count1, const StringView &str, size_type pos2, size_type count2=npos) const
int compare (const WStringView &str) const
int compare (size_type pos1, size_type count1, const WStringView &str) const
int compare (size_type pos1, size_type count1, const WStringView &str, size_type pos2, size_type count2=npos) const
UTF8String substr (size_type pos=0, size_type cout=npos) const
void resize (size_type size, char ch='\0')
UTF8String & append (size_type count, char ch)
UTF8String & append (const char *first, const char *last)
SmallVector< wchar_t > to_utf16 () const
 Convert this string to a NUL-terminated UTF-16 string.
UTF8String & operator= (const UTF8String &rhs)
UTF8String & operator= (UTF8String &&rhs)
UTF8String & operator+= (const UTF8String &rhs)
UTF8String & operator+= (const StringView &rhs)
UTF8String & operator+= (const WStringView &rhs)
UTF8String & operator+= (const char *rhs)
UTF8String & operator+= (const wchar_t *rhs)
UTF8String & operator+= (char chr)
UTF8String & operator+= (wchar_t chr)
const_reference operator[] (size_type pos) const
 operator const_pointer () const
 Conversion operator to a null-terminated string.
 operator StringView () const
 Conversion operator to a string view.

Static Public Member Functions

static UTF8String Printf (const char *format,...)
 Prints a formatted UTF-8 string with a variable number of arguments.

Static Public Attributes

static constexpr size_type npos = size_type(-1)

Detailed Description

Container class for UTF-8 encoded strings.

Remarks
This class converts between char and wchar_t strings automatically, but stores strings always as UTF-8 encoded char strings.

Member Typedef Documentation

◆ const_iterator

◆ const_pointer

◆ const_reference

◆ const_reverse_iterator

◆ difference_type

using LLGL::UTF8String::difference_type = std::ptrdiff_t

◆ iterator

◆ pointer

◆ reference

◆ reverse_iterator

using LLGL::UTF8String::reverse_iterator = std::reverse_iterator<iterator>

◆ size_type

using LLGL::UTF8String::size_type = std::size_t

◆ value_type

Constructor & Destructor Documentation

◆ UTF8String() [1/9]

LLGL::UTF8String::UTF8String ( )

Initialize an empty string.

◆ UTF8String() [2/9]

LLGL::UTF8String::UTF8String ( const UTF8String & rhs)

Initializes the UTF-8 string with a copy of the specified string.

◆ UTF8String() [3/9]

LLGL::UTF8String::UTF8String ( UTF8String && rhs)

Takes the ownership of the specified UTF-8 string.

◆ UTF8String() [4/9]

LLGL::UTF8String::UTF8String ( const StringView & str)

Initializes the UTF-8 string with a copy of the specified string view.

◆ UTF8String() [5/9]

LLGL::UTF8String::UTF8String ( const WStringView & str)

Initializes the UTF-8 string with a UTF-8 encoded conversion of the specified wide string view.

◆ UTF8String() [6/9]

LLGL::UTF8String::UTF8String ( const char * str)

Initializes the UTF-8 string with a copy of the specified null-terminated string.

◆ UTF8String() [7/9]

LLGL::UTF8String::UTF8String ( const wchar_t * str)

Initializes the UTF-8 string with a UTF-8 encoded conversion of the specified null-terminated wide string.

◆ UTF8String() [8/9]

template<template< class, class, class > class TString, class TChar, class Traits, class Allocator>
LLGL::UTF8String::UTF8String ( const TString< TChar, Traits, Allocator > & str)
inline

Initializes the UTF-8 string with a copy of another templated string class. This would usually be std::basic_string.

◆ UTF8String() [9/9]

LLGL::UTF8String::UTF8String ( SmallVector< char > && data)
explicit

Initializes the UTF-8 string by moving the ownership of the internal data container.

Parameters
[in]dataThe input data must already be in UTF-8 format. This constructor does not perform any checks on this input container!

Member Function Documentation

◆ append() [1/2]

UTF8String & LLGL::UTF8String::append ( const char * first,
const char * last )

◆ append() [2/2]

UTF8String & LLGL::UTF8String::append ( size_type count,
char ch )

◆ at()

const_reference LLGL::UTF8String::at ( size_type pos) const
inline

◆ back()

const_reference LLGL::UTF8String::back ( ) const
inline

◆ begin()

const_iterator LLGL::UTF8String::begin ( ) const
inlinenoexcept

◆ c_str()

const_pointer LLGL::UTF8String::c_str ( ) const
inlinenoexcept

◆ capacity()

size_type LLGL::UTF8String::capacity ( ) const
inlinenoexcept

◆ cbegin()

const_iterator LLGL::UTF8String::cbegin ( ) const
inlinenoexcept

◆ cend()

const_iterator LLGL::UTF8String::cend ( ) const
inlinenoexcept

◆ clear()

void LLGL::UTF8String::clear ( )

◆ compare() [1/6]

int LLGL::UTF8String::compare ( const StringView & str) const

◆ compare() [2/6]

int LLGL::UTF8String::compare ( const WStringView & str) const

◆ compare() [3/6]

int LLGL::UTF8String::compare ( size_type pos1,
size_type count1,
const StringView & str ) const

◆ compare() [4/6]

int LLGL::UTF8String::compare ( size_type pos1,
size_type count1,
const StringView & str,
size_type pos2,
size_type count2 = npos ) const

◆ compare() [5/6]

int LLGL::UTF8String::compare ( size_type pos1,
size_type count1,
const WStringView & str ) const

◆ compare() [6/6]

int LLGL::UTF8String::compare ( size_type pos1,
size_type count1,
const WStringView & str,
size_type pos2,
size_type count2 = npos ) const

◆ crbegin()

const_reverse_iterator LLGL::UTF8String::crbegin ( ) const
inline

◆ crend()

const_reverse_iterator LLGL::UTF8String::crend ( ) const
inline

◆ data()

const_pointer LLGL::UTF8String::data ( ) const
inlinenoexcept

◆ empty()

bool LLGL::UTF8String::empty ( ) const
inlinenoexcept

◆ end()

const_iterator LLGL::UTF8String::end ( ) const
inlinenoexcept

◆ front()

const_reference LLGL::UTF8String::front ( ) const
inline

◆ length()

size_type LLGL::UTF8String::length ( ) const
inlinenoexcept

◆ operator const_pointer()

LLGL::UTF8String::operator const_pointer ( ) const
inline

Conversion operator to a null-terminated string.

◆ operator StringView()

LLGL::UTF8String::operator StringView ( ) const
inline

Conversion operator to a string view.

◆ operator+=() [1/7]

UTF8String & LLGL::UTF8String::operator+= ( char chr)

◆ operator+=() [2/7]

UTF8String & LLGL::UTF8String::operator+= ( const char * rhs)

◆ operator+=() [3/7]

UTF8String & LLGL::UTF8String::operator+= ( const StringView & rhs)

◆ operator+=() [4/7]

UTF8String & LLGL::UTF8String::operator+= ( const UTF8String & rhs)

◆ operator+=() [5/7]

UTF8String & LLGL::UTF8String::operator+= ( const wchar_t * rhs)

◆ operator+=() [6/7]

UTF8String & LLGL::UTF8String::operator+= ( const WStringView & rhs)

◆ operator+=() [7/7]

UTF8String & LLGL::UTF8String::operator+= ( wchar_t chr)

◆ operator=() [1/2]

UTF8String & LLGL::UTF8String::operator= ( const UTF8String & rhs)

◆ operator=() [2/2]

UTF8String & LLGL::UTF8String::operator= ( UTF8String && rhs)

◆ operator[]()

const_reference LLGL::UTF8String::operator[] ( size_type pos) const
inline

◆ Printf()

UTF8String LLGL::UTF8String::Printf ( const char * format,
... )
static

Prints a formatted UTF-8 string with a variable number of arguments.

Remarks
This follows the same formatting syntax as std::printf.
See also
Report::Printf
Log::Printf

◆ rbegin()

const_reverse_iterator LLGL::UTF8String::rbegin ( ) const
inline

◆ rend()

const_reverse_iterator LLGL::UTF8String::rend ( ) const
inline

◆ resize()

void LLGL::UTF8String::resize ( size_type size,
char ch = '\0' )

◆ size()

size_type LLGL::UTF8String::size ( ) const
inlinenoexcept

◆ substr()

UTF8String LLGL::UTF8String::substr ( size_type pos = 0,
size_type cout = npos ) const

◆ to_utf16()

SmallVector< wchar_t > LLGL::UTF8String::to_utf16 ( ) const

Convert this string to a NUL-terminated UTF-16 string.

Member Data Documentation

◆ npos

size_type LLGL::UTF8String::npos = size_type(-1)
staticconstexpr

The documentation for this class was generated from the following file: