Changeset 142

Show
Ignore:
Timestamp:
04/08/05 05:17:21 (4 years ago)
Author:
athomas
Message:

Support for bool in Variable and made vector<T>/list<T> template stream
operators global.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libcrash/trunk/crash/StringManip.h

    r135 r142  
    386386        public : 
    387387                osprintf(char const *fmt, ...); 
     388 
     389                const char *getBuffer() const { return buffer; } 
    388390        private : 
    389                 friend std::ostream &operator << (std::ostream &out, osprintf const &p); 
    390  
    391391                char buffer[2048]; 
    392392}; 
    393393 
    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 
     396inline std::ostream &operator << (std::ostream &out, crash::osprintf const &p) { 
     397        return out << p.getBuffer(); 
     398
     399 
     400template <typename T> 
     401inline std::istream &operator >> (std::istream &in, std::vector<T> &v) { 
    400402T t; 
    401403 
     
    403405        while (in >> t) { 
    404406                v.push_back(t); 
    405                 eat(in); 
     407                crash::eat(in); 
    406408                if (in.peek() != ',') 
    407409                        break; 
    408410                else { 
    409411                        in.get(); 
    410                         eat(in); 
     412                        crash::eat(in); 
    411413                } 
    412414        } 
     
    415417 
    416418template <typename T> 
    417 std::ostream &operator << (std::ostream &out, std::vector<T> const &v) { 
    418         out << "{ "; 
     419inline std::ostream &operator << (std::ostream &out, std::vector<T> const &v) { 
    419420        for (unsigned i = 0; i != v.size(); ++i) { 
    420421                out << v[i]; 
    421422                if (i != v.size() - 1) out << ", "; 
    422423        } 
    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 
     427template <typename T> 
     428inline std::istream &operator >> (std::istream &in, std::list<T> &v) { 
    429429T t; 
    430430 
     
    432432        while (in >> t) { 
    433433                v.push_back(t); 
    434                 eat(in); 
     434                crash::eat(in); 
    435435                if (in.peek() != ',') 
    436436                        break; 
    437437                else { 
    438438                        in.get(); 
    439                         eat(in); 
     439                        crash::eat(in); 
    440440                } 
    441441        } 
     
    444444 
    445445template <typename T> 
    446 std::ostream &operator << (std::ostream &out, std::list<T> const &v) { 
     446inline std::ostream &operator << (std::ostream &out, std::list<T> const &v) { 
    447447typename std::list<T>::const_iterator end; 
    448448 
    449         out << "{ "; 
    450449        for (typename std::list<T>::const_iterator i = v.begin(); i != v.end(); ++i) { 
    451450                out << *i; 
    452451                if (i != end) out << ", "; 
    453452        } 
    454         out << " }"; 
    455         return out; 
    456 
    457  
     453        return out; 
    458454} 
    459455 
  • libcrash/trunk/crash/Variable.h

    r140 r142  
    5555                        mtype = NUMBER; 
    5656                        mnumber = num; 
     57                } 
     58 
     59                Variable(bool val) { 
     60                        mtype = NUMBER; 
     61                        mnumber = val; 
    5762                } 
    5863