#include <strngs.h>
Definition at line 45 of file strngs.h.
◆ STRING() [1/4]
◆ STRING() [2/4]
STRING::STRING |
( |
const STRING & |
string | ) |
|
Definition at line 106 of file strngs.cpp.
110 const STRING_HEADER* str_header = str.GetHeader();
111 const int str_used = str_header->used_;
112 char *this_cstr = AllocData(str_used, str_used);
113 memcpy(this_cstr, str.GetCStr(), str_used);
◆ STRING() [3/4]
STRING::STRING |
( |
const char * |
string | ) |
|
Definition at line 115 of file strngs.cpp.
118 if (cstr ==
nullptr) {
122 const int len = strlen(cstr) + 1;
123 char* this_cstr = AllocData(len, len);
124 memcpy(this_cstr, cstr, len);
◆ STRING() [4/4]
STRING::STRING |
( |
const char * |
data, |
|
|
int |
length |
|
) |
| |
Definition at line 127 of file strngs.cpp.
130 if (data ==
nullptr) {
135 memcpy(this_cstr, data,
length);
◆ ~STRING()
◆ add_str_double()
void STRING::add_str_double |
( |
const char * |
str, |
|
|
double |
number |
|
) |
| |
Definition at line 380 of file strngs.cpp.
386 std::stringstream stream;
388 stream.imbue(std::locale::classic());
◆ add_str_int()
void STRING::add_str_int |
( |
const char * |
str, |
|
|
int |
number |
|
) |
| |
◆ assign()
void STRING::assign |
( |
const char * |
cstr, |
|
|
int |
len |
|
) |
| |
Definition at line 413 of file strngs.cpp.
417 STRING_HEADER* this_header = GetHeader();
418 this_header->used_ = 0;
419 char* this_cstr = ensure_cstr(len + 1);
421 this_header = GetHeader();
422 memcpy(this_cstr, cstr, len);
423 this_cstr[len] =
'\0';
424 this_header->used_ = len + 1;
◆ c_str()
const char * STRING::c_str |
( |
| ) |
const |
Definition at line 192 of file strngs.cpp.
195 const STRING_HEADER* header = GetHeader();
196 if (!header || header->used_ == 0)
◆ contains()
bool STRING::contains |
( |
char |
c | ) |
const |
◆ DeSerialize() [1/2]
bool STRING::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 157 of file strngs.cpp.
165 if (len > UINT16_MAX)
return false;
◆ DeSerialize() [2/2]
◆ ensure()
void STRING::ensure |
( |
int32_t |
min_capacity | ) |
|
|
inline |
Definition at line 121 of file strngs.h.
123 ensure_cstr(min_capacity);
◆ length()
int32_t STRING::length |
( |
| ) |
const |
◆ operator!=() [1/2]
Definition at line 318 of file strngs.cpp.
323 const STRING_HEADER* this_header = GetHeader();
326 return this_header->used_ > 1;
328 const int32_t
length = strlen(cstr) + 1;
329 return (this_header->used_ !=
length)
◆ operator!=() [2/2]
Definition at line 306 of file strngs.cpp.
312 const STRING_HEADER* str_header = str.GetHeader();
313 const STRING_HEADER* this_header = GetHeader();
314 const int this_used = this_header->used_;
315 const int str_used = str_header->used_;
◆ operator+() [1/2]
STRING STRING::operator+ |
( |
char |
ch | ) |
const |
Definition at line 435 of file strngs.cpp.
441 const STRING_HEADER* this_header = GetHeader();
442 const int this_used = this_header->used_;
443 char* result_cstr = result.ensure_cstr(this_used + 1);
444 STRING_HEADER* result_header = result.GetHeader();
445 const int result_used = result_header->used_;
448 memcpy(result_cstr, GetCStr(), this_used);
449 result_cstr[result_used] = ch;
450 result_cstr[result_used + 1] =
'\0';
451 ++result_header->used_;
◆ operator+() [2/2]
◆ operator+=() [1/3]
STRING & STRING::operator+= |
( |
char |
ch | ) |
|
Definition at line 480 of file strngs.cpp.
488 int this_used = GetHeader()->used_;
489 char* this_cstr = ensure_cstr(this_used + 1);
490 STRING_HEADER* this_header = GetHeader();
495 this_cstr[this_used++] = ch;
496 this_cstr[this_used++] =
'\0';
497 this_header->used_ = this_used;
◆ operator+=() [2/3]
STRING & STRING::operator+= |
( |
const char * |
string | ) |
|
Definition at line 455 of file strngs.cpp.
463 const int len = strlen(str) + 1;
464 const int this_used = GetHeader()->used_;
465 char* this_cstr = ensure_cstr(this_used + len);
466 STRING_HEADER* this_header = GetHeader();
471 memcpy(this_cstr + this_used - 1, str, len);
472 this_header->used_ += len - 1;
474 memcpy(this_cstr, str, len);
475 this_header->used_ = len;
◆ operator+=() [3/3]
Definition at line 347 of file strngs.cpp.
353 const STRING_HEADER* str_header = str.GetHeader();
354 const char* str_cstr = str.GetCStr();
355 const int str_used = str_header->used_;
356 const int this_used = GetHeader()->used_;
357 char* this_cstr = ensure_cstr(this_used + str_used);
359 STRING_HEADER* this_header = GetHeader();
362 memcpy(this_cstr + this_used - 1, str_cstr, str_used);
363 this_header->used_ += str_used - 1;
365 memcpy(this_cstr, str_cstr, str_used);
366 this_header->used_ = str_used;
◆ operator=() [1/2]
STRING & STRING::operator= |
( |
const char * |
string | ) |
|
Definition at line 392 of file strngs.cpp.
396 STRING_HEADER* this_header = GetHeader();
398 const int len = strlen(cstr) + 1;
400 this_header->used_ = 0;
401 char* this_cstr = ensure_cstr(len);
402 this_header = GetHeader();
403 memcpy(this_cstr, cstr, len);
404 this_header->used_ = len;
◆ operator=() [2/2]
Definition at line 331 of file strngs.cpp.
336 const STRING_HEADER* str_header = str.GetHeader();
337 const int str_used = str_header->used_;
339 GetHeader()->used_ = 0;
340 char* this_cstr = ensure_cstr(str_used);
341 STRING_HEADER* this_header = GetHeader();
343 memcpy(this_cstr, str.GetCStr(), str_used);
344 this_header->used_ = str_used;
◆ operator==()
bool STRING::operator== |
( |
const STRING & |
string | ) |
const |
Definition at line 294 of file strngs.cpp.
300 const STRING_HEADER* str_header = str.GetHeader();
301 const STRING_HEADER* this_header = GetHeader();
302 const int this_used = this_header->used_;
303 const int str_used = str_header->used_;
◆ operator[]()
char & STRING::operator[] |
( |
int32_t |
index | ) |
const |
◆ Serialize() [1/2]
bool STRING::Serialize |
( |
FILE * |
fp | ) |
const |
◆ Serialize() [2/2]
◆ size()
int32_t STRING::size |
( |
| ) |
const |
|
inline |
◆ SkipDeSerialize()
◆ split()
Definition at line 275 of file strngs.cpp.
281 for (
int i = 0; i < len; i++) {
282 if ((*
this)[i] == c) {
283 if (i != start_index) {
292 if (len != start_index) {
◆ strdup()
char* STRING::strdup |
( |
| ) |
const |
|
inline |
Definition at line 79 of file strngs.h.
81 int32_t len =
length() + 1;
82 return strncpy(
new char[len], GetCStr(), len);
◆ truncate_at()
void STRING::truncate_at |
( |
int32_t |
index | ) |
|
Definition at line 258 of file strngs.cpp.
264 char* this_cstr = ensure_cstr(index + 1);
265 this_cstr[index] =
'\0';
◆ unsigned_size()
uint32_t STRING::unsigned_size |
( |
| ) |
const |
|
inline |
Definition at line 72 of file strngs.h.
74 const int32_t len =
length();
76 return static_cast<uint32_t>(len);
The documentation for this class was generated from the following files: