当前位置: 首页>>代码示例>>C++>>正文


C++ FileFormat::read方法代码示例

本文整理汇总了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;
	}
}
开发者ID:StepDevelop,项目名称:NodeBoxEditor,代码行数:64,代码来源:FileDialog.cpp


注:本文中的FileFormat::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。