MyScript Interactive Ink SDK 4.5.0
String.h
1// Copyright @ MyScript. All rights reserved.
2
3#pragma once
4
5#include <iink/APIVisibility.h>
6
7#include <string>
8
9namespace myscript {
10namespace iink {
11
16class String
17{
18public:
22 IINK_API String();
23
28 IINK_API String(const String& str);
29
34 IINK_API String(String&& str);
35
40 IINK_API String(const std::string& str);
41
46 IINK_API String(std::string&& str);
47
52 IINK_API String(const char* str);
53
58 IINK_API String(const std::u16string& str);
59
64 IINK_API String(std::u16string&& str);
65
70 IINK_API String(const char16_t* str);
71
72 IINK_API virtual ~String();
73
79 IINK_API String& operator=(const String& other);
80
86 IINK_API String& operator=(String&& other);
87
94 IINK_API bool isUtf8() const;
95
102 IINK_API bool isUtf16() const;
103
108 IINK_API bool isEmpty() const;
109
115 IINK_API size_t size() const;
116
124 IINK_API const char* c_str() const;
125
132 IINK_API String toUtf8() const;
133
140 IINK_API String toUtf16() const;
141
147 IINK_API const std::string& asUtf8() const;
148
153 IINK_API operator std::string() const;
154
159 IINK_API explicit operator std::u16string() const;
160
161 IINK_API int compare(const char* other) const;
162
163 IINK_API int compare(const std::string& other) const;
164
165 IINK_API int compare(const char16_t* other) const;
166
167 IINK_API int compare(const std::u16string& other) const;
168
169 IINK_API int compare(const String& other) const;
170
171 IINK_API bool operator==(const String& other) const;
172
173 IINK_API bool operator!=(const String& other) const;
174
175 IINK_API bool operator<(const String& other) const;
176
177 IINK_API bool operator<=(const String& other) const;
178
179 IINK_API bool operator>(const String& other) const;
180
181 IINK_API bool operator>=(const String& other) const;
182
183private:
184 std::string impl;
185};
186
187inline bool operator==(const String& s1, const char* s2) { return s1.compare(s2) == 0; }
188inline bool operator!=(const String& s1, const char* s2) { return s1.compare(s2) != 0; }
189inline bool operator< (const String& s1, const char* s2) { return s1.compare(s2) < 0; }
190inline bool operator<=(const String& s1, const char* s2) { return s1.compare(s2) <= 0; }
191inline bool operator> (const String& s1, const char* s2) { return s1.compare(s2) > 0; }
192inline bool operator>=(const String& s1, const char* s2) { return s1.compare(s2) >= 0; }
193
194inline bool operator==(const String& s1, const char16_t* s2) { return s1.compare(s2) == 0; }
195inline bool operator!=(const String& s1, const char16_t* s2) { return s1.compare(s2) != 0; }
196inline bool operator< (const String& s1, const char16_t* s2) { return s1.compare(s2) < 0; }
197inline bool operator<=(const String& s1, const char16_t* s2) { return s1.compare(s2) <= 0; }
198inline bool operator> (const String& s1, const char16_t* s2) { return s1.compare(s2) > 0; }
199inline bool operator>=(const String& s1, const char16_t* s2) { return s1.compare(s2) >= 0; }
200
201inline bool operator==(const String& s1, const std::string& s2) { return s1.compare(s2) == 0; }
202inline bool operator!=(const String& s1, const std::string& s2) { return s1.compare(s2) != 0; }
203inline bool operator< (const String& s1, const std::string& s2) { return s1.compare(s2) < 0; }
204inline bool operator<=(const String& s1, const std::string& s2) { return s1.compare(s2) <= 0; }
205inline bool operator> (const String& s1, const std::string& s2) { return s1.compare(s2) > 0; }
206inline bool operator>=(const String& s1, const std::string& s2) { return s1.compare(s2) >= 0; }
207
208inline bool operator==(const String& s1, const std::u16string& s2) { return s1.compare(s2) == 0; }
209inline bool operator!=(const String& s1, const std::u16string& s2) { return s1.compare(s2) != 0; }
210inline bool operator< (const String& s1, const std::u16string& s2) { return s1.compare(s2) < 0; }
211inline bool operator<=(const String& s1, const std::u16string& s2) { return s1.compare(s2) <= 0; }
212inline bool operator> (const String& s1, const std::u16string& s2) { return s1.compare(s2) > 0; }
213inline bool operator>=(const String& s1, const std::u16string& s2) { return s1.compare(s2) >= 0; }
214
215inline bool operator==(const char* s1, const String& s2) { return s2.compare(s1) == 0; }
216inline bool operator!=(const char* s1, const String& s2) { return s2.compare(s1) != 0; }
217inline bool operator< (const char* s1, const String& s2) { return s2.compare(s1) >= 0; }
218inline bool operator<=(const char* s1, const String& s2) { return s2.compare(s1) > 0; }
219inline bool operator> (const char* s1, const String& s2) { return s2.compare(s1) <= 0; }
220inline bool operator>=(const char* s1, const String& s2) { return s2.compare(s1) < 0; }
221
222inline bool operator==(const char16_t* s1, const String& s2) { return s2.compare(s1) == 0; }
223inline bool operator!=(const char16_t* s1, const String& s2) { return s2.compare(s1) != 0; }
224inline bool operator< (const char16_t* s1, const String& s2) { return s2.compare(s1) >= 0; }
225inline bool operator<=(const char16_t* s1, const String& s2) { return s2.compare(s1) > 0; }
226inline bool operator> (const char16_t* s1, const String& s2) { return s2.compare(s1) <= 0; }
227inline bool operator>=(const char16_t* s1, const String& s2) { return s2.compare(s1) < 0; }
228
229inline bool operator==(const std::string& s1, const String& s2) { return s2.compare(s1) == 0; }
230inline bool operator!=(const std::string& s1, const String& s2) { return s2.compare(s1) != 0; }
231inline bool operator< (const std::string& s1, const String& s2) { return s2.compare(s1) >= 0; }
232inline bool operator<=(const std::string& s1, const String& s2) { return s2.compare(s1) > 0; }
233inline bool operator> (const std::string& s1, const String& s2) { return s2.compare(s1) <= 0; }
234inline bool operator>=(const std::string& s1, const String& s2) { return s2.compare(s1) < 0; }
235
236inline bool operator==(const std::u16string& s1, const String& s2) { return s2.compare(s1) == 0; }
237inline bool operator!=(const std::u16string& s1, const String& s2) { return s2.compare(s1) != 0; }
238inline bool operator< (const std::u16string& s1, const String& s2) { return s2.compare(s1) >= 0; }
239inline bool operator<=(const std::u16string& s1, const String& s2) { return s2.compare(s1) > 0; }
240inline bool operator> (const std::u16string& s1, const String& s2) { return s2.compare(s1) <= 0; }
241inline bool operator>=(const std::u16string& s1, const String& s2) { return s2.compare(s1) < 0; }
242
243} // end of: namespace iink
244} // end of: namespace myscript
Definition: String.h:17
String(const std::string &str)
String(const std::u16string &str)
String(String &&str)
bool operator<(const String &other) const
String(const char16_t *str)
bool operator==(const String &other) const
int compare(const std::string &other) const
bool operator>(const String &other) const
const char * c_str() const
String(const char *str)
String(const String &str)
int compare(const char *other) const
int compare(const String &other) const
String(std::u16string &&str)
bool operator<=(const String &other) const
size_t size() const
String & operator=(String &&other)
String(std::string &&str)
int compare(const char16_t *other) const
int compare(const std::u16string &other) const
String toUtf8() const
String & operator=(const String &other)
String toUtf16() const
bool operator>=(const String &other) const
const std::string & asUtf8() const
bool operator!=(const String &other) const
bool operator<(const String &s1, const char *s2)
Definition: String.h:189
bool operator<=(const String &s1, const char *s2)
Definition: String.h:190
bool operator==(const String &s1, const char *s2)
Definition: String.h:187
bool operator>(const String &s1, const char *s2)
Definition: String.h:191
bool operator>=(const String &s1, const char *s2)
Definition: String.h:192
bool operator!=(const String &s1, const char *s2)
Definition: String.h:188
Definition: Configuration.h:10