#ifndef CEPH_OBJECT_H
#define CEPH_OBJECT_H
-#include <stdint.h>
-#include <stdio.h>
-
+#include <cstdint>
+#include <cstdio>
#include <iosfwd>
#include <iomanip>
+#include <string>
+
#include "include/rados.h"
#include "include/unordered_map.h"
using namespace std;
struct object_t {
- string name;
+ std::string name;
object_t() {}
// cppcheck-suppress noExplicitConstructor
object_t(const char *s) : name(s) {}
// cppcheck-suppress noExplicitConstructor
- object_t(const string& s) : name(s) {}
+ object_t(const std::string& s) : name(s) {}
void swap(object_t& o) {
name.swap(o.name);
void clear() {
name.clear();
}
-
- void encode(bufferlist &bl) const {
+
+ void encode(ceph::buffer::list &bl) const {
using ceph::encode;
encode(name, bl);
}
- void decode(bufferlist::const_iterator &bl) {
+ void decode(ceph::buffer::list::const_iterator &bl) {
using ceph::decode;
decode(name, bl);
}
inline bool operator<(const object_t& l, const object_t& r) {
return l.name < r.name;
}
-inline bool operator>=(const object_t& l, const object_t& r) {
+inline bool operator>=(const object_t& l, const object_t& r) {
return l.name >= r.name;
}
inline bool operator<=(const object_t& l, const object_t& r) {
return l.name <= r.name;
}
-inline ostream& operator<<(ostream& out, const object_t& o) {
+inline std::ostream& operator<<(std::ostream& out, const object_t& o) {
return out << o.name;
}
namespace std {
- template<> struct hash<object_t> {
- size_t operator()(const object_t& r) const {
- //static hash<string> H;
- //return H(r.name);
- return ceph_str_hash_linux(r.name.c_str(), r.name.length());
- }
- };
+template<> struct hash<object_t> {
+ size_t operator()(const object_t& r) const {
+ //static hash<string> H;
+ //return H(r.name);
+ return ceph_str_hash_linux(r.name.c_str(), r.name.length());
+ }
+};
} // namespace std
snapid_t(uint64_t v=0) : val(v) {}
snapid_t operator+=(snapid_t o) { val += o.val; return *this; }
snapid_t operator++() { ++val; return *this; }
- operator uint64_t() const { return val; }
+ operator uint64_t() const { return val; }
};
-inline void encode(snapid_t i, bufferlist &bl) { encode(i.val, bl); }
-inline void decode(snapid_t &i, bufferlist::const_iterator &p) { decode(i.val, p); }
+inline void encode(snapid_t i, ceph::buffer::list &bl) {
+ using ceph::encode;
+ encode(i.val, bl);
+}
+inline void decode(snapid_t &i, ceph::buffer::list::const_iterator &p) {
+ using ceph::decode;
+ decode(i.val, p);
+}
template<>
struct denc_traits<snapid_t> {
static void bound_encode(const snapid_t& o, size_t& p) {
denc(o.val, p);
}
- static void encode(const snapid_t &o, buffer::list::contiguous_appender& p) {
+ static void encode(const snapid_t &o, ceph::buffer::list::contiguous_appender& p) {
denc(o.val, p);
}
- static void decode(snapid_t& o, buffer::ptr::const_iterator &p) {
+ static void decode(snapid_t& o, ceph::buffer::ptr::const_iterator &p) {
denc(o.val, p);
}
};
-inline ostream& operator<<(ostream& out, const snapid_t& s) {
+inline std::ostream& operator<<(std::ostream& out, const snapid_t& s) {
if (s == CEPH_NOSNAP)
return out << "head";
else if (s == CEPH_SNAPDIR)
return out << "snapdir";
else
- return out << hex << s.val << dec;
+ return out << std::hex << s.val << std::dec;
}
o.snap = t;
}
- void encode(bufferlist& bl) const {
+ void encode(ceph::buffer::list& bl) const {
using ceph::encode;
encode(oid, bl);
encode(snap, bl);
}
- void decode(bufferlist::const_iterator& bl) {
+ void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
decode(oid, bl);
decode(snap, bl);
inline bool operator<=(const sobject_t &l, const sobject_t &r) {
return l.oid < r.oid || (l.oid == r.oid && l.snap <= r.snap);
}
-inline ostream& operator<<(ostream& out, const sobject_t &o) {
+inline std::ostream& operator<<(std::ostream& out, const sobject_t &o) {
return out << o.oid << "/" << o.snap;
}
namespace std {
- template<> struct hash<sobject_t> {
- size_t operator()(const sobject_t &r) const {
- static hash<object_t> H;
- static rjhash<uint64_t> I;
- return H(r.oid) ^ I(r.snap);
- }
- };
+template<> struct hash<sobject_t> {
+ size_t operator()(const sobject_t &r) const {
+ static hash<object_t> H;
+ static rjhash<uint64_t> I;
+ return H(r.oid) ^ I(r.snap);
+ }
+};
} // namespace std
#endif