2017-03-06 07:49:24 +00:00
|
|
|
#include "String.hpp"
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2017-04-06 00:32:24 +00:00
|
|
|
#include "NodePath.hpp"
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
#include <godot/godot_string.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2017-04-17 22:38:09 +00:00
|
|
|
namespace godot {
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
godot::String::String()
|
|
|
|
{
|
|
|
|
godot_string_new(&_godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
String::String(const char *contents)
|
|
|
|
{
|
|
|
|
godot_string_new_data(&_godot_string, contents, strlen(contents));
|
|
|
|
}
|
|
|
|
|
|
|
|
String::String(const wchar_t *contents)
|
|
|
|
{
|
|
|
|
// @Todo
|
|
|
|
// godot_string_new_data(&_godot_string, contents, strlen(contents));
|
|
|
|
godot_string_new(&_godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
String::String(const wchar_t c)
|
|
|
|
{
|
|
|
|
// @Todo
|
|
|
|
godot_string_new(&_godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
String::String(const String& other)
|
|
|
|
{
|
2017-06-18 11:21:18 +00:00
|
|
|
godot_string_new_copy(&_godot_string, &other._godot_string);
|
2017-03-06 02:30:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String::~String()
|
|
|
|
{
|
|
|
|
godot_string_destroy(&_godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String String::substr(int p_from,int p_chars) const
|
|
|
|
{
|
|
|
|
return String(); // @Todo
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wchar_t &String::operator [](const int idx)
|
|
|
|
{
|
|
|
|
return *godot_string_operator_index(&_godot_string, idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
wchar_t String::operator [](const int idx) const
|
|
|
|
{
|
|
|
|
return *godot_string_operator_index((godot_string *) &_godot_string, idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
int String::length() const
|
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
godot_string_get_data(&_godot_string, nullptr, &len);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2017-03-18 14:23:28 +00:00
|
|
|
void String::operator =(const String &s)
|
|
|
|
{
|
2017-06-18 11:21:18 +00:00
|
|
|
godot_string_destroy(&_godot_string);
|
|
|
|
godot_string_new_copy(&_godot_string, &s._godot_string);
|
2017-03-18 14:23:28 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
bool String::operator ==(const String &s)
|
|
|
|
{
|
|
|
|
return godot_string_operator_equal(&_godot_string, &s._godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool String::operator !=(const String &s)
|
|
|
|
{
|
|
|
|
return !(*this == s);
|
|
|
|
}
|
|
|
|
|
|
|
|
String String::operator +(const String &s)
|
|
|
|
{
|
2017-06-18 11:21:18 +00:00
|
|
|
String new_string = *this;
|
|
|
|
godot_string_operator_plus(&new_string._godot_string, &s._godot_string);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
return new_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
void String::operator +=(const String &s)
|
|
|
|
{
|
2017-06-18 11:21:18 +00:00
|
|
|
godot_string_operator_plus(&_godot_string, &s._godot_string);
|
2017-03-06 02:30:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void String::operator +=(const wchar_t c)
|
|
|
|
{
|
|
|
|
// @Todo
|
|
|
|
}
|
|
|
|
|
|
|
|
bool String::operator <(const String &s)
|
|
|
|
{
|
|
|
|
return godot_string_operator_less(&_godot_string, &s._godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool String::operator <=(const String &s)
|
|
|
|
{
|
|
|
|
return godot_string_operator_less(&_godot_string, &s._godot_string) || (*this == s);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool String::operator >(const String &s)
|
|
|
|
{
|
|
|
|
return !(*this <= s);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool String::operator >=(const String &s)
|
|
|
|
{
|
|
|
|
return !(*this < s);
|
|
|
|
}
|
|
|
|
|
2017-04-06 00:32:24 +00:00
|
|
|
String::operator NodePath() const
|
|
|
|
{
|
|
|
|
return NodePath(*this);
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:48:26 +00:00
|
|
|
const char *String::c_string() const
|
2017-03-06 02:30:46 +00:00
|
|
|
{
|
|
|
|
return godot_string_c_str(&_godot_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
String operator +(const char *a, const String& b)
|
|
|
|
{
|
|
|
|
return String(a) + b;
|
|
|
|
}
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|