]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/options: operator<< for value_t
authorSage Weil <sage@redhat.com>
Fri, 5 Jan 2018 19:39:13 +0000 (13:39 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:48 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/options.cc
src/common/options.h

index d93a9e8d5445065e5692729be508a846c1c9685a..6628ca5b7eba10df0e38183f7c8510a740b0b161 100644 (file)
@@ -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<boost::blank>(&v)) {
+    return out;
+  }
+  if (const bool *flag = boost::get<const bool>(&v)) {
+    return out << (*flag ? "true" : "false");
+  }
+  if (const double *dp = boost::get<const double>(&v)) {
+    ostringstream oss;
+    oss << std::fixed << *dp;
+    return out << oss.str();
+  }
+  if (const uint64_t *i = boost::get<const uint64_t>(&v)) {
+    return out << *i;
+  }
+  if (const int64_t *i = boost::get<const int64_t>(&v)) {
+    return out << *i;
+  }
+  if (const std::string *i = boost::get<const std::string>(&v)) {
+    return out << *i;
+  }
+  if (const uuid_d *i = boost::get<const uuid_d>(&v)) {
+    return out << *i;
+  }
+  if (const entity_addr_t *i = boost::get<const entity_addr_t>(&v)) {
+    return out << *i;
+  }
+  ceph_abort();
+}
+
 constexpr unsigned long long operator"" _min (unsigned long long min) {
   return min * 60;
 }
index bdcc5a921e74c492a27892a6231c64b4cea099ee..4138a6ec076d21faca153604df8af1e2861f5ae6 100644 (file)
@@ -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.