Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
String.h
Go to the documentation of this file.
1/******************************************************************************
2 * This file is a part of Ultralight, an ultra-portable web-browser engine. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2023 Ultralight, Inc. *
7 *****************************************************************************/
8#pragma once
10#include <Ultralight/String8.h>
11#include <Ultralight/String16.h>
12#include <Ultralight/String32.h>
13
14namespace ultralight {
15
16///
17/// @brief UTF-8 String container with conversions for UTF-16 and UTF-32.
18///
19/// @note Internally, all strings are represented as String8 (UTF-8).
20///
22public:
23 ///
24 /// Create empty string
25 ///
27
28 ///
29 /// Create from null-terminated, ASCII C-string
30 ///
31 String(const char* str);
32
33 ///
34 /// Create from raw, UTF-8 string with certain length
35 ///
36 String(const char* str, size_t len);
37
38 ///
39 /// Create from existing String8 (UTF-8).
40 ///
41 String(const String8& str);
42
43 ///
44 /// Create from raw UTF-16 string with certain length
45 ///
46 String(const Char16* str, size_t len);
47
48 ///
49 /// Create from existing String16 (UTF-16)
50 ///
51 String(const String16& str);
52
53 ///
54 /// Create from existing String32 (UTF-32)
55 ///
56 String(const String32& str);
57
58 ///
59 /// Copy constructor
60 ///
61 String(const String& other);
62
63 ///
64 /// Destructor
65 ///
67
68 ///
69 /// Assign string from another, copy is made
70 ///
71 String& operator=(const String& other);
72
73 ///
74 /// Append string with another
75 ///
76 String& operator+=(const String& other);
77
78 ///
79 /// Concatenation operator
80 ///
81 inline friend String operator+(String lhs, const String& rhs) { lhs += rhs; return lhs; }
82
83 ///
84 /// Get native UTF-8 string
85 ///
86 String8& utf8() { return str_; }
87
88 ///
89 /// Get native UTF-8 string
90 ///
91 const String8& utf8() const { return str_; }
92
93 ///
94 /// Convert to UTF-16 string
95 ///
96 String16 utf16() const;
97
98 ///
99 /// Convert to UTF-32 string
100 ///
102
103 ///
104 /// Check if string is empty or not
105 ///
106 bool empty() const { return str_.empty(); }
107
108private:
109 String8 str_;
110};
111
112
113} // namespace ultralight
114
#define UExport
Definition Defines.h:65
A UTF-16 string container.
Definition String16.h:35
A UTF-32 string container.
Definition String32.h:20
A UTF-8 string container.
Definition String8.h:20
UTF-8 String container with conversions for UTF-16 and UTF-32.
Definition String.h:21
friend String operator+(String lhs, const String &rhs)
Concatenation operator.
Definition String.h:81
String(const String8 &str)
Create from existing String8 (UTF-8).
String(const char *str)
Create from null-terminated, ASCII C-string.
String(const Char16 *str, size_t len)
Create from raw UTF-16 string with certain length.
String(const char *str, size_t len)
Create from raw, UTF-8 string with certain length.
bool empty() const
Check if string is empty or not.
Definition String.h:106
String()
Create empty string.
String & operator=(const String &other)
Assign string from another, copy is made.
const String8 & utf8() const
Get native UTF-8 string.
Definition String.h:91
String(const String &other)
Copy constructor.
String32 utf32() const
Convert to UTF-32 string.
String(const String16 &str)
Create from existing String16 (UTF-16)
String8 & utf8()
Get native UTF-8 string.
Definition String.h:86
String(const String32 &str)
Create from existing String32 (UTF-32)
~String()
Destructor.
String & operator+=(const String &other)
Append string with another.
String16 utf16() const
Convert to UTF-16 string.
Definition App.h:14
detail::selector< sizeof(wchar_t)>::Char16 Char16
Definition String16.h:29