Skip to content
Snippets Groups Projects
Commit 18c68bf2 authored by MichelJuillard's avatar MichelJuillard
Browse files

fix previous commit

parent 1dfd9448
No related merge requests found
......@@ -185,82 +185,84 @@ void
OptionsList::writeOutputCommon(ostream &output, const string &option_group) const
{
for (const auto &[name, val] : options)
auto name1 = name;
std::visit([&]<class T>(const T &v)
{
if constexpr(is_same_v<T, SymbolListVal>)
v.writeOutput(option_group + "." + name1, output);
else
{
output << option_group << "." << name1 << " = ";
if constexpr(is_same_v<T, NumVal> || is_same_v<T, DateVal>)
output << v;
else if constexpr(is_same_v<T, pair<string, string>>)
output << '[' << v.first << "; " << v.second << ']';
else if constexpr(is_same_v<T, StringVal>)
output << "'" << v << "'";
else if constexpr(is_same_v<T, vector<int>>)
{
if (v.size() > 1)
auto name1 = name;
std::visit([&]<class T>(const T &v)
{
if constexpr(is_same_v<T, SymbolListVal>)
v.writeOutput(option_group + "." + name1, output);
else
{
output << option_group << "." << name1 << " = ";
if constexpr(is_same_v<T, NumVal> || is_same_v<T, DateVal>)
output << v;
else if constexpr(is_same_v<T, pair<string, string>>)
output << '[' << v.first << "; " << v.second << ']';
else if constexpr(is_same_v<T, StringVal>)
output << "'" << v << "'";
else if constexpr(is_same_v<T, vector<int>>)
{
if (v.size() > 1)
{
output << '[';
for (int it : v)
output << it << ";";
output << ']';
}
else
output << v.front();
}
else if constexpr(is_same_v<T, VecStrVal>)
{
output << '[';
for (int it : v)
output << it << ";";
output << ']';
}
else
output << v.front();
}
else if constexpr(is_same_v<T, VecStrVal>)
{
if (v.size() > 1)
if (v.size() > 1)
{
output << '{';
for (const auto &it : v)
output << "'" << it << "';";
output << '}';
}
else
output << v.front();
}
else if constexpr(is_same_v<T, VecCellStrVal>)
{
output << '{';
for (const auto &it : v)
output << "'" << it << "';";
output << '}';
}
else
output << v.front();
}
else if constexpr(is_same_v<T, VecCellStrVal>)
{
/* VecCellStrVal should ideally be merged into VecStrVal.
only difference is treatment of v.size==1, where VecStrVal
does not add quotes and curly brackets, i.e. allows for type conversion of
'2' into the number 2 */
output << '{';
for (const auto &it : v)
output << "'" << it << "';";
output << '}';
}
else if constexpr(is_same_v<T, VecValueVal>)
{
/* For historical reason, those vectors are output as row vectors (contrary
to vectors of integers which are output as column vectors) */
output << '[';
for (const auto &it : v)
output << it << ',';
output << ']';
}
else if constexpr(is_same_v<T, vector<vector<string>>>)
{
// Same remark as for VecValueVal
output << '{';
for (const auto &v2 : v)
/* VecCellStrVal should ideally be merged into VecStrVal.
only difference is treatment of v.size==1, where VecStrVal
does not add quotes and curly brackets, i.e. allows for type conversion of
'2' into the number 2 */
output << '{';
for (const auto &it : v)
output << "'" << it << "';";
output << '}';
}
else if constexpr(is_same_v<T, VecValueVal>)
{
output << '[';
for (const auto &it : v2)
output << it << ',';
output << "], ";
}
output << '}';
}
else
static_assert(always_false_v<T>, "Non-exhaustive visitor!");
output << ";" << endl;
}
}, val);
/* For historical reason, those vectors are output as row vectors (contrary
to vectors of integers which are output as column vectors) */
output << '[';
for (const auto &it : v)
output << it << ',';
output << ']';
}
else if constexpr(is_same_v<T, vector<vector<string>>>)
{
// Same remark as for VecValueVal
output << '{';
for (const auto &v2 : v)
{
output << '[';
for (const auto &it : v2)
output << it << ',';
output << "], ";
}
output << '}';
}
else
static_assert(always_false_v<T>, "Non-exhaustive visitor!");
output << ";" << endl;
}
}, val);
}
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment