- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/osg/AsciiStreamOperator.h
r12808 r13041 14 14 if (precision>0) _out->precision(precision); 15 15 } 16 16 17 17 virtual ~AsciiOutputIterator() {} 18 18 19 19 virtual bool isBinary() const { return false; } 20 20 21 21 virtual void writeBool( bool b ) 22 22 { … … 25 25 else *_out << "FALSE "; 26 26 } 27 27 28 28 virtual void writeChar( char c ) 29 29 { indentIfRequired(); *_out << (short)c << ' '; } 30 30 31 31 virtual void writeUChar( unsigned char c ) 32 32 { indentIfRequired(); *_out << (unsigned short)c << ' '; } 33 33 34 34 virtual void writeShort( short s ) 35 35 { indentIfRequired(); *_out << s << ' '; } 36 36 37 37 virtual void writeUShort( unsigned short s ) 38 38 { indentIfRequired(); *_out << s << ' '; } 39 39 40 40 virtual void writeInt( int i ) 41 41 { indentIfRequired(); *_out << i << ' '; } 42 42 43 43 virtual void writeUInt( unsigned int i ) 44 44 { indentIfRequired(); *_out << i << ' '; } 45 45 46 46 virtual void writeLong( long l ) 47 47 { indentIfRequired(); *_out << l << ' '; } 48 48 49 49 virtual void writeULong( unsigned long l ) 50 50 { indentIfRequired(); *_out << l << ' '; } 51 51 52 52 virtual void writeFloat( float f ) 53 53 { indentIfRequired(); *_out << f << ' '; } 54 54 55 55 virtual void writeDouble( double d ) 56 56 { indentIfRequired(); *_out << d << ' '; } 57 57 58 58 virtual void writeString( const std::string& s ) 59 59 { indentIfRequired(); *_out << s << ' '; } 60 60 61 61 virtual void writeStream( std::ostream& (*fn)(std::ostream&) ) 62 62 { … … 67 67 } 68 68 } 69 69 70 70 virtual void writeBase( std::ios_base& (*fn)(std::ios_base&) ) 71 71 { 72 72 indentIfRequired(); *_out << fn; 73 73 } 74 74 75 75 virtual void writeGLenum( const osgDB::ObjectGLenum& value ) 76 76 { … … 79 79 indentIfRequired(); *_out << enumString << ' '; 80 80 } 81 81 82 82 virtual void writeProperty( const osgDB::ObjectProperty& prop ) 83 83 { … … 89 89 indentIfRequired(); *_out << enumString << ' '; 90 90 } 91 91 92 92 virtual void writeMark( const osgDB::ObjectMark& mark ) 93 93 { … … 95 95 indentIfRequired(); *_out << mark._name; 96 96 } 97 97 98 98 virtual void writeCharArray( const char* s, unsigned int size ) {} 99 99 100 100 virtual void writeWrappedString( const std::string& str ) 101 101 { … … 109 109 wrappedStr += ch; 110 110 } 111 111 112 112 wrappedStr.insert( std::string::size_type(0), 1, '\"' ); 113 113 wrappedStr += '\"'; … … 116 116 writeString( wrappedStr ); 117 117 } 118 118 119 119 protected: 120 120 … … 128 128 } 129 129 } 130 130 131 131 bool _readyForIndent; 132 132 int _indent; … … 138 138 AsciiInputIterator( std::istream* istream ) { _in = istream; } 139 139 virtual ~AsciiInputIterator() {} 140 140 141 141 virtual bool isBinary() const { return false; } 142 142 143 143 virtual void readBool( bool& b ) 144 144 { … … 148 148 else b = false; 149 149 } 150 150 151 151 virtual void readChar( char& c ) 152 152 { … … 155 155 c = (char)s; 156 156 } 157 157 158 158 virtual void readSChar( signed char& c ) 159 159 { … … 162 162 c = (signed char)s; 163 163 } 164 164 165 165 virtual void readUChar( unsigned char& c ) 166 166 { … … 169 169 c = (unsigned char)s; 170 170 } 171 171 172 172 virtual void readShort( short& s ) 173 173 { std::string str; readString(str); s = static_cast<short>(strtol(str.c_str(), NULL, 0)); } 174 174 175 175 virtual void readUShort( unsigned short& s ) 176 176 { std::string str; readString(str); s = static_cast<unsigned short>(strtoul(str.c_str(), NULL, 0)); } 177 177 178 178 virtual void readInt( int& i ) 179 179 { std::string str; readString(str); i = static_cast<int>(strtol(str.c_str(), NULL, 0)); } 180 180 181 181 virtual void readUInt( unsigned int& i ) 182 182 { std::string str; readString(str); i = static_cast<unsigned int>(strtoul(str.c_str(), NULL, 0)); } 183 183 184 184 virtual void readLong( long& l ) 185 185 { std::string str; readString(str); l = strtol(str.c_str(), NULL, 0); } 186 186 187 187 virtual void readULong( unsigned long& l ) 188 188 { std::string str; readString(str); l = strtoul(str.c_str(), NULL, 0); } 189 189 190 190 virtual void readFloat( float& f ) 191 191 { std::string str; readString(str); f = osg::asciiToFloat(str.c_str()); } 192 192 193 193 virtual void readDouble( double& d ) 194 194 { std::string str; readString(str); d = osg::asciiToDouble(str.c_str()); } 195 195 196 196 virtual void readString( std::string& s ) 197 197 { … … 204 204 } 205 205 } 206 206 207 207 virtual void readStream( std::istream& (*fn)(std::istream&) ) 208 208 { *_in >> fn; } 209 209 210 210 virtual void readBase( std::ios_base& (*fn)(std::ios_base&) ) 211 211 { *_in >> fn; } 212 212 213 213 virtual void readGLenum( osgDB::ObjectGLenum& value ) 214 214 { … … 219 219 value.set( e ); 220 220 } 221 221 222 222 virtual void readProperty( osgDB::ObjectProperty& prop ) 223 223 { … … 240 240 prop.set( value ); 241 241 } 242 242 243 243 virtual void readMark( osgDB::ObjectMark& mark ) 244 244 { … … 246 246 readString( markString ); 247 247 } 248 248 249 249 virtual void readCharArray( char* s, unsigned int size ) {} 250 250 251 251 virtual void readWrappedString( std::string& str ) 252 252 { … … 291 291 if ( _preReadString.empty() ) 292 292 *_in >> _preReadString; 293 293 294 294 if ( _preReadString==str ) 295 295 { … … 299 299 return false; 300 300 } 301 301 302 302 virtual void advanceToCurrentEndBracket() 303 303 { … … 308 308 passString.clear(); 309 309 readString( passString ); 310 310 311 311 if ( passString=="}" ) 312 312 { … … 318 318 } 319 319 } 320 320 321 321 protected: 322 322 void getCharacter( char& ch ) … … 333 333 } 334 334 } 335 335 336 336 std::string _preReadString; 337 337 };
