diff options
author | Andy Maloney <asmaloney@gmail.com> | 2016-12-07 19:33:08 -0500 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-14 11:26:18 +0000 |
commit | 3cd55c54dbf66a320438d743fbd223952043cd39 (patch) | |
tree | aecda25c473f481695619102a907249a47823190 /src/3rdparty/assimp/code/irrXMLWrapper.h | |
parent | 9675579a6d7955b0b278a54050f6f503e2b10b1a (diff) |
Update assimp lib to 3.3.1
The currently included assimp lib is v3.0 from 2012.
This updates assimp lib to the latest released version (3.3.1).
Change-Id: I15a60e3150c0b268422f23137107b34e4c5c4342
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/3rdparty/assimp/code/irrXMLWrapper.h')
-rw-r--r-- | src/3rdparty/assimp/code/irrXMLWrapper.h | 155 |
1 files changed, 79 insertions, 76 deletions
diff --git a/src/3rdparty/assimp/code/irrXMLWrapper.h b/src/3rdparty/assimp/code/irrXMLWrapper.h index b06b426f8..41e418811 100644 --- a/src/3rdparty/assimp/code/irrXMLWrapper.h +++ b/src/3rdparty/assimp/code/irrXMLWrapper.h @@ -2,11 +2,11 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2012, assimp team +Copyright (c) 2006-2016, assimp team All rights reserved. -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above @@ -23,16 +23,16 @@ contributors may be used to endorse or promote products derived from this software without specific prior written permission of the assimp team. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- @@ -44,7 +44,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // some long includes .... #include "./../contrib/irrXML/irrXML.h" #include "./../include/assimp/IOStream.hpp" -namespace Assimp { +#include "BaseImporter.h" +#include <vector> + +namespace Assimp { // --------------------------------------------------------------------------------- /** @brief Utility class to make IrrXML work together with our custom IO system @@ -53,86 +56,86 @@ namespace Assimp { * Construct IrrXML-Reader in BaseImporter::InternReadFile(): * @code * // open the file - * boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile)); + * std::unique_ptr<IOStream> file( pIOHandler->Open( pFile)); * if( file.get() == NULL) { - * throw DeadlyImportError( "Failed to open file " + pFile + "."); + * throw DeadlyImportError( "Failed to open file " + pFile + "."); * } * * // generate a XML reader for it - * boost::scoped_ptr<CIrrXML_IOStreamReader> mIOWrapper( new CIrrXML_IOStreamReader( file.get())); + * std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper( new CIrrXML_IOStreamReader( file.get())); * mReader = irr::io::createIrrXMLReader( mIOWrapper.get()); * if( !mReader) { * ThrowException( "xxxx: Unable to open file."); * } * @endcode **/ -class CIrrXML_IOStreamReader - : public irr::io::IFileReadCallBack +class CIrrXML_IOStreamReader + : public irr::io::IFileReadCallBack { public: - // ---------------------------------------------------------------------------------- - //! Construction from an existing IOStream - CIrrXML_IOStreamReader(IOStream* _stream) - : stream (_stream) - , t (0) - { - - // Map the buffer into memory and convert it to UTF8. IrrXML provides its - // own conversion, which is merely a cast from uintNN_t to uint8_t. Thus, - // it is not suitable for our purposes and we have to do it BEFORE IrrXML - // gets the buffer. Sadly, this forces us to map the whole file into - // memory. - - data.resize(stream->FileSize()); - stream->Read(&data[0],data.size(),1); - - // Remove null characters from the input sequence otherwise the parsing will utterly fail - unsigned int size = 0; - unsigned int size_max = data.size(); - for(unsigned int i = 0; i < size_max; i++) { - if(data[i] != '\0') { - data[size++] = data[i]; - } - } - data.resize(size); - - BaseImporter::ConvertToUTF8(data); - } - - // ---------------------------------------------------------------------------------- - //! Virtual destructor - virtual ~CIrrXML_IOStreamReader() {}; - - // ---------------------------------------------------------------------------------- - //! Reads an amount of bytes from the file. - /** @param buffer: Pointer to output buffer. - * @param sizeToRead: Amount of bytes to read - * @return Returns how much bytes were read. */ - virtual int read(void* buffer, int sizeToRead) { - if(sizeToRead<0) { - return 0; - } - if(t+sizeToRead>data.size()) { - sizeToRead = data.size()-t; - } - - memcpy(buffer,&data.front()+t,sizeToRead); - - t += sizeToRead; - return sizeToRead; - } - - // ---------------------------------------------------------------------------------- - //! Returns size of file in bytes - virtual int getSize() { - return (int)data.size(); - } + // ---------------------------------------------------------------------------------- + //! Construction from an existing IOStream + explicit CIrrXML_IOStreamReader(IOStream* _stream) + : stream (_stream) + , t (0) + { + + // Map the buffer into memory and convert it to UTF8. IrrXML provides its + // own conversion, which is merely a cast from uintNN_t to uint8_t. Thus, + // it is not suitable for our purposes and we have to do it BEFORE IrrXML + // gets the buffer. Sadly, this forces us to map the whole file into + // memory. + + data.resize(stream->FileSize()); + stream->Read(&data[0],data.size(),1); + + // Remove null characters from the input sequence otherwise the parsing will utterly fail + unsigned int size = 0; + unsigned int size_max = data.size(); + for(unsigned int i = 0; i < size_max; i++) { + if(data[i] != '\0') { + data[size++] = data[i]; + } + } + data.resize(size); + + BaseImporter::ConvertToUTF8(data); + } + + // ---------------------------------------------------------------------------------- + //! Virtual destructor + virtual ~CIrrXML_IOStreamReader() {} + + // ---------------------------------------------------------------------------------- + //! Reads an amount of bytes from the file. + /** @param buffer: Pointer to output buffer. + * @param sizeToRead: Amount of bytes to read + * @return Returns how much bytes were read. */ + virtual int read(void* buffer, int sizeToRead) { + if(sizeToRead<0) { + return 0; + } + if(t+sizeToRead>data.size()) { + sizeToRead = data.size()-t; + } + + memcpy(buffer,&data.front()+t,sizeToRead); + + t += sizeToRead; + return sizeToRead; + } + + // ---------------------------------------------------------------------------------- + //! Returns size of file in bytes + virtual int getSize() { + return (int)data.size(); + } private: - IOStream* stream; - std::vector<char> data; - size_t t; + IOStream* stream; + std::vector<char> data; + size_t t; }; // ! class CIrrXML_IOStreamReader |