From: Adam C. Emerson Date: Fri, 29 Mar 2019 01:03:30 +0000 (-0400) Subject: include: Update types.h to work without using namespace X-Git-Tag: v15.0.0~19^2~57 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2e68dba1b450500d7fe013184f269711b13e5b7;p=ceph.git include: Update types.h to work without using namespace Signed-off-by: Adam C. Emerson --- diff --git a/src/include/types.h b/src/include/types.h index 04c62e38974..f58213895e3 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -360,11 +360,11 @@ struct client_t { // cppcheck-suppress noExplicitConstructor client_t(int64_t _v = -2) : v(_v) {} - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { using ceph::encode; encode(v, bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { using ceph::decode; decode(v, bl); } @@ -381,7 +381,7 @@ static inline bool operator>=(const client_t& l, const client_t& r) { return l.v static inline bool operator>=(const client_t& l, int64_t o) { return l.v >= o; } static inline bool operator<(const client_t& l, int64_t o) { return l.v < o; } -inline ostream& operator<<(ostream& out, const client_t& c) { +inline std::ostream& operator<<(std::ostream& out, const client_t& c) { return out << c.v; } @@ -390,7 +390,7 @@ inline ostream& operator<<(ostream& out, const client_t& c) { // -- namespace { - inline ostream& format_u(ostream& out, const uint64_t v, const uint64_t n, +inline std::ostream& format_u(std::ostream& out, const uint64_t v, const uint64_t n, const int index, const uint64_t mult, const char* u) { char buffer[32]; @@ -430,7 +430,7 @@ struct si_u_t { explicit si_u_t(uint64_t _v) : v(_v) {}; }; -inline ostream& operator<<(ostream& out, const si_u_t& b) +inline std::ostream& operator<<(std::ostream& out, const si_u_t& b) { uint64_t n = b.v; int index = 0; @@ -458,7 +458,7 @@ struct byte_u_t { explicit byte_u_t(uint64_t _v) : v(_v) {}; }; -inline ostream& operator<<(ostream& out, const byte_u_t& b) +inline std::ostream& operator<<(std::ostream& out, const byte_u_t& b) { uint64_t n = b.v; int index = 0; @@ -472,7 +472,7 @@ inline ostream& operator<<(ostream& out, const byte_u_t& b) return format_u(out, b.v, n, index, 1ULL << (10 * index), u[index]); } -inline ostream& operator<<(ostream& out, const ceph_mon_subscribe_item& i) +inline std::ostream& operator<<(std::ostream& out, const ceph_mon_subscribe_item& i) { return out << i.start << ((i.flags & CEPH_SUBSCRIBE_ONETIME) ? "" : "+"); @@ -484,7 +484,7 @@ struct weightf_t { weightf_t(float _v) : v(_v) {} }; -inline ostream& operator<<(ostream& out, const weightf_t& w) +inline std::ostream& operator<<(std::ostream& out, const weightf_t& w) { if (w.v < -0.01F) { return out << "-"; @@ -506,11 +506,11 @@ struct shard_id_t { const static shard_id_t NO_SHARD; - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { using ceph::encode; encode(id, bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { using ceph::decode; decode(id, bl); } @@ -518,7 +518,7 @@ struct shard_id_t { WRITE_CLASS_ENCODER(shard_id_t) WRITE_EQ_OPERATORS_1(shard_id_t, id) WRITE_CMP_OPERATORS_1(shard_id_t, id) -ostream &operator<<(ostream &lhs, const shard_id_t &rhs); +std::ostream &operator<<(std::ostream &lhs, const shard_id_t &rhs); #if defined(__sun) || defined(_AIX) || defined(__APPLE__) || defined(__FreeBSD__) __s32 ceph_to_hostos_errno(__s32 e); @@ -543,12 +543,12 @@ struct errorcode32_t { int operator<(int i) { return code < i; } int operator<=(int i) { return code <= i; } - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { using ceph::encode; __s32 newcode = hostos_to_ceph_errno(code); encode(newcode, bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { using ceph::decode; decode(code, bl); code = ceph_to_hostos_errno(code); @@ -565,7 +565,7 @@ struct sha_digest_t { // as sha_digest_t is a part of our public API. unsigned char v[S] = {0}; - string to_str() const { + std::string to_str() const { char str[S * 2 + 1] = {0}; str[0] = '\0'; for (size_t i = 0; i < S; i++) { @@ -583,14 +583,14 @@ struct sha_digest_t { return ::memcmp(v, r.v, SIZE) != 0; } - void encode(bufferlist &bl) const { + void encode(ceph::buffer::list &bl) const { // copy to avoid reinterpret_cast, is_pod and other nasty things using ceph::encode; std::array tmparr; memcpy(tmparr.data(), v, SIZE); encode(tmparr, bl); } - void decode(bufferlist::const_iterator &bl) { + void decode(ceph::buffer::list::const_iterator &bl) { using ceph::decode; std::array tmparr; decode(tmparr, bl); @@ -598,9 +598,9 @@ struct sha_digest_t { } }; -template -inline ostream &operator<<(ostream &out, const sha_digest_t &b) { - string str = b.to_str(); +template +inline std::ostream &operator<<(std::ostream &out, const sha_digest_t &b) { + std::string str = b.to_str(); return out << str; }