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


C++ CIFile::close方法代码示例

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


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

示例1: printf

// ***************************************************************************
void			CSkills::load(std::string configFileName)
{

    _Updated=false;
    CIFile f;
    try
    {
        if (f.open(configFileName+".skills"))
        {
            printf("reading skills for %s\n", configFileName.c_str());
            serial(f);
            f.close();
            _MyName=configFileName;
        }
        else
        {
            printf("Serialized file not found: %s.skills\n", configFileName.c_str());
            printf("Entering skills createFromConfigFile file.");
            createFromConfigFile(configFileName);
            printf("I have saved the file\n");
            printf("Serialized file is done and written");
            f.close();
            _MyName=configFileName;
        }
    }
    catch(exception &e)
    {
        printf ("My T3 Error %s\n", e.what ());
    }


}
开发者ID:rbjarnason,项目名称:Mayans,代码行数:33,代码来源:skills.cpp

示例2: load

void CSoundAnimation::load()
{
	CIFile file;

	// Open the file
	if (!file.open(_Filename.c_str()))
	{
		throw NLMISC::Exception("Can't open the file for reading");
	}

	// Create the XML stream
	CIXml input;

	// Init
	if (input.init (file))
	{
		xmlNodePtr animNode = input.getRootNode ();
		xmlNodePtr markerNode = input.getFirstChildNode(animNode, "MARKER");

		while (markerNode != 0)
		{
			CSoundAnimMarker* marker = new CSoundAnimMarker();

			const char *time = (const char*) xmlGetProp(markerNode, (xmlChar*) "time");
			if (time == 0)
			{
				throw NLMISC::Exception("Invalid sound animation marker");
			}

			marker->setTime((float) atof(time));
			xmlFree ((void*)time);


			xmlNodePtr soundNode = input.getFirstChildNode(markerNode, "SOUND");

			while (soundNode != 0)
			{
				char *name = (char*) xmlGetProp(soundNode, (xmlChar*) "name");
				if (name == 0)
				{
					throw NLMISC::Exception("Invalid sound animation marker");
				}

				marker->addSound(NLMISC::CSheetId(string(name), "sound"));

				xmlFree ((void*)name);

				soundNode = input.getNextChildNode(soundNode, "SOUND");
			}

			addMarker(marker);

			markerNode = input.getNextChildNode(markerNode, "MARKER");
		}
	}

	// Close the file
	file.close ();
	_Dirty = false;
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:60,代码来源:sound_animation.cpp

示例3: loadDump

//-----------------------------------------------
// loadDump :
// Create a file with the current state of the client (good to report a bug).
//-----------------------------------------------
void loadDump(const std::string &name)
{
	CVectorD currentPos;

	// Load information to start as the version
	CIFile fStart;
	if(fStart.open(name + "_start.rec", false))
	{
		fStart.serialVersion(RecordVersion);
		fStart.serial(currentPos);
		// Close the File.
		fStart.close();
	}
	else
		nlwarning("loadDump: cannot open the file '%s_start.rec'.", name.c_str());

	// Update the position for the vision.
	NetMngr.setReferencePosition(currentPos);

	// Select the closest continent from the new position.
	class CDummyProgress : public IProgressCallback
	{
		void progress (float /* value */) {}
	};
	CDummyProgress dummy;
	ContinentMngr.select(currentPos, dummy);

	// Load the DB
	IngameDbMngr.read(name + "_db.rec");

	// Open the file.
	CIFile f;
	if(f.open(name + ".rec", false))
	{
		// Dump entities.
		EntitiesMngr.dump(f);

		// Close the File.
		f.close();
	}
	else
		nlwarning("loadDump: cannot open '%s.rec'.", name.c_str());
}// loadDump //
开发者ID:AzyxWare,项目名称:ryzom,代码行数:47,代码来源:misc.cpp

示例4: toString

//-----------------------------------------------------------------------------
CGmTpPendingCommand::CGmTpPendingCommand()
{
	CIFile f;
	string fileName = Bsi.getLocalPath() + toString("gm_pending_tp.bin");
	bool open = f.open(fileName);
	if( open )
	{
		f.serialCont( _CharacterTpPending );
	}
	f.close();
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:12,代码来源:gm_tp_pending_command.cpp

示例5: main

int main(int argc, char *argv[])
{
	if(argc != 4)
	{
		usage();
		return -1;
	}
	else
	{
		CBitmap		btmp;
		CIFile		inFile;
		COFile		outFile;

		uint	divideRatio;
		NLMISC::fromString(argv[3], divideRatio);
		if(divideRatio==0 || !isPowerOf2(divideRatio))
		{
			printf("divideRatio must be a powerOf2 (1, 2, 4, 8 ...) \n");
			return 0;
		}

		try
		{
			// read.
			if (!inFile.open(argv[1]))
			{
				printf("Can't open input file %s \n", argv[1]);
				return -1;
			}
			uint8	depth= btmp.load(inFile);
			if(depth==0)
				throw Exception("Bad File Format");
			inFile.close();

			// resize.
			btmp.resample(btmp.getWidth() / divideRatio, btmp.getHeight() / divideRatio);

			// output.
			if (!outFile.open(argv[2]))
			{
				printf("Can't open output file %s \n", argv[2]);
				return -1;
			}
			btmp.writeTGA(outFile, depth);
		}
		catch (const Exception &e)
		{
			printf("Error: %s\n", e.what());
				return -1;
		}

		return 0;
	}
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:54,代码来源:main.cpp

示例6: EFileNotOpened

/** Load the given zone (name without extension)
  * return a pointer to the zone, or NULL if not found
  * Throw an exception if a read error occured
  */
static CZone *LoadZone(uint16 xPos, uint16 yPos, std::string zoneExt)
{
	std::string zoneName;
	::getZoneNameByCoord(xPos, yPos, zoneName);
	std::auto_ptr<CZone> zone(new CZone);		
	std::string lookedUpZoneName = CPath::lookup(zoneName + zoneExt, false, false, false);
	if (lookedUpZoneName.empty()) return NULL;
	CIFile iF;
	if (!iF.open(lookedUpZoneName))
	{
		throw EFileNotOpened(lookedUpZoneName);
	}
	zone->serial(iF);
	iF.close();
	return zone.release();
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:20,代码来源:zone_check_bind.cpp

示例7: strncmp

void	CMailForumService::checkFile(const std::string& file)
{
	uint	fsz = CFile::getFileSize(file);

	if (fsz == 0)
		return;

	vector<uint8>	buffer(fsz);

	CIFile	fi;
	if (!fi.open(file))
		return;

	fi.serialBuffer(&(buffer[0]), fsz);
	fi.close();

	char*	pb = (char*)(&(buffer[0]));
	char*	pt = pb;

	while (*pt != '\0' && strncmp(pt, "$$$$", 4))
		++pt;

	// file contents "$$$$" -> end of file marker, file is complete, can be deleted
	if (pt != '\0')
	{
		CFile::deleteFile(file);

		int		shard_id;
		char	to_username[256];
		char	from_username[256];

		int		scanned = sscanf(pb, "shard=%d to=%s from=%s", &shard_id, to_username, from_username);

		CMessage	msgout("MAIL_NOTIF");

		uint32	shardId = (uint32)shard_id;
		string	toUserName = to_username;
		string	fromUserName = from_username;

		nldebug("MAIL: sent notification for user '%s' on shard '%d'", toUserName.c_str(), shardId);

		msgout.serial(shardId, toUserName, fromUserName);

		CUnifiedNetwork::getInstance()->send("EGS", msgout);
	}
}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:46,代码来源:mail_forum_service.cpp

示例8: Exception

int	main(int argc, char *argv[])
{
	uint	i;

	// Avoid warnings.
	NLMISC::createDebug();
	DebugLog->addNegativeFilter("Exception will be launched");
	WarningLog->addNegativeFilter("Exception will be launched");
	InfoLog->addNegativeFilter("FEHTIMER>");
	InfoLog->addNegativeFilter("adding the path");

	// Init serial
	registerSerial3d();

	if(argc<4)
	{
		puts("Usage:    build_clod_bank  path_file.cfg  config_file.cfg  destfile.clodbank  [bakeFrameRate=20] ");
		return 0;
	}


	try
	{
		// The bank to fill
		CLodCharacterShapeBank	lodShapeBank;


		// Read the frameRate to process bake of anims
		float	bakeFrameRate= 20;
		if(argc>=5)
		{
			bakeFrameRate= (float)atof(argv[4]);
			if(bakeFrameRate<=1)
			{
				nlwarning("bad bakeFrameRate value, use a default of 20");
				bakeFrameRate= 20;
			}
		}


		// parse the path file.
		//==================

		// try to load the config file.
		CConfigFile pathConfig;
		pathConfig.load (argv[1]);

		// Get the search pathes
		CConfigFile::CVar &search_pathes = pathConfig.getVar ("search_pathes");
		for (i = 0; i < (uint)search_pathes.size(); i++)
		{
			// Add to search path
			CPath::addSearchPath (search_pathes.asString(i));
		}

		// parse the config file.
		//==================

		// try to load the config file.
		CConfigFile config;
		config.load (argv[2]);

		// For all .clod to process
		//==================
		CConfigFile::CVar &clod_list = config.getVar ("clod_list");
		uint	lodId;
		for (lodId = 0; lodId < (uint)clod_list.size(); lodId++)
		{
			string	lodName= clod_list.asString(lodId);

			printf("Process LOD: %s\n", lodName.c_str());

			// Search the variable with this name.
			try
			{
				CIFile		iFile;

				// get the anim list.
				CConfigFile::CVar &clod_anim_list = config.getVar (lodName);

				// Correct format?
				if(clod_anim_list.size()<3)
				{
					nlwarning("%s skipped. Must have at least the skeleton file name, the lod file name, and one animation", lodName.c_str());
					// go to next.
					continue;
				}

				// Init lod shape process
				//===========================

				// The first variable is the name of the skeleton.
				string	skeletonName= clod_anim_list.asString(0);
				CSmartPtr<CSkeletonShape>	skeletonShape;

				// Load it.
				iFile.open(CPath::lookup(skeletonName));
				CShapeStream		strShape;
				strShape.serial(iFile);
				iFile.close();
//.........这里部分代码省略.........
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:build_clod_bank.cpp

示例9: main


//.........这里部分代码省略.........
			float cellRaytraceDeltaZ= cell_raytrace_delta_z.asFloat ();


			// colIdentifierPrefix
			CConfigFile::CVar &col_identifier_prefix = parameter.getVar ("col_identifier_prefix");
			string colIdentifierPrefix= col_identifier_prefix.asString ();

			// colIdentifierSuffix
			CConfigFile::CVar &col_identifier_suffix = parameter.getVar ("col_identifier_suffix");
			string colIdentifierSuffix= col_identifier_suffix.asString ();

			// colIdentifierSuffix
			CConfigFile::CVar &build_debug_surface_shape = parameter.getVar ("build_debug_surface_shape");
			bool	buildDebugSurfaceShape= build_debug_surface_shape.asInt()!=0;
			

			// try to open gr and rbank
			CRetrieverBank		*retrieverBank= NULL;
			CGlobalRetriever	*globalRetriever= NULL;
			uint32		grFileDate= 0;
			uint32		rbankFileDate= 0;
			if( grFile!="" && rbankFile!="" )
			{
				CIFile	fin;
				// serial the retrieverBank. Exception if not found.
				fin.open(CPath::lookup(rbankFile));
				retrieverBank= new CRetrieverBank;
				retrieverBank->setNamePrefix(CFile::getFilenameWithoutExtension(rbankFile).c_str ());

				// Add the search path for LR files
				CPath::addSearchPath (CFile::getPath(rbankFile));

				fin.serial(*retrieverBank);
				fin.close();

				// serial the globalRetriever. Exception if not found.
				fin.open(CPath::lookup(grFile));
				globalRetriever= new CGlobalRetriever;

				// set the RetrieverBank before loading
				globalRetriever->setRetrieverBank(retrieverBank);
				fin.serial(*globalRetriever);
				fin.close();

				// Get File Dates
				rbankFileDate= CFile::getFileModificationDate(CPath::lookup(rbankFile));
				grFileDate= CFile::getFileModificationDate(CPath::lookup(grFile));

				// And init them.
				globalRetriever->initAll();
			}


			// Scan and load all files .ig in directories
			//=================
			vector<string>				listFile;
			vector<CInstanceGroup*>		listIg;
			vector<string>				listIgFileName;
			vector<string>				listIgPathName;
			CPath::getPathContent(directoryIn, false, false, true, listFile);
			for(uint iFile=0; iFile<listFile.size(); iFile++)
			{
				string	&igFile= listFile[iFile];
				// verify it is a .ig.
				if( CFile::getExtension(igFile) == "ig" )
				{
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:67,代码来源:ig_lighter.cpp

示例10: computeBBoxFromVillage

//=======================================================================================
// ryzom specific build bbox of a village in a zone
static void computeBBoxFromVillage(const NLGEORGES::UFormElm *villageItem, 
								   const std::string &continentName,
								   uint villageIndex,
								   TShapeMap &shapeMap,
								   CLightingBBox &result
								  )
{	
	result = CLightingBBox();
	const NLGEORGES::UFormElm *igNamesItem;
	if (! (villageItem->getNodeByName (&igNamesItem, "IgList") && igNamesItem) )
	{
		nlwarning("No list of IGs was found in the continent form %s, village #%d", continentName.c_str(), villageIndex);
		return;
	}	
	// Get number of village
	uint numIgs;
	nlverify (igNamesItem->getArraySize (numIgs));
	const NLGEORGES::UFormElm *currIg;
	for(uint l = 0; l < numIgs; ++l)
	{														
		if (!(igNamesItem->getArrayNode (&currIg, l) && currIg))
		{
			nlwarning("Couldn't get ig #%d in the continent form %s, in village #%d", l, continentName.c_str(), villageIndex);
			continue;
		}			
		const NLGEORGES::UFormElm *igNameItem;
		currIg->getNodeByName (&igNameItem, "IgName");
		std::string igName;
		if (!igNameItem->getValue (igName))
		{
			nlwarning("Couldn't get ig name of ig #%d in the continent form %s, in village #%d", l, continentName.c_str(), villageIndex);
			continue;
		}
		if (igName.empty())
		{
			nlwarning("Ig name of ig #%d in the continent form %s, in village #%d is an empty string", l, continentName.c_str(), villageIndex);
			continue;
		}

		igName = CFile::getFilenameWithoutExtension(igName) + ".ig";
		string nameLookup = CPath::lookup (igName, false, true);
		if (!nameLookup.empty())
		{		
			CIFile inputFile;
			// Try to open the file
			if (inputFile.open (nameLookup))
			{				
				CInstanceGroup group;
				try
				{
					CLightingBBox currBBox;
					group.serial (inputFile);
					computeIGBBox(group, currBBox, shapeMap);											
					result.makeUnion(currBBox);					
				}
				catch(NLMISC::Exception &)
				{
					nlwarning ("Error while loading instance group %s\n", igName.c_str());	
					continue;
				}								
				inputFile.close();				
			}
			else
			{
				// Error
				nlwarning ("Can't open instance group %s\n", igName.c_str());
			}
		}								
	}	
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:72,代码来源:zone_dependencies.cpp

示例11: main


//.........这里部分代码省略.........
					lighterDesc.OverSampling= 0;

				// For ig of Zones, never disable Sun contrib !!!
				lighterDesc.DisableSunContribution= false;

				// Get the search pathes
				CConfigFile::CVar &search_pathes = parameter.getVar ("search_pathes");
				uint path;
				for (path = 0; path < (uint)search_pathes.size(); path++)
				{
					// Add to search path
					CPath::addSearchPath (search_pathes.asString(path));
				}

				// A landscape allocated with new: it is not delete because destruction take 3 secondes more!
				CLandscape *landscape=new CLandscape;
				landscape->init();

				// A zone lighter
				CMyIgZoneLighter lighter;
				lighter.init ();

				// A vector of zone id
				vector<uint> listZoneId;

				// The zone
				CZone zone;

				// List of ig
				std::list<CInstanceGroup*> instanceGroup;

				// Load
				zone.serial (inputFile);
				inputFile.close();

				// Load ig of the zone
				string igName = getName (argv[1])+".ig";
				string igNameLookup = CPath::lookup (igName, false, false);
				if (!igNameLookup.empty())
					igName = igNameLookup;

				bool zoneIgLoaded;

				// Try to open the file
				CInstanceGroup *centerInstanceGroup= NULL;
				if (inputFile.open (igName))
				{
					// load the center ig
					centerInstanceGroup=new CInstanceGroup;

					// Serial it
					centerInstanceGroup->serial (inputFile);
					inputFile.close();

					// Add to the list
					instanceGroup.push_back (centerInstanceGroup);
					zoneIgLoaded = true;
				}
				else
				{
					// Warning
					fprintf (stderr, "Warning: can't load instance group %s\n", igName.c_str());
					zoneIgLoaded = false;
				}

				// If can't load the center instanceGroup, skip it.
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:67,代码来源:zone_ig_lighter.cpp

示例12: init


//.........这里部分代码省略.........
		_R2PlotItemSheetId.insert( CSheetId( NLMISC::toString("r2_plot_item_%d.sitem", i)));
	}

	_SheetIdToAccess.clear();//only usefull when manualy re init file
	// File stream
	CIFile file;


	std::string pathFileName = CPath::lookup(RingAccessFilename, false, false, false);
	// Open the file
	if (pathFileName.empty() || !file.open(pathFileName.c_str()))
	{
		nlinfo("Can't open the file for reading : %s", RingAccessFilename.c_str());
		return;
	}



	// Create the XML stream
	CIXml input;

	// Init
	if(input.init(file))
	{
		xmlNodePtr entitiesAccess = input.getRootNode();
		xmlNodePtr entityAccess = input.getFirstChildNode(entitiesAccess, "entityAccess");

		while (entityAccess != 0)
		{

			// island name
			CXMLAutoPtr namePtr( (const char*) xmlGetProp(entityAccess, (xmlChar*) "name") );
			CXMLAutoPtr packagePtr( (const char*) xmlGetProp(entityAccess, (xmlChar*) "package") );
			CXMLAutoPtr sheetClientPtr( (const char*) xmlGetProp(entityAccess, (xmlChar*) "sheetClient") );
			CXMLAutoPtr sheetPtr( (const char*) xmlGetProp(entityAccess, (xmlChar*) "sheetServer") );

			if (!namePtr.getDatas()|| !packagePtr.getDatas() || !sheetPtr.getDatas() || !sheetPtr.getDatas())
			{
				nlerror( "Syntax error in %s", pathFileName.c_str());
				return;
			}

			std::string sheet( sheetPtr.getDatas() );
			std::string package( packagePtr.getDatas() );
			std::string sheetClient(sheetClientPtr.getDatas());


			CSheetId sheetClientId(sheetClient);
			CSheetId sheetId; // no sheet server

			if (sheet.empty())
			{
				bool ok = _SheetIdToAccess.insert( std::make_pair(std::make_pair(sheetClientId, sheetId), package)).second;
				if (!ok)
				{
					std::string previousPackage = _SheetIdToAccess[std::make_pair(sheetClientId, sheetId)];
					// only display warning if one key has multiple package
					if ( previousPackage != package )
					{
						nlwarning("%s: Entity %s sheet(%s) is defined more than once with different package definition. Previous definition is '%s', current definition is '%s'", RingAccessFilename.c_str(), namePtr.getDatas(), sheetClientPtr.getDatas(), previousPackage.c_str(), package.c_str());
					}

				}
			}
			else
			{


				sheetId = CSheetId(sheet);
				if (_CustomNpcSheetId.find(sheetClientId) != _CustomNpcSheetId.end())
				{

					bool ok = _SheetIdToAccess.insert( std::make_pair(std::make_pair(sheetClientId, sheetId), package)).second;
					if (!ok)
					{
						std::string previousPackage = _SheetIdToAccess[std::make_pair(sheetClientId, sheetId)];
						// only display warning if one key has multiple package
						if ( previousPackage != package )
						{
							nlwarning("%s: Entity %s sheet(%s) is defined more than once. Previous definition is '%s', current definition is '%s'", RingAccessFilename.c_str(), namePtr.getDatas(), sheetPtr.getDatas(), previousPackage.c_str(), package.c_str());
						}
					}
				}
				else
				{
					nlwarning("%s: Entity %s has invalid sheets %s %s", RingAccessFilename.c_str(), namePtr.getDatas(), sheetClientPtr.getDatas(), sheetPtr.getDatas());
				}
			}


			entityAccess = input.getNextChildNode(entityAccess, "entityAccess");
		}
	}

	// Close the file
	file.close ();

	_Initialised = true;

}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:ring_access.cpp

示例13: toLower

// ***************************************************************************
void	makeAnimByRace(const std::string &animSetFile, const std::vector<string> &animList)
{
	// *** Read the animset file.
	CIFile	iFile;
	iFile.open(animSetFile, true);
	// Read all text
	static vector<string>	animSetText;
	animSetText.clear();
	while(!iFile.eof())
	{
		char	tmp[50000];
		iFile.getline(tmp, 50000);
		animSetText.push_back(tmp);
	}
	iFile.close();


	bool	someChangeDone= false;

	// *** For each possible anim
	for(uint i=0;i<animList.size();i++)
	{
		// get the possible anim file name (lowered)
		static vector<string>	raceAnimNames;
		raceAnimNames.clear();
		buildRaceAnimNames(raceAnimNames, toLower(CFile::getFilename(animList[i])));

		// For each line of the animSet
		uint	lastStructLine= 0;
		bool	raceRestrictionFound= false;
		for(uint j=0;j<animSetText.size();)
		{
			string	line= animSetText[j];
			string	lineLwr= toLower(line);

			// Find <LOG> TAg? => stop
			if(line.find("<LOG>")!=string::npos)
				break;

			// Find a STRUCT start?
			if(line.find("<STRUCT>")!=string::npos)
			{
				lastStructLine= j;
				raceRestrictionFound= false;
			}
			
			// Find a RaceRestriction?
			if( line.find("Name=\"Race Restriction\"")!=string::npos )
				raceRestrictionFound= true;

			// Find the anim name?
			uint	nameIndexInLine= findAnimName(lineLwr, raceAnimNames);
			if(nameIndexInLine!=-1)
			{
				// Find the enclosing struct
				nlassert(lastStructLine!=0);
				uint	startBlock= lastStructLine;
				uint	nameLineInBlock= j-startBlock;
				uint	endBlock= 0;
				for(uint k=j+1;k<animSetText.size();k++)
				{
					string	line= animSetText[k];

					// Find a RaceRestriction?
					if( line.find("Name=\"Race Restriction\"")!=string::npos )
						raceRestrictionFound= true;

					// end of block?
					if(line.find("</STRUCT>")!=string::npos)
					{
						// endBlock is exclusive 
						endBlock= k+1;
						break;
					}
				}

				// if not found, abort
				if(endBlock==0)
					break;

				// if a raceRestriction has been found, no op (already done)
				if(raceRestrictionFound)
				{
					j= endBlock;
				}
				else
				{
					// LOG
					InfoLog->displayRawNL("%s: Specifying %s by race", 
						CFile::getFilename(animSetFile).c_str(), 
						CFile::getFilename(animList[i]).c_str());

					// *** Start a copy paste ^^
					// Copy
					static vector<string>	copyText;
					copyText.clear();
					for(uint k=startBlock;k<endBlock;k++)
					{
						// add an empty line before </STRUCT>, for race selection node (filled later)
//.........这里部分代码省略.........
开发者ID:mixxit,项目名称:solinia,代码行数:101,代码来源:main.cpp

示例14: loadSheetId

void CSheetId::loadSheetId ()
{
	H_AUTO(CSheetIdInit);
	//nldebug("Loading sheet_id.bin");

	// Open the sheet id to sheet file name association
	CIFile file;
	std::string path = CPath::lookup("sheet_id.bin", false, false);
	if(!path.empty() && file.open(path))
	{
		// clear entries
		_FileExtensions.clear ();
		_SheetIdToName.clear ();
		_SheetNameToId.clear ();

		// reserve space for the vector of file extensions
		_FileExtensions.resize(1 << (NL_SHEET_ID_TYPE_BITS));

		// Get the map from the file
		map<uint32,string> tempMap;
		contReset(tempMap);
		file.serialCont(tempMap);
		file.close();

		if (_RemoveUnknownSheet)
		{
			uint32 removednbfiles = 0;
			uint32 nbfiles = (uint32)tempMap.size();

			// now we remove all files that not available
			map<uint32,string>::iterator itStr2;
			for( itStr2 = tempMap.begin(); itStr2 != tempMap.end(); )
			{
				if (CPath::exists ((*itStr2).second))
				{
					++itStr2;
				}
				else
				{
					map<uint32,string>::iterator olditStr = itStr2;
					//nldebug ("Removing file '%s' from CSheetId because the file not exists", (*olditStr).second.c_str ());
					itStr2++;
					tempMap.erase (olditStr);
					removednbfiles++;
				}
			}
			nlinfo ("SHEETID: Removed %d files on %d from CSheetId because these files doesn't exists", removednbfiles, nbfiles);
		}

		// Convert the map to one big string and 1 static map (id to name)
		{
			// Get the number and size of all strings
			vector<CChar> tempVec; // Used to initialise the first map
			uint32 nNb = 0;
			uint32 nSize = 0;
			map<uint32,string>::const_iterator it = tempMap.begin();
			while (it != tempMap.end())
			{
				nSize += (uint32)it->second.size()+1;
				nNb++;
				it++;
			}

			// Make the big string (composed of all strings) and a vector referencing each string
			tempVec.resize(nNb);
			_AllStrings.Ptr = new char[nSize];
			it = tempMap.begin();
			nSize = 0;
			nNb = 0;
			while (it != tempMap.end())
			{
				tempVec[nNb].Ptr = _AllStrings.Ptr+nSize;
				strcpy(_AllStrings.Ptr+nSize, it->second.c_str());
				toLower(_AllStrings.Ptr+nSize);
				nSize += (uint32)it->second.size()+1;
				nNb++;
				it++;
			}

			// Finally build the static map (id to name)
			_SheetIdToName.reserve(tempVec.size());
			it = tempMap.begin();
			nNb = 0;
			while (it != tempMap.end())
			{
				_SheetIdToName.add(pair<uint32, CChar>(it->first, CChar(tempVec[nNb])));

				nNb++;
				it++;
			}

			// The vector of all small string is not needed anymore we have all the info in
			// the static map and with the pointer AllStrings referencing the beginning.
		}

		// Build the invert map (Name to Id) & file extension vector
		{
			uint32 nSize = (uint32)_SheetIdToName.size();
			_SheetNameToId.reserve(nSize);
			CStaticMap<uint32,CChar>::iterator itStr;
//.........这里部分代码省略.........
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:sheet_id.cpp


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