AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AString Class Reference

Represents a Unicode character string. More...

Detailed Description

Represents a Unicode character string.

AString stores a string of 16-bit chars, where each char corresponds to one UTF-16 code unit. Unicode characters with code values above 65535 are stored using two consecutive chars.

Unicode is an international standard that supports most of the writing systems in use today.

Examples
/github/workspace/aui.core/src/AUI/Common/AObject.h, /github/workspace/aui.core/src/AUI/IO/APath.h, /github/workspace/aui.json/src/AUI/Json/Conversion.h, and /github/workspace/aui.views/src/AUI/View/AView.h.

Public Types

using iterator = super::iterator
 
using value_type = super::value_type
 
using const_iterator = super::const_iterator
 
using reverse_iterator = super::reverse_iterator
 
using const_reverse_iterator = super::const_reverse_iterator
 

Public Member Functions

 AString (AString &&other) noexcept
 
 AString (const basic_string &other) noexcept
 
 AString (const std::string &utf8) noexcept
 
 AString (const AString &other) noexcept
 
 AString (const basic_string &rhs, const std::allocator< char16_t > &allocator) noexcept
 
template<class Iterator >
 AString (Iterator first, Iterator last) noexcept
 
 AString (char16_t c) noexcept
 
 AString (const char *utf8) noexcept
 
 AString (std::string_view utf8) noexcept
 
 AString (const std::allocator< char16_t > &allocator) noexcept
 
 AString (const basic_string &rhs, size_type offset, const std::allocator< char16_t > &allocator) noexcept
 
 AString (const basic_string &rhs, size_type offset, size_type count, const std::allocator< char16_t > &allocator) noexcept
 
 AString (const char16_t *cStyleString, size_type count) noexcept
 
 AString (const char16_t *cStyleString, size_type count, const std::allocator< char16_t > &allocator) noexcept
 
 AString (const char16_t *cStyleString) noexcept
 
 AString (const char16_t *cStyleString, const std::allocator< char16_t > &allocator) noexcept
 
 AString (size_type count, char16_t _Ch) noexcept
 
 AString (size_type count, char16_t _Ch, const std::allocator< char16_t > &allocator) noexcept
 
 AString (basic_string &&rhs) noexcept
 
 AString (basic_string &&rhs, const std::allocator< char16_t > &allocator) noexcept
 
 AString (std::initializer_list< char16_t > _Ilist) noexcept
 
void push_back (char16_t c) noexcept
 
void pop_back () noexcept
 
AString uppercase () const
 
AString lowercase () const
 
bool startsWith (const AString &other) const noexcept
 
bool startsWith (char16_t c) const noexcept
 
bool endsWith (const AString &other) const noexcept
 
bool endsWith (char16_t c) const noexcept
 
AStringVector split (char16_t c) const noexcept
 
size_type find (char c, size_type offset=0) const noexcept
 
size_type find (char16_t c, size_type offset=0) const noexcept
 
size_type find (const AString &str, size_type offset=0) const noexcept
 
size_type rfind (char c, size_type offset=NPOS) const noexcept
 
size_type rfind (char16_t c, size_type offset=NPOS) const noexcept
 
size_type rfind (const AString &str, size_type offset=NPOS) const noexcept
 
size_type length () const noexcept
 
AString trimLeft (char16_t symbol=' ') const noexcept
 
AString trimRight (char16_t symbol=' ') const noexcept
 
AString trim (char16_t symbol=' ') const noexcept
 
void reserve (size_t s)
 
void resize (size_t s)
 
AString restrictLength (size_t s, const AString &stringAtEnd="...") const
 
char16_t * data () noexcept
 
const char16_t * data () const noexcept
 
AStringreplaceAll (const AString &from, const AString &to)
 
AString replacedAll (const AString &from, const AString &to) const
 
AString replacedAll (char16_t from, char16_t to) const noexcept
 
AString replacedAll (const ASet< char16_t > &from, char16_t to) const noexcept
 
AStringreplaceAll (char16_t from, char16_t to) noexcept
 
template<typename OtherContainer >
void insertAll (const OtherContainer &c) noexcept
 
AOptional< float > toFloat () const noexcept
 Converts the string to a float number. More...
 
AOptional< double > toDouble () const noexcept
 Converts the string to a double number. More...
 
double toDoubleOrException () const noexcept
 Converts the string to a double number. More...
 
AOptional< int > toInt () const noexcept
 Converts the string to int value. More...
 
int toIntOrException () const
 Converts the string to int value. More...
 
AOptional< int64_t > toLongInt () const noexcept
 Converts the string to int value. More...
 
int64_t toLongIntOrException () const
 Converts the string to int value. More...
 
AOptional< unsigned > toUInt () const noexcept
 Converts the string to int value. More...
 
unsigned toUIntOrException () const
 Converts the string to int value. More...
 
bool toBool () const noexcept
 Converts the string to boolean value. More...
 
bool contains (char16_t c) const noexcept
 
bool contains (const AString &other) const noexcept
 
AOptional< int > toNumber (aui::ranged_number< int, 2, 36 > base=TO_NUMBER_BASE_DEC) const noexcept
 Returns the string converted to an int using base. Returns std::nullopt if the conversion fails. More...
 
int toNumberOrException (aui::ranged_number< int, 2, 36 > base=TO_NUMBER_BASE_DEC) const
 Returns the string converted to an int using base. Throws an exception if the conversion fails. More...
 
std::string toStdString () const noexcept
 
void resizeToNullTerminator ()
 
iterator erase (const_iterator begin, const_iterator end) noexcept
 
iterator erase (const_iterator begin) noexcept
 
AStringerase (size_type offset) noexcept
 
AStringerase (size_type offset, size_type count) noexcept
 
AByteBuffer toUtf8 () const noexcept
 
void removeAt (unsigned at) noexcept
 
AString excessSpacesRemoved () const noexcept
 
iterator insert (size_type at, char16_t c) noexcept
 
iterator insert (size_type at, const AString &c) noexcept
 
template<typename Iterator >
iterator insert (const_iterator at, Iterator begin, Iterator end) noexcept
 
AStringoperator<< (char c) noexcept
 
AStringoperator<< (char16_t c) noexcept
 
inline ::AStringoperator+= (const AString &str) noexcept
 
inline ::AStringoperator+= (const char *str) noexcept
 
bool empty () const noexcept
 
size_type size () const noexcept
 
char16_t operator[] (size_type index) const
 
char16_t & operator[] (size_type index)
 
bool operator< (const AString &other) const noexcept
 
void clear () noexcept
 
char16_t & front () noexcept
 
char16_t & back () noexcept
 
const char16_t & front () const noexcept
 
const char16_t & back () const noexcept
 
char16_t & first () noexcept
 
char16_t & last () noexcept
 
const char16_t & first () const noexcept
 
const char16_t & last () const noexcept
 
const char16_t * c_str () const
 
iterator begin () noexcept
 
iterator end () noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
reverse_iterator rbegin () noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator rend () const noexcept
 
AStringappend (const AString &s) noexcept
 
AStringappend (size_t count, char16_t ch) noexcept
 
const AStringoperator= (const AString &value) noexcept
 
const AStringoperator= (AString &&value) noexcept
 
bool operator== (const AString &other) const noexcept
 
bool operator== (const char16_t *other) const noexcept
 
size_t sizeInBytes () const noexcept
 
bool operator!= (const AString &other) const noexcept
 
bool operator!= (const char16_t *other) const noexcept
 
bool operator== (const char *other) const noexcept
 
bool operator!= (const char *other) const noexcept
 
template<typename... Args>
AString format (Args &&... args) const
 
AString processEscapes () const
 
AStringremoveAll (char16_t c) noexcept
 
AString substr (std::size_t offset, std::size_t count=npos) const
 

Static Public Member Functions

static AString fromLatin1 (const AByteBuffer &buffer)
 
static AString fromUtf8 (const AByteBufferView &buffer)
 
static AString fromUtf8 (const char *buffer, size_t length)
 
static AString fromLatin1 (const char *buffer)
 
static AString numberHex (int i) noexcept
 
template<typename T , std::enable_if_t< std::is_integral_v< std::decay_t< T > >||std::is_floating_point_v< std::decay_t< T > >, int > = 0>
static AString number (T i) noexcept
 

Static Public Attributes

constexpr static auto NPOS = super::npos
 
static constexpr auto TO_NUMBER_BASE_BIN = 2
 
static constexpr auto TO_NUMBER_BASE_OCT = 8
 
static constexpr auto TO_NUMBER_BASE_DEC = 10
 
static constexpr auto TO_NUMBER_BASE_HEX = 16
 

Friends

struct std::hash< AString >
 

Constructor & Destructor Documentation

◆ AString() [1/4]

AString::AString ( const basic_string &  other)
inlinenoexcept
Parameters
otherutf8 string

◆ AString() [2/4]

AString::AString ( const std::string &  utf8)
noexcept
Parameters
utf8utf8 string

◆ AString() [3/4]

AString::AString ( const char *  utf8)
noexcept
Parameters
utf8utf8 string

◆ AString() [4/4]

AString::AString ( std::string_view  utf8)
noexcept
Parameters
utf8utf8 string

Member Function Documentation

◆ insertAll()

template<typename OtherContainer >
void AString::insertAll ( const OtherContainer &  c)
inlinenoexcept

Inserts all values of the specified container to the end.

Template Parameters
OtherContainerother container type.
Parameters
cother container
Returns
iterator pointing to the first element inserted.

◆ toBool()

bool AString::toBool ( ) const
inlinenoexcept

Converts the string to boolean value.

Returns
If the string equals to "true", true returned, false otherwise.

◆ toDouble()

AOptional< double > AString::toDouble ( ) const
noexcept

Converts the string to a double number.

Returns
The string converted to a double number.

If conversion to int is not possible, nullopt is returned.

◆ toDoubleOrException()

double AString::toDoubleOrException ( ) const
inlinenoexcept

Converts the string to a double number.

Returns
The string converted to a double number.

If conversion to int is not possible, exception is thrown.

◆ toFloat()

AOptional< float > AString::toFloat ( ) const
noexcept

Converts the string to a float number.

Returns
The string converted to a float number.

If conversion to int is not possible, nullopt is returned.

◆ toInt()

AOptional< int > AString::toInt ( ) const
noexcept

Converts the string to int value.

Returns
The string converted to an integer value using base 10. If the string starts with 0x or 0X, the base 16 used.

If conversion to int is not possible, nullopt is returned.

◆ toIntOrException()

int AString::toIntOrException ( ) const
inline

Converts the string to int value.

Returns
The string converted to an integer value using base 10. If the string starts with 0x or 0X, the base 16 used.

If conversion to int is not possible, exception is thrown.

◆ toLongInt()

AOptional< int64_t > AString::toLongInt ( ) const
noexcept

Converts the string to int value.

Returns
The string converted to an integer value using base 10. If the string starts with 0x or 0X, the base 16 used.

If conversion to int is not possible, nullopt is returned.

◆ toLongIntOrException()

int64_t AString::toLongIntOrException ( ) const
inline

Converts the string to int value.

Returns
The string converted to an integer value using base 10. If the string starts with 0x or 0X, the base 16 used.

If conversion to int is not possible, nullopt is returned.

◆ toNumber()

AOptional< int > AString::toNumber ( aui::ranged_number< int, 2, 36 >  base = TO_NUMBER_BASE_DEC) const
noexcept

Returns the string converted to an int using base. Returns std::nullopt if the conversion fails.

See also
toNumberOrException

◆ toNumberOrException()

int AString::toNumberOrException ( aui::ranged_number< int, 2, 36 >  base = TO_NUMBER_BASE_DEC) const
inline

Returns the string converted to an int using base. Throws an exception if the conversion fails.

See also
toNumber

◆ toStdString()

std::string AString::toStdString ( ) const
noexcept
Returns
utf8-encoded std::string.

◆ toUInt()

AOptional< unsigned > AString::toUInt ( ) const
noexcept

Converts the string to int value.

Returns
The string converted to an integer value using base 10. If the string starts with 0x or 0X, the base 16 used.

If conversion to int is not possible, exception is thrown.

◆ toUIntOrException()

unsigned AString::toUIntOrException ( ) const
inline

Converts the string to int value.

Returns
The string converted to an integer value using base 10. If the string starts with 0x or 0X, the base 16 used.

If conversion to int is not possible, exception is thrown.

#include <AUI/Common/AString.h>


The documentation for this class was generated from the following files:
Inheritance diagram for AString:
Collaboration diagram for AString: