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


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

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


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

示例1: 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

示例2: 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

示例3: 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


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