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