1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

C++20 fixes

This commit is contained in:
Leonid Fedorov
2022-02-01 15:54:05 +00:00
parent 0ee5203262
commit 65252df4f6
36 changed files with 22433 additions and 310 deletions

View File

@ -23,9 +23,8 @@
#include <openssl/rand.h>
#include <openssl/opensslv.h>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include "utils/json/json.hpp"
#include "idberrorinfo.h"
#include "logger.h"
#include "mcsconfig.h"
@ -393,16 +392,16 @@ ReadKeyResult secrets_readkeys(const string& filepath)
{
// File contents should be json.
// json_error_t err;
boost::property_tree::ptree jsontree;
nlohmann::json jsontree;
try
{
boost::property_tree::read_json(filepath, jsontree);
std::ifstream i(filepath);
jsontree = nlohmann::json::parse(i);
}
catch (boost::property_tree::json_parser::json_parser_error& je)
catch (const nlohmann::json::exception& je)
{
std::cout << "Error reading JSON from secrets file: " << je.filename() << " on line: " << je.line()
<< std::endl;
std::cout << je.message() << std::endl;
std::cout << "Error reading JSON from secrets file: " << filepath << std::endl;
std::cout << je.what() << std::endl;
}
catch (...)
{
@ -410,8 +409,8 @@ ReadKeyResult secrets_readkeys(const string& filepath)
strerror(errno));
}
// json_t* obj = json_load_file(filepathc, 0, &err);
string enc_cipher = jsontree.get<string>(field_cipher);
string enc_key = jsontree.get<string>(field_key);
string enc_cipher = jsontree[field_cipher];
string enc_key = jsontree[field_key];
// const char* enc_cipher = json_string_value(json_object_get(obj, field_cipher));
// const char* enc_key = json_string_value(json_object_get(obj, field_key));
bool cipher_ok = !enc_cipher.empty() && (enc_cipher == CIPHER_NAME);
@ -648,23 +647,24 @@ bool secrets_write_keys(const ByteVec& key, const string& filepath, const string
utils::VLArray<char> key_hex(2 * keylen + 1);
bin2hex(key.data(), keylen, key_hex.data());
boost::property_tree::ptree jsontree;
jsontree.put(field_desc, desc);
jsontree.put(field_version, columnstore_version.c_str());
jsontree.put(field_cipher, CIPHER_NAME);
jsontree.put(field_key, (const char*)key_hex.data());
nlohmann::json jsontree;
jsontree[field_desc] = desc;
jsontree[field_version] = columnstore_version;
jsontree[field_cipher] = CIPHER_NAME;
jsontree[field_key] = (const char*)key_hex.data();
auto filepathc = filepath.c_str();
bool write_ok = false;
errno = 0;
try
{
write_json(filepathc, jsontree);
std::ofstream o(filepath);
o << jsontree;
}
catch (boost::property_tree::json_parser::json_parser_error& je)
catch (const nlohmann::json::exception& je)
{
std::cout << "Write to secrets file: " << je.filename() << " on line: " << je.line() << std::endl;
std::cout << je.message() << std::endl;
std::cout << "Write to secrets file: " << filepath << std::endl;
std::cout << je.what() << std::endl;
}
catch (...)
{