Main Page ? Class Hierarchy ? Compound List ? File List ? Compound Members ? File Members ?

cmt_string Class Reference

#include <cmt_string.h>

List of all members.


Public Types

enum ? pos_type { npos = -1 }

Public Methods

? 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 Methods

void? extend (int n)
void? allocate (int n)

Private Attributes

char *? _data
int? _allocated
int? _size

Member Enumeration Documentation

enum cmt_string::pos_type
?

Enumeration values:
npos?

Definition at line 10 of file cmt_string.h.

00011     {
00012       npos = -1
00013     } pos_type;

Constructor & Destructor Documentation

cmt_string::cmt_string (? ? )?
?

Definition at line 7 of file cmt_string.cxx.

References _allocated, _data, and _size.

00008 {
00009   _data = 0;
00010   _allocated = 0;
00011   _size = 0;
00012 }

cmt_string::cmt_string (? int? ? n )?
?

Definition at line 14 of file cmt_string.cxx.

References _allocated, _data, _size, and allocate().

00015 {
00016   _data = 0;
00017   _allocated = 0;
00018   _size = 0;
00019   allocate (n + 1);
00020 }

cmt_string::cmt_string (? char? ? c )?
?

Definition at line 22 of file cmt_string.cxx.

References _allocated, _data, _size, and allocate().

00023 {
00024   _data = 0;
00025   _allocated = 0;
00026   _size = 0;
00027 
00028   allocate (2);
00029 
00030   _data[0] = c;
00031   _data[1] = 0;
00032   _size = 1;
00033 }

cmt_string::cmt_string (? const char *? ? text )?
?

Definition at line 35 of file cmt_string.cxx.

References _allocated, _data, _size, and allocate().

00036 {
00037   _data = 0;
00038   _allocated = 0;
00039   _size = 0;
00040 
00041   if (text != 0)
00042     {
00043       _size = strlen (text);
00044       allocate (_size + 1);
00045       strcpy (_data, text);
00046     }
00047 }

cmt_string::cmt_string (? const cmt_string &? ? other )?
?

Definition at line 49 of file cmt_string.cxx.

References _allocated, _data, _size, and allocate().

00050 {
00051   const char* text = other._data;
00052 
00053   _data = 0;
00054   _allocated = 0;
00055   _size = 0;
00056 
00057   if (text != 0)
00058     {
00059       _size = strlen (text);
00060       allocate (_size + 1);
00061       strcpy (_data, text);
00062     }
00063 }

cmt_string::~cmt_string (? ? )?
?

Definition at line 65 of file cmt_string.cxx.

References _allocated, _data, and _size.

00066 {
00067   if (_data != 0)
00068     {
00069 #ifdef CMT_USE_NEW_DELETE
00070       delete[] _data;
00071 #else
00072       free (_data);
00073 #endif
00074     }
00075   _data = 0;
00076   _allocated = 0;
00077   _size = 0;
00078 }

Member Function Documentation

void cmt_string::allocate (? int? ? n )? [private]
?

Definition at line 665 of file cmt_string.cxx.

References _allocated, and _data.

Referenced by cmt_string(), extend(), operator=(), read(), and resize().

00666 {
00667   if ((n + 1) > _allocated)
00668     {
00669       static const int quantum = 128;
00670       int frames = ((n + 1)/quantum) + 1;
00671       _allocated = frames * quantum;
00672 
00673 #ifdef CMT_USE_NEW_DELETE
00674       char* new_data = new char [_allocated + 1];
00675 #else
00676       char* new_data = (char*) malloc (_allocated + 1);
00677 #endif
00678 
00679 
00680       if (_data != 0)
00681         {
00682           strcpy (new_data, _data);
00683 
00684 #ifdef CMT_USE_NEW_DELETE
00685           delete[] _data;
00686 #else
00687           free (_data);
00688 #endif
00689 
00690           _data = new_data;
00691         }
00692       else
00693         {
00694           new_data[0] = 0;
00695         }
00696 
00697       _data = new_data;
00698     }
00699 }

const char * cmt_string::c_str (? ? )?
?

Definition at line 132 of file cmt_string.cxx.

References _data.

Referenced by Prototyper::begin(), DependencyGenerator::build(), MakeSetupGenerator::build(), DefaultMakefileGenerator::build(), ReadmeGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), build_deps(), VSNETGenerator::build_project(), MSDEVGenerator::build_project(), VSNETGenerator::build_workspace(), MSDEVGenerator::build_workspace(), CmtSystem::cd(), CmtGenerator::check(), CmtGenerator::commit(), CmtSystem::compare_and_update_files(), CmtSystem::compare_files(), CmtSystem::create_symlink(), Cmt::do_broadcast(), dos_script_prefix(), CmtSystem::execute(), Pattern::expand(), CmtPathPattern::expand(), CmtSystem::file_size(), Prototyper::filter(), Cmt::install_cleanup_scripts(), Cmt::install_setup_scripts(), Cmt::install_test_cleanup_scripts(), Cmt::install_test_setup_scripts(), CmtSystem::is_version_directory(), Cmt::load(), CmtSystem::mkdir(), Cmt::parser(), CmtGenerator::prepare_output(), CmtSystem::putenv(), read(), PackageSelector::run(), PAwk::run(), CmtSystem::scan_dir(), CmtSystem::split(), CmtSystem::test_directory(), CmtSystem::test_file(), and write().

00133 {
00134   if (_data == 0) return ("");
00135   else return (_data);
00136 }

bool cmt_string::compare_no_case (? const cmt_string &? ? other )? const
?

bool cmt_string::compare_no_case (? const char *? ? text )? const
?

void cmt_string::erase (? int? ? pos,
int? ? length
)?
?

Definition at line 345 of file cmt_string.cxx.

References _data, and _size.

00346 {
00347   if ((_data == 0) ||
00348       (pos < 0) ||
00349       (pos >= _size))
00350     {
00351       return;
00352     }
00353   else
00354     {
00355       if ((pos + length) >= _size)
00356         {
00357           _data[pos] = 0;
00358           _size = pos;
00359         }
00360       else if (length > 0)
00361         {
00362           char* d = &_data[pos];
00363           char* s = &_data[pos + length];
00364           for (;;)
00365             {
00366               *d = *s;
00367               if (*s == 0) break;
00368               d++;
00369               s++;
00370             }
00371           _size -= length;
00372         }
00373     }
00374 }

void cmt_string::erase (? int? ? pos )?
?

Definition at line 330 of file cmt_string.cxx.

References _data, and _size.

Referenced by ApplyPattern::action(), Language::action(), Script::add(), DepsBuilder::add(), add_cmt_paths(), DependencyGenerator::add_line_to_text(), CmtSystem::basename(), MacroBuilder::build(), SetBuilder::build(), ConstituentsMakefileGenerator::build(), ReadmeGenerator::build(), CmtGenerator::check(), CmtGenerator::commit(), CmtSystem::compress_path(), CmtInstallAreaMgr::config(), Cmt::configure_current_package(), CmtSystem::dirname(), Cmt::do_broadcast(), Cmt::do_do(), SyntaxParser::do_parse_line(), SyntaxParser::do_parse_text(), Pattern::expand(), CmtModel::expand(), DependencyFilter::filter(), Packager::filter(), WinDefAwk::filter(), CvsImplementation::filter_dir(), CmtSystem::name(), Parser::parse(), Cmt::parse_arguments(), Parser::parse_line(), Use::reach_package(), CvsImplementation::really_checkout_package(), resolve_value(), resolve_value_for_macros(), ClientCollector::run(), CmtSystem::scan_dir(), PathScanner::scan_package(), PathScanner::scan_path(), use_action_iterator::set(), constituents_action_iterator::set(), Use::show_all(), substr(), suppress_OS_delimiters(), trim(), and Cmt::vector_to_string().

00331 {
00332   if ((_data == 0) ||
00333       (pos < 0) ||
00334       (pos >= _size))
00335     {
00336       return;
00337     }
00338   else
00339     {
00340       _data[pos] = 0;
00341       _size = pos;
00342     }
00343 }

void cmt_string::extend (? int? ? n )? [private]
?

Definition at line 659 of file cmt_string.cxx.

References _data, _size, and allocate().

Referenced by operator+=(), replace(), and replace_all().

00660 {
00661   if (_data != 0) n += _size;
00662   allocate (n);
00663 }

int cmt_string::find (? int? ? pos,
const cmt_string &? ? other
)? const
?

Definition at line 292 of file cmt_string.cxx.

References _data, and find().

00293 {
00294   const char* text = other._data;
00295   return (find (pos, text));
00296 }

int cmt_string::find (? int? ? pos,
const char *? ? text
)? const
?

Definition at line 280 of file cmt_string.cxx.

References _data, and _size.

00281 {
00282   if (_data == 0) return (npos);
00283   if (text == 0) return (npos);
00284   if (pos < 0) return (npos);
00285   if (pos >= _size) return (npos);
00286 
00287   char* p = strstr (&_data[pos], text);
00288   if (p == 0) return (npos);
00289   return (p - _data);
00290 }

int cmt_string::find (? int? ? pos,
char? ? c
)? const
?

Definition at line 269 of file cmt_string.cxx.

References _data, and _size.

00270 {
00271   if (_data == 0) return (npos);
00272   if (pos < 0) return (npos);
00273   if (pos >= _size) return (npos);
00274 
00275   char* p = strchr (&_data[pos], c);
00276   if (p == 0) return (npos);
00277   return (p - _data);
00278 }

int cmt_string::find (? const cmt_string &? ? other )? const
?

Definition at line 263 of file cmt_string.cxx.

References _data, and find().

00264 {
00265   const char* text = other._data;
00266   return (find (text));
00267 }

int cmt_string::find (? const char *? ? text )? const
?

Definition at line 253 of file cmt_string.cxx.

References _data.

00254 {
00255   if (_data == 0) return (npos);
00256   if (text == 0) return (npos);
00257 
00258   char* p = strstr (_data, text);
00259   if (p == 0) return (npos);
00260   return (p - _data);
00261 }

int cmt_string::find (? char? ? c )? const
?

Definition at line 244 of file cmt_string.cxx.

References _data.

Referenced by Symbol::action(), ApplyPattern::action(), Tag::add(), Script::add(), Pattern::add(), CmtPathPattern::add(), add_cmt_paths(), DepsBuilder::add_includes(), DependencyGenerator::add_line_to_text(), DependencyFilter::add_source(), fragment_action_iterator::add_word(), CmtPathPattern::apply(), PathBuilder::build(), DependencyGenerator::build(), DefaultMakefileGenerator::build(), VSNETGenerator::build_project(), CvsImplementation::checkout_package(), PathBuilder::clean(), CmtSystem::compress_path(), CmtInstallAreaMgr::config(), Cmt::configure_current_package(), ProjectFactory::create_project(), Cmt::do_broadcast(), Cmt::do_do(), SyntaxParser::do_parse_text(), Pattern::expand(), CmtModel::expand(), DependencyAnalyzer::filter(), TriggerAnalyzer::filter(), CmtMountFilterParser::filter(), DependencyFilter::filter(), Prototyper::filter(), Packager::filter(), WinDefAwk::filter(), RecursivePass2::filter(), RecursivePass1::filter(), CvsImplementation::filter_dir(), find(), Project::find_in_cmt_paths(), CvsImplementation::find_matching_version(), find_path_entry(), CmtGenerator::get_all_files(), Project::get_current(), CvsImplementation::get_version(), CmtSystem::has_prefix(), DependencyFilter::has_source(), History::is_installed(), CmtSystem::is_version_directory(), Parser::parse(), Cmt::parse_arguments(), Parser::parse_line(), Script::print(), Use::reach_package(), CvsImplementation::really_checkout_package(), CmtSystem::reduce_file_separators(), replace(), replace_all(), resolve_value(), resolve_value_for_macros(), ClientCollector::run(), PAwk::run(), Awk::run(), CmtSystem::scan_dir(), PathScanner::scan_package(), PathScanner::scan_path(), constituents_action_iterator::set(), Libmap::set_used(), Project::show(), CvsImplementation::show_cvs_infos(), suppress_OS_delimiters(), and Fragment::wincopy().

00245 {
00246   if (_data == 0) return (npos);
00247 
00248   char* p = strchr (_data, c);
00249   if (p == 0) return (npos);
00250   return (p - _data);
00251 }

int cmt_string::find_last_of (? const cmt_string &? ? other )? const
?

Definition at line 324 of file cmt_string.cxx.

References _data, and find_last_of().

00325 {
00326   const char* text = other._data;
00327   return (find_last_of (text));
00328 }

int cmt_string::find_last_of (? const char *? ? text )? const
?

Definition at line 307 of file cmt_string.cxx.

References _data.

00308 {
00309   if (_data == 0) return (npos);
00310   if (text == 0) return (npos);
00311 
00312   char* ptr = _data;
00313   char* last = 0;
00314   char* p;
00315   while ((p = strstr (ptr, text)) != 0)
00316     {
00317       last = p;
00318       ptr = p + 1;
00319     }
00320   if (last == 0) return (npos);
00321   return (last - _data);
00322 }

int cmt_string::find_last_of (? char? ? c )? const
?

Definition at line 298 of file cmt_string.cxx.

References _data.

Referenced by CmtSystem::basename(), ReadmeGenerator::build(), VSNETGenerator::build_project(), CmtGenerator::check(), CmtGenerator::commit(), CmtSystem::compress_path(), CmtSystem::dirname(), SyntaxParser::do_parse_line(), DependencyAnalyzer::filter(), find_last_of(), CmtSystem::get_dot_suffix(), CmtSystem::get_suffix(), CmtSystem::name(), Parser::parse_line(), and Use::show_all().

00299 {
00300   if (_data == 0) return (npos);
00301 
00302   char* p = strrchr (_data, c);
00303   if (p == 0) return (npos);
00304   return (p - _data);
00305 }

cmt_string::operator const char * (? ? )?
?

Definition at line 126 of file cmt_string.cxx.

References _data.

00127 {
00128   if (_data == 0) return ("");
00129   else return (_data);
00130 }

bool cmt_string::operator!= (? const cmt_string &? ? other )? const
?

Definition at line 634 of file cmt_string.cxx.

References _data.

00635 {
00636   const char* text = other._data;
00637   const cmt_string& me = *this;
00638 
00639   return (me != text);
00640 }

bool cmt_string::operator!= (? const char *? ? text )? const
?

Definition at line 626 of file cmt_string.cxx.

00627 {
00628   const cmt_string& me = *this;
00629 
00630   if (!(me == text)) return (true);
00631   return (false);
00632 }

cmt_string cmt_string::operator+ (? const cmt_string &? ? other )? const
?

Definition at line 190 of file cmt_string.cxx.

References _data.

00191 {
00192   cmt_string result (_data);
00193   result += other;
00194 
00195   return (result);
00196 }

cmt_string cmt_string::operator+ (? const char *? ? text )? const
?

Definition at line 182 of file cmt_string.cxx.

References _data.

00183 {
00184   cmt_string result (_data);
00185   result += text;
00186 
00187   return (result);
00188 }

cmt_string cmt_string::operator+ (? char? ? c )? const
?

Definition at line 174 of file cmt_string.cxx.

References _data.

00175 {
00176   cmt_string result (_data);
00177   result += c;
00178 
00179   return (result);
00180 }

void cmt_string::operator+= (? const cmt_string &? ? other )?
?

Definition at line 166 of file cmt_string.cxx.

References _data.

00167 {
00168   const char* text = other._data;
00169   cmt_string& me = *this;
00170 
00171   me += text;
00172 }

void cmt_string::operator+= (? const char *? ? text )?
?

Definition at line 155 of file cmt_string.cxx.

References _data, _size, and extend().

00156 {
00157   if (text == 0) return;
00158 
00159   int s = strlen (text);
00160   extend (s + 1);
00161 
00162   strcat (&_data[_size], text);
00163   _size += s;
00164 }

void cmt_string::operator+= (? char? ? c )?
?

Definition at line 145 of file cmt_string.cxx.

References _data, _size, and extend().

00146 {
00147   extend (2);
00148 
00149   char temp[2] = { c, 0 };
00150 
00151   strcat (&_data[_size], temp);
00152   _size++;
00153 }

bool cmt_string::operator< (? const cmt_string &? ? other )? const
?

Definition at line 591 of file cmt_string.cxx.

References _data.

00592 {
00593   const char* text = other._data;
00594   const cmt_string& me = *this;
00595 
00596   return (me < text);
00597 }

bool cmt_string::operator< (? const char *? ? text )? const
?

Definition at line 582 of file cmt_string.cxx.

References _data.

00583 {
00584   if (text == 0) return (false);
00585   if (_data == 0) return (false);
00586 
00587   if (strcmp (_data, text) < 0) return (true);
00588   return (false);
00589 }

cmt_string & cmt_string::operator= (? const cmt_string &? ? other )?
?

Definition at line 118 of file cmt_string.cxx.

References _data.

00119 {
00120   const char* text = other._data;
00121   cmt_string& me = *this;
00122   me = text;
00123   return (me);
00124 }

cmt_string & cmt_string::operator= (? const char *? ? text )?
?

Definition at line 95 of file cmt_string.cxx.

References _data, _size, and allocate().

00096 {
00097   if (text == _data) return (*this);
00098 
00099   if (text != 0)
00100     {
00101       _size = strlen (text);
00102       allocate (_size + 1);
00103       strcpy (_data, text);
00104     }
00105   else
00106     {
00107       _size = 0;
00108 
00109       if (_data != 0)
00110         {
00111           _data[0] = 0;
00112         }
00113     }
00114 
00115   return (*this);
00116 }

cmt_string & cmt_string::operator= (? char? ? c )?
?

Definition at line 83 of file cmt_string.cxx.

References _data, _size, and allocate().

00084 {
00085   allocate (2);
00086 
00087   _data[0] = c;
00088   _data[1] = 0;
00089 
00090   _size = 1;
00091 
00092   return (*this);
00093 }

bool cmt_string::operator== (? const cmt_string &? ? other )? const
?

Definition at line 618 of file cmt_string.cxx.

References _data.

00619 {
00620   const char* text = other._data;
00621   const cmt_string& me = *this;
00622 
00623   return (me == text);
00624 }

bool cmt_string::operator== (? const char *? ? text )? const
?

Definition at line 599 of file cmt_string.cxx.

References _data, and _size.

00600 {
00601   if (text == 0)
00602     {
00603       if (_data == 0) return (true);
00604       if (_size == 0) return (true);
00605       return (false);
00606     }
00607   if (_data == 0)
00608     {
00609       if (text == 0) return (true);
00610       if (text[0] == 0) return (true);
00611       return (false);
00612     }
00613 
00614   if (strcmp (_data, text) == 0) return (true);
00615   return (false);
00616 }

bool cmt_string::operator> (? const cmt_string &? ? other )? const
?

Definition at line 651 of file cmt_string.cxx.

References _data.

00652 {
00653   const char* text = other._data;
00654   const cmt_string& me = *this;
00655 
00656   return (me > text);
00657 }

bool cmt_string::operator> (? const char *? ? text )? const
?

Definition at line 642 of file cmt_string.cxx.

References _data.

00643 {
00644   if (text == 0) return (false);
00645   if (_data == 0) return (false);
00646 
00647   if (strcmp (_data, text) > 0) return (true);
00648   return (false);
00649 }

char & cmt_string::operator[] (? int? ? index )?
?

Definition at line 212 of file cmt_string.cxx.

References _data, and _size.

00213 {
00214   if ((_data == 0) ||
00215       (index < 0) ||
00216       (index >= _size))
00217     {
00218       static char temp;
00219       return (temp);
00220     }
00221   else
00222     {
00223       return (_data[index]);
00224     }
00225 }

char cmt_string::operator[] (? int? ? index )? const
?

Definition at line 198 of file cmt_string.cxx.

References _data, and _size.

00199 {
00200   if ((_data == 0) ||
00201       (index < 0) ||
00202       (index >= _size))
00203     {
00204       return (0);
00205     }
00206   else
00207     {
00208       return (_data[index]);
00209     }
00210 }

bool cmt_string::read (? const cmt_string &? ? file_name )?
?

Definition at line 721 of file cmt_string.cxx.

References _data, _size, allocate(), c_str(), and size().

Referenced by add_cmt_paths(), DependencyGenerator::build(), DefaultMakefileGenerator::build(), CmtLock::check(), CvsImplementation::checkout_from_requirements(), CmtSystem::compare_and_update_files(), CmtSystem::compare_files(), CmtInstallAreaMgr::config(), Cmt::configure_current_package(), Fragment::copy(), Project::create(), ProjectFactory::create_project(), Cmt::do_awk(), Cmt::do_build_CMT_pacman(), Cmt::do_filter(), SyntaxParser::do_parse_requirements(), Cmt::do_remove(), Use::reach_package(), CvsImplementation::really_checkout_package(), ClientCollector::run(), FAwk::run(), PathScanner::scan_package(), PathScanner::scan_path(), and Fragment::wincopy().

00722 {
00723   FILE* f = fopen (file_name.c_str (), "rb");
00724   if (f != NULL)
00725     {
00726       fseek (f, 0L, SEEK_END);
00727       int size = ftell (f);
00728       fseek (f, 0L, SEEK_SET);
00729 
00730       allocate (size + 1);
00731 
00732       fread (&_data[0], size, 1, f);
00733 
00734       _data[size] = 0;
00735       _size = size;
00736 
00737       fclose (f);
00738 
00739       return (true);
00740     }
00741   else
00742     {
00743       cmt_string& me = *this;
00744       me = "";
00745 
00746       return (false);
00747     }
00748 }

void cmt_string::replace (? const cmt_string &? ? pattern,
const cmt_string &? ? replacement
)?
?

Definition at line 431 of file cmt_string.cxx.

References _data, and replace().

00433 {
00434   const char* p_text = pattern._data;
00435   const char* r_text = replacement._data;
00436   cmt_string& me = *this;
00437 
00438   me.replace (p_text, r_text);
00439 }

void cmt_string::replace (? const char *? ? pattern,
const char *? ? replacement
)?
?

Definition at line 377 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(), MacroBuilder::build(), VSNETGenerator::build_project(), 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_version(), header_file_action(), Use::reduce_path(), replace(), resolve_value_for_macros(), PackageSelector::run(), PAwk::run(), CvsImplementation::show_cvs_infos(), and suppress_OS_delimiters().

00378 {
00379   if (_data == 0) return;
00380   if (_size == 0) return;
00381   if (pattern == 0) return;
00382 
00383   if (replacement == 0) replacement = "";
00384 
00385   if (pattern[0] == 0) return;
00386 
00387   int pattern_length = strlen (pattern);
00388 
00389   int replacement_length = strlen (replacement);
00390   int delta = replacement_length - pattern_length;
00391 
00392   int pos;
00393 
00394   if ((pos = find (pattern)) != npos)
00395     {
00396       if (delta > 0)
00397         {
00398             // string will be enlarged
00399           extend (delta);
00400 
00401           char* src = &_data[_size];
00402           char* dest = src + delta;
00403           while (src > &_data[pos])
00404             {
00405               *dest = *src;
00406               src--;
00407               dest--;
00408             }
00409         }
00410       else if (delta < 0)
00411         {
00412             // string will be shortened
00413 
00414           char* src = &_data[pos + pattern_length];
00415           char* dest = src + delta;
00416           while (*src != 0)
00417             {
00418               *dest = *src;
00419               src++;
00420               dest++;
00421             }
00422           *dest = *src;
00423         }
00424 
00425       strncpy (&_data[pos], replacement, replacement_length);
00426 
00427       _size += delta;
00428     }
00429 }

void cmt_string::replace_all (? const cmt_string &? ? pattern,
const cmt_string &? ? replacement
)?
?

Definition at line 495 of file cmt_string.cxx.

References _data, and replace_all().

00497 {
00498   const char* p_text = pattern._data;
00499   const char* r_text = replacement._data;
00500   cmt_string& me = *this;
00501 
00502   me.replace_all (p_text, r_text);
00503 }

void cmt_string::replace_all (? const char *? ? pattern,
const char *? ? replacement
)?
?

Definition at line 441 of file cmt_string.cxx.

References _data, _size, extend(), find(), and npos.

Referenced by CmtSystem::add_cmt_path(), DepsBuilder::add_includes(), Symbol::all_set(), MacroBuilder::build(), PathBuilder::build(), SetBuilder::build(), LibraryGenerator::build(), CvsImplementation::checkout(), PathBuilder::clean(), CmtSystem::compress_path(), CmtInstallAreaMgr::config(), Fragment::copy(), DependencyAnalyzer::DependencyAnalyzer(), CmtModel::display(), 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(), find_path_entry(), CvsImplementation::get_version(), CmtSystem::mkdir(), CmtSystem::now(), Symbol::print(), Cmt::print_context(), CmtSystem::reduce_file_separators(), replace_all(), resolve_value(), resolve_value_for_macros(), DepsBuilder::run(), ApplyPattern::show(), CvsImplementation::show_cvs_infos(), suppress_OS_delimiters(), and Fragment::wincopy().

00442 {
00443   if (_data == 0) return;
00444   if (_size == 0) return;
00445   if (pattern == 0) return;
00446 
00447   if (replacement == 0) replacement = "";
00448 
00449   if (pattern[0] == 0) return;
00450 
00451   int pattern_length = strlen (pattern);
00452 
00453   int replacement_length = strlen (replacement);
00454   int delta = replacement_length - pattern_length;
00455 
00456   int pos = 0;
00457 
00458   while ((pos = find (pos, pattern)) != npos)
00459     {
00460       if (delta > 0)
00461         {
00462             // string will be enlarged
00463           extend (delta);
00464 
00465           char* src = &_data[_size];
00466           char* dest = src + delta;
00467           while (src > &_data[pos])
00468             {
00469               *dest = *src;
00470               src--;
00471               dest--;
00472             }
00473         }
00474       else if (delta < 0)
00475         {
00476             // string will be shortened
00477 
00478           char* src = &_data[pos + pattern_length];
00479           char* dest = src + delta;
00480           while (*src != 0)
00481             {
00482               *dest = *src;
00483               src++;
00484               dest++;
00485             }
00486           *dest = *src;
00487         }
00488 
00489       strncpy (&_data[pos], replacement, replacement_length);
00490       pos += replacement_length;
00491       _size += delta;
00492     }
00493 }

void cmt_string::resize (? int? ? n )?
?

Definition at line 239 of file cmt_string.cxx.

References allocate().

00240 {
00241   allocate (n + 1);
00242 }

int cmt_string::size (? ? )?
?

Definition at line 233 of file cmt_string.cxx.

References _data.

00234 {
00235   if (_data == 0) return (0);
00236   return (_size);
00237 }

int cmt_string::size (? ? )?
?

Definition at line 227 of file cmt_string.cxx.

References _data.

Referenced by CmtSystem::absolute_path(), Symbol::action(), ApplyPattern::action(), Tag::add(), DepsBuilder::add(), CmtSystem::add_cmt_path(), cmt_regexp::begin(), Cmt::build_makefile(), Cmt::build_prefix(), CmtSystem::cd(), Use::change_path(), cmt_char_list_node::cmt_char_list_node(), CmtSystem::compress_path(), DependencyAnalyzer::DependencyAnalyzer(), Cmt::do_broadcast(), Cmt::do_do(), SyntaxParser::do_parse_line(), SyntaxParser::do_parse_text(), SyntaxParser::do_parse_words(), get_best_form(), CmtSystem::has_device(), CmtSystem::is_version_directory(), cmt_or_node::match(), cmt_and_node::match(), cmt_end_node::match(), cmt_one_more::match(), cmt_zero_more::match(), cmt_zero_one::match(), cmt_any_node::match(), cmt_not_char_list_node::match(), cmt_char_list_node::match(), cmt_string_node::match(), cmt_char_node::match(), Parser::parse(), Cmt::parse_arguments(), Parser::parse_line(), Cmt::parser(), Symbol::print(), Include::print_filters(), VSNETGenerator::pseudoGUID(), Use::reach_package(), read(), cmt_and_node::reduce(), ClientCollector::run(), Awk::run(), CmtSystem::scan_dir(), cmt_regexp::set(), Symbol::show_macro(), CmtSystem::split(), trim(), Cmt::use_cmt(), Cmt::use_special_requirements(), Symbol::value_is_reflexive(), and write().

00228 {
00229   if (_data == 0) return (0);
00230   return (_size);
00231 }

void cmt_string::substr (? int? ? pos,
int? ? length,
cmt_string &? ? dest
)? const
?

Definition at line 567 of file cmt_string.cxx.

References _data, _size, and erase().

00568 {
00569   if ((_data == 0) ||
00570       (pos < 0) ||
00571       (pos >= _size))
00572     {
00573       dest = "";
00574     }
00575   else
00576     {
00577       dest = (const char*) &_data[pos];
00578       dest.erase (length);
00579     }
00580 }

void cmt_string::substr (? int? ? pos,
cmt_string &? ? dest
)? const
?

Definition at line 553 of file cmt_string.cxx.

References _data, and _size.

00554 {
00555   if ((_data == 0) ||
00556       (pos < 0) ||
00557       (pos >= _size))
00558     {
00559       dest = "";
00560     }
00561   else
00562     {
00563       dest = (const char*) &_data[pos];
00564     }
00565 }

cmt_string cmt_string::substr (? int? ? pos,
int? ? length
)? const
?

Definition at line 537 of file cmt_string.cxx.

References _data, _size, and erase().

00538 {
00539   if ((_data == 0) ||
00540       (pos < 0) ||
00541       (pos >= _size))
00542     {
00543       return ((cmt_string) "");
00544     }
00545   else
00546     {
00547       cmt_string result (&_data[pos]);
00548       result.erase (length);
00549       return (result);
00550     }
00551 }

cmt_string cmt_string::substr (? int? ? pos )? const
?

Definition at line 523 of file cmt_string.cxx.

References _data, and _size.

Referenced by ApplyPattern::action(), Language::action(), Tag::add(), DepsBuilder::add_includes(), DependencyGenerator::add_line_to_text(), CmtSystem::basename(), ConstituentsMakefileGenerator::build(), ReadmeGenerator::build(), VSNETGenerator::build_project(), CmtSystem::compress_path(), Cmt::do_broadcast(), Cmt::do_do(), SyntaxParser::do_parse_text(), dos_script_prefix(), CmtModel::expand(), DependencyAnalyzer::filter(), TriggerAnalyzer::filter(), SequenceRunner::filter(), CmtSystem::get_dot_suffix(), CmtSystem::get_suffix(), cmt_string_node::match(), Parser::parse(), Cmt::parse_arguments(), resolve_value(), resolve_value_for_macros(), ClientCollector::run(), Awk::run(), constituents_action_iterator::set(), Libmap::set_used(), suppress_OS_delimiters(), and Fragment::wincopy().

00524 {
00525   if ((_data == 0) ||
00526       (pos < 0) ||
00527       (pos >= _size))
00528     {
00529       return ((cmt_string) "");
00530     }
00531   else
00532     {
00533       return ((cmt_string) &_data[pos]);
00534     }
00535 }

void cmt_string::trim (? ? )?
?

Definition at line 505 of file cmt_string.cxx.

References _data, _size, erase(), and size().

Referenced by DependencyAnalyzer::filter().

00506 {
00507   if (size () == 0) return;
00508 
00509   int i = 0;
00510 
00511   i = strspn (_data, " \t");
00512   if (i > 0) erase (0, i);
00513 
00514   for (i = _size - 1; i >= 0; i--)
00515     {
00516       char c = _data[i];
00517       if ((c == ' ') || (c == '\t')) continue;
00518       erase (i + 1);
00519       break;
00520     }
00521 }

void cmt_string::write (? ostream &? ? output )?
?

Definition at line 770 of file cmt_string.cxx.

References _data, and size().

00771 {
00772   output.write (&_data[0], size ());
00773 }

void cmt_string::write (? FILE *? ? f )? const
?

Definition at line 765 of file cmt_string.cxx.

References _data, and size().

00766 {
00767   fwrite (&_data[0], size (), 1, f);
00768 }

bool cmt_string::write (? const cmt_string &? ? file_name )? const
?

Definition at line 750 of file cmt_string.cxx.

References c_str().

Referenced by DependencyGenerator::build(), DefaultMakefileGenerator::build(), CvsImplementation::checkout_package(), ProjectPatcher::commit(), Fragment::copy(), Cmt::do_filter(), Cmt::do_set_version(), SequenceRunner::end(), SequenceRunner::filter(), install_library(), CmtLock::lock(), CvsImplementation::really_checkout_package(), and Fragment::wincopy().

00751 {
00752   FILE* f = fopen (file_name.c_str (), "wb");
00753   if (f != NULL)
00754     {
00755       write (f);
00756       fclose (f);
00757       return (true);
00758     }
00759   else
00760     {
00761       return (false);
00762     }
00763 }

Member Data Documentation

int cmt_string::_allocated [private]
?

Definition at line 105 of file cmt_string.h.

Referenced by allocate(), cmt_string(), and ~cmt_string().

char* cmt_string::_data [private]
?

Definition at line 104 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().

int cmt_string::_size [private]
?

Definition at line 106 of file cmt_string.h.

Referenced by cmt_string(), erase(), extend(), find(), operator+=(), operator=(), operator==(), operator[](), read(), replace(), replace_all(), substr(), trim(), and ~cmt_string().


The documentation for this class was generated from the following files:
Generated on Thu Jul 1 15:26:38 2004 for CMT by 1.2.18