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


C++ FileReader::ReadLine方法代码示例

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


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

示例1: if

void IGFManager :: LoadConfig(void)
{
	char buffer[256];
	Platform::GenerateFilePath(buffer, "IGForum", "IGFSession.txt");
	FileReader lfr;
	if(lfr.OpenText(buffer) != Err_OK)
	{
		g_Logs.data->error("IGFManager::LoadConfig failed to open file.");
		return;
	}
	lfr.CommentStyle = Comment_Semi;
	while(lfr.FileOpen() == true)
	{
		lfr.ReadLine();
		int r = lfr.BreakUntil("=", '=');
		if(r > 0)
		{
			lfr.BlockToStringC(0, 0);
			if(strcmp(lfr.SecBuffer, "NextCategoryID") == 0)
				mNextCategoryID = lfr.BlockToIntC(1);
			else if(strcmp(lfr.SecBuffer, "NextThreadID") == 0)
				mNextThreadID = lfr.BlockToIntC(1);
			else if(strcmp(lfr.SecBuffer, "NextPostID") == 0)
				mNextPostID = lfr.BlockToIntC(1);
			else if(strcmp(lfr.SecBuffer, "PlatformLaunchMinute") == 0)
				mPlatformLaunchMinute = lfr.BlockToULongC(1);
			else
				g_Logs.data->warn("IGFManager::LoadConfig unknown identifier [%v] in file [%v] on line [%v]", lfr.SecBuffer, buffer, lfr.LineNumber);
		}
	}
	lfr.CloseCurrent();
}
开发者ID:kgrubb,项目名称:iceee,代码行数:32,代码来源:IGForum.cpp

示例2: LoadNetworkData

void FriendListManager :: LoadNetworkData(void)
{
	if(networkDataFile.size() == 0)
	{
		g_Log.AddMessageFormat("Network Cache filename not set.");
		return;
	}
	FileReader lfr;
	if(lfr.OpenText(networkDataFile.c_str()) != Err_OK)
	{
		g_Log.AddMessageFormat("Error opening Network Cache file for reading: %s", networkDataFile.c_str());
		return;
	}

	lfr.CommentStyle = Comment_Semi;
	while(lfr.FileOpen() == true)
	{
		lfr.ReadLine();
		int r = lfr.MultiBreak("=,");
		if(r >= 2)
		{
			int sourceDefID = lfr.BlockToIntC(0);
			std::vector<int> &ref = networkData[sourceDefID];
			for(int i = 1; i < r; i++)
				ref.push_back(lfr.BlockToIntC(i));
		}
	}
	lfr.CloseCurrent();
}
开发者ID:Wuffie12,项目名称:iceee,代码行数:29,代码来源:FriendStatus.cpp

示例3: LoadScripts

int AIScriptManager :: LoadScripts(void)
{
	std::string FileName = Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "AIScript"), "script_list.txt");
	FileReader lfr;
	if(lfr.OpenText(FileName.c_str()) != Err_OK)
	{
		g_Logs.data->error("Error opening master script list [%v]", FileName);
		return -1;
	}

	AIScriptDef newItem;
	lfr.CommentStyle = Comment_Semi;
	string LoadName;
	while(lfr.FileOpen() == true)
	{
		int r = lfr.ReadLine();
		if(r > 0)
		{
			aiDef.push_back(newItem);
			aiDef.back().CompileFromSource(Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "AIScript"), lfr.DataBuffer));
		}
	}
	lfr.CloseCurrent();
	g_Logs.data->info("Loaded %v AI Scripts", aiDef.size());

	return 0;
}
开发者ID:rockfireredmoon,项目名称:iceee,代码行数:27,代码来源:AIScript.cpp

示例4: LoadClan

bool ClanManager::LoadClan(int id, Clan &clan) {
	std::string path = GetPath(id);
	if (!Platform::FileExists(path)) {
		g_Logs.data->info("No file for CS item [%v]", path.c_str());
		return NULL;
	}

	FileReader lfr;
	if (lfr.OpenText(path.c_str()) != Err_OK) {
		g_Logs.data->error("Could not open file [%v]", path.c_str());
		return false;
	}

	lfr.CommentStyle = Comment_Semi;
	int r = 0;
	long amt = -1;
	while (lfr.FileOpen() == true) {
		r = lfr.ReadLine();
		lfr.SingleBreak("=");
		lfr.BlockToStringC(0, Case_Upper);
		if (r > 0) {
			if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) {
				if (clan.mId != 0) {
					g_Logs.data->warn(
							"%v contains multiple entries. CS items have one entry per file",
							path.c_str());
					break;
				}
				clan.mId = id;
			} else if (strcmp(lfr.SecBuffer, "NAME") == 0)
				clan.mName = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "MOTD") == 0)
				clan.mMOTD = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "MEMBER") == 0) {
				std::vector<std::string> l;
				Util::Split(lfr.BlockToStringC(1, 0), ",", l);
				ClanMember mem;
				if (l.size() > 1) {
					mem.mID = atoi(l[0].c_str());
					mem.mRank = atoi(l[1].c_str());
					clan.mMembers.push_back(mem);
				} else {
					g_Logs.data->info(
							"Incomplete clan member information [%v] in file [%v]",
							lfr.SecBuffer, path.c_str());
				}
			} else
				g_Logs.data->info("Unknown identifier [%v] in file [%v]",
						lfr.SecBuffer, path.c_str());
		}
	}
	lfr.CloseCurrent();
	return true;
}
开发者ID:kgrubb,项目名称:iceee,代码行数:54,代码来源:Clan.cpp

示例5: LoadStringsFile

int LoadStringsFile(std::string filename, vector<string> &list) {
	FileReader lfr;
	if (lfr.OpenText(filename.c_str()) != Err_OK) {
		g_Logs.data->error("Error opening file: %v", filename);
		return -1;
	}

	lfr.CommentStyle = Comment_Semi;
	while (lfr.FileOpen() == true) {
		int r = lfr.ReadLine();
		if (r > 0) {
			list.push_back(lfr.DataBuffer);
		}
	}
	lfr.CloseCurrent();
	return list.size();
}
开发者ID:rockfireredmoon,项目名称:iceee,代码行数:17,代码来源:Config.cpp

示例6: LoadSocialData

void FriendListManager :: LoadSocialData(void)
{
	if(socialDataFile.size() == 0)
	{
		g_Log.AddMessageFormat("Social Cache filename not set.");
		return;
	}
	FileReader lfr;
	if(lfr.OpenText(socialDataFile.c_str()) != Err_OK)
	{
		g_Log.AddMessageFormat("Error opening Social Cache file for reading: %s", socialDataFile.c_str());
		return;
	}
	lfr.CommentStyle = Comment_Semi;
	SocialWindowEntry newItem;
	while(lfr.FileOpen() == true)
	{
		lfr.ReadLine();
		int r = lfr.BreakUntil(",|", '|');
		if(r >= 6)
		{
			newItem.creatureDefID = lfr.BlockToIntC(0);
			newItem.name = lfr.BlockToStringC(1, 0);
			newItem.level = lfr.BlockToIntC(2);
			newItem.profession = lfr.BlockToIntC(3);
			newItem.online = lfr.BlockToBoolC(4);
			newItem.shard = lfr.BlockToStringC(5, 0);

			//HACK: since the friend list is only loaded when the server is launched,
			//it's safe to assume that everyone is offline.  This should auto fix any
			//players that are stuck offline.  If I had been thinking when I designed
			//this, the online flag wouldn't be saved at all.
			//TODO: remove onine status from save files
			newItem.online = false;

			//Get the status last in case it contains any unusual characters.
			if(r >= 7)
				newItem.status = lfr.BlockToStringC(6, 0);
			else
				newItem.status.clear();
			UpdateSocialEntry(newItem);
		}
	}
	lfr.CloseCurrent();
}
开发者ID:Wuffie12,项目名称:iceee,代码行数:45,代码来源:FriendStatus.cpp

示例7: LoadStringKeyValFile

int LoadStringKeyValFile(std::string filename, vector<StringKeyVal> &list) {
	FileReader lfr;
	if (lfr.OpenText(filename.c_str()) != Err_OK) {
		g_Logs.data->error("Error opening file: %v", filename);
		return -1;
	}

	lfr.CommentStyle = Comment_Semi;
	StringKeyVal newItem;
	while (lfr.FileOpen() == true) {
		int r = lfr.ReadLine();
		lfr.SingleBreak("=");
		if (r > 0) {
			newItem.key = lfr.BlockToStringC(0, 0);
			newItem.value = lfr.BlockToStringC(1, 0);
			list.push_back(newItem);
		}
	}
	lfr.CloseCurrent();
	return list.size();
}
开发者ID:rockfireredmoon,项目名称:iceee,代码行数:21,代码来源:Config.cpp

示例8: LoadItemPackages

void ItemManager :: LoadItemPackages(char *listFile, bool itemOverride)
{
	FileReader lfr;
	if(lfr.OpenText(listFile) != Err_OK)
	{
		g_Logs.data->error("Could not open Item list file [%v]", listFile);
		Finalize();
		return;
	}
	lfr.CommentStyle = Comment_Semi;
	while(lfr.FileOpen() == true)
	{
		int r = lfr.ReadLine();
		if(r > 0)
		{
			Platform::FixPaths(lfr.DataBuffer);
			LoadItemList(lfr.DataBuffer, itemOverride);
		}
	}
	lfr.CloseCurrent();

	//Run any post-processing, like sorting.
	Finalize();
}
开发者ID:kgrubb,项目名称:iceee,代码行数:24,代码来源:Item.cpp

示例9: LoadConfig

bool LoadConfig(std::string filename) {
	bool oauthSet = false;

	//Loads the configuration options from the target file.  These are core options
	//required for the server to operate.

	FileReader lfr;
	if (lfr.OpenText(filename.c_str()) != Err_OK) {
		return false;
	}
	static char Delimiter[] = { '=', 13, 10 };
	lfr.Delimiter = Delimiter;
	lfr.CommentStyle = Comment_Semi;

	while (lfr.FileOpen() == true) {
		int r = lfr.ReadLine();
		if (r > 0) {
			lfr.SingleBreak("=");
			char *NameBlock = lfr.BlockToString(0);
			if (strcmp(NameBlock, "ProtocolVersion") == 0) {
				g_ProtocolVersion = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "AuthMode") == 0) {
				g_AuthMode = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "AuthKey") == 0) {
				strncpy(g_AuthKey, lfr.BlockToString(1), sizeof(g_AuthKey) - 1);
			} else if (strcmp(NameBlock, "RouterPort") == 0) {
				g_RouterPort = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "SimulatorAddress") == 0) {
				strncpy(g_SimulatorAddress, lfr.BlockToString(1),
						sizeof(g_SimulatorAddress) - 1);
			} else if (strcmp(NameBlock, "BindAddress") == 0) {
				strncpy(g_BindAddress, lfr.BlockToString(1),
						sizeof(g_BindAddress) - 1);
			} else if (strcmp(NameBlock, "SimulatorPort") == 0) {
				g_SimulatorPort = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "ThreadSleep") == 0) {
				g_ThreadSleep = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "ErrorSleep") == 0) {
				g_ErrorSleep = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "MainSleep") == 0) {
				g_MainSleep = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "DefX") == 0) {
				g_Config.DefX = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "DefY") == 0) {
				g_Config.DefY = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "DefZ") == 0) {
				g_Config.DefZ = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "DefZone") == 0) {
				g_Config.DefZone = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "DefRotation") == 0) {
				g_Config.DefRotation = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "HTTPBaseFolder") == 0) {
				g_Config.HTTPBaseFolder = lfr.BlockToString(1);
			} else if (strcmp(NameBlock, "HTTPCARFolder") == 0) {
				g_Config.HTTPCARFolder = lfr.BlockToString(1);
			} else if (strcmp(NameBlock, "HTTPListenPort") == 0) {
				g_HTTPListenPort = lfr.BlockToInt(1);
			}
#ifndef NO_SSL
			else if(strcmp(NameBlock, "HTTPSListenPort") == 0)
			{
				g_HTTPSListenPort = lfr.BlockToInt(1);
			}
			else if(strcmp(NameBlock, "SSLCertificate") == 0)
			{
				AppendString(g_SSLCertificate, lfr.BlockToStringC(1, 0));
			}
#endif
			else if (strcmp(NameBlock, "RebroadcastDelay") == 0) {
				g_RebroadcastDelay = lfr.BlockToULongC(1);
			} else if (strcmp(NameBlock, "SceneryAutosaveTime") == 0) {
				g_SceneryAutosaveTime = lfr.BlockToULongC(1);
			} else if (strcmp(NameBlock, "ForceUpdateTime") == 0) {
				g_ForceUpdateTime = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "ItemBindingTypeOverride") == 0) {
				g_ItemBindingTypeOverride = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "ItemArmorTypeOverride") == 0) {
				g_ItemArmorTypeOverride = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "ItemWeaponTypeOverride") == 0) {
				g_ItemWeaponTypeOverride = lfr.BlockToInt(1);
			} else if (strcmp(NameBlock, "MOTD_Name") == 0) {
				g_MOTD_Name = lfr.BlockToStringC(1, 0);
			} else if (strcmp(NameBlock, "MOTD_Channel") == 0) {
				g_MOTD_Channel = lfr.BlockToStringC(1, 0);
			} else if (strcmp(NameBlock, "RemoteAuthenticationPassword") == 0) {
				g_Config.RemoteAuthenticationPassword = lfr.BlockToStringC(1,
						0);
			} else if (strcmp(NameBlock, "ProperSceneryList") == 0) {
				g_Config.ProperSceneryList = lfr.BlockToIntC(1);
			} else if (strcmp(NameBlock, "BuybackLimit") == 0) {
				g_Config.BuybackLimit = lfr.BlockToIntC(1);
			} else if (strcmp(NameBlock, "Upgrade") == 0)
				g_Config.Upgrade = lfr.BlockToIntC(1);
			else if (strcmp(NameBlock, "HeartbeatIntervalMS") == 0)
				g_Config.HeartbeatIntervalMS = lfr.BlockToIntC(1);
			else if (strcmp(NameBlock, "HeartbeatAbortCount") == 0)
				g_Config.HeartbeatAbortCount = lfr.BlockToIntC(1);
			else if (strcmp(NameBlock, "WarpMovementBlockTime") == 0)
				g_Config.WarpMovementBlockTime = lfr.BlockToIntC(1);
			else if (strcmp(NameBlock, "IdleCheckVerification") == 0)
//.........这里部分代码省略.........
开发者ID:rockfireredmoon,项目名称:iceee,代码行数:101,代码来源:Config.cpp

示例10: if

CreditShopItem * CreditShopManager::LoadItem(int id) {
	std::string buf = GetPath(id);
	if (!Platform::FileExists(buf.c_str())) {
		g_Logs.data->error("No file for CS item [%v]", buf.c_str());
		return NULL;
	}

	CreditShopItem *item = new CreditShopItem();

	FileReader lfr;
	if (lfr.OpenText(buf.c_str()) != Err_OK) {
		g_Logs.data->error("Could not open file [%v]", buf.c_str());
		return NULL;
	}

//		unsigned long mStartDate;
//		unsigned long mEndDate;

	lfr.CommentStyle = Comment_Semi;
	int r = 0;
	long amt = -1;
	while (lfr.FileOpen() == true) {
		r = lfr.ReadLine();
		lfr.SingleBreak("=");
		lfr.BlockToStringC(0, Case_Upper);
		if (r > 0) {
			if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) {
				if (item->mId != 0) {
					g_Logs.data->warn(
							"%v contains multiple entries. CS items have one entry per file",
							buf.c_str());
					break;
				}
				item->mId = id;
			} else if (strcmp(lfr.SecBuffer, "TITLE") == 0)
				item->mTitle = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "DESCRIPTION") == 0)
				item->mDescription = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "BEGINDATE") == 0)
				Util::ParseDate(lfr.BlockToStringC(1, 0), item->mStartDate);
			else if (strcmp(lfr.SecBuffer, "ENDDATE") == 0)
				Util::ParseDate(lfr.BlockToStringC(1, 0), item->mEndDate);
			else if (strcmp(lfr.SecBuffer, "CREATEDDATE") == 0)
				Util::ParseDate(lfr.BlockToStringC(1, 0), item->mCreatedDate);
			else if (strcmp(lfr.SecBuffer, "PRICECURRENCY") == 0)
				item->mPriceCurrency = Currency::GetIDByName(
						lfr.BlockToStringC(1, 0));
			else if (strcmp(lfr.SecBuffer, "PRICEAMOUNT") == 0)
				amt = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "PRICECOPPER") == 0)
				item->mPriceCopper = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "PRICECREDITS") == 0)
				item->mPriceCredits = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "ITEMID") == 0)
				item->mItemId = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "ITEMAMOUNT") == 0
					|| strcmp(lfr.SecBuffer, "IV1") == 0)
				item->mIv1 = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "IV2") == 0)
				item->mIv2 = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "LOOKID") == 0)
				item->mLookId = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "CATEGORY") == 0)
				item->mCategory = Category::GetIDByName(
						lfr.BlockToStringC(1, 0));
			else if (strcmp(lfr.SecBuffer, "STATUS") == 0)
				item->mStatus = Status::GetIDByName(lfr.BlockToStringC(1, 0));
			else if (strcmp(lfr.SecBuffer, "QUANTITYLIMIT") == 0)
				item->mQuantityLimit = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "QUANTITYSOLD") == 0)
				item->mQuantitySold = lfr.BlockToIntC(1);
			else
				g_Logs.data->error("Unknown identifier [%v] in file [%v]",
						lfr.SecBuffer, buf.c_str());
		}
	}
	lfr.CloseCurrent();

// For backwards compatibility - will be able to remove once all items resaved or removed
	if (amt > 0) {
		if (item->mPriceCurrency == Currency::COPPER)
			item->mPriceCopper = amt;
		else if (item->mPriceCurrency == Currency::CREDITS)
			item->mPriceCredits = amt;
	}

	cs.Enter("CreditShopManager::LoadItem");
	mItems[id] = item;
	cs.Leave();

	return item;
}
开发者ID:kgrubb,项目名称:iceee,代码行数:92,代码来源:CreditShop.cpp

示例11: Init

bool InfoManager::Init() {

	TextFileEntityReader ter(Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "Data"), "Tips.txt" ), Case_None, Comment_Semi);
	ter.Start();
	if (!ter.Exists())
		return false;

	ter.Key("", "", true);
	ter.Index("ENTRY");
	STRINGLIST sections = ter.Sections();
	int i = 0;
	for (auto a = sections.begin(); a != sections.end(); ++a) {
		ter.PushSection(*a);
		Tip t;
		t.mID = ++i;
		if (!t.EntityKeys(&ter) || !t.ReadEntity(&ter))
			return false;
		mTips.push_back(t);
		ter.PopSection();
	}
	ter.End();

	std::string filename = Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "Data"), "Game.txt" );
	FileReader lfr;
	if (lfr.OpenText(filename.c_str()) != Err_OK) {
		g_Logs.data->error("Could not open configuration file: %v", filename);
		return false;
	}
	else {
		static char Delimiter[] = { '=', 13, 10 };
		lfr.Delimiter = Delimiter;
		lfr.CommentStyle = Comment_Semi;

		while (lfr.FileOpen() == true) {
			int r = lfr.ReadLine();
			if (r > 0) {
				lfr.SingleBreak("=");
				char *NameBlock = lfr.BlockToString(0);
				if (strcmp(NameBlock, "GameName") == 0) {
					mGameName = lfr.BlockToStringC(1, 0);
				} else if (strcmp(NameBlock, "Edition") == 0) {
					mEdition = lfr.BlockToStringC(1, 0);
				} else if (strcmp(NameBlock, "StartZone") == 0) {
					mStartZone = lfr.BlockToInt(1);
				} else if (strcmp(NameBlock, "StartX") == 0) {
					mStartX = lfr.BlockToInt(1);
				} else if (strcmp(NameBlock, "StartY") == 0) {
					mStartY = lfr.BlockToInt(1);
				} else if (strcmp(NameBlock, "StartZ") == 0) {
					mStartZ = lfr.BlockToInt(1);
				} else if (strcmp(NameBlock, "StartRotation") == 0) {
					mStartRotation = lfr.BlockToInt(1);
				}
				else {
					g_Logs.data->error("Unknown identifier [%v] in config file [%v]",
							lfr.BlockToString(0), filename);
				}
			}
		}
		lfr.CloseCurrent();
	}

	return true;

}
开发者ID:rockfireredmoon,项目名称:iceee,代码行数:65,代码来源:Info.cpp

示例12: BenchmarkDArray

void BenchmarkDArray(Sorter<char *> &sorter)
{
	DArray<char *> data, rdata;
	Stopwatch sw;
	char buffer[512], format[64];
	sprintf(format, "%s", "%4.3lfs");

	FileReader file;

	file.SetLineEndings(CC_LN_LF);
	file.Open("dataset");

	if (file.IsOpen()) {
		data.setStepDouble();
		rdata.setStepDouble();

		console->Write("Loading... ");

		sw.Start();

		/* Load the file into the data DArray */
		while (file.ReadLine(buffer, sizeof(buffer)) >= 0)
			data.insert(cc_strdup(buffer));

		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		file.Close();

		console->WriteLine("Loaded %d items.", data.used());

		console->Write("Random: ");
		sw.Start();
		data.sort(sorter);
		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		/* Create a reverse-sorted DArray */
		for (long i = (long)data.size(); i >= 0; i--) {
			if (data.valid(i)) {
				rdata.insert(data.get(i));
			}
		}

		console->Write("Pre-sorted: ");
		sw.Start();
		data.sort(sorter);
		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		console->Write("Reverse-sorted: ");
		sw.Start();
		rdata.sort(sorter);
		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		for (size_t i = 0; i < data.size(); i++) {
			if (data.valid(i)) {
				free(data.get(i));
				data.remove(i);
			}
		}

		data.empty();
		rdata.empty();
	} else {
		console->WriteLine("Dataset not found.");
	}
}
开发者ID:prophile,项目名称:crisscross,代码行数:69,代码来源:main.cpp

示例13: LoadItemFromStream

int LoadItemFromStream(FileReader &fr, ItemDef *itemDef, char *debugFilename)
{
	//Return codes:
	//   1  Section end marker reached.
	//   0  End of file reached.
	//  -1  Another entry was encountered

	bool curEntry = false;
	int r;
	while(fr.FileOpen())
	{
		long CurPos = ftell(fr.FileHandle[0]);
		r = fr.ReadLine();
		if(r > 0)
			r = fr.SingleBreak(NULL);
		if(r > 0)
		{
			fr.BlockToStringC(0, Case_Upper);
			if(strcmp(fr.SecBuffer, "[ENTRY]") == 0)
			{
				if(curEntry == true)
				{
					//Reset the position so it doesn't interfere with reading the next
					//entry
					fr.FilePos = CurPos;
					fseek(fr.FileHandle[0], CurPos, SEEK_SET);
					return -1;
				}
				else
					curEntry = true;
			}
			else if(strcmp(fr.SecBuffer, "[END]") == 0)
			{
				return 1;
			}
			else
			{
				char *ValueBuf = fr.BlockToString(1);
				char *NameBuf = fr.BlockToString(0);
				if(strcmp(NameBuf, "mBindingType") == 0)
				{
					if(g_ItemBindingTypeOverride > 0)
					{
						if(ValueBuf[0] == '0' + g_ItemBindingTypeOverride)
							ValueBuf[0] = 0;
					}
					else if(g_ItemBindingTypeOverride == 0)
						ValueBuf = BindingTypeOverride;
				}
				else if(strcmp(NameBuf, "mArmorType") == 0)
				{
					if(g_ItemArmorTypeOverride >= 0)
						ValueBuf = ArmorTypeOverride;
				}
				else if(strcmp(NameBuf, "mWeaponType") == 0)
				{
					if(g_ItemWeaponTypeOverride >= 0)
						ValueBuf = WeaponTypeOverride;
				}
				/*
				if(strcmp(NameBuf, "craftItemDefId") == 0)
				{
					itemDef->craftItemDefId.push_back(fr.BlockToInt(1));
				}*/
				//int r = SetItemProperty(itemDef, fr.BlockToString(0), fr.BlockToString(1));
				int r = SetItemProperty(itemDef, NameBuf, ValueBuf);
				if(r == -1)
					g_Logs.data->warn("Unknown property [%v] in item file [%v] on line [%v]", fr.BlockToString(0), debugFilename, fr.LineNumber);
			}
		}
	}
	fr.CloseCurrent();

	return 1;
}
开发者ID:kgrubb,项目名称:iceee,代码行数:75,代码来源:Item.cpp

示例14: if

CreditShopItem * CreditShopManager::LoadItem(int id) {
	const char * buf = GetPath(id).c_str();
	if (!Platform::FileExists(buf)) {
		g_Log.AddMessageFormat("No file for CS item [%s]", buf);
		return NULL;
	}

	CreditShopItem *item = new CreditShopItem();
	item->mId = id;

	FileReader lfr;
	if (lfr.OpenText(buf) != Err_OK) {
		g_Log.AddMessageFormat("Could not open file [%s]", buf);
		return NULL;
	}

//		unsigned long mStartDate;
//		unsigned long mEndDate;

	lfr.CommentStyle = Comment_Semi;
	int r = 0;
	while (lfr.FileOpen() == true) {
		r = lfr.ReadLine();
		lfr.SingleBreak("=");
		lfr.BlockToStringC(0, Case_Upper);
		if (r > 0) {
			if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) {
				if (item->mId != 0)
					g_Log.AddMessageFormat(
							"[WARNING] %s contains multiple entries. CS items have one entry per file",
							buf);
			}
			else if (strcmp(lfr.SecBuffer, "TITLE") == 0)
				item->mTitle = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "DESCRIPTION") == 0)
				item->mDescription = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "BEGINDATE") == 0)
				Util::ParseDate(lfr.BlockToStringC(1, 0), item->mStartDate);
			else if (strcmp(lfr.SecBuffer, "ENDDATE") == 0)
				Util::ParseDate(lfr.BlockToStringC(1, 0), item->mEndDate);
			else if (strcmp(lfr.SecBuffer, "PRICECURRENCY") == 0)
				item->mPriceCurrency =Currency::GetIDByName(lfr.BlockToStringC(1, 0));
			else if (strcmp(lfr.SecBuffer, "PRICEAMOUNT") == 0)
				item->mPriceAmount = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "ITEMID") == 0)
				item->mItemId = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "ITEMAMOUNT") == 0 || strcmp(lfr.SecBuffer, "IV1") == 0)
				item->mIv1 = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "IV2") == 0)
				item->mIv2 = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "LOOKID") == 0)
				item->mLookId = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "CATEGORY") == 0)
				item->mCategory =Category::GetIDByName(lfr.BlockToStringC(1, 0));
			else if (strcmp(lfr.SecBuffer, "STATUS") == 0)
				item->mStatus = Status::GetIDByName(lfr.BlockToStringC(1, 0));
			else if (strcmp(lfr.SecBuffer, "QUANTITYLIMIT") == 0)
				item->mQuantityLimit = lfr.BlockToIntC(1);
			else if (strcmp(lfr.SecBuffer, "QUANTITYSOLD") == 0)
				item->mQuantitySold = lfr.BlockToIntC(1);
			else
				g_Log.AddMessageFormat("Unknown identifier [%s] in file [%s]",
						lfr.SecBuffer, buf);
		}
	}
	lfr.CloseCurrent();
	mItems[id] = item;

	return item;
}
开发者ID:Wuffie12,项目名称:iceee,代码行数:70,代码来源:CreditShop.cpp

示例15: LoadFile

void BookManager::LoadFile(std::string filename) {
	FileReader lfr;
	if (lfr.OpenText(filename.c_str()) != Err_OK) {
		g_Logs.data->error("Could not open file [%v]", filename);
		return;
	}
	int bookID = atoi(Platform::Basename(filename).c_str());
	BookDefinition newItem;
	newItem.bookID = bookID;
	int r = 0;
	std::string page;
	bool inPageText = false;
	while (lfr.FileOpen() == true) {
		r = lfr.ReadLine();
		std::string wholeLine = std::string(lfr.DataBuffer);
		bool escapedLine = Util::HasBeginning(wholeLine, "\\");
		if (r > 0 && !escapedLine) {
			lfr.SingleBreak("=");
			lfr.BlockToStringC(0, Case_Upper);
			if (strcmp(lfr.SecBuffer, "[PAGE]") == 0) {
				if(page.length() > 0) {
					newItem.pages.push_back(page);
					page = "";
				}
				inPageText = false;
			} else if (strcmp(lfr.SecBuffer, "TITLE") == 0)
				newItem.title = lfr.BlockToStringC(1, 0);
			else if (strcmp(lfr.SecBuffer, "TEXT") == 0) {
				page.clear();
				page.append(lfr.BlockToStringC(1, 0));
				inPageText = true;
			}
			else {
				if(inPageText) {
					if(page.length() > 0) {
						if(Util::HasEnding(page, "\\")) {
							page = page.substr(0, page.length() - 1);
						}
						else
							page.append("<br>");
					}
					page.append(wholeLine);
				}
			}
		}
		else if(inPageText) {
			if(escapedLine) {
				wholeLine = wholeLine.substr(1);
			}
			if(page.length() > 0) {
				if(Util::HasEnding(page, "\\")) {
					page = page.substr(0, page.length() - 1);
				}
				else
					page.append("<br>");
			}
			if(r != 0) {
				page.append(wholeLine);
			}
		}
	}
	if(page.length() > 0) {
		newItem.pages.push_back(page);
	}
	books[newItem.bookID] = newItem;
	lfr.CloseCurrent();
}
开发者ID:rockfireredmoon,项目名称:iceee,代码行数:67,代码来源:Books.cpp


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