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


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

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


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

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

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