summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarroffel <therzog@mail.de>2017-03-02 23:51:31 +0100
committerKarroffel <therzog@mail.de>2017-03-02 23:51:31 +0100
commit649bb3d0f589397ec7b633acba7efbcf2e50f4b8 (patch)
tree941cc3f3b937a4d7030d3a50a97698d06f9970c6
parentc5a7453a588dc5afa9a8ef768b069f067533c323 (diff)
downloadredot-cpp-649bb3d0f589397ec7b633acba7efbcf2e50f4b8.tar.gz
Added String.h
-rw-r--r--include/godot/core/String.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/godot/core/String.h b/include/godot/core/String.h
new file mode 100644
index 0000000..081788e
--- /dev/null
+++ b/include/godot/core/String.h
@@ -0,0 +1,102 @@
+#ifndef STRING_H
+#define STRING_H
+
+namespace godot {
+
+
+#include <godot/godot_string.h>
+
+#include <string.h>
+
+
+class String
+{
+ godot_string _godot_string;
+public:
+ String()
+ {
+ godot_string_new(&_godot_string);
+ }
+
+ String(const char *contents)
+ {
+ godot_string_new_data(&_godot_string, contents, strlen(contents));
+ }
+
+ String(const String& other)
+ {
+ godot_string_new(&_godot_string);
+ godot_string_copy_string(&_godot_string, &other._godot_string);
+ }
+
+ ~String()
+ {
+ godot_string_destroy(&_godot_string);
+ }
+
+
+
+ wchar_t &operator [](const int idx)
+ {
+ return *godot_string_operator_index(&_godot_string, idx);
+ }
+
+ int length() const
+ {
+ int len = 0;
+ godot_string_get_data(&_godot_string, nullptr, &len);
+ return len;
+ }
+
+ bool operator ==(const String &s)
+ {
+ return godot_string_operator_equal(&_godot_string, &s._godot_string);
+ }
+
+ bool operator !=(const String &s)
+ {
+ return !(*this == s);
+ }
+
+ String operator +(const String &s)
+ {
+ String new_string;
+ godot_string_operator_plus(&new_string._godot_string, &_godot_string, &s._godot_string);
+
+ return new_string;
+ }
+
+ bool operator <(const String &s)
+ {
+ return godot_string_operator_less(&_godot_string, &s._godot_string);
+ }
+
+ bool operator <=(const String &s)
+ {
+ return godot_string_operator_less(&_godot_string, &s._godot_string) || (*this == s);
+ }
+
+ bool operator >(const String &s)
+ {
+ return !(*this <= s);
+ }
+
+ bool operator >=(const String &s)
+ {
+ return !(*this < s);
+ }
+
+ const wchar_t *c_string()
+ {
+ return godot_string_c_str(&_godot_string);
+ }
+
+};
+
+
+
+}
+
+
+
+#endif // STRING_H