From a8e65a1e8aff4a254453f26719df95f8cacdaadf Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 18 Nov 2017 18:32:16 +0100 Subject: [PATCH] Fix android build. --- CMakeLists.txt | 2 +- code/FIReader.cpp | 24 +++++++++++++----------- code/FIReader.hpp | 10 ++++++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79db04762..73a30e9d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,7 +186,7 @@ IF( UNIX ) IF( ${OPERATING_SYSTEM} MATCHES "Android") ELSE() IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux - ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 ) + #ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 ) ENDIF() ENDIF() diff --git a/code/FIReader.cpp b/code/FIReader.cpp index fdf6b8a83..e167db026 100755 --- a/code/FIReader.cpp +++ b/code/FIReader.cpp @@ -45,13 +45,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER +#include "FIReader.hpp" +#include "StringUtils.h" + // Workaround for issue #1361 // https://github.com/assimp/assimp/issues/1361 #ifdef __ANDROID__ -#define _GLIBCXX_USE_C99 1 +# define _GLIBCXX_USE_C99 1 #endif -#include "FIReader.hpp" #include "Exceptional.h" #include #include @@ -685,7 +687,7 @@ public: if (intValue) { return intValue->value.size() == 1 ? intValue->value.front() : 0; } - return stoi(attr->value->toString()); + return atoi(attr->value->toString().c_str()); } virtual int getAttributeValueAsInt(int idx) const /*override*/ { @@ -696,7 +698,7 @@ public: if (intValue) { return intValue->value.size() == 1 ? intValue->value.front() : 0; } - return stoi(attributes[idx].value->toString()); + return atoi(attributes[idx].value->toString().c_str()); } virtual float getAttributeValueAsFloat(const char* name) const /*override*/ { @@ -708,7 +710,7 @@ public: if (floatValue) { return floatValue->value.size() == 1 ? floatValue->value.front() : 0; } - return stof(attr->value->toString()); + return atof(attr->value->toString().c_str()); } virtual float getAttributeValueAsFloat(int idx) const /*override*/ { @@ -719,7 +721,7 @@ public: if (floatValue) { return floatValue->value.size() == 1 ? floatValue->value.front() : 0; } - return stof(attributes[idx].value->toString()); + return atof(attributes[idx].value->toString().c_str()); } virtual const char* getNodeName() const /*override*/ { @@ -984,13 +986,13 @@ private: if (index < 32) { FIDecoder *decoder = defaultDecoder[index]; if (!decoder) { - throw DeadlyImportError("Invalid encoding algorithm index " + std::to_string(index)); + throw DeadlyImportError("Invalid encoding algorithm index " + to_string(index)); } return decoder->decode(dataP, len); } else { if (index - 32 >= vocabulary.encodingAlgorithmTable.size()) { - throw DeadlyImportError("Invalid encoding algorithm index " + std::to_string(index)); + throw DeadlyImportError("Invalid encoding algorithm index " + to_string(index)); } std::string uri = vocabulary.encodingAlgorithmTable[index - 32]; auto it = decoderMap.find(uri); @@ -1014,12 +1016,12 @@ private: alphabet = "0123456789-:TZ "; break; default: - throw DeadlyImportError("Invalid restricted alphabet index " + std::to_string(index)); + throw DeadlyImportError("Invalid restricted alphabet index " + to_string(index)); } } else { if (index - 16 >= vocabulary.restrictedAlphabetTable.size()) { - throw DeadlyImportError("Invalid restricted alphabet index " + std::to_string(index)); + throw DeadlyImportError("Invalid restricted alphabet index " + to_string(index)); } alphabet = vocabulary.restrictedAlphabetTable[index - 16]; } @@ -1027,7 +1029,7 @@ private: utf8::utf8to32(alphabet.begin(), alphabet.end(), back_inserter(alphabetUTF32)); std::string::size_type alphabetLength = alphabetUTF32.size(); if (alphabetLength < 2) { - throw DeadlyImportError("Invalid restricted alphabet length " + std::to_string(alphabetLength)); + throw DeadlyImportError("Invalid restricted alphabet length " + to_string(alphabetLength)); } std::string::size_type bitsPerCharacter = 1; while ((1ull << bitsPerCharacter) <= alphabetLength) { diff --git a/code/FIReader.hpp b/code/FIReader.hpp index 4e9f712a9..5f4e5bb48 100644 --- a/code/FIReader.hpp +++ b/code/FIReader.hpp @@ -46,12 +46,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_FI_READER_H #define INCLUDED_AI_FI_READER_H +#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER + +//#include #include +#include #include #include -#include #include -#include +//#include +//#include #include namespace Assimp { @@ -176,4 +180,6 @@ FIReader::~FIReader() { }// namespace Assimp +#endif // #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER + #endif // INCLUDED_AI_FI_READER_H