root/OpenSceneGraph/trunk/include/osgDB/StreamOperator @ 10988

Revision 10988, 3.0 kB (checked in by robert, 4 years ago)

Added back in StreamOperation? with executation bit disabled

Line 
1#ifndef OSGDB_STREAMOPERATOR
2#define OSGDB_STREAMOPERATOR
3
4#include <iostream>
5#include <sstream>
6#include <osgDB/DataTypes>
7
8namespace osgDB
9{
10
11class OSGDB_EXPORT OutputIterator
12{
13public:
14    OutputIterator() : _out(0) {}
15    virtual ~OutputIterator() {}
16   
17    void setStream( std::ostream* ostream ) { _out = ostream; }
18    std::ostream* getStream() { return _out; }
19    const std::ostream* getStream() const { return _out; }
20   
21    virtual bool isBinary() const = 0;
22   
23    virtual void writeBool( bool b ) = 0;
24    virtual void writeChar( char c ) = 0;
25    virtual void writeUChar( unsigned char c ) = 0;
26    virtual void writeShort( short s ) = 0;
27    virtual void writeUShort( unsigned short s ) = 0;
28    virtual void writeInt( int i ) = 0;
29    virtual void writeUInt( unsigned int i ) = 0;
30    virtual void writeLong( long l ) = 0;
31    virtual void writeULong( unsigned long l ) = 0;
32    virtual void writeFloat( float f ) = 0;
33    virtual void writeDouble( double d ) = 0;
34    virtual void writeString( const std::string& s ) = 0;
35    virtual void writeStream( std::ostream& (*fn)(std::ostream&) ) = 0;
36    virtual void writeBase( std::ios_base& (*fn)(std::ios_base&) ) = 0;
37   
38    virtual void writeGLenum( const ObjectGLenum& value ) = 0;
39    virtual void writeProperty( const ObjectProperty& prop ) = 0;
40    virtual void writeMark( const ObjectMark& mark ) = 0;
41    virtual void writeCharArray( const char* s, unsigned int size ) = 0;
42   
43protected:
44    std::ostream* _out;
45};
46
47class OSGDB_EXPORT InputIterator
48{
49public:
50    InputIterator() : _in(0), _failed(false) {}
51    virtual ~InputIterator() {}
52   
53    void setStream( std::istream* istream ) { _in = istream; }
54    std::istream* getStream() { return _in; }
55    const std::istream* getStream() const { return _in; }
56   
57    bool isFailed() const { return _failed; }
58    virtual bool isBinary() const = 0;
59   
60    virtual void readBool( bool& b ) = 0;
61    virtual void readChar( char& c ) = 0;
62    virtual void readSChar( signed char& c ) = 0;
63    virtual void readUChar( unsigned char& c ) = 0;
64    virtual void readShort( short& s ) = 0;
65    virtual void readUShort( unsigned short& s ) = 0;
66    virtual void readInt( int& i ) = 0;
67    virtual void readUInt( unsigned int& i ) = 0;
68    virtual void readLong( long& l ) = 0;
69    virtual void readULong( unsigned long& l ) = 0;
70    virtual void readFloat( float& f ) = 0;
71    virtual void readDouble( double& d ) = 0;
72    virtual void readString( std::string& s ) = 0;
73    virtual void readStream( std::istream& (*fn)(std::istream&) ) = 0;
74    virtual void readBase( std::ios_base& (*fn)(std::ios_base&) ) = 0;
75   
76    virtual void readGLenum( ObjectGLenum& value ) = 0;
77    virtual void readProperty( ObjectProperty& prop ) = 0;
78    virtual void readMark( ObjectMark& mark ) = 0;
79    virtual void readCharArray( char* s, unsigned int size ) = 0;
80   
81protected:
82    void checkStream() const
83    { if (_in->rdstate()&_in->failbit) _failed = true; }
84   
85    std::istream* _in;
86    mutable bool _failed;
87};
88
89}
90
91#endif
Note: See TracBrowser for help on using the browser.