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
String8.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
String16
;
15
class
String32
;
16
17
///
18
/// A null-terminated UTF-8 string container.
19
//
20
class
UExport
String8
{
21
public
:
22
// Native character type
23
typedef
char
CharType
;
24
25
// Make an empty String8
26
String8
();
27
28
// Make a String8 from raw, null-terminated UTF-8 string
29
String8
(
const
char
* c_str);
30
31
// Make a String8 from raw UTF-8 string with certain length
32
String8
(
const
char
* c_str,
size_t
len);
33
34
// Make a deep copy of String8
35
String8
(
const
String8
& other);
36
37
// Move constructor
38
String8
(
String8
&& other);
39
40
// Destructor
41
~String8
();
42
43
// Assign a String8 to this one, deep copy is made
44
String8
&
operator=
(
const
String8
& other);
45
46
// Move assignment operator
47
String8
&
operator=
(
String8
&& other);
48
49
// Append a String8 to this one.
50
String8
&
operator+=
(
const
String8
& other);
51
52
// Concatenation operator
53
inline
friend
String8
operator+
(
String8
lhs,
const
String8
& rhs) { lhs += rhs;
return
lhs; }
54
55
// Get raw UTF-8 data
56
char
*
data
() {
return
data_; }
57
58
// Get raw UTF-8 data (const)
59
const
char
*
data
()
const
{
return
data_; }
60
61
// Get length in characters.
62
size_t
length
()
const
{
return
length_; }
63
64
// Get size in characters (synonym for length)
65
size_t
size
()
const
{
return
length_; }
66
67
// Get size in bytes
68
size_t
sizeBytes
()
const
{
return
length_ *
sizeof
(char); }
69
70
// Check if string is empty.
71
bool
empty
()
const
{
return
!data_ || length_ == 0; }
72
73
// Get character at specific position
74
char
&
operator[]
(
size_t
pos) {
return
data_[pos]; }
75
76
// Get character at specific position (const)
77
const
char
&
operator[]
(
size_t
pos)
const
{
return
data_[pos]; }
78
79
// Get a UTF-16 copy of this string
80
String16
utf16
()
const
;
81
82
// Get a UTF-32 copy of this string
83
String32
utf32
()
const
;
84
85
// Hash function
86
size_t
Hash
()
const
;
87
88
// Comparison operator
89
bool
operator<
(
const
String8
& other)
const
;
90
91
// Equality operator
92
bool
operator==
(
const
String8
& other)
const
;
93
94
// Inequality operator
95
bool
operator!=
(
const
String8
& other)
const
;
96
97
private
:
98
char
* data_;
99
size_t
length_;
100
};
101
102
}
// 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
A null-terminated UTF-32 string container.
Definition
String32.h:20
ultralight::String8::size
size_t size() const
Definition
String8.h:65
ultralight::String8::data
char * data()
Definition
String8.h:56
ultralight::String8::operator+=
String8 & operator+=(const String8 &other)
ultralight::String8::operator<
bool operator<(const String8 &other) const
ultralight::String8::utf16
String16 utf16() const
ultralight::String8::operator[]
const char & operator[](size_t pos) const
Definition
String8.h:77
ultralight::String8::empty
bool empty() const
Definition
String8.h:71
ultralight::String8::operator=
String8 & operator=(const String8 &other)
ultralight::String8::length
size_t length() const
Definition
String8.h:62
ultralight::String8::CharType
char CharType
Definition
String8.h:23
ultralight::String8::utf32
String32 utf32() const
ultralight::String8::String8
String8(const String8 &other)
ultralight::String8::String8
String8(const char *c_str, size_t len)
ultralight::String8::operator==
bool operator==(const String8 &other) const
ultralight::String8::~String8
~String8()
ultralight::String8::sizeBytes
size_t sizeBytes() const
Definition
String8.h:68
ultralight::String8::operator!=
bool operator!=(const String8 &other) const
ultralight::String8::data
const char * data() const
Definition
String8.h:59
ultralight::String8::operator=
String8 & operator=(String8 &&other)
ultralight::String8::String8
String8()
ultralight::String8::Hash
size_t Hash() const
ultralight::String8::String8
String8(String8 &&other)
ultralight::String8::String8
String8(const char *c_str)
ultralight::String8::operator[]
char & operator[](size_t pos)
Definition
String8.h:74
ultralight::String8::operator+
friend String8 operator+(String8 lhs, const String8 &rhs)
Definition
String8.h:53
ultralight
Definition
Bitmap.h:14
Ultralight
String8.h
Docs
C++ API
C API
Version
1.4
2.0
latest
1.4