#include <cmt_string.h>
Public Types | |
enum | pos_type { npos = -1 } |
Public Member Functions | |
cmt_string () | |
cmt_string (int n) | |
cmt_string (char c) | |
cmt_string (const char *text) | |
cmt_string (const cmt_string &other) | |
~cmt_string () | |
cmt_string & | operator= (char c) |
cmt_string & | operator= (const char *text) |
cmt_string & | operator= (const cmt_string &other) |
bool | read (const cmt_string &file_name) |
bool | write (const cmt_string &file_name) const |
void | write (FILE *f) const |
void | write (ostream &output) |
operator const char * () const | |
const char * | c_str () const |
void | operator+= (char c) |
void | operator+= (const char *text) |
void | operator+= (const cmt_string &other) |
cmt_string | operator+ (char c) const |
cmt_string | operator+ (const char *text) const |
cmt_string | operator+ (const cmt_string &other) const |
char | operator[] (int index) const |
char & | operator[] (int index) |
int | size () const |
int | size () |
void | resize (int n) |
int | find (char c) const |
int | find (const char *text) const |
int | find (const cmt_string &other) const |
int | find (int pos, char c) const |
int | find (int pos, const char *text) const |
int | find (int pos, const cmt_string &other) const |
int | find_last_of (char c) const |
int | find_last_of (const char *text) const |
int | find_last_of (const cmt_string &other) const |
void | erase (int pos) |
void | erase (int pos, int length) |
void | replace (const char *pattern, const char *replacement) |
void | replace (const cmt_string &pattern, const cmt_string &replacement) |
void | replace_all (const char *pattern, const char *replacement) |
void | replace_all (const cmt_string &pattern, const cmt_string &replacement) |
void | trim () |
cmt_string | substr (int pos) const |
cmt_string | substr (int pos, int length) const |
void | substr (int pos, cmt_string &dest) const |
void | substr (int pos, int length, cmt_string &dest) const |
bool | operator< (const char *text) const |
bool | operator< (const cmt_string &other) const |
bool | operator== (const char *text) const |
bool | operator== (const cmt_string &other) const |
bool | compare_no_case (const char *text) const |
bool | compare_no_case (const cmt_string &other) const |
bool | operator!= (const char *text) const |
bool | operator!= (const cmt_string &other) const |
bool | operator> (const char *text) const |
bool | operator> (const cmt_string &other) const |
Private Member Functions | |
void | extend (int n) |
void | allocate (int n) |
Private Attributes | |
char * | _data |
int | _allocated |
int | _size |
|
Definition at line 16 of file cmt_string.h.
|
|
Definition at line 12 of file cmt_string.cxx. References _allocated, _data, and _size.
00013 { 00014 _data = 0; 00015 _allocated = 0; 00016 _size = 0; 00017 } |
|
Definition at line 19 of file cmt_string.cxx. References _allocated, _data, _size, and allocate().
00020 { 00021 _data = 0; 00022 _allocated = 0; 00023 _size = 0; 00024 allocate (n + 1); 00025 } |
|
Definition at line 27 of file cmt_string.cxx. References _allocated, _data, _size, and allocate().
|
|
Definition at line 40 of file cmt_string.cxx. References _allocated, _data, _size, and allocate().
00041 { 00042 _data = 0; 00043 _allocated = 0; 00044 _size = 0; 00045 00046 if (text != 0) 00047 { 00048 _size = strlen (text); 00049 allocate (_size + 1); 00050 strcpy (_data, text); 00051 } 00052 } |
|
Definition at line 54 of file cmt_string.cxx. References _allocated, _data, _size, and allocate().
|
|
Definition at line 70 of file cmt_string.cxx. References _allocated, _data, and _size.
00071 { 00072 if (_data != 0) 00073 { 00074 #ifdef CMT_USE_NEW_DELETE 00075 delete[] _data; 00076 #else 00077 free (_data); 00078 #endif 00079 } 00080 _data = 0; 00081 _allocated = 0; 00082 _size = 0; 00083 } |
|
Definition at line 670 of file cmt_string.cxx. References _allocated, and _data. Referenced by cmt_string(), extend(), operator=(), read(), and resize().
00671 { 00672 if ((n + 1) > _allocated) 00673 { 00674 static const int quantum = 128; 00675 int frames = ((n + 1)/quantum) + 1; 00676 _allocated = frames * quantum; 00677 00678 #ifdef CMT_USE_NEW_DELETE 00679 char* new_data = new char [_allocated + 1]; 00680 #else 00681 char* new_data = (char*) malloc (_allocated + 1); 00682 #endif 00683 00684 00685 if (_data != 0) 00686 { 00687 strcpy (new_data, _data); 00688 00689 #ifdef CMT_USE_NEW_DELETE 00690 delete[] _data; 00691 #else 00692 free (_data); 00693 #endif 00694 00695 _data = new_data; 00696 } 00697 else 00698 { 00699 new_data[0] = 0; 00700 } 00701 00702 _data = new_data; 00703 } 00704 } |
|
|
|
|
|
|
Definition at line 350 of file cmt_string.cxx.
00351 { 00352 if ((_data == 0) || 00353 (pos < 0) || 00354 (pos >= _size)) 00355 { 00356 return; 00357 } 00358 else 00359 { 00360 if ((pos + length) >= _size) 00361 { 00362 _data[pos] = 0; 00363 _size = pos; 00364 } 00365 else if (length > 0) 00366 { 00367 char* d = &_data[pos]; 00368 char* s = &_data[pos + length]; 00369 for (;;) 00370 { 00371 *d = *s; 00372 if (*s == 0) break; 00373 d++; 00374 s++; 00375 } 00376 _size -= length; 00377 } 00378 } 00379 } |
|
|
Definition at line 664 of file cmt_string.cxx. References _data, _size, and allocate(). Referenced by operator+=(), replace(), and replace_all().
|
|
Definition at line 297 of file cmt_string.cxx.
|
|
Definition at line 285 of file cmt_string.cxx. References _data, _size, and npos.
|
|
Definition at line 274 of file cmt_string.cxx. References _data, _size, and npos.
|
|
Definition at line 268 of file cmt_string.cxx.
|
|
Definition at line 258 of file cmt_string.cxx.
|
|
|
Definition at line 329 of file cmt_string.cxx. References _data, and find_last_of().
00330 { 00331 const char* text = other._data; 00332 return (find_last_of (text)); 00333 } |
|
Definition at line 312 of file cmt_string.cxx.
00313 { 00314 if (_data == 0) return (npos); 00315 if (text == 0) return (npos); 00316 00317 char* ptr = _data; 00318 char* last = 0; 00319 char* p; 00320 while ((p = strstr (ptr, text)) != 0) 00321 { 00322 last = p; 00323 ptr = p + 1; 00324 } 00325 if (last == 0) return (npos); 00326 return (last - _data); 00327 } |
|
|
Definition at line 131 of file cmt_string.cxx. References _data.
|
|
Definition at line 639 of file cmt_string.cxx. References _data.
00640 { 00641 const char* text = other._data; 00642 const cmt_string& me = *this; 00643 00644 return (me != text); 00645 } |
|
Definition at line 631 of file cmt_string.cxx.
00632 { 00633 const cmt_string& me = *this; 00634 00635 if (!(me == text)) return (true); 00636 return (false); 00637 } |
|
Definition at line 195 of file cmt_string.cxx. References _data.
00196 { 00197 cmt_string result (_data); 00198 result += other; 00199 00200 return (result); 00201 } |
|
Definition at line 187 of file cmt_string.cxx. References _data.
00188 { 00189 cmt_string result (_data); 00190 result += text; 00191 00192 return (result); 00193 } |
|
Definition at line 179 of file cmt_string.cxx. References _data.
00180 { 00181 cmt_string result (_data); 00182 result += c; 00183 00184 return (result); 00185 } |
|
Definition at line 171 of file cmt_string.cxx. References _data.
00172 { 00173 const char* text = other._data; 00174 cmt_string& me = *this; 00175 00176 me += text; 00177 } |
|
Definition at line 160 of file cmt_string.cxx. References _data, _size, and extend().
|
|
Definition at line 150 of file cmt_string.cxx. References _data, _size, and extend().
|
|
Definition at line 596 of file cmt_string.cxx. References _data.
00597 { 00598 const char* text = other._data; 00599 const cmt_string& me = *this; 00600 00601 return (me < text); 00602 } |
|
Definition at line 587 of file cmt_string.cxx. References _data.
00588 { 00589 if (text == 0) return (false); 00590 if (_data == 0) return (false); 00591 00592 if (strcmp (_data, text) < 0) return (true); 00593 return (false); 00594 } |
|
Definition at line 123 of file cmt_string.cxx. References _data.
00124 { 00125 const char* text = other._data; 00126 cmt_string& me = *this; 00127 me = text; 00128 return (me); 00129 } |
|
Definition at line 100 of file cmt_string.cxx. References _data, _size, and allocate().
00101 { 00102 if (text == _data) return (*this); 00103 00104 if (text != 0) 00105 { 00106 _size = strlen (text); 00107 allocate (_size + 1); 00108 strcpy (_data, text); 00109 } 00110 else 00111 { 00112 _size = 0; 00113 00114 if (_data != 0) 00115 { 00116 _data[0] = 0; 00117 } 00118 } 00119 00120 return (*this); 00121 } |
|
Definition at line 88 of file cmt_string.cxx. References _data, _size, and allocate().
|
|
Definition at line 623 of file cmt_string.cxx. References _data.
00624 { 00625 const char* text = other._data; 00626 const cmt_string& me = *this; 00627 00628 return (me == text); 00629 } |
|
Definition at line 604 of file cmt_string.cxx.
00605 { 00606 if (text == 0) 00607 { 00608 if (_data == 0) return (true); 00609 if (_size == 0) return (true); 00610 return (false); 00611 } 00612 if (_data == 0) 00613 { 00614 if (text == 0) return (true); 00615 if (text[0] == 0) return (true); 00616 return (false); 00617 } 00618 00619 if (strcmp (_data, text) == 0) return (true); 00620 return (false); 00621 } |
|
Definition at line 656 of file cmt_string.cxx. References _data.
00657 { 00658 const char* text = other._data; 00659 const cmt_string& me = *this; 00660 00661 return (me > text); 00662 } |
|
Definition at line 647 of file cmt_string.cxx. References _data.
00648 { 00649 if (text == 0) return (false); 00650 if (_data == 0) return (false); 00651 00652 if (strcmp (_data, text) > 0) return (true); 00653 return (false); 00654 } |
|
Definition at line 217 of file cmt_string.cxx.
|
|
Definition at line 203 of file cmt_string.cxx.
|
|
|
Definition at line 436 of file cmt_string.cxx. References _data, and replace().
00438 { 00439 const char* p_text = pattern._data; 00440 const char* r_text = replacement._data; 00441 cmt_string& me = *this; 00442 00443 me.replace (p_text, r_text); 00444 } |
|
Definition at line 382 of file cmt_string.cxx. References _data, _size, extend(), find(), and npos. Referenced by DependencyGenerator::add_line_to_text(), fragment_action_iterator::add_word(), LibraryGenerator::analyze_file(), Cmt::configure_current_cmtpath(), Cmt::do_broadcast(), DependencyAnalyzer::filter(), TriggerAnalyzer::filter(), SequenceRunner::filter(), CmtMountFilterParser::filter(), Prototyper::filter(), CvsImplementation::find_matching_version(), Use::get_cmtpath_and_offset(), CvsImplementation::get_cvs_infos_with_offset(), CvsImplementation::get_version(), header_file_action(), Use::reduce_path(), replace(), resolve_value_for_macros(), PackageSelector::run(), PAwk::run(), and suppress_OS_delimiters().
00383 { 00384 if (_data == 0) return; 00385 if (_size == 0) return; 00386 if (pattern == 0) return; 00387 00388 if (replacement == 0) replacement = ""; 00389 00390 if (pattern[0] == 0) return; 00391 00392 int pattern_length = strlen (pattern); 00393 00394 int replacement_length = strlen (replacement); 00395 int delta = replacement_length - pattern_length; 00396 00397 int pos; 00398 00399 if ((pos = find (pattern)) != npos) 00400 { 00401 if (delta > 0) 00402 { 00403 // string will be enlarged 00404 extend (delta); 00405 00406 char* src = &_data[_size]; 00407 char* dest = src + delta; 00408 while (src > &_data[pos]) 00409 { 00410 *dest = *src; 00411 src--; 00412 dest--; 00413 } 00414 } 00415 else if (delta < 0) 00416 { 00417 // string will be shortened 00418 00419 char* src = &_data[pos + pattern_length]; 00420 char* dest = src + delta; 00421 while (*src != 0) 00422 { 00423 *dest = *src; 00424 src++; 00425 dest++; 00426 } 00427 *dest = *src; 00428 } 00429 00430 strncpy (&_data[pos], replacement, replacement_length); 00431 00432 _size += delta; 00433 } 00434 } |
|
Definition at line 500 of file cmt_string.cxx. References _data, and replace_all().
00502 { 00503 const char* p_text = pattern._data; 00504 const char* r_text = replacement._data; 00505 cmt_string& me = *this; 00506 00507 me.replace_all (p_text, r_text); 00508 } |
|
Definition at line 446 of file cmt_string.cxx. References _data, _size, extend(), find(), and npos. Referenced by DepsBuilder::add_includes(), Symbol::all_set(), PathBuilder::build(), SetBuilder::build(), LibraryGenerator::build(), CvsImplementation::checkout(), PathBuilder::clean(), CmtSystem::compress_path(), CmtInstallAreaMgr::config(), Fragment::copy(), DependencyAnalyzer::DependencyAnalyzer(), CmtModel::display(), CMTPathManager::do_add_cmt_path(), Cmt::do_broadcast(), Cmt::do_build_CMT_pacman(), SyntaxParser::do_parse_line(), Pattern::expand(), CmtPathPattern::expand(), DependencyAnalyzer::filter(), CmtModel::filter(), Packager::filter(), WinDefAwk::filter(), CmtGenerator::filter_path(), CmtSystem::get_cmt_root(), CmtSystem::get_cmt_version(), CvsImplementation::get_cvs_infos(), CvsImplementation::get_cvs_infos_with_offset(), CvsImplementation::get_version(), CmtSystem::mkdir(), CmtSystem::now(), Cmt::print_context(), CmtSystem::reduce_file_separators(), replace_all(), resolve_value(), resolve_value_for_macros(), CvsImplementation::retreive_cvs_infos(), DepsBuilder::run(), PathScanner::scan_path(), ApplyPattern::show(), suppress_OS_delimiters(), CvsImplementation::tags(), and Fragment::wincopy().
00447 { 00448 if (_data == 0) return; 00449 if (_size == 0) return; 00450 if (pattern == 0) return; 00451 00452 if (replacement == 0) replacement = ""; 00453 00454 if (pattern[0] == 0) return; 00455 00456 int pattern_length = strlen (pattern); 00457 00458 int replacement_length = strlen (replacement); 00459 int delta = replacement_length - pattern_length; 00460 00461 int pos = 0; 00462 00463 while ((pos = find (pos, pattern)) != npos) 00464 { 00465 if (delta > 0) 00466 { 00467 // string will be enlarged 00468 extend (delta); 00469 00470 char* src = &_data[_size]; 00471 char* dest = src + delta; 00472 while (src > &_data[pos]) 00473 { 00474 *dest = *src; 00475 src--; 00476 dest--; 00477 } 00478 } 00479 else if (delta < 0) 00480 { 00481 // string will be shortened 00482 00483 char* src = &_data[pos + pattern_length]; 00484 char* dest = src + delta; 00485 while (*src != 0) 00486 { 00487 *dest = *src; 00488 src++; 00489 dest++; 00490 } 00491 *dest = *src; 00492 } 00493 00494 strncpy (&_data[pos], replacement, replacement_length); 00495 pos += replacement_length; 00496 _size += delta; 00497 } 00498 } |
|
Definition at line 244 of file cmt_string.cxx. References allocate().
00245 { 00246 allocate (n + 1); 00247 } |
|
Definition at line 238 of file cmt_string.cxx.
|
|
|
Definition at line 572 of file cmt_string.cxx. References _data, _size, and erase().
|
|
Definition at line 558 of file cmt_string.cxx.
|
|
Definition at line 542 of file cmt_string.cxx. References _data, _size, and erase().
00543 { 00544 if ((_data == 0) || 00545 (pos < 0) || 00546 (pos >= _size)) 00547 { 00548 return ((cmt_string) ""); 00549 } 00550 else 00551 { 00552 cmt_string result (&_data[pos]); 00553 result.erase (length); 00554 return (result); 00555 } 00556 } |
|
|
Definition at line 510 of file cmt_string.cxx. References _data, _size, erase(), and size(). Referenced by DependencyAnalyzer::filter().
00511 { 00512 if (size () == 0) return; 00513 00514 int i = 0; 00515 00516 i = strspn (_data, " \t"); 00517 if (i > 0) erase (0, i); 00518 00519 for (i = _size - 1; i >= 0; i--) 00520 { 00521 char c = _data[i]; 00522 if ((c == ' ') || (c == '\t')) continue; 00523 erase (i + 1); 00524 break; 00525 } 00526 } |
|
Definition at line 775 of file cmt_string.cxx.
00776 { 00777 output.write (&_data[0], size ()); 00778 } |
|
Definition at line 770 of file cmt_string.cxx.
00771 { 00772 fwrite (&_data[0], size (), 1, f); 00773 } |
|
Definition at line 755 of file cmt_string.cxx. References c_str(). Referenced by DependencyGenerator::build(), DefaultMakefileGenerator::build(), ProjectPatcher::commit(), Fragment::copy(), CvsImplementation::do_checkout_phase2(), Cmt::do_filter(), Cmt::do_set_version(), SequenceRunner::end(), SequenceRunner::filter(), install_library(), CmtLock::lock(), CvsImplementation::make_management_files(), and Fragment::wincopy().
|
|
Definition at line 111 of file cmt_string.h. Referenced by allocate(), cmt_string(), and ~cmt_string(). |
|
Definition at line 110 of file cmt_string.h. Referenced by allocate(), c_str(), cmt_string(), erase(), extend(), find(), find_last_of(), operator const char *(), operator!=(), operator+(), operator+=(), operator<(), operator=(), operator==(), operator>(), operator[](), read(), replace(), replace_all(), size(), substr(), trim(), write(), and ~cmt_string(). |
|
Definition at line 112 of file cmt_string.h. Referenced by cmt_string(), erase(), extend(), find(), operator+=(), operator=(), operator==(), operator[](), read(), replace(), replace_all(), size(), substr(), trim(), and ~cmt_string(). |