Skip to content

Commit

Permalink
Updated PrintParams to no longer print info text to files per tessera…
Browse files Browse the repository at this point in the history
  • Loading branch information
Balearica committed Oct 19, 2022
1 parent a873553 commit 03be197
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/ccutil/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,44 @@ bool ParamUtils::GetParamAsString(const char *name, const ParamsVectors *member_

void ParamUtils::PrintParams(FILE *fp, const ParamsVectors *member_params) {
int num_iterations = (member_params == nullptr) ? 1 : 2;
// When printing to stdout info text is included.
// Info text is omitted when printing to a file (would result in an invalid config file).
bool print_info = (fp == stdout) ? true : false;
std::ostringstream stream;
stream.imbue(std::locale::classic());
for (int v = 0; v < num_iterations; ++v) {
const ParamsVectors *vec = (v == 0) ? GlobalParams() : member_params;
for (auto int_param : vec->int_params) {
stream << int_param->name_str() << '\t' << (int32_t)(*int_param) << '\t'
<< int_param->info_str() << '\n';
if (print_info) {
stream << int_param->name_str() << '\t' << (int32_t)(*int_param) << '\t'
<< int_param->info_str() << '\n';
} else {
stream << int_param->name_str() << '\t' << (int32_t)(*int_param) << '\n';
}
}
for (auto bool_param : vec->bool_params) {
stream << bool_param->name_str() << '\t' << bool(*bool_param) << '\t'
<< bool_param->info_str() << '\n';
if (print_info) {
stream << bool_param->name_str() << '\t' << bool(*bool_param) << '\t'
<< bool_param->info_str() << '\n';
} else {
stream << bool_param->name_str() << '\t' << bool(*bool_param) << '\n';
}
}
for (auto string_param : vec->string_params) {
stream << string_param->name_str() << '\t' << string_param->c_str() << '\t'
<< string_param->info_str() << '\n';
if (print_info) {
stream << string_param->name_str() << '\t' << string_param->c_str() << '\t'
<< string_param->info_str() << '\n';
} else {
stream << string_param->name_str() << '\t' << string_param->c_str() << '\n';
}
}
for (auto double_param : vec->double_params) {
stream << double_param->name_str() << '\t' << (double)(*double_param) << '\t'
<< double_param->info_str() << '\n';
if (print_info) {
stream << double_param->name_str() << '\t' << (double)(*double_param) << '\t'
<< double_param->info_str() << '\n';
} else {
stream << double_param->name_str() << '\t' << (double)(*double_param) << '\n';
}
}
}
fprintf(fp, "%s", stream.str().c_str());
Expand Down

0 comments on commit 03be197

Please sign in to comment.