本文整理汇总了C++中FileFormat::read方法的典型用法代码示例。如果您正苦于以下问题:C++ FileFormat::read方法的具体用法?C++ FileFormat::read怎么用?C++ FileFormat::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileFormat
的用法示例。
在下文中一共展示了FileFormat::read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileDialog_import
void FileDialog_import(EditorState *state)
{
std::string path = getSaveLoadDirectory(state->settings->get("save_directory"),
state->isInstalled);
const char* filters[] = {"*.nbe"};
const char *cfile = tinyfd_openFileDialog("Import Nodes",
path.c_str(), 1, filters, 0);
if (!cfile)
return;
std::string file = cfile;
if (file == "")
return;
std::cerr << file.c_str() << std::endl;
// Get file parser
FileFormat *parser = getFromType(FILE_FORMAT_NBE, state);
if (!parser) {
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"File format does not exist.");
return;
}
// Get directory, and load
std::cerr << "Reading from " << file << std::endl;
Project *tmp = parser->read(file, state->project);
if (tmp) {
state->project->remesh();
} else {
switch(parser->error_code) {
case EFFE_IO_ERROR:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"Failed to open the file\n\t(Does it not exist, or is it readonly?)");
break;
case EFFE_READ_OLD_VERSION:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"This file is outdated and is not supported");
break;
case EFFE_READ_NEW_VERSION:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"This file was created with a new version of NBE\n\t(Update your copy)");
break;
case EFFE_READ_PARSE_ERROR:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"An error occurred while reading the file - it may be corrupted\n\t(This should never happen)");
break;
case EFFE_READ_WRONG_TYPE:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"The file is not in the correct format\n\t(Are you opening the wrong type of file?)");
break;
default:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"Unknown error");
break;
}
delete parser;
parser = NULL;
}
}