1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-19 02:22:39 +00:00

Makes provision for pretty-printed key names.

i.e. keys that don't fit C++ naming rules.
This commit is contained in:
Thomas Harte
2021-04-04 22:20:35 -04:00
parent 27eddf6dff
commit 18d6197d6c
4 changed files with 27 additions and 1 deletions
+5 -1
View File
@@ -205,6 +205,7 @@ void Reflection::Struct::append(std::ostringstream &stream, const std::string &k
std::string Reflection::Struct::description() const {
std::ostringstream stream;
const auto name_map = pretty_names();
stream << "{";
@@ -212,7 +213,10 @@ std::string Reflection::Struct::description() const {
for(const auto &key: all_keys()) {
if(!is_first) stream << ", ";
is_first = false;
stream << key << ": ";
// Use the pretty name for this key, if defined.
const auto mapped_key = name_map.find(key);
stream << (mapped_key != name_map.end() ? mapped_key->second : key) << ": ";
const auto count = count_of(key);
const auto type = type_of(key);