chore(core): update core to C++17 fixes

- remove some tangled templates in jsonpp
- remove one unneeded include of sstream, and rewrite another as a string conversion.

Fixes: #8800
This commit is contained in:
Steven R. Loomis 2024-05-13 17:44:36 -05:00
parent 52c65c2e5d
commit d3c9fbbadc
4 changed files with 31 additions and 16 deletions

View file

@ -13,7 +13,7 @@
#include <limits>
#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<char16_t, char>(str16);
(*this) << str;
return *this;
}
json & json::operator << (json::number f) throw()
{
context(seq);

View file

@ -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<typename C>
inline
json & operator << (json & j, std::basic_string<C> const & s) throw() { return j << json::string(convert<C,char>(s).c_str()); }
json & operator << (json & j, std::string const & s) throw() { return j << json::string(s.c_str()); }
template<typename C>
inline
json & operator << (json & j, C const * s) throw() { return j << json::string(convert<C,char>(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<char16_t,char>(s).c_str()); }
inline
json & operator << (json & j, std::u16string const * s) throw() { return j << json::string(convert<char16_t,char>(*s).c_str()); }
inline
json & operator << (json & j, signed char d) throw() { return j << json::integer(d); }

View file

@ -17,7 +17,6 @@
#include <map>
#include <iostream>
#include <sstream>
/**
* This test will test the infrastructure around the external event processing

View file

@ -14,10 +14,10 @@
#include <test_assert.h>
#include <test_color.h>
#include "../emscripten_filesystem.h"
#include "utfcodec.hpp"
#include <map>
#include <iostream>
#include <sstream>
/** 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<km_core_cu,char>(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;
}