docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C++ API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
String32.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
#pragma once
6
#include <
Ultralight/Defines.h
>
7
#include <stddef.h>
8
9
namespace
ultralight
{
10
11
class
String8
;
12
class
String16
;
13
14
///
15
/// A null-terminated UTF-32 string container.
16
///
17
class
UExport
String32
{
18
public
:
19
/// Native character type
20
typedef
char32_t
CharType
;
21
22
/// Make an empty String32
23
String32
();
24
25
/// Make a String32 from raw UTF-32 string with certain length
26
String32
(
const
char32_t
* c_str,
size_t
len);
27
28
/// Make a deep copy of String32
29
String32
(
const
String32
& other);
30
31
/// Move constructor
32
String32
(
String32
&& other);
33
34
/// Destructor
35
~String32
();
36
37
/// Assign a String32 to this one, deep copy is made
38
String32
&
operator=
(
const
String32
& other);
39
40
/// Move assignment operator
41
String32
&
operator=
(
String32
&& other);
42
43
/// Append a String32 to this one.
44
String32
&
operator+=
(
const
String32
& other);
45
46
/// Concatenation operator
47
inline
friend
String32
operator+
(
String32
lhs,
const
String32
& rhs) { lhs += rhs;
return
lhs; }
48
49
/// Get raw UTF-32 data
50
char32_t
*
data
() {
return
data_; }
51
52
/// Get raw UTF-32 data (const)
53
const
char32_t
*
data
()
const
{
return
data_; }
54
55
/// Get length in characters.
56
size_t
length
()
const
{
return
length_; }
57
58
/// Get size in characters (synonym for length)
59
size_t
size
()
const
{
return
length_; }
60
61
/// Get size in bytes
62
size_t
sizeBytes
()
const
{
return
length_ *
sizeof
(char32_t); }
63
64
/// Check if string is empty.
65
bool
empty
()
const
{
return
!data_ || length_ == 0; }
66
67
/// Get character at specific position
68
char32_t
&
operator[]
(
size_t
pos) {
return
data_[pos]; }
69
70
/// Get character at specific position (const)
71
const
char32_t
&
operator[]
(
size_t
pos)
const
{
return
data_[pos]; }
72
73
/// Get a UTF-8 copy of this string
74
String8
utf8
()
const
;
75
76
/// Get a UTF-16 copy of this string
77
String16
utf16
()
const
;
78
79
/// Hash function
80
size_t
Hash
()
const
;
81
82
/// Comparison operator
83
bool
operator<
(
const
String32
& other)
const
;
84
85
/// Equality operator
86
bool
operator==
(
const
String32
& other)
const
;
87
88
/// Inequality operator
89
bool
operator!=
(
const
String32
& other)
const
;
90
91
private
:
92
char32_t
* data_;
93
size_t
length_;
94
};
95
96
}
// namespace ultralight
UExport
#define UExport
Definition
Exports.h:22
Defines.h
ultralight::String16
A null-terminated UTF-16 string container.
Definition
String16.h:32
ultralight::String32::data
const char32_t * data() const
Get raw UTF-32 data (const).
Definition
String32.h:53
ultralight::String32::operator[]
char32_t & operator[](size_t pos)
Get character at specific position.
Definition
String32.h:68
ultralight::String32::String32
String32(String32 &&other)
Move constructor.
ultralight::String32::size
size_t size() const
Get size in characters (synonym for length).
Definition
String32.h:59
ultralight::String32::utf8
String8 utf8() const
Get a UTF-8 copy of this string.
ultralight::String32::String32
String32(const String32 &other)
Make a deep copy of String32.
ultralight::String32::String32
String32(const char32_t *c_str, size_t len)
Make a String32 from raw UTF-32 string with certain length.
ultralight::String32::operator!=
bool operator!=(const String32 &other) const
Inequality operator.
ultralight::String32::utf16
String16 utf16() const
Get a UTF-16 copy of this string.
ultralight::String32::String32
String32()
Make an empty String32.
ultralight::String32::empty
bool empty() const
Check if string is empty.
Definition
String32.h:65
ultralight::String32::~String32
~String32()
Destructor.
ultralight::String32::length
size_t length() const
Get length in characters.
Definition
String32.h:56
ultralight::String32::CharType
char32_t CharType
Native character type.
Definition
String32.h:20
ultralight::String32::operator=
String32 & operator=(String32 &&other)
Move assignment operator.
ultralight::String32::sizeBytes
size_t sizeBytes() const
Get size in bytes.
Definition
String32.h:62
ultralight::String32::operator+
friend String32 operator+(String32 lhs, const String32 &rhs)
Concatenation operator.
Definition
String32.h:47
ultralight::String32::operator<
bool operator<(const String32 &other) const
Comparison operator.
ultralight::String32::Hash
size_t Hash() const
Hash function.
ultralight::String32::operator[]
const char32_t & operator[](size_t pos) const
Get character at specific position (const).
Definition
String32.h:71
ultralight::String32::operator+=
String32 & operator+=(const String32 &other)
Append a String32 to this one.
ultralight::String32::data
char32_t * data()
Get raw UTF-32 data.
Definition
String32.h:50
ultralight::String32::operator=
String32 & operator=(const String32 &other)
Assign a String32 to this one, deep copy is made.
ultralight::String32::operator==
bool operator==(const String32 &other) const
Equality operator.
ultralight::String8
A null-terminated UTF-8 string container.
Definition
String8.h:17
ultralight
Root namespace for every public Ultralight type, function, and enumeration.
Ultralight
String32.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4