41 #define STRING_IS_PROTECTED 0 50 STRING(
const char *
string);
51 STRING(
const char *data,
int length);
67 bool contains(
const char c)
const;
68 int32_t length()
const;
69 int32_t
size()
const {
return length(); }
72 const int32_t len = length();
74 return static_cast<uint32_t
>(len);
76 const char *string()
const;
77 const char *c_str()
const;
80 int32_t len = length() + 1;
81 return strncpy(
new char[len], GetCStr(), len);
84 #if STRING_IS_PROTECTED 85 const char &operator[] (int32_t index)
const;
87 void insert_range(int32_t index,
const char*s,
int len);
88 void erase_range(int32_t index,
int len);
90 char &operator[] (int32_t index)
const;
93 void truncate_at(int32_t index);
95 bool operator== (
const STRING &
string)
const;
96 bool operator!= (
const STRING &
string)
const;
97 bool operator!= (
const char *
string)
const;
99 STRING & operator= (
const char *
string);
103 STRING operator+ (
const char ch)
const;
105 STRING & operator+= (
const char *
string);
107 STRING & operator+= (
const char ch);
110 void assign(
const char *cstr,
int len);
116 void add_str_int(
const char* str,
int number);
118 void add_str_double(
const char* str,
double number);
121 inline void ensure(int32_t min_capacity) { ensure_cstr(min_capacity); }
163 #if STRING_IS_PROTECTED 164 return (GetHeader()->used_ == 0) ?
165 (string() ==
nullptr) : (GetHeader()->used_ == (strlen(
string()) + 1));
174 char* ensure_cstr(int32_t min_capacity);
176 void FixHeader()
const;
178 char* AllocData(
int used,
int capacity);
char * GetCStr()
Definition: strngs.h:157
void ensure(int32_t min_capacity)
Definition: strngs.h:121
Definition: serialis.h:77
Definition: baseapi.cpp:94
STRING_HEADER * data_
Definition: strngs.h:146
int32_t size() const
Definition: strngs.h:69
uint32_t unsigned_size() const
Definition: strngs.h:71
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:59
const STRING_HEADER * GetHeader() const
Definition: strngs.h:152
const char * GetCStr() const
Definition: strngs.h:159
bool InvariantOk() const
Definition: strngs.h:162
char * strdup() const
Definition: strngs.h:79
bool DeSerialize(FILE *fp, char *data, size_t n)
Definition: serialis.cpp:27
STRING_HEADER * GetHeader()
Definition: strngs.h:149