Skip to content

Commit

Permalink
print overload for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
gf712 committed Feb 21, 2019
1 parent 890636f commit 26bfb3c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/shogun/base/SGObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,19 @@ std::string CSGObject::to_string() const
{
ss << it->first.name() << "=";
auto value = it->second.get_value();
if (value.visitable())
if (m_string_to_enum_map.find(it->first.name()) !=
m_string_to_enum_map.end())
{
auto param_enum_map = m_string_to_enum_map.at(it->first.name());
auto enum_value = any_cast<machine_int_t>(value);
auto enum_map_it = std::find_if(
param_enum_map.begin(), param_enum_map.end(),
[&enum_value](const std::pair<std::string, machine_int_t>& p) {
return p.second == enum_value;
});
ss << enum_map_it->first;
}
else if (value.visitable())
{
value.visit(visitor.get());
}
Expand Down

0 comments on commit 26bfb3c

Please sign in to comment.