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


C++ CKeySet::SetAnyBit方法代码示例

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


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

示例1: if

const CKeyBindings::ActionList&
	CKeyBindings::GetActionList(const CKeySet& ks) const
{
	static const ActionList empty;
	const ActionList* alPtr = NULL;

	if (ks.AnyMod()) {
		KeyMap::const_iterator it = bindings.find(ks);
		if (it == bindings.end()) {
			alPtr = ∅
		} else {
			alPtr = &(it->second);
		}
	}
	else {
		// have to check for an AnyMod keyset as well as the normal one
		CKeySet anyMod = ks;
		anyMod.SetAnyBit();
		KeyMap::const_iterator nit = bindings.find(ks);
		KeyMap::const_iterator ait = bindings.find(anyMod);
		const bool haveNormal = (nit != bindings.end());
		const bool haveAnyMod = (ait != bindings.end());
		if (!haveNormal && !haveAnyMod) {
			alPtr = ∅
		}
		else if (haveNormal && !haveAnyMod) {
			alPtr = &(nit->second);
		}
		else if (!haveNormal && haveAnyMod) {
			alPtr = &(ait->second);
		}
		else {
			// combine the two lists (normal first)
			static ActionList merged;
			merged = nit->second;
			const ActionList& aal = ait->second;
			for (int i = 0; i < (int)aal.size(); ++i) {
				merged.push_back(aal[i]);
			}
			alPtr = &merged;
		}
	}

	if (LOG_IS_ENABLED(L_DEBUG)) {
		const bool isEmpty = (alPtr == &empty);
		LOG_L(L_DEBUG, "GetAction: %s (0x%03X)%s",
				ks.GetString(false).c_str(), ks.Key(),
				(isEmpty ? "  EMPTY" : ""));
		if (!isEmpty) {
			const ActionList& al = *alPtr;
			for (size_t i = 0; i < al.size(); ++i) {
				LOG_L(L_DEBUG, "  %s  \"%s\"",
						al[i].command.c_str(), al[i].rawline.c_str());
			}
		}
	}

	return *alPtr;
}
开发者ID:Arkazon,项目名称:spring,代码行数:59,代码来源:KeyBindings.cpp

示例2: Bind

bool CKeyBindings::Bind(const string& keystr, const string& line)
{
	CKeySet ks;
	if (!ParseKeySet(keystr, ks)) {
		LOG_L(L_WARNING, "Bind: could not parse key: %s", keystr.c_str());
		return false;
	}
	Action action(line);
	action.boundWith = keystr;
	if (action.command.empty()) {
		LOG_L(L_WARNING, "Bind: empty action: %s", line.c_str());
		return false;
	}

	// Try to be safe, force AnyMod mode for stateful commands
	if (statefulCommands.find(action.command) != statefulCommands.end()) {
		ks.SetAnyBit();
	}

	KeyMap::iterator it = bindings.find(ks);
	if (it == bindings.end()) {
		// new entry, push it
		ActionList& al = bindings[ks];
		al.push_back(action);
	} else {
		if (it->first != ks) {
			// not a match, push it
			ActionList& al = it->second;
			al.push_back(action);
		}
		else {
			// an exact keyset match, check the command
			ActionList& al = it->second;
			int i;
			for (i = 0; i < (int)al.size(); i++) {
				if (action.command == al[i].command) {
					break;
				}
			}
			if (i == (int)al.size()) {
				// not a match, push it
				al.push_back(action);
			}
		}
	}

	return true;
}
开发者ID:Arkazon,项目名称:spring,代码行数:48,代码来源:KeyBindings.cpp

示例3: if

const CKeyBindings::ActionList& CKeyBindings::GetActionList(const CKeySet& ks) const
{
    static const ActionList empty;
    const ActionList* alPtr = &empty;

    if (ks.AnyMod()) {
        KeyMap::const_iterator it = bindings.find(ks);
        if (it != bindings.end()) {
            alPtr = &(it->second);
        }
    }
    else {
        // have to check for an AnyMod keyset as well as the normal one
        CKeySet anyMod = ks;
        anyMod.SetAnyBit();
        KeyMap::const_iterator nit = bindings.find(ks);
        KeyMap::const_iterator ait = bindings.find(anyMod);
        const bool haveNormal = (nit != bindings.end());
        const bool haveAnyMod = (ait != bindings.end());
        if (haveNormal && !haveAnyMod) {
            alPtr = &(nit->second);
        }
        else if (!haveNormal && haveAnyMod) {
            alPtr = &(ait->second);
        }
        else if (haveNormal && haveAnyMod) {
            // combine the two lists (normal first)
            static ActionList merged; //FIXME switch to thread_local when all buildbots are using >=gcc4.7
            merged = nit->second;
            merged.insert(merged.end(), ait->second.begin(), ait->second.end());
            alPtr = &merged;
        }
    }

    if (debugEnabled) {
        LOG("GetActions: hex=0x%02X acii=\"%s\":", ks.Key(), ks.GetString(false).c_str());
        if (alPtr != &empty) {
            int i = 1;
            for (const auto& a: *alPtr) {
                LOG("   %i. action=\"%s\"  rawline=\"%s\"  shortcut=\"%s\"", i++, a.command.c_str(), a.rawline.c_str(), a.boundWith.c_str());
            }
        } else {
            LOG("   EMPTY");
        }
    }

    return *alPtr;
}
开发者ID:spring,项目名称:spring,代码行数:48,代码来源:KeyBindings.cpp

示例4: if

const CKeyBindings::ActionList&
	CKeyBindings::GetActionList(const CKeySet& ks) const
{
	static const ActionList empty;
	const ActionList* alPtr = NULL;

	if (ks.AnyMod()) {
		KeyMap::const_iterator it = bindings.find(ks);
		if (it == bindings.end()) {
			alPtr = &empty;
		} else {
			alPtr = &(it->second);
		}
	}
	else {
		// have to check for an AnyMod keyset as well as the normal one
		CKeySet anyMod = ks;
		anyMod.SetAnyBit();
		KeyMap::const_iterator nit = bindings.find(ks);
		KeyMap::const_iterator ait = bindings.find(anyMod);
		const bool haveNormal = (nit != bindings.end());
		const bool haveAnyMod = (ait != bindings.end());
		if (!haveNormal && !haveAnyMod) {
			alPtr = &empty;
		}
		else if (haveNormal && !haveAnyMod) {
			alPtr = &(nit->second);
		}
		else if (!haveNormal && haveAnyMod) {
			alPtr = &(ait->second);
		}
		else {
			// combine the two lists (normal first)
			static ActionList merged;
			merged = nit->second;
			const ActionList& aal = ait->second;
			for (int i = 0; i < (int)aal.size(); ++i) {
				merged.push_back(aal[i]);
			}
			alPtr = &merged;
		}
	}

	if (debug > 0) {
		char buf[256];
		SNPRINTF(buf, sizeof(buf), "GetAction: %s (0x%03X)",
		         ks.GetString(false).c_str(), ks.Key());
		if (alPtr == &empty) {
			strncat(buf, "  EMPTY", sizeof(buf));
			logOutput.Print("%s", buf);
		}
		else {
			logOutput.Print("%s", buf);
			const ActionList& al = *alPtr;
			for (int i = 0; i < (int)al.size(); ++i) {
				SNPRINTF(buf, sizeof(buf), "  %s  \"%s\"",
				         al[i].command.c_str(), al[i].rawline.c_str());
				logOutput.Print("%s", buf);
			}
		}
	}

	return *alPtr;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:64,代码来源:KeyBindings.cpp


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