/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWEAR_MAPLESTREAM_H
#define __IWEAR_MAPLESTREAM_H

#include <iostream>
using std::ios_base;
using std::ostream;

namespace iwear
{
/**
 * This stream is for outputting objects for maple. This means, a certain
 * object has to implement an operator<< for a MapleStream so that it can be
 * output in a maple-readable way.
 */
class MapleStream
{
protected:
    ostream& o;
public:
    inline MapleStream( ostream& _o ) : o(_o) { }
//    template<class T> MapleStream& operator<< (const T& c );

    inline MapleStream& operator<<( ostream::__ostream_type& (*__pf)(ostream::__ostream_type&)) { o << __pf; return *this; }
    inline MapleStream& operator<<( ostream::__ios_type& (*__pf)(ostream::__ios_type&)) { o << __pf; return *this;}
    inline MapleStream& operator<<( ios_base& (*__pf) (ios_base&)) { o << __pf; return *this; }

    template<class T> void print( const T& c ) { o << c; }
    void print( const MapleStream& c ) { o << c.o; }
};

template<class T>
inline MapleStream& operator<< ( MapleStream& o, const T& c ) 
{ 
    o.print(c); 
    return o;
}
/*
template<>
inline MapleStream& operator<< <MapleStream> ( MapleStream& o, const MapleStream& vo )
{ 
    o.print(vo.o); 
    return o;
}
*/

extern MapleStream mout;
extern MapleStream merr;

}

#endif
