mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
- split keyboard loading into loading KMX file into blob and then loading the keyboard processor from the blob. - deprecate `km_core_keyboard_load` - move file access next to deprecated method. This is now the only place that loads a file in Core; unit tests have some more places that load files. - introduce GTest and add unit tests for loading from blob Cherry-picked from `epic/web-core` branch. Cherry-Pick-Commit:1deaa323adCherry-Pick-Commit:59019cc8b7Cherry-Pick-Commit:bc46458368Cherry-Pick-Commit:d06aa29956Cherry-Pick-Commit:1c88166f6eCherry-Pick-Commit:069cd21ecdCherry-Pick-Commit:052ae2ec35Cherry-Pick-Commit:11a2a3ba3aPart-of: #11293 Part-of: #8093
63 lines
1.6 KiB
C++
63 lines
1.6 KiB
C++
/*
|
|
Copyright: © 2018 SIL International.
|
|
Description: Internal keyboard class and adaptor class for the API.
|
|
Create Date: 2 Oct 2018
|
|
Authors: Tim Eves (TSE)
|
|
History: 7 Oct 2018 - TSE - Refactored out of km_core_keyboard_api.cpp
|
|
*/
|
|
#include "keyboard.hpp"
|
|
#include "jsonpp.hpp"
|
|
|
|
using namespace km::core;
|
|
|
|
|
|
inline
|
|
void keyboard_attributes::render()
|
|
{
|
|
// Make attributes point to the stored values above.
|
|
id = _keyboard_id.c_str();
|
|
version_string = _version_string.c_str();
|
|
default_options = _default_opts.data();
|
|
}
|
|
|
|
|
|
keyboard_attributes::keyboard_attributes(std::u16string const & kbid,
|
|
std::u16string const & version,
|
|
options_store const &opts)
|
|
: _keyboard_id(kbid),
|
|
_version_string(version),
|
|
_folder_path(""),
|
|
_default_opts(opts)
|
|
{
|
|
// Ensure that the default_options array will be properly terminated.
|
|
_default_opts.emplace_back();
|
|
render();
|
|
}
|
|
|
|
|
|
keyboard_attributes::keyboard_attributes(keyboard_attributes &&rhs)
|
|
: _keyboard_id(std::move(rhs._keyboard_id)),
|
|
_version_string(std::move(rhs._version_string)),
|
|
_folder_path(""),
|
|
_default_opts(std::move(rhs._default_opts))
|
|
{
|
|
rhs.id = rhs.version_string = nullptr;
|
|
render();
|
|
}
|
|
|
|
|
|
keyboard_attributes & keyboard_attributes::operator = (keyboard_attributes &&rhs)
|
|
{
|
|
return *new (this) keyboard_attributes(std::move(rhs));
|
|
}
|
|
|
|
|
|
json & km::core::operator << (json & j, km::core::keyboard_attributes const & kb)
|
|
{
|
|
j << json::object
|
|
<< "id" << kb.id
|
|
<< "version" << kb.version_string
|
|
<< "rules" << json::array << json::close;
|
|
|
|
return j << json::close;
|
|
}
|