本文整理汇总了C++中Shared::getDefaultExtension方法的典型用法代码示例。如果您正苦于以下问题:C++ Shared::getDefaultExtension方法的具体用法?C++ Shared::getDefaultExtension怎么用?C++ Shared::getDefaultExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shared
的用法示例。
在下文中一共展示了Shared::getDefaultExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveToFile
CC_FILE_ERROR FileIOFilter::SaveToFile( ccHObject* entities,
const QString& filename,
SaveParameters& parameters,
Shared filter)
{
if (!entities || filename.isEmpty() || !filter)
return CC_FERR_BAD_ARGUMENT;
//if the file name has no extension, we had a default one!
QString completeFileName(filename);
if (QFileInfo(filename).suffix().isEmpty())
completeFileName += QString(".%1").arg(filter->getDefaultExtension());
CC_FILE_ERROR result = CC_FERR_NO_ERROR;
try
{
result = filter->saveToFile(entities, completeFileName, parameters);
}
catch(...)
{
ccLog::Warning(QString("[I/O] CC has caught an unhandled exception while saving file '%1'").arg(filename));
result = CC_FERR_CONSOLE_ERROR;
}
if (result == CC_FERR_NO_ERROR)
{
ccLog::Print(QString("[I/O] File '%1' saved successfully").arg(filename));
}
else
{
DisplayErrorMessage(result,"saving",filename);
}
return result;
}
示例2: Register
void FileIOFilter::Register(Shared filter)
{
if (!filter)
{
assert(false);
return;
}
//filters are uniquely recognized by their 'file filter' string
QStringList fileFilters = filter->getFileFilters(true);
QString filterName = filter->getDefaultExtension().toUpper();
for (FilterContainer::const_iterator it=s_ioFilters.begin(); it!=s_ioFilters.end(); ++it)
{
bool error = false;
if (*it == filter)
{
ccLog::Warning(QString("[FileIOFilter::Register] I/O filter '%1' is already registered").arg(filterName));
error = true;
}
else
{
//we are going to compare the file filters as they should remain unique!
QStringList otherFilters = (*it)->getFileFilters(true);
for (int i=0; i<fileFilters.size(); ++i)
{
if (otherFilters.contains(fileFilters[i]))
{
QString otherFilterName = (*it)->getDefaultExtension().toUpper();;
ccLog::Warning(QString("[FileIOFilter::Register] Internal error: file filter '%1' of filter '%2' is already handled by another filter ('%3')!").arg(fileFilters[i]).arg(filterName).arg(otherFilterName));
error = true;
break;
}
}
}
if (error)
return;
}
//insert filter
s_ioFilters.push_back(filter);
}