Loading...
Searching...
No Matches
String

#include <Ultralight/String.h>

Overview

Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.

This class is used to represent strings in Ultralight. It can be created from a variety of string types and converted to a number of unicode string types.

Accessing string data

Strings are natively stored in a null-terminated UTF-8 format. You can access the UTF-8 bytes using the utf8() method:

String str("Hello, world!");
// Print the UTF-8 data (guaranteed to be null-terminated)
printf("%s\n", str.utf8().data());
Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.
Definition String.h:34

Public Member Functions

 String ()
 Create empty string.
 
 String (const char *str)
 Create from null-terminated, ASCII C-string.
 
 String (const char *str, size_t len)
 Create from raw, UTF-8 string with certain length.
 
 String (const String8 &str)
 Create from existing String8 (UTF-8).
 
 String (const Char16 *str, size_t len)
 Create from raw UTF-16 string with certain length.
 
 String (const String16 &str)
 Create from existing String16 (UTF-16)
 
 String (const String32 &str)
 Create from existing String32 (UTF-32)
 
 String (const String &other)
 Copy constructor.
 
 String (String &&other)
 Move constructor.
 
 ~String ()
 Destructor.
 
Stringoperator= (const String &other)
 Assign string from another, copy is made.
 
Stringoperator= (String &&other)
 Move assignment operator.
 
Stringoperator+= (const String &other)
 Append string with another.
 
String8utf8 ()
 Get native UTF-8 string.
 
const String8utf8 () const
 Get native UTF-8 string.
 
String16 utf16 () const
 Convert to UTF-16 string.
 
String32 utf32 () const
 Convert to UTF-32 string.
 
bool empty () const
 Check if string is empty or not.
 
size_t Hash () const
 Hash function.
 
bool operator< (const String &other) const
 Comparison operator.
 
bool operator== (const String &other) const
 Equality operator.
 
bool operator!= (const String &other) const
 Inequality operator.
 

Friends

String operator+ (String lhs, const String &rhs)
 Concatenation operator.
 

Constructor & Destructor Documentation

◆ String() [1/9]

String ( )

Create empty string.

◆ String() [2/9]

String ( const char * str)

Create from null-terminated, ASCII C-string.

◆ String() [3/9]

String ( const char * str,
size_t len )

Create from raw, UTF-8 string with certain length.

◆ String() [4/9]

String ( const String8 & str)

Create from existing String8 (UTF-8).

◆ String() [5/9]

String ( const Char16 * str,
size_t len )

Create from raw UTF-16 string with certain length.

◆ String() [6/9]

String ( const String16 & str)

Create from existing String16 (UTF-16)

◆ String() [7/9]

String ( const String32 & str)

Create from existing String32 (UTF-32)

◆ String() [8/9]

String ( const String & other)

Copy constructor.

◆ String() [9/9]

String ( String && other)

Move constructor.

◆ ~String()

~String ( )

Destructor.

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

Check if string is empty or not.

◆ Hash()

size_t Hash ( ) const

Hash function.

◆ operator!=()

bool operator!= ( const String & other) const

Inequality operator.

◆ operator+=()

String & operator+= ( const String & other)

Append string with another.

◆ operator<()

bool operator< ( const String & other) const

Comparison operator.

◆ operator=() [1/2]

String & operator= ( const String & other)

Assign string from another, copy is made.

◆ operator=() [2/2]

String & operator= ( String && other)

Move assignment operator.

◆ operator==()

bool operator== ( const String & other) const

Equality operator.

◆ utf16()

String16 utf16 ( ) const

Convert to UTF-16 string.

◆ utf32()

String32 utf32 ( ) const

Convert to UTF-32 string.

◆ utf8() [1/2]

String8 & utf8 ( )
inline

Get native UTF-8 string.

◆ utf8() [2/2]

const String8 & utf8 ( ) const
inline

Get native UTF-8 string.

Friends And Related Symbol Documentation

◆ operator+

String operator+ ( String lhs,
const String & rhs )
friend

Concatenation operator.


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