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() {
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;
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 '/'.
// 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(); }
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 ];
parse_bits();
bits.pop_back();
rebuild_path();
- }
+ }
void push_dentry(std::string_view s) {
if (bits.empty() && path.length() > 0)
parse_bits();
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();
}
}
// 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;
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));
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();
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
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>;
}
// 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();
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) {
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;