| 240 | } |
| 241 | |
| 242 | void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f) |
| 243 | { |
| 244 | ceph_assert(f != nullptr); |
| 245 | |
| 246 | class dump_visitor : public boost::static_visitor<void> |
| 247 | { |
| 248 | Formatter *f; |
| 249 | std::string const &key; |
| 250 | public: |
| 251 | dump_visitor(Formatter *f_, std::string const &key_) |
| 252 | : f(f_), key(key_) |
| 253 | { |
| 254 | } |
| 255 | |
| 256 | void operator()(const std::string &operand) const |
| 257 | { |
| 258 | f->dump_string(key, operand); |
| 259 | } |
| 260 | |
| 261 | void operator()(const bool &operand) const |
| 262 | { |
| 263 | f->dump_bool(key, operand); |
| 264 | } |
| 265 | |
| 266 | void operator()(const int64_t &operand) const |
| 267 | { |
| 268 | f->dump_int(key, operand); |
| 269 | } |
| 270 | |
| 271 | void operator()(const double &operand) const |
| 272 | { |
| 273 | f->dump_float(key, operand); |
| 274 | } |
| 275 | |
| 276 | void operator()(const std::vector<std::string> &operand) const |
| 277 | { |
| 278 | f->open_array_section(key); |
| 279 | for (const auto& i : operand) { |
| 280 | f->dump_string("item", i); |
| 281 | } |
| 282 | f->close_section(); |
| 283 | } |
| 284 | |
| 285 | void operator()(const std::vector<int64_t> &operand) const |
| 286 | { |
| 287 | f->open_array_section(key); |
| 288 | for (const auto i : operand) { |
| 289 | f->dump_int("item", i); |
| 290 | } |
| 291 | f->close_section(); |
| 292 | } |
| 293 | |
| 294 | void operator()(const std::vector<double> &operand) const |
| 295 | { |
| 296 | f->open_array_section(key); |
| 297 | for (const auto i : operand) { |
| 298 | f->dump_float("item", i); |
| 299 | } |