45 #ifndef INCLUDED_AI_BASEIMPORTER_H
46 #define INCLUDED_AI_BASEIMPORTER_H
49 #pragma GCC system_header
52 #include "Exceptional.h"
54 #include <assimp/ai_assert.h>
70 class SharedPostProcessInfo;
74 #define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
75 (string[1] << 16) + (string[2] << 8) + string[3]))
115 virtual
bool CanRead(
116 const std::
string &pFile,
118 bool checkSig) const = 0;
141 const std::
string &pFile,
151 const std::
string &GetErrorText()
const {
186 virtual double GetFileScale()
const {
209 virtual void SetApplicationUnits(
const ImporterUnits &unit) {
210 importerScale = importerUnits[unit];
211 applicationUnits = unit;
214 virtual const ImporterUnits &GetApplicationUnits() {
215 return applicationUnits;
226 ImporterUnits applicationUnits = ImporterUnits::M;
227 double importerScale = 1.0;
228 double fileScale = 1.0;
275 const std::string &pFile,
296 const std::string &file,
298 unsigned int numTokens,
299 unsigned int searchBytes = 200,
300 bool tokensSol =
false,
301 bool noAlphaBeforeTokens =
false);
312 const std::string &pFile,
314 const char *ext1 =
nullptr,
315 const char *ext2 =
nullptr);
323 const std::string &pFile);
341 const std::string &pFile,
344 unsigned int offset = 0,
345 unsigned int size = 4);
354 std::vector<char> &data);
383 std::vector<char> &data,
391 template <
typename T>
392 AI_FORCE_INLINE
static void CopyVector(
395 unsigned int &outLength) {
396 outLength = unsigned(vec.size());
398 out =
new T[outLength];
399 std::swap_ranges(vec.begin(), vec.end(), out);
408 template <
typename T>
409 AI_FORCE_INLINE
static void CopyVector(
410 std::vector<std::unique_ptr<T> > &vec,
412 unsigned int &outLength) {
413 outLength = unsigned(vec.size());
415 out =
new T*[outLength];
417 std::for_each(vec.begin(), vec.end(), [&outPtr](std::unique_ptr<T>& uPtr){*outPtr = uPtr.release(); ++outPtr; });
423 virtual void UpdateImporterScale(
Importer *pImp);
436 #endif // AI_BASEIMPORTER_H_INC
virtual void SetFileScale(double scale)
Definition: BaseImporter.h:182
static bool SimpleExtensionCheck(const std::string &pFile, const char *ext0, const char *ext1=nullptr, const char *ext2=nullptr)
Check whether a file has a specific file extension.
BaseImporter() AI_NO_EXCEPT
Definition: Importer.hpp:120
static bool CheckMagicToken(IOSystem *pIOHandler, const std::string &pFile, const void *magic, unsigned int num, unsigned int offset=0, unsigned int size=4)
Check whether a file starts with one or more magic tokens.
const std::exception_ptr & GetException() const
Definition: BaseImporter.h:161
Abstract base class 'ProgressHandler'.
static void ConvertUTF8toISO8859_1(std::string &data)
std::string m_ErrorText
Error description in case there was one.
Definition: BaseImporter.h:427
static void ConvertToUTF8(std::vector< char > &data)
TextFileMode
Enum to define, if empty files are ok or not.
Definition: BaseImporter.h:367
static std::string GetExtension(const std::string &pFile)
Extract file extension from a string.
virtual const aiImporterDesc * GetInfo() const =0
void GetExtensionList(std::set< std::string > &extensions)
Definition: importerdesc.h:91
static void TextFileToBuffer(IOStream *stream, std::vector< char > &data, TextFileMode mode=FORBID_EMPTY)
virtual void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler)=0
virtual void SetupProperties(const Importer *pImp)
ProgressHandler * m_progress
Currently set progress handler.
Definition: BaseImporter.h:431
static bool SearchFileHeaderForToken(IOSystem *pIOSystem, const std::string &file, const char **tokens, unsigned int numTokens, unsigned int searchBytes=200, bool tokensSol=false, bool noAlphaBeforeTokens=false)
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:93
Definition: BaseImporter.h:87
Definition: ai_assert.h:50
std::map< ImporterUnits, double > importerUnits
Definition: BaseImporter.h:207
CPP-API: Class to handle file I/O for C++.
Definition: IOStream.hpp:75
std::exception_ptr m_Exception
The exception, in case there was one.
Definition: BaseImporter.h:429
CPP-API: Abstract interface for custom progress report receivers.
Definition: ProgressHandler.hpp:67