From: Sage Weil Date: Fri, 5 Jan 2018 19:39:13 +0000 (-0600) Subject: common/options: operator<< for value_t X-Git-Tag: v13.0.2~78^2~99 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=86a6cf778c60312097b8240e07489d5f4e5253a0;p=ceph.git common/options: operator<< for value_t Signed-off-by: Sage Weil --- diff --git a/src/common/options.cc b/src/common/options.cc index d93a9e8d5445..6628ca5b7eba 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -204,6 +204,37 @@ void Option::dump(Formatter *f) const f->close_section(); } +ostream& operator<<(ostream& out, const Option::value_t& v) +{ + if (boost::get(&v)) { + return out; + } + if (const bool *flag = boost::get(&v)) { + return out << (*flag ? "true" : "false"); + } + if (const double *dp = boost::get(&v)) { + ostringstream oss; + oss << std::fixed << *dp; + return out << oss.str(); + } + if (const uint64_t *i = boost::get(&v)) { + return out << *i; + } + if (const int64_t *i = boost::get(&v)) { + return out << *i; + } + if (const std::string *i = boost::get(&v)) { + return out << *i; + } + if (const uuid_d *i = boost::get(&v)) { + return out << *i; + } + if (const entity_addr_t *i = boost::get(&v)) { + return out << *i; + } + ceph_abort(); +} + constexpr unsigned long long operator"" _min (unsigned long long min) { return min * 60; } diff --git a/src/common/options.h b/src/common/options.h index bdcc5a921e74..4138a6ec076d 100644 --- a/src/common/options.h +++ b/src/common/options.h @@ -82,6 +82,8 @@ struct Option { value_t value; value_t daemon_value; + friend ostream& operator<<(ostream&, const value_t& v); + // Items like mon, osd, rgw, rbd, ceph-fuse. This is advisory metadata // for presentation layers (like web dashboards, or generated docs), so that // they know which options to display where.