Add usage of log macros.

This commit is contained in:
kimkulling
2018-04-19 16:48:43 +02:00
parent bdbad4c64f
commit 066349f36b
24 changed files with 168 additions and 177 deletions

View File

@@ -64,23 +64,24 @@ using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
BaseImporter::BaseImporter()
: m_progress()
{
: m_progress() {
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
BaseImporter::~BaseImporter()
{
BaseImporter::~BaseImporter() {
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Imports the given file and returns the imported data.
aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler)
{
aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) {
m_progress = pImp->GetProgressHandler();
if (nullptr == m_progress) {
return nullptr;
}
ai_assert(m_progress);
// Gather configuration properties for this run
@@ -100,8 +101,8 @@ aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile,
} catch( const std::exception& err ) {
// extract error description
m_ErrorText = err.what();
DefaultLogger::get()->error(m_ErrorText);
return NULL;
ASSIMP_LOG_ERROR(m_ErrorText);
return nullptr;
}
// return what we gathered from the import.
@@ -195,7 +196,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
// We got a match, either we don't care where it is, or it happens to
// be in the beginning of the file / line
if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') {
DefaultLogger::get()->debug(std::string("Found positive match for header keyword: ") + tokens[i]);
ASSIMP_LOG_DEBUG_F( "Found positive match for header keyword: ", tokens[i] );
return true;
}
}
@@ -322,7 +323,7 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
// UTF 8 with BOM
if((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) {
DefaultLogger::get()->debug("Found UTF-8 BOM ...");
ASSIMP_LOG_DEBUG("Found UTF-8 BOM ...");
std::copy(data.begin()+3,data.end(),data.begin());
data.resize(data.size()-3);
@@ -341,7 +342,7 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
// UTF 32 LE with BOM
if(*((uint32_t*)&data.front()) == 0x0000FFFE) {
DefaultLogger::get()->debug("Found UTF-32 BOM ...");
ASSIMP_LOG_DEBUG("Found UTF-32 BOM ...");
std::vector<char> output;
int *ptr = (int*)&data[ 0 ];
@@ -361,7 +362,7 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
// UTF 16 LE with BOM
if(*((uint16_t*)&data.front()) == 0xFEFF) {
DefaultLogger::get()->debug("Found UTF-16 BOM ...");
ASSIMP_LOG_DEBUG("Found UTF-16 BOM ...");
std::vector<unsigned char> output;
utf8::utf16to8(data.begin(), data.end(), back_inserter(output));
@@ -386,16 +387,14 @@ void BaseImporter::ConvertUTF8toISO8859_1(std::string& data)
data[j] = ((unsigned char) data[++i] + 0x40);
} else {
std::stringstream stream;
stream << "UTF8 code " << std::hex << data[i] << data[i + 1] << " can not be converted into ISA-8859-1.";
DefaultLogger::get()->error(stream.str());
ASSIMP_LOG_ERROR( stream.str() );
data[j++] = data[i++];
data[j] = data[i];
}
} else {
DefaultLogger::get()->error("UTF8 code but only one character remaining");
ASSIMP_LOG_ERROR("UTF8 code but only one character remaining");
data[j] = data[i];
}
@@ -411,7 +410,7 @@ void BaseImporter::TextFileToBuffer(IOStream* stream,
std::vector<char>& data,
TextFileMode mode)
{
ai_assert(NULL != stream);
ai_assert(nullptr != stream);
const size_t fileSize = stream->FileSize();
if (mode == FORBID_EMPTY) {
@@ -472,14 +471,14 @@ struct Assimp::BatchData {
, pImporter( nullptr )
, next_id(0xffff)
, validate( validate ) {
ai_assert( NULL != pIO );
ai_assert( nullptr != pIO );
pImporter = new Importer();
pImporter->SetIOHandler( pIO );
}
~BatchData() {
pImporter->SetIOHandler( NULL ); /* get pointer back into our possession */
pImporter->SetIOHandler( nullptr ); /* get pointer back into our possession */
delete pImporter;
}
@@ -505,9 +504,8 @@ struct Assimp::BatchData {
typedef std::list<LoadRequest>::iterator LoadReqIt;
// ------------------------------------------------------------------------------------------------
BatchLoader::BatchLoader(IOSystem* pIO, bool validate )
{
ai_assert(NULL != pIO);
BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) {
ai_assert(nullptr != pIO);
m_data = new BatchData( pIO, validate );
}
@@ -573,7 +571,7 @@ aiScene* BatchLoader::GetImport( unsigned int which )
return sc;
}
}
return NULL;
return nullptr;
}
// ------------------------------------------------------------------------------------------------
@@ -596,13 +594,13 @@ void BatchLoader::LoadAll()
if (!DefaultLogger::isNullLogger())
{
DefaultLogger::get()->info("%%% BEGIN EXTERNAL FILE %%%");
DefaultLogger::get()->info("File: " + (*it).file);
ASSIMP_LOG_INFO("%%% BEGIN EXTERNAL FILE %%%");
ASSIMP_LOG_INFO("File: ", (*it).file);
}
m_data->pImporter->ReadFile((*it).file,pp);
(*it).scene = m_data->pImporter->GetOrphanedScene();
(*it).loaded = true;
DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%");
ASSIMP_LOG_INFO("%%% END EXTERNAL FILE %%%");
}
}