diff --git a/core/src/jsonpp.cpp b/core/src/jsonpp.cpp index 69c791c2cc..cfde2da976 100644 --- a/core/src/jsonpp.cpp +++ b/core/src/jsonpp.cpp @@ -13,7 +13,7 @@ #include #include "jsonpp.hpp" - +#include "utfcodec.hpp" #if defined(_MSC_VER) #define FORMAT_INTMAX "%lli" @@ -105,6 +105,15 @@ json & json::operator << (json::string s) throw() return *this; } +json & json::operator <<(const char16_t* s) throw() +{ + std::u16string str16(s); + std::string str = convert(str16); + + (*this) << str; + return *this; +} + json & json::operator << (json::number f) throw() { context(seq); diff --git a/core/src/jsonpp.hpp b/core/src/jsonpp.hpp index 985e7af9f6..d97afe50a6 100644 --- a/core/src/jsonpp.hpp +++ b/core/src/jsonpp.hpp @@ -20,8 +20,8 @@ class json { // Prevent copying - json(const json &); - json & operator = (const json &); + json(const json &) = delete; + json & operator = (const json &) = delete; typedef void (*_context_t)(json &); @@ -62,6 +62,7 @@ public: auto & stream() const throw(); + json & operator << (const char16_t*) throw(); json & operator << (string) throw(); json & operator << (number) throw(); json & operator << (integer) throw(); @@ -78,8 +79,8 @@ public: class json::closer { // Prevent copying. - closer(const closer &); - closer & operator = (const closer &); + closer(const closer &) = delete; + closer & operator = (const closer &) = delete; json * const _j; public: @@ -113,13 +114,17 @@ json & json::operator << (json::_context_t ctxt) throw() return *this; } -template inline -json & operator << (json & j, std::basic_string const & s) throw() { return j << json::string(convert(s).c_str()); } +json & operator << (json & j, std::string const & s) throw() { return j << json::string(s.c_str()); } -template inline -json & operator << (json & j, C const * s) throw() { return j << json::string(convert(s).c_str()); } +json & operator << (json & j, std::string const * s) throw() { return j << json::string(s->c_str()); } + +inline +json & operator << (json & j, std::u16string const & s) throw() { return j << json::string(convert(s).c_str()); } + +inline +json & operator << (json & j, std::u16string const * s) throw() { return j << json::string(convert(*s).c_str()); } inline json & operator << (json & j, signed char d) throw() { return j << json::integer(d); } diff --git a/core/tests/unit/kmx/kmx_external_event.cpp b/core/tests/unit/kmx/kmx_external_event.cpp index 9ebdccfc73..d5d48c8ad6 100644 --- a/core/tests/unit/kmx/kmx_external_event.cpp +++ b/core/tests/unit/kmx/kmx_external_event.cpp @@ -17,7 +17,6 @@ #include #include -#include /** * This test will test the infrastructure around the external event processing diff --git a/core/tests/unit/kmx/kmx_imx.cpp b/core/tests/unit/kmx/kmx_imx.cpp index 1972d9dc26..12b3bc9455 100644 --- a/core/tests/unit/kmx/kmx_imx.cpp +++ b/core/tests/unit/kmx/kmx_imx.cpp @@ -14,10 +14,10 @@ #include #include #include "../emscripten_filesystem.h" +#include "utfcodec.hpp" #include #include -#include /** This test will test the infrastructure around IMX third party librays * and callback. The functions tested are: @@ -172,13 +172,15 @@ void test_imx_list(const km::core::path &source_file){ // This keyboard has 4 function names from 2 different libraries in the stores km_core_keyboard_imx *imx_rule_it = kb_imx_list; - std::stringstream extracted_library_function; auto x = 0; for (; imx_rule_it->library_name; ++imx_rule_it) { - extracted_library_function << imx_rule_it->library_name << ":" << imx_rule_it->function_name; - assert(extracted_library_function.str() == expected_imx_map[imx_rule_it->imx_id] ); - g_extract_imx_map[imx_rule_it->imx_id] = extracted_library_function.str(); - extracted_library_function.str(""); + std::u16string str; + str.append(imx_rule_it->library_name); + str.append(u":"); + str.append(imx_rule_it->function_name); + auto extracted_library_function = convert(str); + assert(extracted_library_function == expected_imx_map[imx_rule_it->imx_id] ); + g_extract_imx_map[imx_rule_it->imx_id] = extracted_library_function; ++x; }