ChatON+:RenameTo chaton_meta_load_json to match semantic
Also add simple note wrt itself and its helper.
This commit is contained in:
parent
bd5c39e0f0
commit
f8c0b474ec
3 changed files with 8 additions and 4 deletions
|
@ -515,11 +515,14 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The compiled-in configurable template data (the meta)
|
||||||
#include "chaton_meta.hpp"
|
#include "chaton_meta.hpp"
|
||||||
//ChatTemplates gCT = {{}};
|
//ChatTemplates gCT = {{}};
|
||||||
|
|
||||||
#ifdef CHATON_JSON
|
#ifdef CHATON_JSON
|
||||||
|
|
||||||
|
// Get value corresponding to the specified hierarchy/chain of keys.
|
||||||
|
// Also throw a more informative exception, if it is not found.
|
||||||
template <typename SupportedType>
|
template <typename SupportedType>
|
||||||
inline SupportedType json_get(json &j, const std::vector<std::string_view> &keys, const std::string &msgTag) {
|
inline SupportedType json_get(json &j, const std::vector<std::string_view> &keys, const std::string &msgTag) {
|
||||||
json curJ = j;
|
json curJ = j;
|
||||||
|
@ -540,7 +543,8 @@ inline SupportedType json_get(json &j, const std::vector<std::string_view> &keys
|
||||||
return curJ;
|
return curJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool chaton_meta_load(const std::string &fname) {
|
// Update/Extend the compiled-in configurable template data (the meta) from the specified json file.
|
||||||
|
inline bool chaton_meta_load_json(const std::string &fname) {
|
||||||
std::ifstream f(fname);
|
std::ifstream f(fname);
|
||||||
json conMeta = json::parse(f);
|
json conMeta = json::parse(f);
|
||||||
for(auto it=conMeta.begin(); it != conMeta.end(); ++it) {
|
for(auto it=conMeta.begin(); it != conMeta.end(); ++it) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
if (params.chaton) {
|
if (params.chaton) {
|
||||||
if (!params.chaton_meta_json.empty()) {
|
if (!params.chaton_meta_json.empty()) {
|
||||||
chaton_meta_load(params.chaton_meta_json);
|
chaton_meta_load_json(params.chaton_meta_json);
|
||||||
}
|
}
|
||||||
if (!chaton_meta_ok(params.chaton_template_id)) {
|
if (!chaton_meta_ok(params.chaton_template_id)) {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -116,7 +116,7 @@ static void check_chaton(std::string &metaJson) {
|
||||||
std::vector<char> formatted_chat(1024);
|
std::vector<char> formatted_chat(1024);
|
||||||
int32_t res;
|
int32_t res;
|
||||||
|
|
||||||
chaton_meta_load(metaJson);
|
chaton_meta_load_json(metaJson);
|
||||||
for(auto tmplId: templateIds) {
|
for(auto tmplId: templateIds) {
|
||||||
formatted_chat.resize(1024);
|
formatted_chat.resize(1024);
|
||||||
std::cout << "\n----------" << tmplId << "---------------\n";
|
std::cout << "\n----------" << tmplId << "---------------\n";
|
||||||
|
@ -137,7 +137,7 @@ static void check_chaton_ex(std::string &metaJson) {
|
||||||
std::vector<char> formatted_chat(1024);
|
std::vector<char> formatted_chat(1024);
|
||||||
int32_t res;
|
int32_t res;
|
||||||
|
|
||||||
chaton_meta_load(metaJson);
|
chaton_meta_load_json(metaJson);
|
||||||
for(auto tmplId: templateIds) {
|
for(auto tmplId: templateIds) {
|
||||||
formatted_chat.resize(1024);
|
formatted_chat.resize(1024);
|
||||||
std::cout << "\n----------" << tmplId << "---------------\n";
|
std::cout << "\n----------" << tmplId << "---------------\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue