#include <String.h>
Public Member Functions | |
| String () | |
| String (const String &str) | |
| String (const char *str) | |
| String (const char c) | |
| String (const int) | |
| String (const long int) | |
| String (const double, const int digits=10, const string_double_t form=STRING_NORMAL_FORM) | |
| ~String () | |
| String & | operator= (const String &) |
| String & | operator= (const char) |
| String & | operator= (const char *) |
| String & | operator+= (const String &) |
| char | operator[] (int) const |
| String & | erase (const int pos, const int size=1) |
| String & | insert (const String &, const int pos=0) |
| int | find (const char c, const int start=0, const bool reverse=false) const |
| int | get_length () const |
| bool | is_empty () const |
| const char * | chars () const |
| char * | non_const_chars () const |
| char * | copy_chars () |
Private Member Functions | |
| void | allocate_array (const int size) |
| void | enlarge_array (const int size) |
Private Attributes | |
| char * | array |
| int | length |
| int | buf_size |
Friends | |
| String | operator+ (const String &, const String &) |
| int | operator== (const String &, const String &) |
| int | operator!= (const String &, const String &) |
| ostream & | operator<< (ostream &, const String &) |
| istream & | operator>> (istream &, String &) |
| int | str2int (const String &) |
| long | str2long (const String &) |
| double | str2dbl (const String &) |
| long | str2hex (const String &) |
| String | hex2str (const long) |
| String | get_segment (const String &str, const int start, const int end) |
| String | make_lower_case (const String &str) |
|
|
Definition at line 39 of file String.cc. References allocate_array(), array, buf_size, and length. 00040 {
00041 buf_size = 0;
00042 length = 0;
00043 allocate_array(0);
00044 array[0] = '\0';
00045 }
|
Here is the call graph for this function:

|
|
Definition at line 47 of file String.cc. References buf_size. 00048 {
00049 buf_size = 0;
00050 *this = str;
00051 }
|
|
|
Definition at line 53 of file String.cc. References buf_size. 00054 {
00055 buf_size = 0;
00056 *this = str;
00057 }
|
|
|
Definition at line 59 of file String.cc. References buf_size. 00060 {
00061 buf_size = 0;
00062 *this = c;
00063 }
|
|
|
Definition at line 65 of file String.cc. References allocate_array(), array, buf_size, erase(), and length. 00066 {
00067 // *this = String((long)n);
00068 buf_size = 0;
00069 length = 15;
00070 allocate_array(15);
00071 array[15] = '\0';
00072 int pos = 14;
00073
00074 int k = ( n>0 ? n : -n );
00075
00076 if( k == 0 )
00077 array[pos--] = '0';
00078 else
00079 for(; k > 0; k/=10) array[pos--] = '0' + k%10;
00080
00081 if( n < 0 )
00082 {
00083 array[0] = '-';
00084 erase(1, pos);
00085 }
00086 else
00087 erase(0, pos+1);
00088 }
|
Here is the call graph for this function:

|
|
Definition at line 90 of file String.cc. References allocate_array(), array, buf_size, erase(), and length. 00091 {
00092 buf_size = 0;
00093 length = 15;
00094 allocate_array(15);
00095 array[15] = '\0';
00096 int pos = 14;
00097
00098 int k = ( n>0 ? n : -n );
00099
00100 if( k == 0 )
00101 array[pos--] = '0';
00102 else
00103 for(; k > 0; k/=10) array[pos--] = '0' + k%10;
00104
00105 if( n < 0 )
00106 {
00107 array[0] = '-';
00108 erase(1, pos);
00109 }
00110 else
00111 erase(0, pos+1);
00112 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 114 of file String.cc. References allocate_array(), array, buf_size, and length. 00115 {
00116 if( form == STRING_NORMAL_FORM ) {
00117 // ss << setprecision(digits) << x << endl;
00118 // Problems with internationalisation
00119 // Fall back to good old shitty sprintf()
00120
00121 buf_size = 0;
00122 length = 15;
00123 allocate_array(15);
00124
00125 sprintf(array , "%f", x);
00126 }
00127 else {
00128 /*buf_size = 0;
00129 strstream ss;
00130 ss << (form == STRING_EXP_FORM ? setiosflags(ios::scientific) : setiosflags(ios::fixed))
00131 << setprecision(digits) << x << endl;
00132 ss >> *this;*/
00133 buf_size = 0;
00134 length = 15;
00135 allocate_array(15);
00136
00137 sprintf(array , "%e", x);
00138
00139 }
00140 }
|
Here is the call graph for this function:

|
|
Definition at line 142 of file String.cc. 00143 {
00144 delete [] array;
00145 }
|
|
|
Definition at line 148 of file String.cc. References array, and buf_size. Referenced by hex2str(), operator=(), and String(). 00149 {
00150 if( buf_size > 0 ) delete [] array;
00151 buf_size = (size / 8 + 1) * 8;
00152 array = new char[buf_size];
00153 }
|
|
|
|
Definition at line 392 of file String.cc. 00393 {
00394 char* str = new char[length+1];
00395
00396 strcpy(str, array);
00397
00398 return str;
00399 }
|
|
|
Definition at line 156 of file String.cc. References array, and buf_size. Referenced by get_segment(), insert(), and operator+=(). 00157 {
00158 if( buf_size <= size )
00159 {
00160 char* temp = array;
00161 buf_size = (size / 8 + 1) * 8;
00162 array = new char[buf_size];
00163 strcpy(array, temp);
00164 delete [] temp;
00165 }
00166 }
|
|
||||||||||||
|
Definition at line 237 of file String.cc. References array, Error(), and length. Referenced by entry_handler(), hex2str(), and String(). 00238 {
00239 if( pos < 0 || pos + size > length || size <= 0 ) Error(true, "String out of range", "String::erase");
00240
00241 strcpy(&array[pos], &array[pos+size]); // ???
00242 length -= size;
00243
00244 return *this;
00245 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 268 of file String.cc. Referenced by check_for_robots_and_arenas(), StartTournamentWindow::new_tournament(), Robot::Robot(), ArenaReplay::search_forward(), split_colonseparated_dirs(), and ArenaRealTime::start_game(). 00269 {
00270 char * ans;
00271
00272 int st = ( start < 0 ? length + start : start );
00273 if( st < 0 || st >= length ) return -1;
00274
00275 if(NULL != ( reverse ? (ans = strrchr(array + st, c)) : (ans = strchr(array+st, c))))
00276 return (int)(ans-array);
00277
00278 return -1;
00279 }
|
|
|
Definition at line 66 of file String.h. Referenced by check_for_robots_and_arenas(), check_if_filename_is_arena(), entry_handler(), ControlWindow::replay(), and split_colonseparated_dirs(). 00066 { return length; }
|
|
||||||||||||
|
Definition at line 248 of file String.cc. References array, enlarge_array(), Error(), and length. 00249 {
00250 if( pos < 0 || pos > length ) Error(true, "String out of range", "String::insert");
00251
00252 char temp[length - pos + 1];
00253 strcpy(temp, &array[pos]);
00254
00255 length += str.length;
00256 enlarge_array(length);
00257
00258 strcpy(&array[pos], str.array);
00259 strcpy(&array[pos+str.length], temp);
00260
00261 return *this;
00262 }
|
Here is the call graph for this function:

|
|
Definition at line 67 of file String.h. References length(). 00067 { return length == 0; }
|
Here is the call graph for this function:

|
|
Definition at line 71 of file String.h. Referenced by StartTournamentWindow::add_all_selected(), MessageWindow::add_message(), StatisticsWindow::add_new_row(), ScoreWindow::add_robots(), and Robot::display_score(). 00071 { return array; }
|
|
|
Definition at line 197 of file String.cc. References array, enlarge_array(), length(), and length. 00198 {
00199 int newlength = length + str.length;
00200 enlarge_array(newlength);
00201 strcpy(&array[length], str.array);
00202 length = newlength;
00203
00204 return *this;
00205 }
|
Here is the call graph for this function:

|
|
Definition at line 178 of file String.cc. References allocate_array(), array, and length. 00179 {
00180 length = strlen(str);
00181 allocate_array(length);
00182 strcpy(array, str);
00183 return *this;
00184 }
|
Here is the call graph for this function:

|
|
Definition at line 187 of file String.cc. References allocate_array(), array, and length. 00188 {
00189 length = 1;
00190 allocate_array(length);
00191 array[0] = c;
00192 array[1] = '\0';
00193 return *this;
00194 }
|
Here is the call graph for this function:

|
|
Definition at line 169 of file String.cc. References allocate_array(), array, and length. 00170 {
00171 length = str.length;
00172 allocate_array(length);
00173 strcpy(array, str.array);
00174 return *this;
00175 }
|
Here is the call graph for this function:

|
|
Definition at line 229 of file String.cc. References array, and Error(). 00230 {
00231 if( pos < 0 || pos > length ) Error(true, "String out of range", "String::operator[]");
00232
00233 return array[pos];
00234 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 284 of file String.cc. 00285 {
00286 String segment;
00287 int st = ( start < 0 ? str.length + start : start );
00288 int en = ( end < 0 ? str.length + end : end );
00289 if( st < 0 || st > str.length || en < 0 || en > str.length || st > en + 1 )
00290 Error(true, "String out of range", "String::get_segment");
00291
00292 if( st == en + 1 ) return segment;
00293
00294 segment.length = en - st + 1;
00295 segment.enlarge_array(segment.length);
00296 strncpy( segment.array, &str.array[st], segment.length );
00297 segment.array[segment.length] = '\0';
00298
00299 return segment;
00300 }
|
|
|
Definition at line 359 of file String.cc. 00360 {
00361 String str;
00362 str.length = 15;
00363 str.allocate_array(15);
00364 str.array[15] = '\0';
00365 int pos = 14;
00366
00367 int k = ( n>0 ? n : -n );
00368
00369 if( k == 0 )
00370 str.array[pos--] = '0';
00371 else
00372 for(; k > 0; k/=16)
00373 {
00374 if( k%16 < 10 )
00375 str.array[pos--] = '0' + k%16;
00376 else
00377 str.array[pos--] = 'A' - 10 + k%16;
00378 }
00379
00380 if( n < 0 )
00381 {
00382 str.array[0] = '-';
00383 str.erase(1, pos);
00384 }
00385 else
00386 str.erase(0, pos+1);
00387
00388 return str;
00389 }
|
|
|
Definition at line 303 of file String.cc. 00304 {
00305 String lower_str(str);
00306 for(int i = 0;i<lower_str.length;i++)
00307 lower_str.array[i] = tolower(lower_str.array[i]);
00308
00309 return lower_str;
00310 }
|
|
||||||||||||
|
Definition at line 223 of file String.cc.
|
|
||||||||||||
|
Definition at line 208 of file String.cc. 00209 {
00210 String sum(str1);
00211 sum += str2;
00212
00213 return sum;
00214 }
|
|
||||||||||||
|
Definition at line 413 of file String.cc. 00414 {
00415 os << str.array;
00416 return( os );
00417 }
|
|
||||||||||||
|
Definition at line 217 of file String.cc.
|
|
||||||||||||
|
Definition at line 402 of file String.cc. 00403 {
00404 char buf[500];
00405 is.get(buf, 500, '\n');
00406
00407 str = buf;
00408
00409 return( is );
00410 }
|
|
|
Definition at line 324 of file String.cc. 00325 {
00326 return atof(str.array);
00327 }
|
|
|
Definition at line 330 of file String.cc. 00331 {
00332 int pos = 0;
00333 long sign = 1;
00334 char c;
00335 long number = 0;
00336
00337 if( str.array[pos] == '-' )
00338 {
00339 pos++;
00340 sign = -1;
00341 }
00342
00343 for( ; pos < str.length; pos++)
00344 {
00345 c = str.array[pos];
00346 if( c >= '0' && c <= '9' )
00347 number=number*16+(c-'0');
00348 else if( c >='a' && c <= 'f' )
00349 number=number*16+10+(c-'a');
00350 else if( c >='A' && c <= 'F' )
00351 number=number*16+10+(c-'A');
00352 else break;
00353 }
00354
00355 return sign*number;
00356 }
|
|
|
Definition at line 312 of file String.cc. 00313 {
00314 return atoi(str.array);
00315 }
|
|
|
Definition at line 318 of file String.cc. 00319 {
00320 return atol(str.array);
00321 }
|
|
|
Definition at line 77 of file String.h. Referenced by allocate_array(), copy_chars(), enlarge_array(), erase(), find(), get_segment(), hex2str(), insert(), make_lower_case(), operator!=(), operator+=(), operator<<(), operator=(), operator==(), operator[](), str2dbl(), str2hex(), str2int(), str2long(), and String(). |
|
|
Definition at line 79 of file String.h. Referenced by allocate_array(), enlarge_array(), and String(). |
|
|
Definition at line 78 of file String.h. Referenced by copy_chars(), erase(), find(), get_segment(), hex2str(), insert(), make_lower_case(), operator+=(), operator=(), str2hex(), and String(). |
1.3.9.1