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


C++ CIRCNetwork::ParseConfig方法代码示例

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


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

示例1: ParseConfig

bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
	TOption<const CString&> StringOptions[] = {
		{ "nick", &CUser::SetNick },
		{ "quitmsg", &CUser::SetQuitMsg },
		{ "altnick", &CUser::SetAltNick },
		{ "ident", &CUser::SetIdent },
		{ "realname", &CUser::SetRealName },
		{ "chanmodes", &CUser::SetDefaultChanModes },
		{ "bindhost", &CUser::SetBindHost },
		{ "vhost", &CUser::SetBindHost },
		{ "dccbindhost", &CUser::SetDCCBindHost },
		{ "dccvhost", &CUser::SetDCCBindHost },
		{ "timestampformat", &CUser::SetTimestampFormat },
		{ "skin", &CUser::SetSkinName },
		{ "language", &CUser::SetLanguage },
	};
	size_t numStringOptions = sizeof(StringOptions) / sizeof(StringOptions[0]);
	TOption<unsigned int> UIntOptions[] = {
		{ "jointries", &CUser::SetJoinTries },
		{ "maxjoins", &CUser::SetMaxJoins },
	};
	size_t numUIntOptions = sizeof(UIntOptions) / sizeof(UIntOptions[0]);
	TOption<bool> BoolOptions[] = {
		{ "keepbuffer", &CUser::SetKeepBuffer },
		{ "multiclients", &CUser::SetMultiClients },
		{ "denyloadmod", &CUser::SetDenyLoadMod },
		{ "admin", &CUser::SetAdmin },
		{ "denysetbindhost", &CUser::SetDenySetBindHost },
		{ "denysetvhost", &CUser::SetDenySetBindHost },
		{ "appendtimestamp", &CUser::SetTimestampAppend },
		{ "prependtimestamp", &CUser::SetTimestampPrepend },
		{ "ircconnectenabled", &CUser::SetIRCConnectEnabled },
	};
	size_t numBoolOptions = sizeof(BoolOptions) / sizeof(BoolOptions[0]);

	for (size_t i = 0; i < numStringOptions; i++) {
		CString sValue;
		if (pConfig->FindStringEntry(StringOptions[i].name, sValue))
			(this->*StringOptions[i].pSetter)(sValue);
	}
	for (size_t i = 0; i < numUIntOptions; i++) {
		CString sValue;
		if (pConfig->FindStringEntry(UIntOptions[i].name, sValue))
			(this->*UIntOptions[i].pSetter)(sValue.ToUInt());
	}
	for (size_t i = 0; i < numBoolOptions; i++) {
		CString sValue;
		if (pConfig->FindStringEntry(BoolOptions[i].name, sValue))
			(this->*BoolOptions[i].pSetter)(sValue.ToBool());
	}

	VCString vsList;
	VCString::const_iterator vit;
	pConfig->FindStringVector("allow", vsList);
	for (vit = vsList.begin(); vit != vsList.end(); ++vit) {
		AddAllowedHost(*vit);
	}
	pConfig->FindStringVector("ctcpreply", vsList);
	for (vit = vsList.begin(); vit != vsList.end(); ++vit) {
		const CString& sValue = *vit;
		AddCTCPReply(sValue.Token(0), sValue.Token(1, true));
	}

	CString sValue;

	CString sDCCLookupValue;
	pConfig->FindStringEntry("dcclookupmethod", sDCCLookupValue);
	if (pConfig->FindStringEntry("bouncedccs", sValue))  {
		if (sValue.ToBool()) {
			CUtils::PrintAction("Loading Module [bouncedcc]");
			CString sModRet;
			bool bModRet = GetModules().LoadModule("bouncedcc", "", CModInfo::UserModule, this, NULL, sModRet);

			CUtils::PrintStatus(bModRet, sModRet);
			if (!bModRet) {
				sError = sModRet;
				return false;
			}

			if (sDCCLookupValue.Equals("Client")) {
				GetModules().FindModule("bouncedcc")->SetNV("UseClientIP", "1");
			}
		}
	}
	if (pConfig->FindStringEntry("buffer", sValue))
		SetBufferCount(sValue.ToUInt(), true);
	if (pConfig->FindStringEntry("awaysuffix", sValue)) {
		CUtils::PrintMessage("WARNING: AwaySuffix has been depricated, instead try -> LoadModule = awaynick %nick%_" + sValue);
	}
	if (pConfig->FindStringEntry("autocycle", sValue)) {
		if (sValue.Equals("true"))
			CUtils::PrintError("WARNING: AutoCycle has been removed, instead try -> LoadModule = autocycle");
	}
	if (pConfig->FindStringEntry("keepnick", sValue)) {
		if (sValue.Equals("true"))
			CUtils::PrintError("WARNING: KeepNick has been deprecated, instead try -> LoadModule = keepnick");
	}
	if (pConfig->FindStringEntry("statusprefix", sValue)) {
		if (!SetStatusPrefix(sValue)) {
			sError = "Invalid StatusPrefix [" + sValue + "] Must be 1-5 chars, no spaces.";
//.........这里部分代码省略.........
开发者ID:b3rend,项目名称:znc,代码行数:101,代码来源:User.cpp

示例2: ParseConfig

bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
    TOption<const CString&> StringOptions[] = {
        {"nick", &CUser::SetNick},
        {"quitmsg", &CUser::SetQuitMsg},
        {"altnick", &CUser::SetAltNick},
        {"ident", &CUser::SetIdent},
        {"realname", &CUser::SetRealName},
        {"chanmodes", &CUser::SetDefaultChanModes},
        {"bindhost", &CUser::SetBindHost},
        {"vhost", &CUser::SetBindHost},
        {"dccbindhost", &CUser::SetDCCBindHost},
        {"dccvhost", &CUser::SetDCCBindHost},
        {"timestampformat", &CUser::SetTimestampFormat},
        {"skin", &CUser::SetSkinName},
        {"clientencoding", &CUser::SetClientEncoding},
    };
    TOption<unsigned int> UIntOptions[] = {
        {"jointries", &CUser::SetJoinTries},
        {"maxnetworks", &CUser::SetMaxNetworks},
        {"maxquerybuffers", &CUser::SetMaxQueryBuffers},
        {"maxjoins", &CUser::SetMaxJoins},
    };
    TOption<bool> BoolOptions[] = {
        {"keepbuffer",
         &CUser::SetKeepBuffer},  // XXX compatibility crap from pre-0.207
        {"autoclearchanbuffer", &CUser::SetAutoClearChanBuffer},
        {"autoclearquerybuffer", &CUser::SetAutoClearQueryBuffer},
        {"multiclients", &CUser::SetMultiClients},
        {"denyloadmod", &CUser::SetDenyLoadMod},
        {"admin", &CUser::SetAdmin},
        {"denysetbindhost", &CUser::SetDenySetBindHost},
        {"denysetvhost", &CUser::SetDenySetBindHost},
        {"appendtimestamp", &CUser::SetTimestampAppend},
        {"prependtimestamp", &CUser::SetTimestampPrepend},
    };

    for (const auto& Option : StringOptions) {
        CString sValue;
        if (pConfig->FindStringEntry(Option.name, sValue))
            (this->*Option.pSetter)(sValue);
    }
    for (const auto& Option : UIntOptions) {
        CString sValue;
        if (pConfig->FindStringEntry(Option.name, sValue))
            (this->*Option.pSetter)(sValue.ToUInt());
    }
    for (const auto& Option : BoolOptions) {
        CString sValue;
        if (pConfig->FindStringEntry(Option.name, sValue))
            (this->*Option.pSetter)(sValue.ToBool());
    }

    VCString vsList;
    pConfig->FindStringVector("allow", vsList);
    for (const CString& sHost : vsList) {
        AddAllowedHost(sHost);
    }
    pConfig->FindStringVector("ctcpreply", vsList);
    for (const CString& sReply : vsList) {
        AddCTCPReply(sReply.Token(0), sReply.Token(1, true));
    }

    CString sValue;

    CString sDCCLookupValue;
    pConfig->FindStringEntry("dcclookupmethod", sDCCLookupValue);
    if (pConfig->FindStringEntry("bouncedccs", sValue)) {
        if (sValue.ToBool()) {
            CUtils::PrintAction("Loading Module [bouncedcc]");
            CString sModRet;
            bool bModRet = GetModules().LoadModule(
                "bouncedcc", "", CModInfo::UserModule, this, nullptr, sModRet);

            CUtils::PrintStatus(bModRet, sModRet);
            if (!bModRet) {
                sError = sModRet;
                return false;
            }

            if (sDCCLookupValue.Equals("Client")) {
                GetModules().FindModule("bouncedcc")->SetNV("UseClientIP", "1");
            }
        }
    }
    if (pConfig->FindStringEntry("buffer", sValue))
        SetBufferCount(sValue.ToUInt(), true);
    if (pConfig->FindStringEntry("chanbuffersize", sValue))
        SetChanBufferSize(sValue.ToUInt(), true);
    if (pConfig->FindStringEntry("querybuffersize", sValue))
        SetQueryBufferSize(sValue.ToUInt(), true);
    if (pConfig->FindStringEntry("awaysuffix", sValue)) {
        CUtils::PrintMessage(
            "WARNING: AwaySuffix has been deprecated, instead try -> "
            "LoadModule = awaynick %nick%_" +
            sValue);
    }
    if (pConfig->FindStringEntry("autocycle", sValue)) {
        if (sValue.Equals("true"))
            CUtils::PrintError(
                "WARNING: AutoCycle has been removed, instead try -> "
//.........这里部分代码省略.........
开发者ID:Un1matr1x,项目名称:znc,代码行数:101,代码来源:User.cpp


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