]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include: Build target 'common' without using namespace in headers
authorAdam C. Emerson <aemerson@redhat.com>
Sat, 7 Mar 2020 09:31:14 +0000 (04:31 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Sat, 7 Mar 2020 09:31:14 +0000 (04:31 -0500)
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 <aemerson@redhat.com>
src/include/compact_set.h
src/include/filepath.h
src/include/frag.h
src/include/types.h

index 7a9c0336f0a910500e1f25b0ad8a669044cacbca..a364fd8c48d911ead5aabec1e3f05c6fe25441b2 100644 (file)
@@ -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();
   }
index 7241e5e0cf7fcfb50a24c2448fe5e5dfa0c093d3..a9f096265889ab5dc51adb6ab48d9f524017fea9 100644 (file)
 
 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<string> bits;
+  mutable std::vector<std::string> 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<filepath*>& o) {
+  static void generate_test_instances(std::list<filepath*>& 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();
index de532d63af4472752cc9567840c587bc7ccdf7c5..699a0698f5ca691c7e9f919d31c1ff597743dec0 100644 (file)
@@ -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<frag_t, 4>;
 
@@ -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<frag_t,int32_t>::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<frag_t,int32_t>::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;
index 79826105b05a642fc7e0c021a54e2724242a2093..c2d3c6216009cf422abec77f687ae4ad78047aef 100644 (file)
@@ -574,7 +574,7 @@ struct sha_digest_t {
     for (size_t i = 0; i < S; i++) {
       ::sprintf(&str[i * 2], "%02x", static_cast<int>(v[i]));
     }
-    return string(str);
+    return std::string(str);
   }
   sha_digest_t(const unsigned char *_v) { memcpy(v, _v, SIZE); };
   sha_digest_t() {}