W
William Payne
Hello, I have a std::map<const char*, int> in a class and in the constructor
of the class (there is only one), I do the following initilization of the
map:
KeyMap::KeyMap()
{
keymap["F1"] = VK_F1;
keymap["F2"] = VK_F2;
keymap["F3"] = VK_F3;
keymap["F4"] = VK_F4;
keymap["F5"] = VK_F5;
keymap["F6"] = VK_F6;
keymap["F7"] = VK_F7;
keymap["F8"] = VK_F8;
keymap["F9"] = VK_F9;
keymap["F10"] = VK_F10;
keymap["F11"] = VK_F11;
keymap["F12"] = VK_F12;
keymap["Page Up"] = VK_PRIOR;
keymap["Page Down"] = VK_NEXT;
keymap["Insert"] = VK_INSERT;
keymap["Home"] = VK_HOME;
keymap["Delete"] = VK_DELETE;
keymap["End"] = VK_END;
keymap["Divide"] = VK_DIVIDE;
keymap["Multiply"] = VK_MULTIPLY;
keymap["Subtract"] = VK_SUBTRACT;
keymap["Add"] = VK_ADD;
keymap["Decimal Point"] = VK_DECIMAL;
}
But when I call the following function (get_key_code) with the string F1, an
exception is thrown
because the key is not present in the map.
int KeyMap::get_key_code(const char* key)
{
if(keymap.count(key))
{
return keymap[key];
}
throw keymap_error("No such key exists in the map.");
}
Why? And how to remedy it?
// William Payne
of the class (there is only one), I do the following initilization of the
map:
KeyMap::KeyMap()
{
keymap["F1"] = VK_F1;
keymap["F2"] = VK_F2;
keymap["F3"] = VK_F3;
keymap["F4"] = VK_F4;
keymap["F5"] = VK_F5;
keymap["F6"] = VK_F6;
keymap["F7"] = VK_F7;
keymap["F8"] = VK_F8;
keymap["F9"] = VK_F9;
keymap["F10"] = VK_F10;
keymap["F11"] = VK_F11;
keymap["F12"] = VK_F12;
keymap["Page Up"] = VK_PRIOR;
keymap["Page Down"] = VK_NEXT;
keymap["Insert"] = VK_INSERT;
keymap["Home"] = VK_HOME;
keymap["Delete"] = VK_DELETE;
keymap["End"] = VK_END;
keymap["Divide"] = VK_DIVIDE;
keymap["Multiply"] = VK_MULTIPLY;
keymap["Subtract"] = VK_SUBTRACT;
keymap["Add"] = VK_ADD;
keymap["Decimal Point"] = VK_DECIMAL;
}
But when I call the following function (get_key_code) with the string F1, an
exception is thrown
because the key is not present in the map.
int KeyMap::get_key_code(const char* key)
{
if(keymap.count(key))
{
return keymap[key];
}
throw keymap_error("No such key exists in the map.");
}
Why? And how to remedy it?
// William Payne