#include <strngs.h>
Definition at line 40 of file strngs.h.
| STRING::STRING |
( |
const STRING & |
string | ) |
|
Definition at line 103 of file strngs.cpp.
105 const STRING_HEADER* str_header = str.GetHeader();
106 int str_used = str_header->used_;
107 char *this_cstr = AllocData(str_used, str_used);
108 memcpy(this_cstr, str.GetCStr(), str_used);
109 assert(InvariantOk());
| STRING::STRING |
( |
const char * |
string | ) |
|
Definition at line 112 of file strngs.cpp.
117 int len = strlen(cstr) + 1;
118 char* this_cstr = AllocData(len, len);
119 memcpy(this_cstr, cstr, len);
121 assert(InvariantOk());
| void STRING::add_str_int |
( |
const char * |
str, |
|
|
int |
number |
|
) |
| |
| void STRING::assign |
( |
const char * |
cstr, |
|
|
int |
len |
|
) |
| |
Definition at line 365 of file strngs.cpp.
366 STRING_HEADER* this_header = GetHeader();
367 this_header->used_ = 0;
368 char* this_cstr = ensure_cstr(len + 1);
370 this_header = GetHeader();
371 memcpy(this_cstr, cstr, len);
372 this_cstr[len] =
'\0';
373 this_header->used_ = len + 1;
375 assert(InvariantOk());
| BOOL8 STRING::contains |
( |
const char |
c | ) |
const |
Definition at line 147 of file strngs.cpp.
148 return (c !=
'\0') && (strchr (GetCStr(), c) !=
NULL);
| bool STRING::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 137 of file strngs.cpp.
139 if (fread(&len,
sizeof(len), 1, fp) != 1)
return false;
143 if (fread(GetCStr(), 1, len, fp) != len)
return false;
void truncate_at(inT32 index)
void ReverseN(void *ptr, int num_bytes)
| void STRING::ensure |
( |
inT32 |
min_capacity | ) |
|
|
inline |
Definition at line 99 of file strngs.h.
99 { ensure_cstr(min_capacity); }
| inT32 STRING::length |
( |
| ) |
const |
Definition at line 151 of file strngs.cpp.
153 return GetHeader()->used_ - 1;
Definition at line 270 of file strngs.cpp.
273 const STRING_HEADER* str_header = str.GetHeader();
274 const STRING_HEADER* this_header = GetHeader();
275 int this_used = this_header->used_;
276 int str_used = str_header->used_;
278 return (this_used != str_used)
279 || (memcmp(GetCStr(), str.GetCStr(), this_used) != 0);
Definition at line 282 of file strngs.cpp.
284 const STRING_HEADER* this_header = GetHeader();
287 return this_header->used_ > 1;
290 return (this_header->used_ != length)
291 || (memcmp(GetCStr(), cstr, length) != 0);
Definition at line 378 of file strngs.cpp.
382 assert(InvariantOk());
| STRING STRING::operator+ |
( |
const char |
ch | ) |
const |
Definition at line 387 of file strngs.cpp.
390 const STRING_HEADER* this_header = GetHeader();
391 int this_used = this_header->used_;
392 char* result_cstr = result.ensure_cstr(this_used + 1);
393 STRING_HEADER* result_header = result.GetHeader();
394 int result_used = result_header->used_;
397 memcpy(result_cstr, GetCStr(), this_used);
398 result_cstr[result_used] = ch;
399 result_cstr[result_used + 1] =
'\0';
400 ++result_header->used_;
402 assert(InvariantOk());
| STRING & STRING::operator+= |
( |
const char * |
string | ) |
|
Definition at line 407 of file strngs.cpp.
412 int len = strlen(str) + 1;
413 int this_used = GetHeader()->used_;
414 char* this_cstr = ensure_cstr(this_used + len);
415 STRING_HEADER* this_header = GetHeader();
420 memcpy(this_cstr + this_used - 1, str, len);
421 this_header->used_ += len - 1;
423 memcpy(this_cstr, str, len);
424 this_header->used_ = len;
427 assert(InvariantOk());
Definition at line 311 of file strngs.cpp.
314 const STRING_HEADER* str_header = str.GetHeader();
315 const char* str_cstr = str.GetCStr();
316 int str_used = str_header->used_;
317 int this_used = GetHeader()->used_;
318 char* this_cstr = ensure_cstr(this_used + str_used);
320 STRING_HEADER* this_header = GetHeader();
323 memcpy(this_cstr + this_used - 1, str_cstr, str_used);
324 this_header->used_ += str_used - 1;
326 memcpy(this_cstr, str_cstr, str_used);
327 this_header->used_ = str_used;
330 assert(InvariantOk());
| STRING & STRING::operator+= |
( |
const char |
ch | ) |
|
Definition at line 432 of file strngs.cpp.
437 int this_used = GetHeader()->used_;
438 char* this_cstr = ensure_cstr(this_used + 1);
439 STRING_HEADER* this_header = GetHeader();
444 this_cstr[this_used++] = ch;
445 this_cstr[this_used++] =
'\0';
446 this_header->used_ = this_used;
448 assert(InvariantOk());
| STRING & STRING::operator= |
( |
const char * |
string | ) |
|
Definition at line 344 of file strngs.cpp.
345 STRING_HEADER* this_header = GetHeader();
347 int len = strlen(cstr) + 1;
349 this_header->used_ = 0;
350 char* this_cstr = ensure_cstr(len);
351 this_header = GetHeader();
352 memcpy(this_cstr, cstr, len);
353 this_header->used_ = len;
361 assert(InvariantOk());
Definition at line 295 of file strngs.cpp.
297 const STRING_HEADER* str_header = str.GetHeader();
298 int str_used = str_header->used_;
300 GetHeader()->used_ = 0;
301 char* this_cstr = ensure_cstr(str_used);
302 STRING_HEADER* this_header = GetHeader();
304 memcpy(this_cstr, str.GetCStr(), str_used);
305 this_header->used_ = str_used;
307 assert(InvariantOk());
| BOOL8 STRING::operator== |
( |
const STRING & |
string | ) |
const |
Definition at line 258 of file strngs.cpp.
261 const STRING_HEADER* str_header = str.GetHeader();
262 const STRING_HEADER* this_header = GetHeader();
263 int this_used = this_header->used_;
264 int str_used = str_header->used_;
266 return (this_used == str_used)
267 && (memcmp(GetCStr(), str.GetCStr(), this_used) == 0);
| char & STRING::operator[] |
( |
inT32 |
index | ) |
const |
Definition at line 230 of file strngs.cpp.
233 GetHeader()->used_ = -1;
234 return ((
char *)GetCStr())[index];
| bool STRING::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 129 of file strngs.cpp.
131 if (fwrite(&len,
sizeof(len), 1, fp) != 1)
return false;
132 if (fwrite(GetCStr(), 1, len, fp) != len)
return false;
| inT32 STRING::size |
( |
| ) |
const |
|
inline |
Definition at line 238 of file strngs.cpp.
240 for (
int i = 0; i <
length(); i++) {
241 if ((*
this)[i] == c) {
242 if (i != start_index) {
244 STRING tmp = GetCStr() + start_index;
252 if (
length() != start_index) {
253 STRING tmp = GetCStr() + start_index;
| char* STRING::strdup |
( |
| ) |
const |
|
inline |
Definition at line 59 of file strngs.h.
61 return strncpy(
new char[len], GetCStr(), len);
| const char * STRING::string |
( |
| ) |
const |
Definition at line 156 of file strngs.cpp.
157 const STRING_HEADER* header = GetHeader();
158 if (header->used_ == 0)
| void STRING::truncate_at |
( |
inT32 |
index | ) |
|
Definition at line 223 of file strngs.cpp.
224 char* this_cstr = ensure_cstr(index + 1);
225 this_cstr[index] =
'\0';
226 GetHeader()->used_ = index + 1;
227 assert(InvariantOk());
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/ccutil/strngs.h
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/ccutil/strngs.cpp