Exemplo n.º 1
0
KeySeq CacheConfigClient::getFilterKeys(const KeySeq& keys, const std::vector<std::string>& prxVec, const std::string& namespaceId) {
    {
        boost::shared_lock<boost::shared_mutex> lock(hashHolderMaplock_);
        std::map<std::string, MemcachedClientPoolHashHolderPtr>::const_iterator findIt = hashHolderMap_.find(namespaceId);
        if(findIt == hashHolderMap_.end()) {
            return KeySeq();
        }
        return findIt->second->get(keys, prxVec);
    }
}
Exemplo n.º 2
0
/* load m_setting
   If called by "include", 'filename' describes filename.
   Otherwise the 'filename' is empty.
 */
bool SettingLoader::load(Setting *i_setting, const tstringi &i_filename)
{
	m_setting = i_setting;
	m_isThereAnyError = false;

	tstringi path;
	if (!getFilename(i_filename, &path)) {
		if (i_filename.empty()) {
			Acquire a(m_soLog);
			getFilename(i_filename, &path, 0);	// show filenames
			return false;
		} else
			throw ErrorMessage() << _T("`") << i_filename
			<< _T("': no such file or other error.");
	}

	// create global keymap's default keySeq
	ActionFunction af(createFunctionData(_T("OtherWindowClass")));
	KeySeq *globalDefault = m_setting->m_keySeqs.add(KeySeq(_T("")).add(af));

	// add default keymap
	m_currentKeymap = m_setting->m_keymaps.add(
						  Keymap(Keymap::Type_windowOr, _T("Global"), _T(""), _T(""),
								 globalDefault, NULL));

	/*
	// add keyboard layout name
	if (filename.empty())
	{
	  char keyboardLayoutName[KL_NAMELENGTH];
	  if (GetKeyboardLayoutName(keyboardLayoutName))
	  {
	    tstringi kl = tstringi(_T("KeyboardLayout/")) + keyboardLayoutName;
	    m_setting->symbols.insert(kl);
	    Acquire a(m_soLog);
	    *m_log << _T("KeyboardLayout: ") << kl << std::endl;
	  }
	}
	*/

	// load
	load(path);

	// finalize
	if (i_filename.empty())
		m_setting->m_keymaps.adjustModifier(m_setting->m_keyboard);

	return !m_isThereAnyError;
}
Exemplo n.º 3
0
void DisassemblyView::_UpdateActions(void)
{
  auto ActionsMap = medusa::Action::GetMap();
  AddUiActions(ActionsMap);

  medusa::UserConfiguration UserCfg;

  for (auto const& rActionPair : ActionsMap)
  {
    auto spAction = rActionPair.second(*_core);

    std::string Opt;
    if (!UserCfg.GetOption(rActionPair.first, Opt))
    {
      medusa::Log::Write("ui_qt") << "failed to get option for " << spAction->GetName() << medusa::LogEnd;
      continue;
    }
    QKeySequence KeySeq(QString::fromStdString(Opt), QKeySequence::PortableText);
    medusa::Log::Write("ui_qt") << "bind " << rActionPair.first << " with \"" << KeySeq.toString().toStdString() << "\"" << medusa::LogEnd;

    auto pUiAction = new UiAction(this, spAction, KeySeq, this);
    addAction(pUiAction);
  }
}
Exemplo n.º 4
0
// <KEYMAP_DEFINITION>
void SettingLoader::load_KEYMAP_DEFINITION(const Token *i_which)
{
	Keymap::Type type = Keymap::Type_keymap;
	Token *name = getToken();	// <KEYMAP_NAME>
	tstringi windowClassName;
	tstringi windowTitleName;
	KeySeq *keySeq = NULL;
	Keymap *parentKeymap = NULL;
	bool isKeymap2 = false;
	bool doesLoadDefaultKeySeq = false;

	if (!isEOL()) {
		Token *t = lookToken();
		if (*i_which == _T("window")) {	// <WINDOW>
			if (t->isOpenParen())
				// "(" <WINDOW_CLASS_NAME> "&&" <WINDOW_TITLE_NAME> ")"
				// "(" <WINDOW_CLASS_NAME> "||" <WINDOW_TITLE_NAME> ")"
			{
				getToken();
				windowClassName = getToken()->getRegexp();
				t = getToken();
				if (*t == _T("&&"))
					type = Keymap::Type_windowAnd;
				else if (*t == _T("||"))
					type = Keymap::Type_windowOr;
				else
					throw ErrorMessage() << _T("`") << *t << _T("': unknown operator.");
				windowTitleName = getToken()->getRegexp();
				if (!getToken()->isCloseParen())
					throw ErrorMessage() << _T("there must be `)'.");
			} else if (t->isRegexp()) {	// <WINDOW_CLASS_NAME>
				getToken();
				type = Keymap::Type_windowAnd;
				windowClassName = t->getRegexp();
			}
		} else if (*i_which == _T("keymap"))
			;
		else if (*i_which == _T("keymap2"))
			isKeymap2 = true;
		else
			ASSERT(false);

		if (!isEOL())
			doesLoadDefaultKeySeq = true;
	}

	m_currentKeymap = m_setting->m_keymaps.add(
						  Keymap(type, name->getString(), windowClassName, windowTitleName,
								 NULL, NULL));

	if (doesLoadDefaultKeySeq) {
		Token *t = lookToken();
		// <KEYMAP_PARENT>
		if (*t == _T(":")) {
			getToken();
			t = getToken();
			parentKeymap = m_setting->m_keymaps.searchByName(t->getString());
			if (!parentKeymap)
				throw ErrorMessage() << _T("`") << *t
				<< _T("': unknown keymap name.");
		}
		if (!isEOL()) {
			t = getToken();
			if (!(*t == _T("=>") || *t == _T("=")))
				throw ErrorMessage() << _T("`") << *t << _T("': syntax error.");
			keySeq = SettingLoader::load_KEY_SEQUENCE();
		}
	}
	if (keySeq == NULL) {
		FunctionData *fd;
		if (type == Keymap::Type_keymap && !isKeymap2)
			fd = createFunctionData(_T("KeymapParent"));
		else if (type == Keymap::Type_keymap && !isKeymap2)
			fd = createFunctionData(_T("Undefined"));
		else // (type == Keymap::Type_windowAnd || type == Keymap::Type_windowOr)
			fd = createFunctionData(_T("KeymapParent"));
		ASSERT( fd );
		keySeq = m_setting->m_keySeqs.add(
					 KeySeq(name->getString()).add(ActionFunction(fd)));
	}

	m_currentKeymap->setIfNotYet(keySeq, parentKeymap);
}