Commit 8a41a75c authored by Sébastien Villemot's avatar Sébastien Villemot

Apply modernize-raw-string-literal from clang-tidy

Use ReplaceShorterLiterals option to enforce replacement of all strings.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.html
parent 6ba31087
This diff is collapsed.
......@@ -845,7 +845,7 @@ DataTree::writePowerDeriv(ostream &output) const
string
DataTree::packageDir(const string &package)
{
regex pat{"\\."};
regex pat{R"(\.)"};
string dirname = "+" + regex_replace(package, pat, "/+");
boost::filesystem::create_directories(dirname);
return dirname;
......
This diff is collapsed.
......@@ -77,12 +77,12 @@ parse_options_line(istream &modfile)
string first_line;
getline(modfile, first_line);
regex pat{"^\\s*//\\s*--\\+\\s*options:([^\\+]*)\\+--"};
regex pat{R"(^\s*//\s*--\+\s*options:([^\+]*)\+--)"};
smatch matches;
if (regex_search(first_line, matches, pat))
if (matches.size() > 1 && matches[1].matched)
{
regex pat2{"([^,\\s]+)"};
regex pat2{R"(([^,\s]+))"};
string s{matches[1]};
for (sregex_iterator p(s.begin(), s.end(), pat2);
p != sregex_iterator{}; ++p)
......
This diff is collapsed.
......@@ -301,7 +301,7 @@ ModFile::checkPass(bool nostrict, bool stochastic)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::lessEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::equalEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::different)))
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
warnings << R"(WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about "Expressions", for more details.)" << endl;
if (linear
&& (dynamic_model.isUnaryOpUsed(UnaryOpcode::sign)
......@@ -944,7 +944,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
mOutputFile << "options_.parallel_info.local_files = {" << endl;
for (const auto & parallel_local_file : parallel_local_files)
{
size_t j = parallel_local_file.find_last_of("/\\");
size_t j = parallel_local_file.find_last_of(R"(/\)");
if (j == string::npos)
mOutputFile << "'', '" << parallel_local_file << "';" << endl;
else
......@@ -1158,10 +1158,10 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
<< "using SteadyState" << endl << endl
<< "using " << basename << "Static" << endl
<< "using " << basename << "Dynamic" << endl
<< "if isfile(\"" << basename << "SteadyState.jl" "\")" << endl
<< R"(if isfile(")" << basename << R"(SteadyState.jl"))" << endl
<< " using " << basename << "SteadyState" << endl
<< "end" << endl
<< "if isfile(\"" << basename << "SteadyState2.jl" "\")" << endl
<< R"(if isfile(")" << basename << R"(SteadyState2.jl"))" << endl
<< " using " << basename << "SteadyState2" << endl
<< "end" << endl << endl
<< "export model_, options_, oo_" << endl;
......@@ -1169,20 +1169,20 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
// Write Output
jlOutputFile << endl
<< "oo_ = dynare_output()" << endl
<< "oo_.dynare_version = \"" << PACKAGE_VERSION << "\"" << endl;
<< R"(oo_.dynare_version = ")" << PACKAGE_VERSION << R"(")" << endl;
// Write Options
jlOutputFile << endl
<< "options_ = dynare_options()" << endl
<< "options_.dynare_version = \"" << PACKAGE_VERSION << "\"" << endl;
<< R"(options_.dynare_version = ")" << PACKAGE_VERSION << R"(")" << endl;
if (linear == 1)
jlOutputFile << "options_.linear = true" << endl;
// Write Model
jlOutputFile << endl
<< "model_ = dynare_model()" << endl
<< "model_.fname = \"" << basename << "\"" << endl
<< "model_.dynare_version = \"" << PACKAGE_VERSION << "\"" << endl
<< R"(model_.fname = ")" << basename << R"(")" << endl
<< R"(model_.dynare_version = ")" << PACKAGE_VERSION << R"(")" << endl
<< "model_.sigma_e = zeros(Float64, " << symbol_table.exo_nbr() << ", "
<< symbol_table.exo_nbr() << ")" << endl
<< "model_.correlation_matrix = ones(Float64, " << symbol_table.exo_nbr() << ", "
......@@ -1229,19 +1229,19 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
<< "model_.dynamic = " << basename << "Dynamic.dynamic!" << endl
<< "model_.temporaries.static = " << basename << "Static.tmp_nbr" << endl
<< "model_.temporaries.dynamic = " << basename << "Dynamic.tmp_nbr" << endl
<< "if isfile(\"" << basename << "SteadyState.jl" "\")" << endl
<< R"(if isfile(")" << basename << R"(SteadyState.jl"))" << endl
<< " model_.user_written_analytical_steady_state = true" << endl
<< " model_.steady_state = " << basename << "SteadyState.steady_state!" << endl
<< "end" << endl
<< "if isfile(\"" << basename << "SteadyState2.jl" "\")" << endl
<< R"(if isfile(")" << basename << R"(SteadyState2.jl"))" << endl
<< " model_.analytical_steady_state = true" << endl
<< " model_.steady_state = " << basename << "SteadyState2.steady_state!" << endl
<< "end" << endl
<< "if isfile(\"" << basename << "StaticParamsDerivs.jl" "\")" << endl
<< R"(if isfile(")" << basename << R"(StaticParamsDerivs.jl"))" << endl
<< " using " << basename << "StaticParamsDerivs" << endl
<< " model_.static_params_derivs = " << basename << "StaticParamsDerivs.params_derivs" << endl
<< "end" << endl
<< "if isfile(\"" << basename << "DynamicParamsDerivs.jl" "\")" << endl
<< R"(if isfile(")" << basename << R"(DynamicParamsDerivs.jl"))" << endl
<< " using " << basename << "DynamicParamsDerivs" << endl
<< " model_.dynamic_params_derivs = " << basename << "DynamicParamsDerivs.params_derivs" << endl
<< "end" << endl
......@@ -1312,7 +1312,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|| !var_model_table.empty()
|| !trend_component_model_table.empty())
{
output << ", \"statements\": [";
output << R"(, "statements": [)";
if (!var_model_table.empty())
{
var_model_table.writeJsonOutput(output);
......@@ -1350,7 +1350,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
original_model.writeJsonOriginalModelOutput(original_model_output);
if (!statements.empty() || !var_model_table.empty() || !trend_component_model_table.empty())
{
original_model_output << endl << ", \"statements\": [";
original_model_output << endl << R"(, "statements": [)";
if (!var_model_table.empty())
{
var_model_table.writeJsonOutput(original_model_output);
......@@ -1381,14 +1381,14 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
if (json_output_mode == JsonFileOutputType::standardout)
{
if (transformpass || computingpass)
cout << "\"transformed_modfile\": ";
cout << R"("transformed_modfile": )";
else
cout << "\"modfile\": ";
cout << R"("modfile": )";
cout << output.str();
if (!original_model_output.str().empty())
cout << ", \"original_model\": " << original_model_output.str();
cout << R"(, "original_model": )" << original_model_output.str();
if (!steady_state_model_output.str().empty())
cout << ", \"steady_state_model\": " << steady_state_model_output.str();
cout << R"(, "steady_state_model": )" << steady_state_model_output.str();
}
else
{
......@@ -1492,14 +1492,14 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType
if (json_output_mode == JsonFileOutputType::standardout)
{
cout << ", \"static_model\": " << static_output.str() << endl
<< ", \"dynamic_model\": " << dynamic_output.str() << endl;
cout << R"(, "static_model": )" << static_output.str() << endl
<< R"(, "dynamic_model": )" << dynamic_output.str() << endl;
if (!static_paramsd_output.str().empty())
cout << ", \"static_params_deriv\": " << static_paramsd_output.str() << endl;
cout << R"(, "static_params_deriv": )" << static_paramsd_output.str() << endl;
if (!dynamic_paramsd_output.str().empty())
cout << ", \"dynamic_params_deriv\": " << dynamic_paramsd_output.str() << endl;
cout << R"(, "dynamic_params_deriv": )" << dynamic_paramsd_output.str() << endl;
}
else
{
......
......@@ -1434,7 +1434,7 @@ ModelTree::writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_
bool wrote_term = false;
temporary_terms_t tt2 = ttm1;
output << "\"external_functions_temporary_terms_" << concat << "\": [";
output << R"("external_functions_temporary_terms_)" << concat << R"(": [)";
for (auto it : tt)
if (ttm1.find(it) == ttm1.end())
{
......@@ -1458,19 +1458,19 @@ ModelTree::writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_
tt2 = ttm1;
wrote_term = false;
output << "]"
<< ", \"temporary_terms_" << concat << "\": [";
<< R"(, "temporary_terms_)" << concat << R"(": [)";
for (auto it = tt.begin();
it != tt.end(); it++)
if (ttm1.find(*it) == ttm1.end())
{
if (wrote_term)
output << ", ";
output << "{\"temporary_term\": \"";
output << R"({"temporary_term": ")";
(*it)->writeJsonOutput(output, tt, tef_terms);
output << "\""
<< ", \"value\": \"";
output << R"(")"
<< R"(, "value": ")";
(*it)->writeJsonOutput(output, tt2, tef_terms);
output << "\"}" << endl;
output << R"("})" << endl;
wrote_term = true;
// Insert current node into tt2
......@@ -1647,7 +1647,7 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
for (auto equation : equations)
equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
output << "\"model_local_variables\": [";
output << R"("model_local_variables": [)";
bool printed = false;
for (int it : local_variables_vector)
if (used_local_vars.find(it) != used_local_vars.end())
......@@ -1673,10 +1673,10 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
also VariableNode::writeOutput) */
output << "{\"variable\": \"" << symbol_table.getName(id) << "__\""
<< ", \"value\": \"";
output << R"({"variable": ")" << symbol_table.getName(id) << R"(__")"
<< R"(, "value": ")";
value->writeJsonOutput(output, tt, tef_terms);
output << "\"}" << endl;
output << R"("})" << endl;
}
output << "]";
}
......@@ -1800,7 +1800,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
SaveCode.open(filename, ios::out | ios::binary);
if (!SaveCode.is_open())
{
cerr << "Error : Can't open file \"" << filename << "\" for writing" << endl;
cerr << R"(Error : Can't open file ")" << filename << R"(" for writing)" << endl;
exit(EXIT_FAILURE);
}
u_count_int = 0;
......@@ -1852,24 +1852,24 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
exit(EXIT_FAILURE);
}
output << "\\documentclass[10pt,a4paper]{article}" << endl
<< "\\usepackage[landscape]{geometry}" << endl
<< "\\usepackage{fullpage}" << endl
<< "\\usepackage{amsfonts}" << endl
<< "\\usepackage{breqn}" << endl
<< "\\begin{document}" << endl
<< "\\footnotesize" << endl;
output << R"(\documentclass[10pt,a4paper]{article})" << endl
<< R"(\usepackage[landscape]{geometry})" << endl
<< R"(\usepackage{fullpage})" << endl
<< R"(\usepackage{amsfonts})" << endl
<< R"(\usepackage{breqn})" << endl
<< R"(\begin{document})" << endl
<< R"(\footnotesize)" << endl;
// Write model local variables
for (int id : local_variables_vector)
{
expr_t value = local_variables_table.find(id)->second;
content_output << "\\begin{dmath*}" << endl
content_output << R"(\begin{dmath*})" << endl
<< symbol_table.getTeXName(id) << " = ";
// Use an empty set for the temporary terms
value->writeOutput(content_output, output_type);
content_output << endl << "\\end{dmath*}" << endl;
content_output << endl << R"(\end{dmath*})" << endl;
}
for (int eq = 0; eq < (int) equations.size(); eq++)
......@@ -1882,7 +1882,7 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
if (equation_tag.first == eq)
{
if (!wrote_eq_tag)
content_output << "\\noindent[";
content_output << R"(\noindent[)";
else
content_output << ", ";
......@@ -1898,14 +1898,14 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
content_output << "]";
}
content_output << "\\begin{dmath}" << endl;
content_output << R"(\begin{dmath})" << endl;
// Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found
dynamic_cast<ExprNode *>(equations[eq])->writeOutput(content_output, output_type);
content_output << endl << "\\end{dmath}" << endl;
content_output << endl << R"(\end{dmath})" << endl;
}
output << "\\include{" << content_basename << "}" << endl
<< "\\end{document}" << endl;
output << R"(\include{)" << content_basename << "}" << endl
<< R"(\end{document})" << endl;
output.close();
content_output.close();
......@@ -2114,9 +2114,9 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
vector<pair<string, string>> eqtags;
temporary_terms_t tt_empty;
if (residuals)
output << endl << "\"residuals\":[" << endl;
output << endl << R"("residuals":[)" << endl;
else
output << endl << "\"model\":[" << endl;
output << endl << R"("model":[)" << endl;
for (int eq = 0; eq < (int) equations.size(); eq++)
{
if (eq > 0)
......@@ -2128,22 +2128,22 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
if (residuals)
{
output << "{\"residual\": {"
<< "\"lhs\": \"";
output << R"({"residual": {)"
<< R"("lhs": ")";
lhs->writeJsonOutput(output, temporary_terms, {});
output << "\"";
output << R"(")";
output << ", \"rhs\": \"";
output << R"(, "rhs": ")";
rhs->writeJsonOutput(output, temporary_terms, {});
output << "\"";
output << R"(")";
try
{
// Test if the right hand side of the equation is empty.
if (rhs->eval(eval_context_t()) != 0)
{
output << ", \"rhs\": \"";
output << R"(, "rhs": ")";
rhs->writeJsonOutput(output, temporary_terms, {});
output << "\"";
output << R"(")";
}
}
catch (ExprNode::EvalException &e)
......@@ -2153,12 +2153,12 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
}
else
{
output << "{\"lhs\": \"";
output << R"({"lhs": ")";
lhs->writeJsonOutput(output, tt_empty, {});
output << "\", \"rhs\": \"";
output << R"(", "rhs": ")";
rhs->writeJsonOutput(output, tt_empty, {});
output << "\""
<< ", \"line\": " << equations_lineno[eq];
output << R"(")"
<< R"(, "line": )" << equations_lineno[eq];
for (const auto & equation_tag : equation_tags)
if (equation_tag.first == eq)
......@@ -2166,13 +2166,13 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
if (!eqtags.empty())
{
output << ", \"tags\": {";
output << R"(, "tags": {)";
int i = 0;
for (vector<pair<string, string>>::const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
{
if (i != 0)
output << ", ";
output << "\"" << it->first << "\": \"" << it->second << "\"";
output << R"(")" << it->first << R"(": ")" << it->second << R"(")";
}
output << "}";
eqtags.clear();
......
......@@ -67,9 +67,9 @@ InitParamStatement::writeJuliaOutput(ostream &output, const string &basename)
void
InitParamStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"param_init\", \"name\": \"" << symbol_table.getName(symb_id) << "\", " << "\"value\": \"";
output << R"({"statementName": "param_init", "name": ")" << symbol_table.getName(symb_id) << R"(", )" << R"("value": ")";
param_value->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
void
......@@ -179,9 +179,9 @@ InitOrEndValStatement::writeJsonInitValues(ostream &output) const
{
if (it != init_values.begin())
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", " << "\"value\": \"";
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(", )" << R"("value": ")";
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
}
......@@ -233,7 +233,7 @@ InitValStatement::writeOutput(ostream &output, const string &basename, bool mini
void
InitValStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"initval\", \"vals\": [";
output << R"({"statementName": "initval", "vals": [)";
writeJsonInitValues(output);
output << "]}";
}
......@@ -298,7 +298,7 @@ EndValStatement::writeOutput(ostream &output, const string &basename, bool minim
void
EndValStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"endval\", \"vals\": [";
output << R"({"statementName": "endval", "vals": [)";
writeJsonInitValues(output);
output << "]}";
}
......@@ -394,17 +394,17 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
void
HistValStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"histval\", \"vals\": [";
output << R"({"statementName": "histval", "vals": [)";
for (auto it = hist_values.begin();
it != hist_values.end(); it++)
{
if (it != hist_values.begin())
output << ", ";
output << "{ \"name\": \"" << symbol_table.getName(it->first.first) << "\""
<< ", \"lag\": " << it->first.second
<< ", \"value\": \"";
output << R"({ "name": ")" << symbol_table.getName(it->first.first) << R"(")"
<< R"(, "lag": )" << it->first.second
<< R"(, "value": ")";
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]}";
}
......@@ -427,8 +427,8 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename, bool
void
InitvalFileStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"init_val_file\""
<< ", \"filename\": \"" << filename << "\""
output << R"({"statementName": "init_val_file")"
<< R"(, "filename": ")" << filename << R"(")"
<< "}";
}
......@@ -446,8 +446,8 @@ HistvalFileStatement::writeOutput(ostream &output, const string &basename, bool
void
HistvalFileStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"hist_val_file\""
<< ", \"filename\": \"" << filename << "\""
output << R"({"statementName": "hist_val_file")"
<< R"(, "filename": ")" << filename << R"(")"
<< "}";
}
......@@ -489,8 +489,8 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename, bool min
void
HomotopyStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"homotopy\", "
<< "\"values\": [";
output << R"({"statementName": "homotopy", )"
<< R"("values": [)";
for (auto it = homotopy_values.begin();
it != homotopy_values.end(); ++it)
{
......@@ -501,15 +501,15 @@ HomotopyStatement::writeJsonOutput(ostream &output) const
expr_t expression1, expression2;
tie(symb_id, expression1, expression2) = *it;
output << "{\"name\": \"" << symbol_table.getName(symb_id) << "\""
<< ", \"initial_value\": \"";
output << R"({"name": ")" << symbol_table.getName(symb_id) << R"(")"
<< R"(, "initial_value": ")";
if (expression1)
expression1->writeJsonOutput(output, {}, {});
else
output << "NaN";
output << "\", \"final_value\": \"";
output << R"(", "final_value": ")";
expression2->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]"
<< "}";
......@@ -529,8 +529,8 @@ SaveParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
void
SaveParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"save_params_and_steady_state\""
<< ", \"filename\": \"" << filename << "\""
output << R"({"statementName": "save_params_and_steady_state")"
<< R"(, "filename": ")" << filename << R"(")"
<< "}";
}
......@@ -601,15 +601,15 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
void
LoadParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"load_params_and_steady_state\""
<< "\"values\": [";
output << R"({"statementName": "load_params_and_steady_state")"
<< R"("values": [)";
for (auto it = content.begin();
it != content.end(); it++)
{
if (it != content.begin())
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\""
<< ", \"value\": \"" << it->second << "\"}";
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(")"
<< R"(, "value": ")" << it->second << R"("})";
}
output << "]"
<< "}";
......
......@@ -70,24 +70,24 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
void
AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
{
output << "\"deterministic_shocks\": [";
output << R"("deterministic_shocks": [)";
for (auto it = det_shocks.begin();
it != det_shocks.end(); it++)
{
if (it != det_shocks.begin())
output << ", ";
output << "{\"var\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"values\": [";
output << R"({"var": ")" << symbol_table.getName(it->first) << R"(", )"
<< R"("values": [)";
for (auto it1 = it->second.begin();
it1 != it->second.end(); it1++)
{
if (it1 != it->second.begin())
output << ", ";
output << "{\"period1\": " << it1->period1 << ", "
<< "\"period2\": " << it1->period2 << ", "
<< "\"value\": \"";
output << R"({"period1": )" << it1->period1 << ", "
<< R"("period2": )" << it1->period2 << ", "
<< R"("value": ")";
it1->value->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]}";
}
......@@ -153,8 +153,8 @@ ShocksStatement::writeOutput(ostream &output, const string &basename, bool minim
void
ShocksStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"shocks\""
<< ", \"overwrite\": ";
output << R"({"statementName": "shocks")"
<< R"(, "overwrite": )";
if (overwrite)
output << "true";
else
......@@ -164,52 +164,52 @@ ShocksStatement::writeJsonOutput(ostream &output) const
output << ", ";
writeJsonDetShocks(output);
}
output<< ", \"variance\": [";
output<< R"(, "variance": [)";
for (auto it = var_shocks.begin(); it != var_shocks.end(); it++)
{
if (it != var_shocks.begin())
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"variance\": \"";
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(", )"
<< R"("variance": ")";
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]"
<< ", \"stderr\": [";
<< R"(, "stderr": [)";
for (auto it = std_shocks.begin(); it != std_shocks.end(); it++)
{
if (it != std_shocks.begin())
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"stderr\": \"";
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(", )"
<< R"("stderr": ")";
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]"
<< ", \"covariance\": [";
<< R"(, "covariance": [)";
for (auto it = covar_shocks.begin(); it != covar_shocks.end(); it++)
{
if (it != covar_shocks.begin())
output << ", ";
output << "{"
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
<< "\"covariance\": \"";
<< R"("name": ")" << symbol_table.getName(it->first.first) << R"(", )"
<< R"("name2": ")" << symbol_table.getName(it->first.second) << R"(", )"
<< R"("covariance": ")";
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]"
<< ", \"correlation\": [";
<< R"(, "correlation": [)";
for (auto it = corr_shocks.begin(); it != corr_shocks.end(); it++)
{
if (it != corr_shocks.begin())
output << ", ";
output << "{"
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
<< "\"correlation\": \"";
<< R"("name": ")" << symbol_table.getName(it->first.first) << R"(", )"
<< R"("name2": ")" << symbol_table.getName(it->first.second) << R"(", )"
<< R"("correlation": ")";
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]"
<< "}";
......@@ -487,23 +487,23 @@ ConditionalForecastPathsStatement::writeOutput(ostream &output, const string &ba
void
ConditionalForecastPathsStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"conditional_forecast_paths\""
<< ", \"paths\": [";
output << R"({"statementName": "conditional_forecast_paths")"
<< R"(, "paths": [)";
for (auto it = paths.begin(); it != paths.end(); it++)
{
if (it != paths.begin())
output << ", ";
output << "{\"var\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"values\": [";
output << R"({"var": ")" << symbol_table.getName(it->first) << R"(", )"
<< R"("values": [)";
for (auto it1 = it->second.begin(); it1 != it->second.end(); it1++)
{
if (it1 != it->second.begin())
output << ", ";
output << "{\"period1\": " << it1->period1 << ", "
<< "\"period2\": " << it1->period2 << ", "
<< "\"value\": \"";
output << R"({"period1": )" << it1->period1 << ", "
<< R"("period2": )" << it1->period2 << ", "
<< R"("value": ")";
it1->value->writeJsonOutput(output, {}, {});
output << "\"}";
output << R"("})";
}
output << "]}";
}
......@@ -534,17 +534,17 @@ MomentCalibration::writeOutput(ostream &output, const string &basename, bool min
void
MomentCalibration::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"moment_calibration\""
<< ", \"moment_calibration_criteria\": [";
output << R"({"statementName": "moment_calibration")"
<< R"(, "moment_calibration_criteria": [)";
for (auto it = constraints.begin(); it != constraints.end(); it++)
{
if (it != constraints.begin())
output << ", ";
output << "{\"endogenous1\": \"" << symbol_table.getName(it->endo1) << "\""
<< ", \"endogenous2\": \"" << symbol_table.getName(it->endo2) << "\""
<< ", \"lags\": \"" << it->lags << "\""
<< ", \"lower_bound\": \"" << it->lower_bound << "\""
<< ", \"upper_bound\": \"" << it->upper_bound << "\""
output << R"({"endogenous1": ")" << symbol_table.getName(it->endo1) << R"(")"
<< R"(, "endogenous2": ")" << symbol_table.getName(it->endo2) << R"(")"
<< R"(, "lags": ")" << it->lags << R"(")"
<< R"(, "lower_bound": ")" << it->lower_bound << R"(")"
<< R"(, "upper_bound": ")" << it->upper_bound << R"(")"
<< "}";
}
output << "]"
......@@ -578,23 +578,23 @@ IrfCalibration::writeOutput(ostream &output, const string &basename, bool minima
void