Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
String32.h
Go to the documentation of this file.
1 #pragma once
15 #include <Ultralight/Defines.h>
16 #include <stddef.h>
17 
18 namespace ultralight {
19 
23 class UExport String32 {
24 public:
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  ~String32();
35 
36  // Assign a String32 to this one, deep copy is made
37  String32& operator=(const String32& other);
38 
39  // Append a String32 to this one.
40  String32& operator+=(const String32& other);
41 
42  // Concatenation operator
43  inline friend String32 operator+(String32 lhs, const String32& rhs) { lhs += rhs; return lhs; }
44 
45  // Get raw UTF-32 data
46  char32_t* data() { return data_; }
47 
48  // Get raw UTF-32 data (const)
49  const char32_t* data() const { return data_; }
50 
51  // Get length in characters.
52  size_t length() const { return length_; }
53 
54  // Get size in characters (synonym for length)
55  size_t size() const { return length_; }
56 
57  // Check if string is empty.
58  bool empty() const { return !data_ || length_ == 0; }
59 
60  // Get character at specific position
61  char32_t& operator[](size_t pos) { return data_[pos]; }
62 
63  // Get character at specific position (const)
64  const char32_t& operator[](size_t pos) const { return data_[pos]; }
65 
66 private:
67  char32_t* data_;
68  size_t length_;
69 };
70 
71 } // namespace ultralight
A UTF-32 string container.
Definition: String32.h:23
This is a set of common JavaScriptCore Helper functions to simplify sample code.
Definition: App.h:19