message: PWGCF: AliFemtoConfigObject - Reimplemented Stringify for map; fixing empty-map bug
diff: @@ -120,34 +120,55 @@ AliFemtoConfigObject::Stringify(bool pretty, int deep) const
  return result;
  }
  case kMAP: {
  - TString result = '{';
  - if (pretty) {
  - result += TString('\n');
  + // an experimental drawing-scheme
  + const static bool STRINGIFY_COMPACT = false;
  +
  + auto it = fValueMap.cbegin();
  +
  + auto stringify_pair = [=] (const auto &pair) {
  + auto &key_str = pair.first;
  + auto value_str = (pretty)
  + ? pair.second.Stringify(pretty, deep+1)
  + : pair.second.Stringify();
  + return key_str + ": " + value_str;
  + };
  +
  + if (fValueMap.size() == 0) {
  + return "{}";
  + } else if (fValueMap.size() == 1 and !it->second.is_map()) {
  + return "{" + stringify_pair(*it) + "}";
  }
  - auto it = fValueMap.cbegin(),
  - end = fValueMap.cend();
  - if (it != end) {
  +
  + TString result = '{';
  + if (!STRINGIFY_COMPACT)
  if (pretty) {
  - result += TString(' ',(deep+1)*INDENTSTEP);
  - result += it->first + ": " + it->second.Stringify(pretty,deep+1);
  - result += TString('\n');
  - }
  - else {
  - result += it->first + ": " + it->second.Stringify(pretty);
  - }
  + result += '\n';
  }
  - for (++it; it != end; ++it) {
  +
  + bool prefix_needs_update = true;
  + TString prefix;
  +
  + if (pretty and STRINGIFY_COMPACT) {
  + prefix = " ";
  + } else
  if (pretty) {
  - result += TString(' ',(deep+1)*INDENTSTEP);
  - result += TString::Format("%s: %s", it->first.c_str(), it->second.Stringify(pretty, deep+1).Data());
  - result += TString('\n');
  + prefix = "\n" + TString(' ', (deep+1)*INDENTSTEP);
  }
  - else {
  - result += TString::Format(", %s: %s", it->first.c_str(), it->second.Stringify(pretty).Data());
  +
  + for (const auto &pair : fValueMap) {
  + result += prefix + stringify_pair(pair);
  +
  + if (prefix_needs_update) {
  + prefix = (pretty)
  + ? ((STRINGIFY_COMPACT) ? "\n" + TString(' ', deep*INDENTSTEP) + ", "
  + : "," + prefix)
  + : ", ";
  + prefix_needs_update = false;
  }
  }
  +
  if (pretty) {
  - result += TString(' ',deep*INDENTSTEP);
  + result += "\n" + TString(' ',deep*INDENTSTEP);
  }
  result += '}';
  return result;
  