Beispiel #1
0
	Point operator() (KeySet const & ks, std::string const & name, option_t const options) const
	{
		Key x = ks.lookup (name + "/x", options);
		if (!x) throw KeyNotFoundException (name + "/x not found");
		Key y = ks.lookup (name + "/y", options);
		if (!y) throw KeyNotFoundException (name + "/y not found");

		return Point (x.get<int> (), y.get<int> ());
	}
Beispiel #2
0
/**
 * @brief Returns the path from the path key
 * 
 * @param pathKey The key of the path to be found
 * @return Path from the path key
 */
string PathManager::getPath(string pathKey){
	if(hasPath(pathKey)){
		return this->m_paths[pathKey];
	} else {
		throw KeyNotFoundException(pathKey);
	}
}
std::string SettingsRegistry::read(const std::string &key)
{
	HKEY keyHandle;
	if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\WhatsApp Viewer", 0, KEY_READ, &keyHandle) != ERROR_SUCCESS)
	{
		throw Exception("Could not open registry key");
	}

	DWORD type;
	DWORD size;
	std::wstring keyW = strtowstr(key);
	if (RegQueryValueEx(keyHandle, keyW.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS)
	{
		RegCloseKey(keyHandle);
		throw KeyNotFoundException("Could not read registry value");
	}

	if (type != REG_SZ)
	{
		RegCloseKey(keyHandle);
		throw Exception("Incorrect registry value type");
	}

	std::wstring value(size / sizeof(wchar_t), L'\0');
	if (RegQueryValueEx(keyHandle, keyW.c_str(), NULL, NULL, reinterpret_cast<BYTE *>(&value[0]), &size) != ERROR_SUCCESS)
	{
		RegCloseKey(keyHandle);
		throw Exception("Could not read registry value");
	}

	RegCloseKey(keyHandle);

	return wstrtostr(value.c_str());
}
Beispiel #4
0
unsigned BiEncoder<Key>::get_value(Key const &key){
  if (!is_checked){compile();}
  typename std::unordered_map<Key,unsigned>::iterator gotcha = codemap.find(key);
  if (gotcha != codemap.end()){return gotcha->second;}
  if (has_unk){return 0;}
  cerr << "key error:" << key << endl;
  throw KeyNotFoundException();
}
Beispiel #5
0
	std::string KSGTaskParams::GetParam(const std::string& key) const
throw(KeyNotFoundException)
{
	KeyValueMap::const_iterator i = _params.find(key);
	if(i == _params.end())
	{
		throw KeyNotFoundException();
	}
	return i->second;
}
Beispiel #6
0
Value& Dictionary<Key,Value>::operator[](Key const &key) {//generic get / set operator
 
  typename std::unordered_map<Key,Value>::iterator gotit = dict.find(key);

 if (gotit != dict.end()){return gotit->second;}
 if (has_default){
      dict[key] = default_val;
      return dict[key];
 }
 throw KeyNotFoundException();
}
Beispiel #7
0
		//////////////////////////////////////////////////////////////////////////
		/// Get a boolean value if it does not exist exception will be thrown
		///
		/// @param path the path to look up
		/// @param key the key to lookup
		/// @return the boolean value
		///
		/// @author mickem
		virtual bool get_real_bool(settings_core::key_path_type key) {
			throw KeyNotFoundException(key);
		}
Beispiel #8
0
		//////////////////////////////////////////////////////////////////////////
		/// Get an integer value if it does not exist exception will be thrown
		///
		/// @param path the path to look up
		/// @param key the key to lookup
		/// @return the int value
		///
		/// @author mickem
		virtual int get_real_int(settings_core::key_path_type key) {
			throw KeyNotFoundException(key);
		}
Beispiel #9
0
		//////////////////////////////////////////////////////////////////////////
		/// Get a string value if it does not exist exception will be thrown
		///
		/// @param path the path to look up
		/// @param key the key to lookup
		/// @return the string value
		///
		/// @author mickem
		virtual std::wstring get_real_string(settings_core::key_path_type key) {
			throw KeyNotFoundException(key);
		}
Beispiel #10
0
const Value& Dictionary<Key,Value>::get_value(Key const &key) const{
  typename std::unordered_map<Key,Value>::const_iterator gotit = dict.find(key);
  if (gotit != dict.end()){return gotit->second;}
  throw KeyNotFoundException();
}
Beispiel #11
0
Key& BiEncoder<Key>::get_key(unsigned const &value){
  if (!is_checked){compile();}
  if (value >= decodemap.size()){throw KeyNotFoundException();}
  return decodemap[value];
}