Changeset 142
- Timestamp:
- 04/08/05 05:17:21 (4 years ago)
- Files:
-
- libcrash/trunk/crash/StringManip.h (modified) (5 diffs)
- libcrash/trunk/crash/Variable.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libcrash/trunk/crash/StringManip.h
r135 r142 386 386 public : 387 387 osprintf(char const *fmt, ...); 388 389 const char *getBuffer() const { return buffer; } 388 390 private : 389 friend std::ostream &operator << (std::ostream &out, osprintf const &p);390 391 391 char buffer[2048]; 392 392 }; 393 393 394 inline std::ostream &operator << (std::ostream &out, osprintf const &p) { 395 return out << p.buffer; 396 } 397 398 template <typename T> 399 std::istream &operator >> (std::istream &in, std::vector<T> &v) { 394 } 395 396 inline std::ostream &operator << (std::ostream &out, crash::osprintf const &p) { 397 return out << p.getBuffer(); 398 } 399 400 template <typename T> 401 inline std::istream &operator >> (std::istream &in, std::vector<T> &v) { 400 402 T t; 401 403 … … 403 405 while (in >> t) { 404 406 v.push_back(t); 405 eat(in);407 crash::eat(in); 406 408 if (in.peek() != ',') 407 409 break; 408 410 else { 409 411 in.get(); 410 eat(in);412 crash::eat(in); 411 413 } 412 414 } … … 415 417 416 418 template <typename T> 417 std::ostream &operator << (std::ostream &out, std::vector<T> const &v) { 418 out << "{ "; 419 inline std::ostream &operator << (std::ostream &out, std::vector<T> const &v) { 419 420 for (unsigned i = 0; i != v.size(); ++i) { 420 421 out << v[i]; 421 422 if (i != v.size() - 1) out << ", "; 422 423 } 423 out << " }"; 424 return out; 425 } 426 427 template <typename T> 428 std::istream &operator >> (std::istream &in, std::list<T> &v) { 424 return out; 425 } 426 427 template <typename T> 428 inline std::istream &operator >> (std::istream &in, std::list<T> &v) { 429 429 T t; 430 430 … … 432 432 while (in >> t) { 433 433 v.push_back(t); 434 eat(in);434 crash::eat(in); 435 435 if (in.peek() != ',') 436 436 break; 437 437 else { 438 438 in.get(); 439 eat(in);439 crash::eat(in); 440 440 } 441 441 } … … 444 444 445 445 template <typename T> 446 std::ostream &operator << (std::ostream &out, std::list<T> const &v) {446 inline std::ostream &operator << (std::ostream &out, std::list<T> const &v) { 447 447 typename std::list<T>::const_iterator end; 448 448 449 out << "{ ";450 449 for (typename std::list<T>::const_iterator i = v.begin(); i != v.end(); ++i) { 451 450 out << *i; 452 451 if (i != end) out << ", "; 453 452 } 454 out << " }"; 455 return out; 456 } 457 453 return out; 458 454 } 459 455 libcrash/trunk/crash/Variable.h
r140 r142 55 55 mtype = NUMBER; 56 56 mnumber = num; 57 } 58 59 Variable(bool val) { 60 mtype = NUMBER; 61 mnumber = val; 57 62 } 58 63
