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


C++ TextFile::writeLine方法代码示例

本文整理汇总了C++中TextFile::writeLine方法的典型用法代码示例。如果您正苦于以下问题:C++ TextFile::writeLine方法的具体用法?C++ TextFile::writeLine怎么用?C++ TextFile::writeLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextFile的用法示例。


在下文中一共展示了TextFile::writeLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnWizardFinished

void ExtensionsWizard::OnWizardFinished(wxWizardEvent &e)
{
	String extensionName = conversions::to_utf16(m_pageGeneral->getExtensionName());
	String extensionDescription = conversions::to_utf16(m_pageGeneral->getExtensionDescription());
	String extensionAuthor = conversions::to_utf16(m_pageGeneral->getExtensionAuthor());
	shared_ptr<ExtensionsWizardPageTemplate::TemplateDetails> extensionTemplate = m_pageTemplate->getTemplate();
	const ExtensionsWizardPageTemplate::TemplateDetails::Files &extensionFiles = extensionTemplate->getFiles();

	ExtensionID extensionID = ExtensionID::generate();

	String rootPath = ExtensionsSystem::instance()->getDataPath();
	String extensionPath = utils::makeFolderPath(rootPath, extensionID.toUTF16());

	shared_ptr<XMLDocument> document(OS_NEW XMLDocument());
	shared_ptr<XMLNode> nodeRoot = document->create(OS_EXTENSION_XML_NODE_ROOT);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_ID, extensionID.getString());
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_NAME, extensionName);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_DESCRIPTION, extensionDescription);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_AUTHOR, extensionAuthor);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_VERSION_CODE, _S("1"));
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_VERSION_NAME, _S("0.1"));
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_ICON, _S("icon.png"));
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_LOGO, _S("logo.png"));

	shared_ptr<XMLNode> nodeScripts;
	ExtensionsWizardPageTemplate::TemplateDetails::Files::const_iterator i;
	for(i = extensionFiles.begin(); i != extensionFiles.end(); ++i)
	{
		if((*i).script)
		{
			if(nodeScripts == nullptr)
				nodeScripts = nodeRoot->addChild(OS_EXTENSION_XML_NODE_SCRIPTS);

			shared_ptr<XMLNode> nodeScript = nodeScripts->addChild(OS_EXTENSION_XML_NODE_SCRIPT);
			nodeScript->setAttributeString(OS_EXTENSION_XML_NODE_SCRIPT_PATH, (*i).target);
			// TODO: temp
			nodeScript->setAttributeString(OS_EXTENSION_XML_NODE_SCRIPT_LANGUAGE, "python");
		}
	}

	String documentString;
	if(document->writeString(documentString) == false)
	{
		OS_ASSERTFALSE();
		Application::instance()->reportError("Internal error generating extension's xml, please report it", true);
		return;
	}

	if(XMLManager::instance()->validateString(documentString, XMLSchema::fromFile(utils::makeFilePath(utils::makeFolderPath(Options::instance()->getSharePath(), OS_SCHEMAS_PATH), OS_EXTENSIONS_EXTENSION_SCHEMA))) == false)
	{
		OS_ASSERTFALSE();
		Application::instance()->reportError("Internal error validating extension's xml, please report it", true);
		return;
	}

	if(FileSystem::instance()->ensureDirectory(extensionPath) == false)
	{
		Application::instance()->reportError("Cannot create directory '" + extensionPath + "'", true);
		return;
	}

	for(i = extensionFiles.begin(); i != extensionFiles.end(); ++i)
	{
		String targetFile = utils::makeFilePath(extensionPath, (*i).target);
		String sourceFile = utils::makeFilePath(extensionTemplate->getFolder(), (*i).source);

		String targetPath = FileSystem::instance()->getFilePath(targetFile);
		if(FileSystem::instance()->ensureDirectory(targetPath) == false)
		{
			Application::instance()->reportError("Cannot create directory '" + targetPath + "'", true);
			return;
		}

		if(FileSystem::instance()->copyFile(sourceFile, targetFile) == false)
		{
			Application::instance()->reportError("Cannot copy file '" + sourceFile + "' to '" + targetFile + "'", true);
			return;
		}

		if((*i).macro)
		{
			// Open file, do replaces and save.
			String data;
			TextFile::readFile(targetFile, data);

			data = data.replace_all("{extension_id}", extensionID.getString());
			data = data.replace_all("{extension_name}", extensionName);
			data = data.replace_all("{extension_description}", extensionDescription);
			data = data.replace_all("{extension_author}", extensionAuthor);
			UniqueID uniqueID = UniqueID::generate();
			data = data.replace_all("{unique_id}", uniqueID.getString());

			TextFile file;
			file.open(targetFile, TextFile::ofWrite);
			file.writeLine(data);
			file.close();
		}
	}

	String documentFile = utils::makeFilePath(extensionPath, OS_MANIFESTXML);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: writeNocashSym

void SymbolData::writeNocashSym()
{
    if (nocashSymFileName.empty())
        return;

    std::vector<NocashSymEntry> entries;
    for (size_t k = 0; k < modules.size(); k++)
    {
        SymDataModule& module = modules[k];
        for (size_t i = 0; i < module.symbols.size(); i++)
        {
            SymDataSymbol& sym = module.symbols[i];

            NocashSymEntry entry;
            entry.address = sym.address;
            entry.text = sym.name;
            entries.push_back(entry);
        }

        for (size_t i = 0; i < module.data.size(); i++)
        {
            SymDataData& data = module.data[i];
            NocashSymEntry entry;
            entry.address = data.address;

            switch (data.type)
            {
            case Data8:
                entry.text = formatString(".byt:%04X",data.size);
                break;
            case Data16:
                entry.text = formatString(".wrd:%04X",data.size);
                break;
            case Data32:
                entry.text = formatString(".dbl:%04X",data.size);
                break;
            case DataAscii:
                entry.text = formatString(".asc:%04X",data.size);
                break;
            }

            entries.push_back(entry);
        }
    }

    std::sort(entries.begin(),entries.end());

    TextFile file;
    if (file.open(nocashSymFileName,TextFile::Write,TextFile::ASCII) == false)
    {
        Logger::printError(Logger::Error,L"Could not open sym file %s.",file.getFileName().c_str());
        return;
    }
    file.writeLine(L"00000000 0");

    for (size_t i = 0; i < entries.size(); i++)
    {
        file.writeFormat(L"%08X %S\n",entries[i].address,entries[i].text.c_str());
    }

    file.write("\x1A");
    file.close();
}
开发者ID:CUE0,项目名称:armips,代码行数:63,代码来源:SymbolData.cpp


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