Assimp
v3.1.1 (June 2014)
|
FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface for all importer worker classes. More...
Public Member Functions | |
BaseImporter () | |
Constructor to be privately used by Importer. | |
virtual bool | CanRead (const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const =0 |
Returns whether the class can handle the format of the given file. | |
const std::string & | GetErrorText () const |
Returns the error description of the last error that occured. | |
void | GetExtensionList (std::set< std::string > &extensions) |
Called by #Importer::GetExtensionList for each loaded importer. | |
virtual const aiImporterDesc * | GetInfo () const =0 |
Called by #Importer::GetImporterInfo to get a description of some loader features. | |
aiScene * | ReadFile (const Importer *pImp, const std::string &pFile, IOSystem *pIOHandler) |
Imports the given file and returns the imported data. | |
virtual void | SetupProperties (const Importer *pImp) |
Called prior to ReadFile(). | |
virtual | ~BaseImporter () |
Destructor, private as well. | |
Static Public Member Functions | |
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. | |
static void | ConvertToUTF8 (std::vector< char > &data) |
An utility for all text file loaders. | |
static void | ConvertUTF8toISO8859_1 (std::string &data) |
An utility for all text file loaders. | |
static std::string | GetExtension (const std::string &pFile) |
Extract file extension from a string. | |
static bool | SearchFileHeaderForToken (IOSystem *pIOSystem, const std::string &file, const char **tokens, unsigned int numTokens, unsigned int searchBytes=200, bool tokensSol=false) |
A utility for CanRead(). | |
static bool | SimpleExtensionCheck (const std::string &pFile, const char *ext0, const char *ext1=NULL, const char *ext2=NULL) |
Check whether a file has a specific file extension. | |
static void | TextFileToBuffer (IOStream *stream, std::vector< char > &data) |
Utility for text file loaders which copies the contents of the file into a memory buffer and converts it to our UTF8 representation. | |
Protected Member Functions | |
virtual void | InternReadFile (const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler)=0 |
Imports the given file into the given scene structure. | |
Protected Attributes | |
std::string | m_ErrorText |
Error description in case there was one. | |
ProgressHandler * | m_progress |
Currently set progress handler. | |
Friends | |
class | Importer |
FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface for all importer worker classes.
The interface defines two functions: CanRead() is used to check if the importer can handle the format of the given file. If an implementation of this function returns true, the importer then calls ReadFile() which imports the given file. ReadFile is not overridable, it just calls InternReadFile() and catches any ImportErrorException that might occur.
Constructor to be privately used by Importer.
virtual Assimp::BaseImporter::~BaseImporter | ( | ) | [virtual] |
Destructor, private as well.
virtual bool Assimp::BaseImporter::CanRead | ( | const std::string & | pFile, |
IOSystem * | pIOHandler, | ||
bool | checkSig | ||
) | const [pure virtual] |
Returns whether the class can handle the format of the given file.
The implementation should be as quick as possible. A check for the file extension is enough. If no suitable loader is found with this strategy, CanRead() is called again, the 'checkSig' parameter set to true this time. Now the implementation is expected to perform a full check of the file structure, possibly searching the first bytes of the file for magic identifiers or keywords.
pFile | Path and file name of the file to be examined. |
pIOHandler | The IO handler to use for accessing any file. |
checkSig | Set to true if this method is called a second time. This time, the implementation may take more time to examine the contents of the file to be loaded for magic bytes, keywords, etc to be able to load files with unknown/not existent file extensions. |
static bool Assimp::BaseImporter::CheckMagicToken | ( | IOSystem * | pIOHandler, |
const std::string & | pFile, | ||
const void * | magic, | ||
unsigned int | num, | ||
unsigned int | offset = 0 , |
||
unsigned int | size = 4 |
||
) | [static] |
Check whether a file starts with one or more magic tokens.
pFile | Input file |
pIOHandler | IO system to be used |
magic | n magic tokens num Size of magic |
offset | Offset from file start where tokens are located |
Size | of one token, in bytes. Maximally 16 bytes. |
static void Assimp::BaseImporter::ConvertToUTF8 | ( | std::vector< char > & | data | ) | [static] |
An utility for all text file loaders.
It converts a file to our UTF8 character set. Errors are reported, but ignored.
data | File buffer to be converted to UTF8 data. The buffer is resized as appropriate. |
static void Assimp::BaseImporter::ConvertUTF8toISO8859_1 | ( | std::string & | data | ) | [static] |
An utility for all text file loaders.
It converts a file from our UTF8 character set back to ISO-8859-1. Errors are reported, but ignored.
data | File buffer to be converted from UTF8 to ISO-8859-1. The buffer is resized as appropriate. |
const std::string& Assimp::BaseImporter::GetErrorText | ( | ) | const [inline] |
Returns the error description of the last error that occured.
static std::string Assimp::BaseImporter::GetExtension | ( | const std::string & | pFile | ) | [static] |
Extract file extension from a string.
pFile | Input file |
void Assimp::BaseImporter::GetExtensionList | ( | std::set< std::string > & | extensions | ) |
Called by #Importer::GetExtensionList for each loaded importer.
Take the extension list contained in the structure returned by GetInfo and insert all file extensions into the given set.
extension | set to collect file extensions in |
virtual const aiImporterDesc* Assimp::BaseImporter::GetInfo | ( | ) | const [pure virtual] |
Called by #Importer::GetImporterInfo to get a description of some loader features.
Importers must provide this information.
virtual void Assimp::BaseImporter::InternReadFile | ( | const std::string & | pFile, |
aiScene * | pScene, | ||
IOSystem * | pIOHandler | ||
) | [protected, pure virtual] |
Imports the given file into the given scene structure.
The function is expected to throw an ImportErrorException if there is an error. If it terminates normally, the data in aiScene is expected to be correct. Override this function to implement the actual importing.
The output scene must meet the following requirements:
If the AI_SCENE_FLAGS_INCOMPLETE-Flag is not set:
This won't be checked (except by the validation step): Assimp will crash if one of the conditions is not met!
pFile | Path of the file to be imported. |
pScene | The scene object to hold the imported data. NULL is not a valid parameter. |
pIOHandler | The IO handler to use for any file access. NULL is not a valid parameter. |
aiScene* Assimp::BaseImporter::ReadFile | ( | const Importer * | pImp, |
const std::string & | pFile, | ||
IOSystem * | pIOHandler | ||
) |
Imports the given file and returns the imported data.
If the import succeeds, ownership of the data is transferred to the caller. If the import fails, NULL is returned. The function takes care that any partially constructed data is destroyed beforehand.
pImp | Importer object hosting this loader. |
pFile | Path of the file to be imported. |
pIOHandler | IO-Handler used to open this and possible other files. |
static bool Assimp::BaseImporter::SearchFileHeaderForToken | ( | IOSystem * | pIOSystem, |
const std::string & | file, | ||
const char ** | tokens, | ||
unsigned int | numTokens, | ||
unsigned int | searchBytes = 200 , |
||
bool | tokensSol = false |
||
) | [static] |
A utility for CanRead().
The function searches the header of a file for a specific token and returns true if this token is found. This works for text files only. There is a rudimentary handling of UNICODE files. The comparison is case independent.
pIOSystem | IO System to work with |
file | File name of the file |
tokens | List of tokens to search for |
numTokens | Size of the token array |
searchBytes | Number of bytes to be searched for the tokens. |
virtual void Assimp::BaseImporter::SetupProperties | ( | const Importer * | pImp | ) | [virtual] |
Called prior to ReadFile().
The function is a request to the importer to update its configuration basing on the Importer's configuration property list.
pImp | Importer instance |
static bool Assimp::BaseImporter::SimpleExtensionCheck | ( | const std::string & | pFile, |
const char * | ext0, | ||
const char * | ext1 = NULL , |
||
const char * | ext2 = NULL |
||
) | [static] |
Check whether a file has a specific file extension.
pFile | Input file |
ext0 | Extension to check for. Lowercase characters only, no dot! |
ext1 | Optional second extension |
ext2 | Optional third extension |
static void Assimp::BaseImporter::TextFileToBuffer | ( | IOStream * | stream, |
std::vector< char > & | data | ||
) | [static] |
Utility for text file loaders which copies the contents of the file into a memory buffer and converts it to our UTF8 representation.
stream | Stream to read from. |
data | Output buffer to be resized and filled with the converted text file data. The buffer is terminated with a binary 0. |
friend class Importer [friend] |
std::string Assimp::BaseImporter::m_ErrorText [protected] |
Error description in case there was one.
ProgressHandler* Assimp::BaseImporter::m_progress [protected] |
Currently set progress handler.