8 #ifndef _RNBO_String_H_
9 #define _RNBO_String_H_
11 #include "RNBO_PlatformInterface.h"
25 String() : _ptr(new char[1]), _len(0), _truelen(1) { _ptr[0] =
'\0'; }
32 String(
const char* str) : _ptr(nullptr), _len(0), _truelen(0) { copy(str); }
39 String(
String const& str) : _ptr(nullptr), _len(0), _truelen(0) { copy(str._ptr); }
51 size_t len()
const {
return _len; }
56 void clear() {
if (_ptr) _ptr[0] =
'\0'; _len = 0; }
64 bool empty()
const {
return _len == 0; }
72 size_t alen = Platform::get()->strlen(astr);
73 size_t newlen = alen + _len;
75 if (newlen >= _truelen) {
78 if (_truelen < 16) _truelen = 16;
79 while (newlen >= _truelen)
81 _ptr =
new char[_truelen];
82 Platform::get()->memcpy(_ptr, oldptr, _len);
86 Platform::get()->memcpy(_ptr + _len, astr, alen);
105 const char*
c_str()
const {
return const_cast<const char*
>(_ptr); }
160 return Platform::get()->strcmp(_ptr, other._ptr) == 0;
171 return (Platform::get()->strcmp(_ptr, other._ptr)) < 0 ? true :
false;
182 return (Platform::get()->strcmp(_ptr, other._ptr)) > 0 ? true :
false;
189 int copy(
const char* origin) {
209 newstr->
append(str2._ptr);
225 const char* str = k.
c_str();
232 #endif // #ifndef _RNBO_String_H_