aboutsummaryrefslogtreecommitdiff
path: root/src/stable/string.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/stable/string.h
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/string.h')
-rw-r--r--src/stable/string.h2098
1 files changed, 1049 insertions, 1049 deletions
diff --git a/src/stable/string.h b/src/stable/string.h
index 197821d..3be5bb9 100644
--- a/src/stable/string.h
+++ b/src/stable/string.h
@@ -22,1055 +22,1055 @@
22 22
23namespace Bu 23namespace Bu
24{ 24{
25 class String; 25 class String;
26 class MemBuf; 26 class MemBuf;
27 27
28 /** @cond DEVEL */ 28 /** @cond DEVEL */
29 class StringCore 29 class StringCore
30 { 30 {
31 friend class String; 31 friend class String;
32 friend class SharedCore<String, StringCore>; 32 friend class SharedCore<String, StringCore>;
33 private: 33 private:
34 struct Chunk 34 struct Chunk
35 { 35 {
36 long nLength; 36 long nLength;
37 char *pData; 37 char *pData;
38 Chunk *pNext; 38 Chunk *pNext;
39 }; 39 };
40 40
41 StringCore(); 41 StringCore();
42 StringCore( const StringCore &rSrc ); 42 StringCore( const StringCore &rSrc );
43 virtual ~StringCore(); 43 virtual ~StringCore();
44 44
45 mutable long nLength; 45 mutable long nLength;
46 mutable Chunk *pFirst; 46 mutable Chunk *pFirst;
47 mutable Chunk *pLast; 47 mutable Chunk *pLast;
48 48
49 void clear() const; 49 void clear() const;
50 Chunk *newChunk() const; 50 Chunk *newChunk() const;
51 Chunk *newChunk( long nLen ) const; 51 Chunk *newChunk( long nLen ) const;
52 Chunk *copyChunk( Chunk *pSrc ) const; 52 Chunk *copyChunk( Chunk *pSrc ) const;
53 void appendChunk( Chunk *pNewChunk ); 53 void appendChunk( Chunk *pNewChunk );
54 void prependChunk( Chunk *pNewChunk ); 54 void prependChunk( Chunk *pNewChunk );
55 }; 55 };
56 /** @endcond */ 56 /** @endcond */
57 57
58 /** 58 /**
59 */ 59 */
60 class String : public SharedCore<String, StringCore> 60 class String : public SharedCore<String, StringCore>
61 { 61 {
62 protected: 62 protected:
63 using SharedCore<String, StringCore >::core; 63 using SharedCore<String, StringCore >::core;
64 using SharedCore<String, StringCore >::_hardCopy; 64 using SharedCore<String, StringCore >::_hardCopy;
65 65
66 private: 66 private:
67 typedef StringCore::Chunk Chunk; 67 typedef StringCore::Chunk Chunk;
68 68
69 public: // Iterators 69 public: // Iterators
70 struct iterator; 70 struct iterator;
71 typedef struct const_iterator 71 typedef struct const_iterator
72 { 72 {
73 friend class String; 73 friend class String;
74 friend struct iterator; 74 friend struct iterator;
75 private: 75 private:
76 const_iterator( Chunk *pChunk, int iPos ) : 76 const_iterator( Chunk *pChunk, int iPos ) :
77 pChunk( pChunk ), 77 pChunk( pChunk ),
78 iPos( iPos ) 78 iPos( iPos )
79 { 79 {
80 } 80 }
81 81
82 Chunk *pChunk; 82 Chunk *pChunk;
83 int iPos; 83 int iPos;
84 84
85 public: 85 public:
86 const_iterator( const const_iterator &i ) : 86 const_iterator( const const_iterator &i ) :
87 pChunk( i.pChunk ), 87 pChunk( i.pChunk ),
88 iPos( i.iPos ) 88 iPos( i.iPos )
89 { 89 {
90 } 90 }
91 91
92 const_iterator( const struct iterator &i ) : 92 const_iterator( const struct iterator &i ) :
93 pChunk( i.pChunk ), 93 pChunk( i.pChunk ),
94 iPos( i.iPos ) 94 iPos( i.iPos )
95 { 95 {
96 } 96 }
97 97
98 const_iterator() : 98 const_iterator() :
99 pChunk( NULL ), 99 pChunk( NULL ),
100 iPos( 0 ) 100 iPos( 0 )
101 { 101 {
102 } 102 }
103 103
104 bool operator==( const const_iterator &i ) const 104 bool operator==( const const_iterator &i ) const
105 { 105 {
106 return pChunk == i.pChunk && iPos == i.iPos; 106 return pChunk == i.pChunk && iPos == i.iPos;
107 } 107 }
108 108
109 bool operator!=( const const_iterator &i ) const 109 bool operator!=( const const_iterator &i ) const
110 { 110 {
111 return !(*this == i); 111 return !(*this == i);
112 } 112 }
113 113
114 const_iterator &operator=( const const_iterator &i ) 114 const_iterator &operator=( const const_iterator &i )
115 { 115 {
116 pChunk = i.pChunk; 116 pChunk = i.pChunk;
117 iPos = i.iPos; 117 iPos = i.iPos;
118 return *this; 118 return *this;
119 } 119 }
120 120
121 const_iterator &operator=( const iterator &i ) 121 const_iterator &operator=( const iterator &i )
122 { 122 {
123 pChunk = i.pChunk; 123 pChunk = i.pChunk;
124 iPos = i.iPos; 124 iPos = i.iPos;
125 return *this; 125 return *this;
126 } 126 }
127 127
128 const_iterator &operator++() 128 const_iterator &operator++()
129 { 129 {
130 if( !pChunk ) return *this; 130 if( !pChunk ) return *this;
131 iPos++; 131 iPos++;
132 if( iPos >= pChunk->nLength ) 132 if( iPos >= pChunk->nLength )
133 { 133 {
134 iPos = 0; 134 iPos = 0;
135 pChunk = pChunk->pNext; 135 pChunk = pChunk->pNext;
136 } 136 }
137 return *this; 137 return *this;
138 } 138 }
139 139
140 const_iterator &operator++( int ) 140 const_iterator &operator++( int )
141 { 141 {
142 if( !pChunk ) return *this; 142 if( !pChunk ) return *this;
143 iPos++; 143 iPos++;
144 if( iPos >= pChunk->nLength ) 144 if( iPos >= pChunk->nLength )
145 { 145 {
146 iPos = 0; 146 iPos = 0;
147 pChunk = pChunk->pNext; 147 pChunk = pChunk->pNext;
148 } 148 }
149 return *this; 149 return *this;
150 } 150 }
151 151
152 const_iterator &operator+=( int iAmnt ) 152 const_iterator &operator+=( int iAmnt )
153 { 153 {
154 if( !pChunk ) return *this; 154 if( !pChunk ) return *this;
155 iPos += iAmnt; 155 iPos += iAmnt;
156 while( iPos >= pChunk->nLength ) 156 while( iPos >= pChunk->nLength )
157 { 157 {
158 iPos -= pChunk->nLength; 158 iPos -= pChunk->nLength;
159 pChunk = pChunk->pNext; 159 pChunk = pChunk->pNext;
160 if( pChunk == NULL ) 160 if( pChunk == NULL )
161 break; 161 break;
162 } 162 }
163 return *this; 163 return *this;
164 } 164 }
165 165
166 const_iterator operator+( int iAmnt ) const 166 const_iterator operator+( int iAmnt ) const
167 { 167 {
168 if( !pChunk ) return *this; 168 if( !pChunk ) return *this;
169 const_iterator ret( *this ); 169 const_iterator ret( *this );
170 ret += iAmnt; 170 ret += iAmnt;
171 return ret; 171 return ret;
172 } 172 }
173 173
174 const char &operator *() const 174 const char &operator *() const
175 { 175 {
176 if( !pChunk ) throw Bu::ExceptionBase("Not a valid const_iterator."); 176 if( !pChunk ) throw Bu::ExceptionBase("Not a valid const_iterator.");
177 return pChunk->pData[iPos]; 177 return pChunk->pData[iPos];
178 } 178 }
179 179
180 bool operator==( const char &c ) const 180 bool operator==( const char &c ) const
181 { 181 {
182 if( !pChunk ) return false; 182 if( !pChunk ) return false;
183 return pChunk->pData[iPos] == c; 183 return pChunk->pData[iPos] == c;
184 } 184 }
185 185
186 bool operator!=( const char &c ) const 186 bool operator!=( const char &c ) const
187 { 187 {
188 if( !pChunk ) return false; 188 if( !pChunk ) return false;
189 return pChunk->pData[iPos] != c; 189 return pChunk->pData[iPos] != c;
190 } 190 }
191 191
192 operator bool() const 192 operator bool() const
193 { 193 {
194 return pChunk != NULL; 194 return pChunk != NULL;
195 } 195 }
196 196
197 bool isValid() const 197 bool isValid() const
198 { 198 {
199 return pChunk != NULL; 199 return pChunk != NULL;
200 } 200 }
201 201
202 bool compare( const const_iterator &c ) const 202 bool compare( const const_iterator &c ) const
203 { 203 {
204 const_iterator a = *this; 204 const_iterator a = *this;
205 const_iterator b = c; 205 const_iterator b = c;
206 if( a == b ) 206 if( a == b )
207 return true; 207 return true;
208 for(; a && b; a++, b++ ) 208 for(; a && b; a++, b++ )
209 { 209 {
210 if( *a != *b ) 210 if( *a != *b )
211 return false; 211 return false;
212 } 212 }
213 if( (bool)a != (bool)b ) 213 if( (bool)a != (bool)b )
214 return false; 214 return false;
215 return true; 215 return true;
216 } 216 }
217 217
218 bool compare( const const_iterator &c, int nLen ) const 218 bool compare( const const_iterator &c, int nLen ) const
219 { 219 {
220 const_iterator a = *this; 220 const_iterator a = *this;
221 const_iterator b = c; 221 const_iterator b = c;
222 if( a == b ) 222 if( a == b )
223 return true; 223 return true;
224 for(int j = 0; j < nLen; a++, b++, j++ ) 224 for(int j = 0; j < nLen; a++, b++, j++ )
225 { 225 {
226 if( !a || !b || *a != *b ) 226 if( !a || !b || *a != *b )
227 return false; 227 return false;
228 } 228 }
229 return true; 229 return true;
230 } 230 }
231 231
232 bool compare( const char *c ) const 232 bool compare( const char *c ) const
233 { 233 {
234 if( !pChunk ) return false; 234 if( !pChunk ) return false;
235 const_iterator a = *this; 235 const_iterator a = *this;
236 for(; a && *c; a++, c++ ) 236 for(; a && *c; a++, c++ )
237 { 237 {
238 if( *a != *c ) 238 if( *a != *c )
239 return false; 239 return false;
240 } 240 }
241 if( a.isValid() != (*c!=(char)0) ) 241 if( a.isValid() != (*c!=(char)0) )
242 return false; 242 return false;
243 return true; 243 return true;
244 } 244 }
245 245
246 bool compare( const char *c, int nLen ) const 246 bool compare( const char *c, int nLen ) const
247 { 247 {
248 if( !pChunk ) return false; 248 if( !pChunk ) return false;
249 const_iterator a = *this; 249 const_iterator a = *this;
250 int j = 0; 250 int j = 0;
251 for(; a && j < nLen; a++, c++, j++ ) 251 for(; a && j < nLen; a++, c++, j++ )
252 { 252 {
253 if( *a != *c ) 253 if( *a != *c )
254 return false; 254 return false;
255 } 255 }
256 if( j < nLen ) 256 if( j < nLen )
257 return false; 257 return false;
258 return true; 258 return true;
259 } 259 }
260 260
261 bool compare( const String &s ) const 261 bool compare( const String &s ) const
262 { 262 {
263 if( !pChunk ) return false; 263 if( !pChunk ) return false;
264 return compare( s.begin() ); 264 return compare( s.begin() );
265 } 265 }
266 266
267 bool compare( const String &s, int nLen ) const 267 bool compare( const String &s, int nLen ) const
268 { 268 {
269 if( !pChunk ) return false; 269 if( !pChunk ) return false;
270 return compare( s.begin(), nLen ); 270 return compare( s.begin(), nLen );
271 } 271 }
272 272
273 const_iterator find( const char c ) const 273 const_iterator find( const char c ) const
274 { 274 {
275 for( const_iterator i = *this; i; i++ ) 275 for( const_iterator i = *this; i; i++ )
276 { 276 {
277 if( *i == c ) 277 if( *i == c )
278 return i; 278 return i;
279 } 279 }
280 return const_iterator( NULL, 0 ); 280 return const_iterator( NULL, 0 );
281 } 281 }
282 282
283 const_iterator find( const char *pStr, int nLen ) const 283 const_iterator find( const char *pStr, int nLen ) const
284 { 284 {
285 for( const_iterator i = *this; i; i++ ) 285 for( const_iterator i = *this; i; i++ )
286 { 286 {
287 if( i.compare( pStr, nLen ) ) 287 if( i.compare( pStr, nLen ) )
288 return i; 288 return i;
289 } 289 }
290 return const_iterator( NULL, 0 ); 290 return const_iterator( NULL, 0 );
291 } 291 }
292 292
293 const_iterator find( const String &s ) const 293 const_iterator find( const String &s ) const
294 { 294 {
295 for( const_iterator i = *this; i; i++ ) 295 for( const_iterator i = *this; i; i++ )
296 { 296 {
297 if( i.compare( s ) ) 297 if( i.compare( s ) )
298 return i; 298 return i;
299 } 299 }
300 return const_iterator( NULL, 0 ); 300 return const_iterator( NULL, 0 );
301 } 301 }
302 302
303 const_iterator find( const String &s, int nLen ) const 303 const_iterator find( const String &s, int nLen ) const
304 { 304 {
305 for( const_iterator i = *this; i; i++ ) 305 for( const_iterator i = *this; i; i++ )
306 { 306 {
307 if( i.compare( s, nLen ) ) 307 if( i.compare( s, nLen ) )
308 return i; 308 return i;
309 } 309 }
310 return const_iterator( NULL, 0 ); 310 return const_iterator( NULL, 0 );
311 } 311 }
312 } const_iterator; 312 } const_iterator;
313 313
314 typedef struct iterator 314 typedef struct iterator
315 { 315 {
316 friend class String; 316 friend class String;
317 friend struct const_iterator; 317 friend struct const_iterator;
318 private: 318 private:
319 iterator( Chunk *pChunk, int iPos ) : 319 iterator( Chunk *pChunk, int iPos ) :
320 pChunk( pChunk ), 320 pChunk( pChunk ),
321 iPos( iPos ) 321 iPos( iPos )
322 { 322 {
323 } 323 }
324 324
325 Chunk *pChunk; 325 Chunk *pChunk;
326 int iPos; 326 int iPos;
327 327
328 public: 328 public:
329 iterator( const iterator &i ) : 329 iterator( const iterator &i ) :
330 pChunk( i.pChunk ), 330 pChunk( i.pChunk ),
331 iPos( i.iPos ) 331 iPos( i.iPos )
332 { 332 {
333 } 333 }
334 334
335 iterator() : 335 iterator() :
336 pChunk( NULL ), 336 pChunk( NULL ),
337 iPos( 0 ) 337 iPos( 0 )
338 { 338 {
339 } 339 }
340 340
341 operator const_iterator() const 341 operator const_iterator() const
342 { 342 {
343 return const_iterator( pChunk, iPos ); 343 return const_iterator( pChunk, iPos );
344 } 344 }
345 345
346 bool operator==( const iterator &i ) const 346 bool operator==( const iterator &i ) const
347 { 347 {
348 return pChunk == i.pChunk && iPos == i.iPos; 348 return pChunk == i.pChunk && iPos == i.iPos;
349 } 349 }
350 350
351 bool operator!=( const iterator &i ) const 351 bool operator!=( const iterator &i ) const
352 { 352 {
353 return !(*this == i); 353 return !(*this == i);
354 } 354 }
355 355
356 iterator &operator=( const iterator &i ) 356 iterator &operator=( const iterator &i )
357 { 357 {
358 pChunk = i.pChunk; 358 pChunk = i.pChunk;
359 iPos = i.iPos; 359 iPos = i.iPos;
360 return *this; 360 return *this;
361 } 361 }
362 362
363 iterator &operator++() 363 iterator &operator++()
364 { 364 {
365 if( !pChunk ) return *this; 365 if( !pChunk ) return *this;
366 iPos++; 366 iPos++;
367 if( iPos >= pChunk->nLength ) 367 if( iPos >= pChunk->nLength )
368 { 368 {
369 iPos = 0; 369 iPos = 0;
370 pChunk = pChunk->pNext; 370 pChunk = pChunk->pNext;
371 } 371 }
372 return *this; 372 return *this;
373 } 373 }
374 374
375 iterator &operator++( int ) 375 iterator &operator++( int )
376 { 376 {
377 if( !pChunk ) return *this; 377 if( !pChunk ) return *this;
378 iPos++; 378 iPos++;
379 if( iPos >= pChunk->nLength ) 379 if( iPos >= pChunk->nLength )
380 { 380 {
381 iPos = 0; 381 iPos = 0;
382 pChunk = pChunk->pNext; 382 pChunk = pChunk->pNext;
383 } 383 }
384 return *this; 384 return *this;
385 } 385 }
386 386
387 iterator &operator+=( int iAmnt ) 387 iterator &operator+=( int iAmnt )
388 { 388 {
389 if( !pChunk ) return *this; 389 if( !pChunk ) return *this;
390 iPos += iAmnt; 390 iPos += iAmnt;
391 while( iPos >= pChunk->nLength ) 391 while( iPos >= pChunk->nLength )
392 { 392 {
393 iPos -= pChunk->nLength; 393 iPos -= pChunk->nLength;
394 pChunk = pChunk->pNext; 394 pChunk = pChunk->pNext;
395 if( pChunk == NULL ) 395 if( pChunk == NULL )
396 break; 396 break;
397 } 397 }
398 return *this; 398 return *this;
399 } 399 }
400 400
401 iterator operator+( int iAmnt ) const 401 iterator operator+( int iAmnt ) const
402 { 402 {
403 if( !pChunk ) return *this; 403 if( !pChunk ) return *this;
404 iterator ret( *this ); 404 iterator ret( *this );
405 ret += iAmnt; 405 ret += iAmnt;
406 return ret; 406 return ret;
407 } 407 }
408 408
409 char &operator*() 409 char &operator*()
410 { 410 {
411 if( !pChunk ) throw Bu::ExceptionBase("Not a valid iterator."); 411 if( !pChunk ) throw Bu::ExceptionBase("Not a valid iterator.");
412 return pChunk->pData[iPos]; 412 return pChunk->pData[iPos];
413 } 413 }
414 414
415 const char &operator*() const 415 const char &operator*() const
416 { 416 {
417 if( !pChunk ) throw Bu::ExceptionBase("Not a valid iterator."); 417 if( !pChunk ) throw Bu::ExceptionBase("Not a valid iterator.");
418 return pChunk->pData[iPos]; 418 return pChunk->pData[iPos];
419 } 419 }
420 420
421 bool operator==( const char &c ) const 421 bool operator==( const char &c ) const
422 { 422 {
423 if( !pChunk ) return false; 423 if( !pChunk ) return false;
424 return pChunk->pData[iPos] == c; 424 return pChunk->pData[iPos] == c;
425 } 425 }
426 426
427 bool operator!=( const char &c ) const 427 bool operator!=( const char &c ) const
428 { 428 {
429 if( !pChunk ) return false; 429 if( !pChunk ) return false;
430 return pChunk->pData[iPos] != c; 430 return pChunk->pData[iPos] != c;
431 } 431 }
432 432
433 iterator &operator=( const char &c ) 433 iterator &operator=( const char &c )
434 { 434 {
435 if( !pChunk ) throw Bu::ExceptionBase("Not a valid iterator."); 435 if( !pChunk ) throw Bu::ExceptionBase("Not a valid iterator.");
436 pChunk->pData[iPos] = c; 436 pChunk->pData[iPos] = c;
437 return *this; 437 return *this;
438 } 438 }
439 439
440 operator bool() const 440 operator bool() const
441 { 441 {
442 return pChunk != NULL; 442 return pChunk != NULL;
443 } 443 }
444 444
445 bool isValid() const 445 bool isValid() const
446 { 446 {
447 return pChunk != NULL; 447 return pChunk != NULL;
448 } 448 }
449 449
450 bool compare( const const_iterator &c ) const 450 bool compare( const const_iterator &c ) const
451 { 451 {
452 const_iterator a( *this ); 452 const_iterator a( *this );
453 const_iterator b = c; 453 const_iterator b = c;
454 if( a == b ) 454 if( a == b )
455 return true; 455 return true;
456 for(; a && b; a++, b++ ) 456 for(; a && b; a++, b++ )
457 { 457 {
458 if( *a != *b ) 458 if( *a != *b )
459 return false; 459 return false;
460 } 460 }
461 if( (bool)a != (bool)b ) 461 if( (bool)a != (bool)b )
462 return false; 462 return false;
463 return true; 463 return true;
464 } 464 }
465 465
466 bool compare( const const_iterator &c, int nLen ) const 466 bool compare( const const_iterator &c, int nLen ) const
467 { 467 {
468 const_iterator a( *this ); 468 const_iterator a( *this );
469 const_iterator b = c; 469 const_iterator b = c;
470 if( a == b ) 470 if( a == b )
471 return true; 471 return true;
472 for(int j = 0; j < nLen; a++, b++, j++ ) 472 for(int j = 0; j < nLen; a++, b++, j++ )
473 { 473 {
474 if( !a || !b || *a != *b ) 474 if( !a || !b || *a != *b )
475 return false; 475 return false;
476 } 476 }
477 return true; 477 return true;
478 } 478 }
479 479
480 bool compare( const char *c ) const 480 bool compare( const char *c ) const
481 { 481 {
482 if( !pChunk ) return false; 482 if( !pChunk ) return false;
483 iterator a = *this; 483 iterator a = *this;
484 for(; a && *c; a++, c++ ) 484 for(; a && *c; a++, c++ )
485 { 485 {
486 if( *a != *c ) 486 if( *a != *c )
487 return false; 487 return false;
488 } 488 }
489 if( a.isValid() != (*c!=(char)0) ) 489 if( a.isValid() != (*c!=(char)0) )
490 return false; 490 return false;
491 return true; 491 return true;
492 } 492 }
493 493
494 bool compare( const char *c, int nLen ) const 494 bool compare( const char *c, int nLen ) const
495 { 495 {
496 if( !pChunk ) return false; 496 if( !pChunk ) return false;
497 iterator a = *this; 497 iterator a = *this;
498 int j = 0; 498 int j = 0;
499 for(; a && j < nLen; a++, c++, j++ ) 499 for(; a && j < nLen; a++, c++, j++ )
500 { 500 {
501 if( *a != *c ) 501 if( *a != *c )
502 return false; 502 return false;
503 } 503 }
504 if( j < nLen ) 504 if( j < nLen )
505 return false; 505 return false;
506 return true; 506 return true;
507 } 507 }
508 508
509 bool compare( const String &s ) const 509 bool compare( const String &s ) const
510 { 510 {
511 if( !pChunk ) return false; 511 if( !pChunk ) return false;
512 return compare( s.begin() ); 512 return compare( s.begin() );
513 } 513 }
514 514
515 bool compare( const String &s, int nLen ) const 515 bool compare( const String &s, int nLen ) const
516 { 516 {
517 if( !pChunk ) return false; 517 if( !pChunk ) return false;
518 return compare( s.begin(), nLen ); 518 return compare( s.begin(), nLen );
519 } 519 }
520 520
521 iterator find( const char c ) const 521 iterator find( const char c ) const
522 { 522 {
523 for( iterator i = *this; i; i++ ) 523 for( iterator i = *this; i; i++ )
524 { 524 {
525 if( *i == c ) 525 if( *i == c )
526 return i; 526 return i;
527 } 527 }
528 return iterator( NULL, 0 ); 528 return iterator( NULL, 0 );
529 } 529 }
530 530
531 iterator find( const char *pStr, int nLen ) const 531 iterator find( const char *pStr, int nLen ) const
532 { 532 {
533 for( iterator i = *this; i; i++ ) 533 for( iterator i = *this; i; i++ )
534 { 534 {
535 if( i.compare( pStr, nLen ) ) 535 if( i.compare( pStr, nLen ) )
536 return i; 536 return i;
537 } 537 }
538 return iterator( NULL, 0 ); 538 return iterator( NULL, 0 );
539 } 539 }
540 540
541 iterator find( const String &s ) const 541 iterator find( const String &s ) const
542 { 542 {
543 for( iterator i = *this; i; i++ ) 543 for( iterator i = *this; i; i++ )
544 { 544 {
545 if( i.compare( s ) ) 545 if( i.compare( s ) )
546 return i; 546 return i;
547 } 547 }
548 return iterator( NULL, 0 ); 548 return iterator( NULL, 0 );
549 } 549 }
550 550
551 iterator find( const String &s, int nLen ) const 551 iterator find( const String &s, int nLen ) const
552 { 552 {
553 for( iterator i = *this; i; i++ ) 553 for( iterator i = *this; i; i++ )
554 { 554 {
555 if( i.compare( s, nLen ) ) 555 if( i.compare( s, nLen ) )
556 return i; 556 return i;
557 } 557 }
558 return iterator( NULL, 0 ); 558 return iterator( NULL, 0 );
559 } 559 }
560 } iterator; 560 } iterator;
561 561
562 public: 562 public:
563 String(); 563 String();
564 String( const char *pData ); 564 String( const char *pData );
565 String( const char *pData, long nLength ); 565 String( const char *pData, long nLength );
566 String( const String &rSrc ); 566 String( const String &rSrc );
567 String( const String &rSrc, long nLength ); 567 String( const String &rSrc, long nLength );
568 String( const String &rSrc, long nStart, long nLength ); 568 String( const String &rSrc, long nStart, long nLength );
569 String( long nSize ); 569 String( long nSize );
570 String( const const_iterator &s ); 570 String( const const_iterator &s );
571 String( const const_iterator &s, const const_iterator &e ); 571 String( const const_iterator &s, const const_iterator &e );
572 virtual ~String(); 572 virtual ~String();
573 573
574 /** 574 /**
575 * Append data to your string. 575 * Append data to your string.
576 *@param pData (const char *) The data to append. 576 *@param pData (const char *) The data to append.
577 */ 577 */
578 void append( const char *pData ); 578 void append( const char *pData );
579 579
580 /** 580 /**
581 * Append data to your string. 581 * Append data to your string.
582 *@param pData (const char *) The data to append. 582 *@param pData (const char *) The data to append.
583 *@param nLen (long) The length of the data to append. 583 *@param nLen (long) The length of the data to append.
584 */ 584 */
585 void append( const char *pData, long nLen ); 585 void append( const char *pData, long nLen );
586 586
587 /** 587 /**
588 * Append data to your string. 588 * Append data to your string.
589 *@param pData (const char *) The data to append. 589 *@param pData (const char *) The data to append.
590 *@param nStart (long) The start position to copy from. 590 *@param nStart (long) The start position to copy from.
591 *@param nLen (long) The length of the data to append. 591 *@param nLen (long) The length of the data to append.
592 */ 592 */
593 void append( const char *pData, long nStart, long nLen ); 593 void append( const char *pData, long nStart, long nLen );
594 594
595 /** 595 /**
596 * Append a single char to your string. 596 * Append a single char to your string.
597 *@param cData (const char &) The character to append. 597 *@param cData (const char &) The character to append.
598 */ 598 */
599 void append( const char &cData ); 599 void append( const char &cData );
600 600
601 /** 601 /**
602 * Append another String to this one. 602 * Append another String to this one.
603 *@param sData (String &) The String to append. 603 *@param sData (String &) The String to append.
604 *@todo This function can be made much faster by not using getStr() 604 *@todo This function can be made much faster by not using getStr()
605 */ 605 */
606 void append( const String & sData ); 606 void append( const String & sData );
607 607
608 /** 608 /**
609 * Append another String to this one. 609 * Append another String to this one.
610 *@param sData (String &) The String to append. 610 *@param sData (String &) The String to append.
611 *@param nLen How much data to append. 611 *@param nLen How much data to append.
612 *@todo This function can be made much faster by not using getStr() 612 *@todo This function can be made much faster by not using getStr()
613 */ 613 */
614 void append( const String & sData, long nLen ); 614 void append( const String & sData, long nLen );
615 615
616 /** 616 /**
617 * Append another String to this one. 617 * Append another String to this one.
618 *@param sData (String &) The String to append. 618 *@param sData (String &) The String to append.
619 *@param nStart Start position in sData to start copying from. 619 *@param nStart Start position in sData to start copying from.
620 *@param nLen How much data to append. 620 *@param nLen How much data to append.
621 *@todo This function can be made much faster by not using getStr() 621 *@todo This function can be made much faster by not using getStr()
622 */ 622 */
623 void append( const String & sData, long nStart, long nLen ); 623 void append( const String & sData, long nStart, long nLen );
624 624
625 /** 625 /**
626 * Append data to this String using the passed in iterator as a base. 626 * Append data to this String using the passed in iterator as a base.
627 * The iterator is const, it is not changed. 627 * The iterator is const, it is not changed.
628 *@param s Iterator from any compatible String to copy data from. 628 *@param s Iterator from any compatible String to copy data from.
629 */ 629 */
630 void append( const const_iterator &s ); 630 void append( const const_iterator &s );
631 631
632 /** 632 /**
633 * Append data to this String using the passed in iterator as a base. 633 * Append data to this String using the passed in iterator as a base.
634 * The iterator is const, it is not changed. 634 * The iterator is const, it is not changed.
635 *@param s Iterator from any compatible String to copy data from. 635 *@param s Iterator from any compatible String to copy data from.
636 */ 636 */
637 void append( const iterator &s ); 637 void append( const iterator &s );
638 638
639 /** 639 /**
640 * Append data to this String using the passed in iterator as a base, 640 * Append data to this String using the passed in iterator as a base,
641 * and copy data until the ending iterator is reached. The character 641 * and copy data until the ending iterator is reached. The character
642 * at the ending iterator is not copied. 642 * at the ending iterator is not copied.
643 * The iterators are const, they are not changed. 643 * The iterators are const, they are not changed.
644 *@param s Iterator from any compatible String to copy data from. 644 *@param s Iterator from any compatible String to copy data from.
645 *@param e Iterator to stop copying at. 645 *@param e Iterator to stop copying at.
646 */ 646 */
647 void append( const const_iterator &s, const const_iterator &e ); 647 void append( const const_iterator &s, const const_iterator &e );
648 648
649 /** 649 /**
650 * Prepend another String to this one. 650 * Prepend another String to this one.
651 *@param sData (String &) The String to prepend. 651 *@param sData (String &) The String to prepend.
652 *@todo This function can be made much faster by not using getStr() 652 *@todo This function can be made much faster by not using getStr()
653 */ 653 */
654 void prepend( const String & sData ); 654 void prepend( const String & sData );
655 655
656 /** 656 /**
657 * Prepend data to your string. 657 * Prepend data to your string.
658 *@param pData (const char *) The data to prepend. 658 *@param pData (const char *) The data to prepend.
659 */ 659 */
660 void prepend( const char *pData ); 660 void prepend( const char *pData );
661 661
662 /** 662 /**
663 * Prepend data to your string. 663 * Prepend data to your string.
664 *@param pData (const char *) The data to prepend. 664 *@param pData (const char *) The data to prepend.
665 *@param nLen (long) The length of the data to prepend. 665 *@param nLen (long) The length of the data to prepend.
666 */ 666 */
667 void prepend( const char *pData, long nLen ); 667 void prepend( const char *pData, long nLen );
668 668
669 void prepend( const char c ); 669 void prepend( const char c );
670 670
671 /** 671 /**
672 * Insert pData before byte nPos, that is, the first byte of pData will 672 * Insert pData before byte nPos, that is, the first byte of pData will
673 * start at nPos. This could probably be made faster by avoiding 673 * start at nPos. This could probably be made faster by avoiding
674 * flattening. 674 * flattening.
675 */ 675 */
676 void insert( long nPos, const char *pData, long nLen ); 676 void insert( long nPos, const char *pData, long nLen );
677 677
678 void insert( long nPos, const String &str ); 678 void insert( long nPos, const String &str );
679 679
680 /** 680 /**
681 *@todo This function shouldn't use strlen, we should add our own to 681 *@todo This function shouldn't use strlen, we should add our own to
682 * this class, one that can be overridden in a specific implementation. 682 * this class, one that can be overridden in a specific implementation.
683 */ 683 */
684 void insert( long nPos, const char *pData ); 684 void insert( long nPos, const char *pData );
685 685
686 void remove( long nPos, long nLen ); 686 void remove( long nPos, long nLen );
687 687
688 /** 688 /**
689 * Clear all data from the string. 689 * Clear all data from the string.
690 */ 690 */
691 void clear(); 691 void clear();
692 692
693 String replace( const String &fnd, const String &rep ) const; 693 String replace( const String &fnd, const String &rep ) const;
694 694
695 /** 695 /**
696 * Force the string to resize 696 * Force the string to resize
697 *@param nNewSize (long) The new size of the string. 697 *@param nNewSize (long) The new size of the string.
698 */ 698 */
699 void resize( long nNewSize ); 699 void resize( long nNewSize );
700 700
701 /** 701 /**
702 * Get the current size of the string. 702 * Get the current size of the string.
703 *@returns (long) The current size of the string. 703 *@returns (long) The current size of the string.
704 */ 704 */
705 long getSize() const; 705 long getSize() const;
706 706
707 /** 707 /**
708 * Get a pointer to the string array. 708 * Get a pointer to the string array.
709 *@returns (char *) The string data. 709 *@returns (char *) The string data.
710 */ 710 */
711 char *getStr(); 711 char *getStr();
712 712
713 /** 713 /**
714 * Get a const pointer to the string array. 714 * Get a const pointer to the string array.
715 *@returns (const char *) The string data. 715 *@returns (const char *) The string data.
716 */ 716 */
717 const char *getStr() const; 717 const char *getStr() const;
718 718
719 /** 719 /**
720 * A convinience function, this one won't cause as much work as the 720 * A convinience function, this one won't cause as much work as the
721 * non-const getStr, so if you're not changing the data, consider it. 721 * non-const getStr, so if you're not changing the data, consider it.
722 */ 722 */
723 const char *getConstStr() const; 723 const char *getConstStr() const;
724 724
725 String getSubStrIdx( long iStart, long iSize=-1 ) const; 725 String getSubStrIdx( long iStart, long iSize=-1 ) const;
726 726
727 String getSubStr( const_iterator iBegin, 727 String getSubStr( const_iterator iBegin,
728 const_iterator iEnd=String::const_iterator() ) const; 728 const_iterator iEnd=String::const_iterator() ) const;
729 729
730 Bu::List<String> split( const char c ) const; 730 Bu::List<String> split( const char c ) const;
731 731
732 /** 732 /**
733 * Plus equals operator for String. 733 * Plus equals operator for String.
734 *@param pData (const char *) The data to append to your String. 734 *@param pData (const char *) The data to append to your String.
735 */ 735 */
736 String &operator+=( const char *pData ); 736 String &operator+=( const char *pData );
737 737
738 /** 738 /**
739 * Plus equals operator for String. 739 * Plus equals operator for String.
740 *@param rSrc (const String &) The String to append to your String. 740 *@param rSrc (const String &) The String to append to your String.
741 */ 741 */
742 String &operator+=( const String &rSrc ); 742 String &operator+=( const String &rSrc );
743 743
744 String &operator+=( const String::const_iterator &i ); 744 String &operator+=( const String::const_iterator &i );
745 745
746 /** 746 /**
747 * Plus equals operator for String. 747 * Plus equals operator for String.
748 *@param cData (const char) The character to append to your String. 748 *@param cData (const char) The character to append to your String.
749 */ 749 */
750 String &operator+=( const char cData ); 750 String &operator+=( const char cData );
751 751
752 /** 752 /**
753 * Assignment operator. 753 * Assignment operator.
754 *@param pData (const char *) The character array to append to your 754 *@param pData (const char *) The character array to append to your
755 * String. 755 * String.
756 */ 756 */
757 String &operator=( const char *pData ); 757 String &operator=( const char *pData );
758 758
759 String operator+( const String &rRight ) const; 759 String operator+( const String &rRight ) const;
760 760
761 String operator+( const char *pRight ) const; 761 String operator+( const char *pRight ) const;
762 762
763 String operator+( char *pRight ) const; 763 String operator+( char *pRight ) const;
764 764
765 /** 765 /**
766 * Reset your String to this character array. 766 * Reset your String to this character array.
767 *@param pData (const char *) The character array to set your String to. 767 *@param pData (const char *) The character array to set your String to.
768 */ 768 */
769 void set( const char *pData ); 769 void set( const char *pData );
770 770
771 /** 771 /**
772 * Reset your String to this character array. 772 * Reset your String to this character array.
773 *@param pData (const char *) The character array to set your String to. 773 *@param pData (const char *) The character array to set your String to.
774 *@param nSize (long) The length of the inputted character array. 774 *@param nSize (long) The length of the inputted character array.
775 */ 775 */
776 void set( const char *pData, long nSize ); 776 void set( const char *pData, long nSize );
777 777
778 void set( const char *pData, long nStart, long nSize ); 778 void set( const char *pData, long nStart, long nSize );
779 779
780 void set( const String &rData ); 780 void set( const String &rData );
781 781
782 void set( const String &rData, long nSize ); 782 void set( const String &rData, long nSize );
783 783
784 void set( const String &rData, long nStart, long nSize ); 784 void set( const String &rData, long nStart, long nSize );
785 785
786 void set( const_iterator s ); 786 void set( const_iterator s );
787 787
788 void set( const_iterator s, const_iterator e ); 788 void set( const_iterator s, const_iterator e );
789 789
790 /** 790 /**
791 * Resize the string, possibly to make room for a copy. At the moment 791 * Resize the string, possibly to make room for a copy. At the moment
792 * this operation *is* destructive. What was in the string will in no 792 * this operation *is* destructive. What was in the string will in no
793 * way be preserved. This is, however, very fast. If you want to 793 * way be preserved. This is, however, very fast. If you want to
794 * keep your data check out resize. 794 * keep your data check out resize.
795 *@param iSize the new size in bytes. The string is guranteed to have 795 *@param iSize the new size in bytes. The string is guranteed to have
796 * at least this much contiguous space available when done. 796 * at least this much contiguous space available when done.
797 */ 797 */
798 void setSize( long iSize ); 798 void setSize( long iSize );
799 799
800 /** 800 /**
801 * Equals comparison operator. 801 * Equals comparison operator.
802 *@param pData (const char *) The character array to compare your String 802 *@param pData (const char *) The character array to compare your String
803 * to. 803 * to.
804 */ 804 */
805 bool operator==( const char *pData ) const; 805 bool operator==( const char *pData ) const;
806 806
807 /** 807 /**
808 * Equals comparison operator. 808 * Equals comparison operator.
809 *@param pData (const String &) The String to compare your String to. 809 *@param pData (const String &) The String to compare your String to.
810 */ 810 */
811 bool operator==( const String &pData ) const; 811 bool operator==( const String &pData ) const;
812 812
813 /** 813 /**
814 * Not equals comparison operator. 814 * Not equals comparison operator.
815 *@param pData (const char *) The character array to compare your String 815 *@param pData (const char *) The character array to compare your String
816 * to. 816 * to.
817 */ 817 */
818 bool operator!=(const char *pData ) const; 818 bool operator!=(const char *pData ) const;
819 819
820 /** 820 /**
821 * Not equals comparison operator. 821 * Not equals comparison operator.
822 *@param pData (const String &) The String to compare your String to. 822 *@param pData (const String &) The String to compare your String to.
823 */ 823 */
824 bool operator!=(const String &pData ) const; 824 bool operator!=(const String &pData ) const;
825 825
826 bool operator<(const String &pData ) const; 826 bool operator<(const String &pData ) const;
827 827
828 bool operator<=(const String &pData ) const; 828 bool operator<=(const String &pData ) const;
829 829
830 bool operator>(const String &pData ) const; 830 bool operator>(const String &pData ) const;
831 831
832 bool operator>=(const String &pData ) const; 832 bool operator>=(const String &pData ) const;
833 833
834 /** 834 /**
835 * Indexing operator 835 * Indexing operator
836 *@param nIndex (long) The index of the character you want. 836 *@param nIndex (long) The index of the character you want.
837 *@returns (char &) The character at position (nIndex). 837 *@returns (char &) The character at position (nIndex).
838 */ 838 */
839 char &operator[]( long nIndex ); 839 char &operator[]( long nIndex );
840 840
841 /** 841 /**
842 * Const indexing operator 842 * Const indexing operator
843 *@param nIndex (long) The index of the character you want. 843 *@param nIndex (long) The index of the character you want.
844 *@returns (const char &) The character at position (nIndex). 844 *@returns (const char &) The character at position (nIndex).
845 */ 845 */
846 const char &operator[]( long nIndex ) const; 846 const char &operator[]( long nIndex ) const;
847 847
848 bool isSet() const; 848 bool isSet() const;
849 849
850 bool compareSub( const char *pData, long nIndex, long nLen ) const; 850 bool compareSub( const char *pData, long nIndex, long nLen ) const;
851 851
852 bool compareSub( const String &rData, long nIndex, long nLen ) const; 852 bool compareSub( const String &rData, long nIndex, long nLen ) const;
853 853
854 /** 854 /**
855 * Is the character at index (nIndex) white space? 855 * Is the character at index (nIndex) white space?
856 *@param nIndex (long) The index of the character you want to check. 856 *@param nIndex (long) The index of the character you want to check.
857 *@returns (bool) Is it white space? 857 *@returns (bool) Is it white space?
858 */ 858 */
859 bool isWS( long nIndex ) const; 859 bool isWS( long nIndex ) const;
860 860
861 /** 861 /**
862 * Is the character at index (nIndex) a letter? 862 * Is the character at index (nIndex) a letter?
863 *@param nIndex (long) The index of the character you want to check. 863 *@param nIndex (long) The index of the character you want to check.
864 *@returns (bool) Is it a letter? 864 *@returns (bool) Is it a letter?
865 */ 865 */
866 bool isAlpha( long nIndex ) const; 866 bool isAlpha( long nIndex ) const;
867 867
868 /** 868 /**
869 * Convert your alpha characters to lower case. 869 * Convert your alpha characters to lower case.
870 */ 870 */
871 String toLower() const; 871 String toLower() const;
872 872
873 /** 873 /**
874 * Convert your alpha characters to upper case. 874 * Convert your alpha characters to upper case.
875 */ 875 */
876 String toUpper() const; 876 String toUpper() const;
877 877
878 const_iterator find( const char cChar, 878 const_iterator find( const char cChar,
879 const_iterator iStart=const_iterator() ) const; 879 const_iterator iStart=const_iterator() ) const;
880 880
881 const_iterator find( const char *sText, int nLen, 881 const_iterator find( const char *sText, int nLen,
882 const_iterator iStart=const_iterator() ) const; 882 const_iterator iStart=const_iterator() ) const;
883 883
884 const_iterator find( const String &rStr, 884 const_iterator find( const String &rStr,
885 const_iterator iStart=const_iterator() ) const; 885 const_iterator iStart=const_iterator() ) const;
886 886
887 const_iterator find( const String &rStr, int nLen, 887 const_iterator find( const String &rStr, int nLen,
888 const_iterator iStart=const_iterator() ) const; 888 const_iterator iStart=const_iterator() ) const;
889 889
890 iterator find( const char cChar, 890 iterator find( const char cChar,
891 const_iterator iStart=const_iterator() ); 891 const_iterator iStart=const_iterator() );
892 892
893 iterator find( const char *sText, int nLen, 893 iterator find( const char *sText, int nLen,
894 const_iterator iStart=const_iterator() ); 894 const_iterator iStart=const_iterator() );
895 895
896 iterator find( const String &rStr, 896 iterator find( const String &rStr,
897 const_iterator iStart=const_iterator() ); 897 const_iterator iStart=const_iterator() );
898 898
899 iterator find( const String &rStr, int nLen, 899 iterator find( const String &rStr, int nLen,
900 const_iterator iStart=const_iterator() ); 900 const_iterator iStart=const_iterator() );
901 901
902 /** 902 /**
903 * Find the index of the first occurrance of cChar 903 * Find the index of the first occurrance of cChar
904 *@param cChar The character to search for. 904 *@param cChar The character to search for.
905 *@param iStart The position in the string to start searching from. 905 *@param iStart The position in the string to start searching from.
906 *@returns (long) The index of the first occurrance. -1 for not found. 906 *@returns (long) The index of the first occurrance. -1 for not found.
907 */ 907 */
908 long findIdx( const char cChar, long iStart=0 ) const; 908 long findIdx( const char cChar, long iStart=0 ) const;
909 909
910 /** 910 /**
911 * Find the index of the first occurrance of sText 911 * Find the index of the first occurrance of sText
912 *@param sText The null-terminated string to search for. 912 *@param sText The null-terminated string to search for.
913 *@param iStart The position in the string to start searching from. 913 *@param iStart The position in the string to start searching from.
914 *@returns The index of the first occurrance. -1 for not found. 914 *@returns The index of the first occurrance. -1 for not found.
915 */ 915 */
916 long findIdx( const char *sText, long iStart=0 ) const; 916 long findIdx( const char *sText, long iStart=0 ) const;
917 917
918 /** 918 /**
919 * Do a reverse search for (sText) 919 * Do a reverse search for (sText)
920 *@param sText (const char *) The string to search for. 920 *@param sText (const char *) The string to search for.
921 *@returns (long) The index of the last occurrance. -1 for not found. 921 *@returns (long) The index of the last occurrance. -1 for not found.
922 */ 922 */
923 long rfindIdx( const char *sText ) const; 923 long rfindIdx( const char *sText ) const;
924 924
925 /** 925 /**
926 * Remove nAmnt bytes from the front of the string. This function 926 * Remove nAmnt bytes from the front of the string. This function
927 * operates in O(n) time and should be used sparingly. 927 * operates in O(n) time and should be used sparingly.
928 */ 928 */
929 void trimFront( long nAmnt ); 929 void trimFront( long nAmnt );
930 930
931 void trimBack( long iAmnt ); 931 void trimBack( long iAmnt );
932 932
933 Bu::String trimWhitespace() const; 933 Bu::String trimWhitespace() const;
934 934
935 iterator begin(); 935 iterator begin();
936 936
937 const_iterator begin() const; 937 const_iterator begin() const;
938 938
939 iterator end(); 939 iterator end();
940 940
941 const_iterator end() const; 941 const_iterator end() const;
942 942
943 bool isEmpty() const; 943 bool isEmpty() const;
944 944
945 private: 945 private:
946 void flatten() const; 946 void flatten() const;
947 bool isFlat() const; 947 bool isFlat() const;
948 948
949 public: 949 public:
950 class FormatProxyEndAction 950 class FormatProxyEndAction
951 { 951 {
952 public: 952 public:
953 virtual ~FormatProxyEndAction() { }; 953 virtual ~FormatProxyEndAction() { };
954 virtual void operator()( const Bu::String &sFinal )=0; 954 virtual void operator()( const Bu::String &sFinal )=0;
955 }; 955 };
956 956
957 class FormatProxy 957 class FormatProxy
958 { 958 {
959 friend class Bu::String; 959 friend class Bu::String;
960 private: 960 private:
961 FormatProxy( const String &rFmt, FormatProxyEndAction *pAct=NULL ); 961 FormatProxy( const String &rFmt, FormatProxyEndAction *pAct=NULL );
962 962
963 public: 963 public:
964 virtual ~FormatProxy(); 964 virtual ~FormatProxy();
965 template<typename T> 965 template<typename T>
966 FormatProxy &arg( const T &x ) 966 FormatProxy &arg( const T &x )
967 { 967 {
968 lArgs.append( Arg( x ) ); 968 lArgs.append( Arg( x ) );
969 969
970 return *this; 970 return *this;
971 } 971 }
972 972
973 template<typename T> 973 template<typename T>
974 FormatProxy &arg( const T &x, const Bu::Fmt &f ) 974 FormatProxy &arg( const T &x, const Bu::Fmt &f )
975 { 975 {
976 lArgs.append( Arg( x, f ) ); 976 lArgs.append( Arg( x, f ) );
977 977
978 return *this; 978 return *this;
979 } 979 }
980 980
981 String end() const; 981 String end() const;
982 operator String() const { return end(); } 982 operator String() const { return end(); }
983 983
984 private: 984 private:
985 const String &rFmt; 985 const String &rFmt;
986 class Arg 986 class Arg
987 { 987 {
988 public: 988 public:
989 template<typename T> 989 template<typename T>
990 Arg( const T &v ) : 990 Arg( const T &v ) :
991 value( v ) 991 value( v )
992 { 992 {
993 } 993 }
994 994
995 template<typename T> 995 template<typename T>
996 Arg( const T &v, const Bu::Fmt &f ) : 996 Arg( const T &v, const Bu::Fmt &f ) :
997 value( v ), 997 value( v ),
998 format( f ) 998 format( f )
999 { 999 {
1000 } 1000 }
1001 1001
1002 Bu::Variant value; 1002 Bu::Variant value;
1003 Bu::Fmt format; 1003 Bu::Fmt format;
1004 }; 1004 };
1005 typedef Bu::List<Arg> ArgList; 1005 typedef Bu::List<Arg> ArgList;
1006 ArgList lArgs; 1006 ArgList lArgs;
1007 FormatProxyEndAction *pAct; 1007 FormatProxyEndAction *pAct;
1008 mutable bool bOpen; 1008 mutable bool bOpen;
1009 }; 1009 };
1010 1010
1011 public: 1011 public:
1012 template<typename ArgType> 1012 template<typename ArgType>
1013 FormatProxy arg( const ArgType &x ) const 1013 FormatProxy arg( const ArgType &x ) const
1014 { 1014 {
1015 return FormatProxy( *this ).arg( x ); 1015 return FormatProxy( *this ).arg( x );
1016 } 1016 }
1017 1017
1018 template<typename ArgType> 1018 template<typename ArgType>
1019 FormatProxy arg( const ArgType &x, const Bu::Fmt &f ) const 1019 FormatProxy arg( const ArgType &x, const Bu::Fmt &f ) const
1020 { 1020 {
1021 return FormatProxy( *this ).arg( x, f ); 1021 return FormatProxy( *this ).arg( x, f );
1022 } 1022 }
1023 1023
1024 FormatProxy format() const 1024 FormatProxy format() const
1025 { 1025 {
1026 return FormatProxy( *this ); 1026 return FormatProxy( *this );
1027 } 1027 }
1028 1028
1029 FormatProxy format( FormatProxyEndAction *pEndAction ) const 1029 FormatProxy format( FormatProxyEndAction *pEndAction ) const
1030 { 1030 {
1031 return FormatProxy( *this, pEndAction ); 1031 return FormatProxy( *this, pEndAction );
1032 } 1032 }
1033 }; 1033 };
1034 1034
1035 template<class T> String operator+( const T *pLeft, const String &rRight ) 1035 template<class T> String operator+( const T *pLeft, const String &rRight )
1036 { 1036 {
1037 Bu::String ret( pLeft ); 1037 Bu::String ret( pLeft );
1038 ret.append( rRight ); 1038 ret.append( rRight );
1039 return ret; 1039 return ret;
1040 } 1040 }
1041 1041
1042 ArchiveBase &operator<<( ArchiveBase &ar, const String &s ); 1042 ArchiveBase &operator<<( ArchiveBase &ar, const String &s );
1043 ArchiveBase &operator>>( ArchiveBase &ar, String &s ); 1043 ArchiveBase &operator>>( ArchiveBase &ar, String &s );
1044 1044
1045 template<typename T> 1045 template<typename T>
1046 uint32_t __calcHashCode( const T &k ); 1046 uint32_t __calcHashCode( const T &k );
1047 1047
1048 template<typename T> 1048 template<typename T>
1049 bool __cmpHashKeys( const T &a, const T &b ); 1049 bool __cmpHashKeys( const T &a, const T &b );
1050 1050
1051 template<> uint32_t __calcHashCode<String>( const String &k ); 1051 template<> uint32_t __calcHashCode<String>( const String &k );
1052 template<> bool __cmpHashKeys<String>( 1052 template<> bool __cmpHashKeys<String>(
1053 const String &a, const String &b ); 1053 const String &a, const String &b );
1054 1054
1055 template<typename t> void __tracer_format( const t &v ); 1055 template<typename t> void __tracer_format( const t &v );
1056 template<> void __tracer_format<String>( const String &v ); 1056 template<> void __tracer_format<String>( const String &v );
1057 1057
1058 bool &operator<<( bool &dst, const String &sIn ); 1058 bool &operator<<( bool &dst, const String &sIn );
1059 uint8_t &operator<<( uint8_t &dst, const String &sIn ); 1059 uint8_t &operator<<( uint8_t &dst, const String &sIn );
1060 int8_t &operator<<( int8_t &dst, const String &sIn ); 1060 int8_t &operator<<( int8_t &dst, const String &sIn );
1061 char &operator<<( char &dst, const String &sIn ); 1061 char &operator<<( char &dst, const String &sIn );
1062 uint16_t &operator<<( uint16_t &dst, const String &sIn ); 1062 uint16_t &operator<<( uint16_t &dst, const String &sIn );
1063 int16_t &operator<<( int16_t &dst, const String &sIn ); 1063 int16_t &operator<<( int16_t &dst, const String &sIn );
1064 uint32_t &operator<<( uint32_t &dst, const String &sIn ); 1064 uint32_t &operator<<( uint32_t &dst, const String &sIn );
1065 int32_t &operator<<( int32_t &dst, const String &sIn ); 1065 int32_t &operator<<( int32_t &dst, const String &sIn );
1066 uint64_t &operator<<( uint64_t &dst, const String &sIn ); 1066 uint64_t &operator<<( uint64_t &dst, const String &sIn );
1067 int64_t &operator<<( int64_t &dst, const String &sIn ); 1067 int64_t &operator<<( int64_t &dst, const String &sIn );
1068 float &operator<<( float &dst, const String &sIn ); 1068 float &operator<<( float &dst, const String &sIn );
1069 double &operator<<( double &dst, const String &sIn ); 1069 double &operator<<( double &dst, const String &sIn );
1070 long double &operator<<( long double &dst, const String &sIn ); 1070 long double &operator<<( long double &dst, const String &sIn );
1071 Bu::String &operator<<( Bu::String &dst, const String &sIn ); 1071 Bu::String &operator<<( Bu::String &dst, const String &sIn );
1072 1072
1073 typedef Bu::List<String> StringList; 1073 typedef Bu::List<String> StringList;
1074}; 1074};
1075 1075
1076#endif 1076#endif