Changeset 11018 for OpenSceneGraph/trunk/include/osgDB/OutputStream
- Timestamp:
- 01/27/10 18:09:05 (3 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgDB/OutputStream (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgDB/OutputStream
r10986 r11018 31 31 { 32 32 33 class OutputException 33 class OutputException : public osg::Referenced 34 34 { 35 35 public: 36 OutputException( const std::string& field, const std::string& err ) 37 : _field(field), _error(err) {} 36 OutputException( const std::vector<std::string>& fields, const std::string& err ) : _error(err) 37 { 38 for ( unsigned int i=0; i<fields.size(); ++i ) 39 { 40 _field += fields[i]; 41 _field += " "; 42 } 43 } 38 44 39 45 const std::string& getField() const { return _field; } … … 71 77 72 78 bool isBinary() const { return _out->isBinary(); } 79 const std::string& getSchemaName() const { return _schemaName; } 73 80 74 81 void setWriteImageHint( WriteImageHint hint ) { _writeImageHint = hint; } … … 126 133 127 134 // Convenient methods for writing 128 inlinevoid writeWrappedString( const std::string& str );135 void writeWrappedString( const std::string& str ); 129 136 void writeCharArray( const char* s, unsigned int size ) { _out->writeCharArray(s, size); } 130 137 … … 141 148 void writeSchema( std::ostream& fout ); 142 149 150 // Exception handlers 151 inline void throwException( const std::string& msg ); 152 const OutputException* getException() const { return _exception.get(); } 153 143 154 protected: 144 155 template<typename T> … … 152 163 153 164 WriteImageHint _writeImageHint; 154 std::string _currentField; 165 std::vector<std::string> _fields; 166 std::string _schemaName; 155 167 std::string _compressorName; 156 168 std::stringstream _compressSource; 157 OutputIterator* _out; 169 osg::ref_ptr<OutputIterator> _out; 170 osg::ref_ptr<OutputException> _exception; 158 171 }; 159 172 160 void OutputStream:: writeWrappedString( const std::string& str)173 void OutputStream::throwException( const std::string& msg ) 161 174 { 162 if ( !isBinary() ) 163 { 164 std::string wrappedStr = std::string("\"") + str + std::string("\""); 165 *this << wrappedStr; 166 } 167 else 168 *this << str; 175 _exception = new OutputException(_fields, msg); 169 176 } 170 177
