From: Adam C. Emerson Date: Sat, 7 Mar 2020 09:31:14 +0000 (-0500) Subject: include: Build target 'common' without using namespace in headers X-Git-Tag: v16.0.0~18^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=08326d4e51454614ebf710b34333680a1284e74e;p=ceph.git include: Build target 'common' without using namespace in headers Part of a changeset to allow building all of 'common' without relying on 'using namespace std' or 'using namespace ceph' at toplevel in headers. Signed-off-by: Adam C. Emerson --- diff --git a/src/include/compact_set.h b/src/include/compact_set.h index 7a9c0336f0a91..a364fd8c48d91 100644 --- a/src/include/compact_set.h +++ b/src/include/compact_set.h @@ -271,7 +271,7 @@ public: decode(n, p); if (n > 0) { alloc_internal(); - decode_nohead(n, *set, p); + ceph::decode_nohead(n, *set, p); } else free_internal(); } diff --git a/src/include/filepath.h b/src/include/filepath.h index 7241e5e0cf7fc..a9f096265889a 100644 --- a/src/include/filepath.h +++ b/src/include/filepath.h @@ -38,14 +38,14 @@ class filepath { inodeno_t ino; // base inode. ino=0 implies pure relative path. - string path; // relative path. + std::string path; // relative path. /** bits - path segments * this is ['a', 'b', 'c'] for both the aboslute and relative case. * * NOTE: this value is LAZILY maintained... i.e. it's a cache */ - mutable vector bits; + mutable std::vector bits; bool encoded; void rebuild_path() { @@ -74,7 +74,7 @@ class filepath { public: filepath() : ino(0), encoded(false) { } filepath(std::string_view s, inodeno_t i) : ino(i), path(s), encoded(false) { } - filepath(const string& s, inodeno_t i) : ino(i), path(s), encoded(false) { } + filepath(const std::string& s, inodeno_t i) : ino(i), path(s), encoded(false) { } filepath(const char* s, inodeno_t i) : ino(i), path(s), encoded(false) { } filepath(const filepath& o) { ino = o.ino; @@ -83,7 +83,7 @@ class filepath { encoded = o.encoded; } filepath(inodeno_t i) : ino(i), encoded(false) { } - + /* * if we are fed a relative path as a string, either set ino=0 (strictly * relative) or 1 (absolute). throw out any leading '/'. @@ -113,7 +113,7 @@ class filepath { // accessors inodeno_t get_ino() const { return ino; } - const string& get_path() const { return path; } + const std::string& get_path() const { return path; } const char *c_str() const { return path.c_str(); } int length() const { return path.length(); } @@ -126,13 +126,13 @@ class filepath { bool absolute() const { return ino == 1; } bool pure_relative() const { return ino == 0; } bool ino_relative() const { return ino > 0; } - - const string& operator[](int i) const { + + const std::string& operator[](int i) const { if (bits.empty() && path.length() > 0) parse_bits(); return bits[i]; } - const string& last_dentry() const { + const std::string& last_dentry() const { if (bits.empty() && path.length() > 0) parse_bits(); ceph_assert(!bits.empty()); return bits[ bits.size()-1 ]; @@ -166,7 +166,7 @@ class filepath { parse_bits(); bits.pop_back(); rebuild_path(); - } + } void push_dentry(std::string_view s) { if (bits.empty() && path.length() > 0) parse_bits(); @@ -175,13 +175,13 @@ class filepath { path += s; bits.emplace_back(s); } - void push_dentry(const string& s) { + void push_dentry(const std::string& s) { push_dentry(std::string_view(s)); } void push_dentry(const char *cs) { push_dentry(std::string_view(cs, strlen(cs))); } - void push_front_dentry(const string& s) { + void push_front_dentry(const std::string& s) { bits.insert(bits.begin(), s); rebuild_path(); } @@ -192,14 +192,14 @@ class filepath { } // encoding - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { using ceph::encode; __u8 struct_v = 1; encode(struct_v, bl); encode(ino, bl); encode(path, bl); } - void decode(bufferlist::const_iterator& blp) { + void decode(ceph::buffer::list::const_iterator& blp) { using ceph::decode; bits.clear(); __u8 struct_v; @@ -208,11 +208,11 @@ class filepath { decode(path, blp); encoded = true; } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_unsigned("base_ino", ino); f->dump_string("relative_path", path); } - static void generate_test_instances(list& o) { + static void generate_test_instances(std::list& o) { o.push_back(new filepath); o.push_back(new filepath("/usr/bin", 0)); o.push_back(new filepath("/usr/sbin", 1)); @@ -239,7 +239,7 @@ class filepath { WRITE_CLASS_ENCODER(filepath) -inline ostream& operator<<(ostream& out, const filepath& path) +inline std::ostream& operator<<(std::ostream& out, const filepath& path) { if (path.get_ino()) { out << '#' << path.get_ino(); diff --git a/src/include/frag.h b/src/include/frag.h index de532d63af447..699a0698f5ca6 100644 --- a/src/include/frag.h +++ b/src/include/frag.h @@ -151,12 +151,12 @@ public: return false; } - void encode(bufferlist& bl) const { - encode_raw(_enc, bl); + void encode(ceph::buffer::list& bl) const { + ceph::encode_raw(_enc, bl); } - void decode(bufferlist::const_iterator& p) { + void decode(ceph::buffer::list::const_iterator& p) { __u32 v; - decode_raw(v, p); + ceph::decode_raw(v, p); _enc = v; } bool operator<(const frag_t& b) const @@ -182,8 +182,8 @@ inline std::ostream& operator<<(std::ostream& out, const frag_t& hb) return out << '*'; } -inline void encode(const frag_t &f, bufferlist& bl) { f.encode(bl); } -inline void decode(frag_t &f, bufferlist::const_iterator& p) { f.decode(p); } +inline void encode(const frag_t &f, ceph::buffer::list& bl) { f.encode(bl); } +inline void decode(frag_t &f, ceph::buffer::list::const_iterator& p) { f.decode(p); } using frag_vec_t = boost::container::small_vector; @@ -464,15 +464,15 @@ public: } // encoding - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { using ceph::encode; encode(_splits, bl); } - void decode(bufferlist::const_iterator& p) { + void decode(ceph::buffer::list::const_iterator& p) { using ceph::decode; decode(_splits, p); } - void encode_nohead(bufferlist& bl) const { + void encode_nohead(ceph::buffer::list& bl) const { using ceph::encode; for (compact_map::const_iterator p = _splits.begin(); p != _splits.end(); @@ -481,7 +481,7 @@ public: encode(p->second, bl); } } - void decode_nohead(int n, bufferlist::const_iterator& p) { + void decode_nohead(int n, ceph::buffer::list::const_iterator& p) { using ceph::decode; _splits.clear(); while (n-- > 0) { @@ -514,11 +514,9 @@ public: out << ")"; } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->open_array_section("splits"); - for (compact_map::const_iterator p = _splits.begin(); - p != _splits.end(); - ++p) { + for (auto p = _splits.begin(); p != _splits.end(); ++p) { f->open_object_section("split"); std::ostringstream frag_str; frag_str << p->first; diff --git a/src/include/types.h b/src/include/types.h index 79826105b05a6..c2d3c6216009c 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -574,7 +574,7 @@ struct sha_digest_t { for (size_t i = 0; i < S; i++) { ::sprintf(&str[i * 2], "%02x", static_cast(v[i])); } - return string(str); + return std::string(str); } sha_digest_t(const unsigned char *_v) { memcpy(v, _v, SIZE); }; sha_digest_t() {}