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


C++ IWriteFile::drop方法代码示例

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


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

示例1: createXMLWriter

//! Creates a XML Writer from a file.
IXMLWriter* CFileSystem::createXMLWriter(const core::string<c16>& filename)
{
	IWriteFile* file = createAndWriteFile(filename);
	IXMLWriter* writer = createXMLWriter(file);
	file->drop();
	return writer;
}
开发者ID:harmboschloo,项目名称:CocaProject,代码行数:8,代码来源:CFileSystem.cpp

示例2: createXMLWriter

//! Creates a XML Writer from a file.
IXMLWriter* CFileSystem::createXMLWriter(const io::path& filename)
{
	IWriteFile* file = createAndWriteFile(filename);
	IXMLWriter* writer = createXMLWriter(file);
	file->drop();
	return writer;
}
开发者ID:RealBadAngel,项目名称:irrlicht.netcp,代码行数:8,代码来源:CFileSystem.cpp

示例3: onWriteFontFile

	bool CBinaryFontWriter::onWriteFontFile( const SFontInfo& fontInfo )
	{
		std::string filename = getFilename() + ".xft";
		IWriteFile* writer = device->getFileSystem()->createAndWriteFile(filename.c_str());

		writeT(writer, 0xabcdefff);
		writeT(writer, (int) FONT_VERSION);
		writeT(writer, useAlphaChannel);
		writeT(writer, fontInfo.images.size());
		std::string imageName;
		for (u32 i = 0; i < fontInfo.images.size(); ++i)
		{
			imageName = getImageName(i);

			// write image
			writeT(writer, imageName.size());
			writer->write(imageName.c_str(), imageName.size());
		}

		// write charmap
		writeT(writer, fontInfo.charMap.size());
		for (const std::pair<wchar_t, SFontArea>& chToarea : fontInfo.charMap)
			writeT(writer, chToarea);

		writer->drop();
		return true;
	}
开发者ID:NextRPG,项目名称:Xihad,代码行数:27,代码来源:CBinaryFontWriter.cpp

示例4: writeText

			void IXMLWriterTest::writeText()
			{

				IWriteFile* fWrite = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);

				if (fWrite)
					fWrite->drop();
				fxml->writeElement("fff", false);
				fxml->writeText("text text text");
				fxml->writeClosingTag("fff");
				if (fxml)
					fxml->drop();

				IReadFile* fRead = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);

				fxmlR->read();
				fxmlR->read();

				if (fxmlR->getNodeType() != EXNT_TEXT)
					mes.append("\n writeText: element text is not created");

				core::stringc strND = core::stringc("text text text");
				if (!strND.equalsn(fxmlR->getNodeData(), 14))
					mes.append(
							"\n writeText: correctly writes text content of the");

				if (fxmlR)
					fxmlR->drop();

			}
开发者ID:CowPlay,项目名称:irrgame_sdk_test,代码行数:34,代码来源:IXMLWriterTest.cpp

示例5: writeXMLHeader

			void IXMLWriterTest::writeXMLHeader()
			{
				IWriteFile* fWrite = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);

				if (fWrite)
					fWrite->drop();

				fxml->writeXMLHeader();

				if (fxml)
					fxml->drop();

				IReadFile* fRead = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);
				fxmlR->read();
				if (fxmlR->getNodeType() != EXNT_UNKNOWN)
					mes.append(
							"\n writeXMLHeader: does not write the XMLHeader");

				if (fxmlR)
					fxmlR->drop();
				if (fRead)
					fRead->drop();
			}
开发者ID:CowPlay,项目名称:irrgame_sdk_test,代码行数:27,代码来源:IXMLWriterTest.cpp

示例6: writeClosingTag

			void IXMLWriterTest::writeClosingTag()
			{

				IWriteFile* fWrite = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);

				if (fWrite)
					fWrite->drop();

				fxml->writeClosingTag("fff");

				if (fxml)
					fxml->drop();

				IReadFile* fRead = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);

				fxmlR->read();

				if (fxmlR->getNodeType() != EXNT_ELEMENT_END)
					mes.append(
							"\n writeClosingTag: Closing tag is not created");

				if (fxmlR)
					fxmlR->drop();

// TODO create empty closing teg

				IWriteFile* fWrite1 = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml1 = IFileSystem::createXMLWriter(fWrite1);

				if (fWrite1)
					fWrite1->drop();

				fxml1->writeClosingTag("");

				if (fxml1)
					fxml1->drop();

				IReadFile* fRead1 = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR1 = IFileSystem::createXMLReader(fRead1);

				fxmlR1->read();

				if (fxmlR1->getNodeType() != EXNT_ELEMENT_END)
					mes.append(
							"\n writeClosingTag: emty closing tag is not created");

				if (fxmlR1)
					fxmlR1->drop();

			}
开发者ID:CowPlay,项目名称:irrgame_sdk_test,代码行数:56,代码来源:IXMLWriterTest.cpp

示例7: SaveGame

bool kx::SaveGame()
{
    fileSys->changeWorkingDirectoryTo( kxBaseDir );

    // kxBaseDir/saves/saveName.kxSave
    stringw saveName = saveEditBox->getText();
    path filename = "./saves/";
    filename += saveName;
    filename += ".kxs";

    IWriteFile* file = fileSys->createAndWriteFile( filename );
    if (!file)
    {
        std::cout<< "Error: couldn't create save file" << endl;
        return false;
    }
    else
    {
        IXMLWriter* writer = fileSys->createXMLWriter( file );
        if (!writer)
        {
            std::cout<< "Error: couldn't create XML writer" << std::endl;
            return false;
        }
        else
        {
            writer->writeXMLHeader();

            const wchar_t* saveElement = L"kxSave";
            writer->writeElement( saveElement );
            writer->writeLineBreak();

            IAttributes* attr = fileSys->createEmptyAttributes();
            attr->addInt( "activeLevelNum", activeLevel->num );  
            attr->addInt( "activeLevelProgress", activeLevel->progress );
            // add more attrib here...

            attr->write( writer );
            attr->drop();

            writer->writeClosingTag( saveElement );
            writer->drop();
            file->drop();

            messages = ""; // reset
            messages += L"Saved "; 
            messages += saveName;
            messages += L".kxs";
            messagesNumLines= 1;
            return true;
        }
    }
    return false;
}
开发者ID:robcmills,项目名称:kyuplex,代码行数:54,代码来源:kxGameSaveLoad.cpp

示例8: createXMLWriter

		//! Creates a XML Writer from a file.
		IXMLWriter* SharedFileSystem::createXMLWriter(
				const core::stringc& filename)
		{
			IWriteFile* file = createWriteFile(filename);

			IXMLWriter* writer = irrgame::io::createXMLWriter(file);

			if (file)
				file->drop();

			return writer;
		}
开发者ID:CowPlay,项目名称:irrgame_sdk,代码行数:13,代码来源:SharedFileSystem.cpp

示例9: writeComment

			void IXMLWriterTest::writeComment()
			{

				IWriteFile* fWrite = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);

				if (fWrite)
					fWrite->drop();

				fxml->writeComment(static_cast<const c8*>("bla bla bla"));

				if (fxml)
					fxml->drop();

				IReadFile* fRead = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);

				fxmlR->read();

				if (fxmlR->getNodeType() != EXNT_COMMENT)
					mes.append("\n writeComment: comment is not created");

				if (fxmlR)
					fxmlR->drop();

//TODO creates an empty comment

				IWriteFile* fWrite1 = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml1 = IFileSystem::createXMLWriter(fWrite1);

				if (fWrite1)
					fWrite1->drop();

				fxml1->writeComment(static_cast<const c8*>(""));

				if (fxml1)
					fxml1->drop();

				IReadFile* fRead1 = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR1 = IFileSystem::createXMLReader(fRead1);

				fxmlR1->read();

				if (fxmlR1->getNodeType() != EXNT_COMMENT)
					mes.append("\n writeComment: empty comment is not created");

				if (fxmlR1)
					fxmlR1->drop();
			}
开发者ID:CowPlay,项目名称:irrgame_sdk_test,代码行数:53,代码来源:IXMLWriterTest.cpp

示例10: writeImageToFile

//! Tests IVideoDriver::writeImageToFile() using IWriteFile
bool writeImageToFile(void)
{
	IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
	if (!device)
		return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager * smgr = device->getSceneManager();

	// Draw a cube background so that we can check that the pixels' alpha is working.
	ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
	cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
	cube->setMaterialFlag(video::EMF_LIGHTING, false);
	(void)smgr->addCameraSceneNode();

	driver->beginScene(true, true, SColor(255,100,101,140));
	smgr->drawAll();

	// Test for benign handling of offscreen pixel values as well as onscreen ones.
	for(s32 x = -10; x < 170; ++x)
	{
		s32 y = 120 * x / 160;
		driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
		y = 120 - y;
		driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
	}

	driver->endScene();

	bool result = false;
	IWriteFile * writtenFile = 0;
	IWriteFile * memoryFile = 0;
	const char * writtenFilename = 0;
	const u32 BUFFER_SIZE = 160 * 120 * 4;
	c8 * buffer = 0;
	const char * referenceFilename = 0;
	video::ECOLOR_FORMAT format;

	irr::video::IImage * screenshot = driver->createScreenShot();
	if(!screenshot)
	{
		logTestString("Failed to take screenshot\n");
		assert(false);
		goto cleanup;
	}

	format = screenshot->getColorFormat();
	if(format != video::ECF_R8G8B8)
	{
		irr::video::IImage * fixedScreenshot = driver->createImage(video::ECF_R8G8B8, screenshot);
		screenshot->drop();

		if(!fixedScreenshot)
		{
			logTestString("Failed to convert screenshot to ECF_A8R8G8B8\n");
			assert(false);
			goto cleanup;
		}

		screenshot = fixedScreenshot;
	}

	buffer = new c8[BUFFER_SIZE];
	writtenFilename = "results" DIR_SEP_STRING "Burning's Video-drawPixel.png";
	memoryFile = device->getFileSystem()->createMemoryWriteFile(buffer, BUFFER_SIZE, writtenFilename, false);
	if(!driver->writeImageToFile(screenshot, memoryFile))
	{
		logTestString("Failed to write png to memory file\n");
		assert(false);
		goto cleanup;
	}

	writtenFile = device->getFileSystem()->createAndWriteFile(memoryFile->getFileName());
	if(!writtenFile)
	{
		logTestString("Can't open %s for writing.\n", writtenFilename);
		assert(false);
		goto cleanup;
	}

	if(memoryFile->getPos() != writtenFile->write(buffer, memoryFile->getPos()))
	{
		logTestString("Error while writing to %s.\n", writtenFilename);
		assert(false);
		goto cleanup;
	}

	writtenFile->drop();
	writtenFile = 0;

	referenceFilename = "media" DIR_SEP_STRING "Burning's Video-drawPixel.png";
	if(!binaryCompareFiles(writtenFilename, referenceFilename))
	{
		logTestString("File written from memory is not the same as the reference file.\n");
		assert(false);
		goto cleanup;
	}

	result = true;
//.........这里部分代码省略.........
开发者ID:jivibounty,项目名称:irrlicht,代码行数:101,代码来源:writeImageToFile.cpp

示例11: build

// ----------------------------------------------------------------------------
void Track::build()
{
    IrrlichtDevice* device = Editor::getEditor()->getDevice();

    PHYSFS_setWriteDir(Editor::getEditor()->getTrackDir().c_str());
    PHYSFS_mkdir(m_file_name.c_str());

    path p = Editor::getEditor()->getTrackDir() + m_file_name;

    CMeshBuffer<S3DVertex2TCoords>* mb = m_terrain->build(p);
    SMesh smesh;
    smesh.addMeshBuffer(mb);

    for (u32 i = 1; i < m_roads.size(); i++)
    {
        IRoad* r = m_roads[i];
        if (r->getSpline()->getPointNum()>1)
            smesh.addMeshBuffer(((Road*)r)->getMeshBuffer());
    }

    B3DMeshWriter* writer = new B3DMeshWriter(device->getFileSystem());
    IWriteFile *file;
    file = device->getFileSystem()->createAndWriteFile((p + "/track.b3d").c_str());
    writer->writeMesh(file, &smesh);
    file->drop();
    delete writer;

    m_driveline->build(p);

    std::ofstream mat;
    mat.open((p + "/materials.xml").c_str());
    mat << "<materials>\n";
    mat << "  <material name=\"splatt.png\" graphical-effect=\"splatting\"";
    SMaterial m = m_terrain->getMaterial(0);
    for (int i = 1; i < 5; i++)
    {
        mat << " splatting-texture-" << i << "=\"";
        mat << Editor::toRelative(m.getTexture(i+1)->getName()).c_str();
        mat << "\"";
    }
    mat << "/>\n";

    if (m_gravity_road)
    {
        for (u32 i = 1; i < m_roads.size(); i++)
        {
            stringc tex = m_roads[i]->getTexName();
            if (tex.size()>0)
            {
                mat << "  <material name=\"";
                mat << tex.c_str();
                mat << "\" has-gravity=\"yes\" />\n";
            }
        } // roads
    } // gravity road mode

    mat <<"</materials>\n";
    mat.close();

    stringw track;
    track += "<track  name           = \"";
    track += m_track_name + L"\"\n";
    track += "        version        = \"5\"\n";
    track += "        groups         = \"made-by-STK-TE\"\n";
    track += "        designer       = \"";
    track += m_designer + "\"\n";
    track += "        music          = \"";
    track += m_music.c_str();
    track += "\"\n";
    track += "        screenshot     = \"screenshot.jpg\"\n";
    track += "        smooth-normals = \"true\"\n";
    track += "        reverse        = \"Y\"\n>\n";
    track += "</track>\n";

    PHYSFS_uint64 len = 4 * track.size();
    char*         dst = new char[len];
#ifdef _WIN32
    PHYSFS_utf8FromUcs2((PHYSFS_uint16*)track.c_str(),dst,len);
#else
    PHYSFS_utf8FromUcs4((PHYSFS_uint32*)track.c_str(), dst, len);
#endif

    FILE* f;
    f = fopen((p + "/track.xml").c_str(), "wb");
    fwrite(dst, sizeof(char), strlen(dst), f);
    fclose(f);
    delete[] dst;


    std::ofstream scene;
    scene.open((p + "/scene.xml").c_str());
    scene << "<scene>\n";
    scene << "  <track model=\"track.b3d\" x=\"0\" y=\"0\" z=\"0\">\n";

    exportElements(scene, true);
    scene << "  </track>\n";
    exportElements(scene, false);


//.........这里部分代码省略.........
开发者ID:mcsab,项目名称:stk-editor,代码行数:101,代码来源:track.cpp

示例12: main

int main(int argc, char* argv[])
{
	if ((argc < 3) ||
			((argc==3) && (argv[1][0]=='-')))
	{
		usage(argv[0]);
		return 1;
	}

	IrrlichtDevice *device = createDevice( video::EDT_NULL,
			dimension2d<s32>(800, 600), 32, false, false, false, 0);

	device->setWindowCaption(L"Image Converter");

	scene::EMESH_WRITER_TYPE type = EMWT_IRR_MESH;
	u32 i=1;
	bool createTangents=false;
	while (argv[i][0]=='-')
	{
		core::stringc format = argv[i];
		if (format.size() > 3)
		{
			if (format.equalsn("--format=",9))
			{
				format = format.subString(9,format.size());
				if (format=="collada")
					type = EMWT_COLLADA;
				else if (format=="stl")
					type = EMWT_STL;
				else if (format=="obj")
					type = EMWT_OBJ;
				else
					type = EMWT_IRR_MESH;
			}
			else
			if (format =="--createTangents")
				createTangents=true;
		}
		else
		if (format=="--")
		{
			++i;
			break;
		}
		++i;
	}

	const s32 srcmesh = i;
	const s32 destmesh = i+1;

	--argc;
	if ((argc<srcmesh) || (argc<destmesh))
	{
		std::cerr << "Not enough files given." << std::endl;
		usage(argv[0]);
		return 1;
	}

	createTangents = createTangents && (type==EMWT_IRR_MESH);
	std::cout << "Converting " << argv[srcmesh] << " to " << argv[destmesh] << std::endl;
	IMesh* mesh = device->getSceneManager()->getMesh(argv[srcmesh])->getMesh(0);
	if (!mesh)
	{
		std::cerr << "Could not load " << argv[srcmesh] << std::endl;
		return 1;
	}
	if (createTangents)
	{
		IMesh* tmp = device->getSceneManager()->getMeshManipulator()->createMeshWithTangents(mesh);
		mesh->drop();
		mesh=tmp;
	}
	IMeshWriter* mw = device->getSceneManager()->createMeshWriter(type);
	IWriteFile* file = device->getFileSystem()->createAndWriteFile(argv[destmesh]);
	mw->writeMesh(file, mesh);
	mesh->drop();
	file->drop();
	mw->drop();

	return 0;
}
开发者ID:jivibounty,项目名称:irrlicht,代码行数:81,代码来源:main.cpp

示例13: writeElement

			void IXMLWriterTest::writeElement()
			{

				IWriteFile* fWrite = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);

				if (fWrite)
					fWrite->drop();

				fxml->writeElement("fff", true, "attr1", "attrValue1");

				if (fxml)
					fxml->drop();

				IReadFile* fRead = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);

				fxmlR->read();

				if (fxmlR->getNodeType() != EXNT_ELEMENT)
					mes.append(
							"\n writeElement: incorrectly indicates the type of node");

				if (fxmlR->getAttributeCount() != 1)
					mes.append(
							"\n writeElement: correctly returns the number of attributes");

				core::stringc strA = core::stringc("attr1");
				if (!strA.equalsn(fxmlR->getAttributeName(0), 4))
					mes.append(
							"\n writeElement: correctly returns the name of attributes");

				core::stringc strV = core::stringc("attrValue1");
				if (!strV.equalsn(fxmlR->getAttributeValue(0), 10))
					mes.append(
							"\n writeElement: correctly returns the value of attributes");
				if (fxmlR)
					fxmlR->drop();
				if (fRead)
					fRead->drop();

//TODO should not create an element with no name

				IWriteFile* fWrite1 = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml1 = IFileSystem::createXMLWriter(fWrite1);

				if (fWrite1)
					fWrite1->drop();
				fxml1->writeElement("", true);
				if (fxml1)
					fxml1->drop();

				IReadFile* fRead1 = IFileSystem::createReadFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLReader* fxmlR1 = IFileSystem::createXMLReader(fRead1);

				fxmlR1->read();
				core::stringc strN = core::stringc("");
				if (strN.equalsn(fxmlR1->getNodeName(), 1))
					mes.append("\n writeElement: node name can not be empty");

				if (fxmlR1->getAttributeCount() != 0)
					mes.append("\n writeElement: sees non-existent attributes");

				if (fxmlR1)
					fxmlR1->drop();

				if (fRead1)
					fRead1->drop();

				core::array<core::stringc> atr;
				atr.insert(core::stringc("atr1"));
				atr.insert(core::stringc("atr2"));
				atr.insert(core::stringc("7"));
				atr.insert(core::stringc(0));
				atr.insert(core::stringc("art5"));
				atr.insert(core::stringc("</>"));
				atr.insert(core::stringc("art7"));

				core::array<core::stringc> atrValue;
				atrValue.insert(core::stringc("atrValue1"));
				atrValue.insert(core::stringc("atrValue2"));
				atrValue.insert(core::stringc("atrValue3"));
				atrValue.insert(core::stringc("atrValue4"));
				atrValue.insert(core::stringc("atrValue5"));
				atrValue.insert(core::stringc("6"));
				atrValue.insert(core::stringc(""));

				IWriteFile* fWrite3 = IFileSystem::createWriteFile(
						"assets/io/fileXMLEmpty.xml");
				IXMLWriter* fxml3 = IFileSystem::createXMLWriter(fWrite3);
				if (fWrite3)
					fWrite3->drop();

				fxml3->writeElement("fff", true, atr, atrValue);

				if (fxml3)
//.........这里部分代码省略.........
开发者ID:CowPlay,项目名称:irrgame_sdk_test,代码行数:101,代码来源:IXMLWriterTest.cpp


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