spiegel-keyman/core/src/ldml/ldml_vkeys.cpp
Steven R. Loomis eba0d12123 chore(core): refactor ldml_processor 🙀
- split out vkeys

for #7234
2022-10-12 17:21:32 -05:00

37 lines
771 B
C++

/*
Copyright: © SIL International.
Description: Implementation for LDML Vkeys
Create Date: 6 Oct 2022
Authors: Steven R. Loomis
*/
#include "ldml_vkeys.hpp"
namespace km {
namespace kbp {
namespace ldml {
vkeys::vkeys() : vkey_to_string() {
}
void
vkeys::add(km_kbp_virtual_key vkey, uint16_t mod, std::u16string str) {
// construct key
const vkey_id id(vkey, mod);
// assign the string
vkey_to_string[id] = str;
}
std::u16string
vkeys::lookup(km_kbp_virtual_key vk, uint16_t modifier_state) const {
const vkey_id id(vk, modifier_state);
const auto key = vkey_to_string.find(id);
if (key == vkey_to_string.end()) {
return std::u16string();
}
return key->second;
}
} // namespace ldml
} // namespace kbp
} // namespace km