Show
Ignore:
Timestamp:
01/27/10 18:09:05 (5 years ago)
Author:
robert
Message:

From Wang Rui, "Changes:

1. Rewrite the reading/writing exception handlers to work like the ive
plugin exceptions.
2. Write a header writing/checking function in ReaderWriterOSG2.cpp,
which may help decide if the stream is ascii or binary. The
readInputIterator() function will return null pointer if the input
file is nither osgb nor osgt format, which indicates that the old .osg
format could be used here, in case we've merged the two plugins
together.
3. Add a new ForceReadingImage? option in the InputStream?, which will
allocate an empty image object with the filename if specifed external
image file is missed. It may be useful for format converting in some
cases.
4. Add new osgParticle wrappers, as well as some modification to the
osgParticle headers, for instance, change isEnabled() to getEnabled().
5. Some fixes to the osg serialization wrappers."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgDB/OutputStream

    r10986 r11018  
    3131{ 
    3232 
    33 class OutputException 
     33class OutputException : public osg::Referenced 
    3434{ 
    3535public: 
    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    } 
    3844     
    3945    const std::string& getField() const { return _field; } 
     
    7177     
    7278    bool isBinary() const { return _out->isBinary(); } 
     79    const std::string& getSchemaName() const { return _schemaName; } 
    7380     
    7481    void setWriteImageHint( WriteImageHint hint ) { _writeImageHint = hint; } 
     
    126133     
    127134    // Convenient methods for writing 
    128     inline void writeWrappedString( const std::string& str ); 
     135    void writeWrappedString( const std::string& str ); 
    129136    void writeCharArray( const char* s, unsigned int size ) { _out->writeCharArray(s, size); } 
    130137     
     
    141148    void writeSchema( std::ostream& fout ); 
    142149     
     150    // Exception handlers 
     151    inline void throwException( const std::string& msg ); 
     152    const OutputException* getException() const { return _exception.get(); } 
     153     
    143154protected: 
    144155    template<typename T> 
     
    152163     
    153164    WriteImageHint _writeImageHint; 
    154     std::string _currentField; 
     165    std::vector<std::string> _fields; 
     166    std::string _schemaName; 
    155167    std::string _compressorName; 
    156168    std::stringstream _compressSource; 
    157     OutputIterator* _out; 
     169    osg::ref_ptr<OutputIterator> _out; 
     170    osg::ref_ptr<OutputException> _exception; 
    158171}; 
    159172 
    160 void OutputStream::writeWrappedString( const std::string& str ) 
     173void OutputStream::throwException( const std::string& msg ) 
    161174{ 
    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); 
    169176} 
    170177