next up previous contents index
Next: cachedDBM Up: eco_strstream class Previous: eco_string class   Contents   Index


eco_strstream

This is a modified version of ostrstream for Eco Lab use, with slightly altered behaviour making it more suited for Eco Lab use.

In particular, operator<< add spaces in between its arguments, and a new operator| is defined that is similar to ostrstream operator<<. This makes it easier to construct TCL commands.

Note that | has higher precedence than <<, so when mixing the two, ensure that no << operator appears to the right of |, or use brackets to ensure the correct interpretaion:

eg.

    s << a << b | c;
or
    (s | a) << b | c;
but not
    s | a << b | c;

In any case, you'll most likely get a compiler warning if you do the wrong thing.

eco_strstream is derived from eco_string class, so has all the string behaviour. The str() member is defiend as equivalent to a (char*) cast for compatibility with ostrstream. However, the contents of the char* are not frozen, unless explicitly specified with freeze() (opposite to ostrstream behaviour).

class eco_strstream: public eco_string
{
  public:
    char* str() const;
    
    template<class T>
    eco_strstream& operator<<(const T x); 

    template<class T>
    eco_strstream& operator|(T);
}

inline ostream& operator<<(ostream& x, eco_strstream& y);


Russell Standish 2016-09-02