map Darabonba_Util::Client::stringifyMapValue()

in cpp/src/parse.cpp [232:261]


map<string, string> Darabonba_Util::Client::stringifyMapValue(
    const shared_ptr<map<string, boost::any>> &m) {
  if (nullptr == m) {
    return map<string, string>();
  }

  map<string, string> data;
  if (m->empty()) {
    return data;
  }

  for (const auto &it : *m) {
    if (typeid(int) == it.second.type()) {
      data[it.first] = to_string(boost::any_cast<int>(it.second));
    } else if (typeid(long) == it.second.type()) {
      data[it.first] = to_string(boost::any_cast<long>(it.second));
    } else if (typeid(double) == it.second.type()) {
      data[it.first] = to_string(boost::any_cast<double>(it.second));
    } else if (typeid(float) == it.second.type()) {
      data[it.first] = to_string(boost::any_cast<float>(it.second));
    } else if (typeid(bool) == it.second.type()) {
      string v = boost::any_cast<bool>(it.second) ? "true" : "false";
      data[it.first] = v;
    } else if (typeid(string) == it.second.type()) {
      string v = boost::any_cast<string>(it.second);
      data[it.first] = v;
    }
  }
  return data;
}