};
CEPH_RADOS_API std::ostream& operator<<(std::ostream& out, const librados::ListObject& lop);
+ class CEPH_RADOS_API NObjectIterator;
+
+ class CEPH_RADOS_API ObjectCursor
+ {
+ public:
+ ObjectCursor();
+ ObjectCursor(const ObjectCursor &rhs);
+ explicit ObjectCursor(rados_object_list_cursor c);
+ ~ObjectCursor();
+ ObjectCursor& operator=(const ObjectCursor& rhs);
+ bool operator<(const ObjectCursor &rhs) const;
+ bool operator==(const ObjectCursor &rhs) const;
+ void set(rados_object_list_cursor c);
+
+ friend class IoCtx;
+ friend class NObjectIteratorImpl;
+ friend std::ostream& operator<<(std::ostream& os, const librados::ObjectCursor& oc);
+
+ std::string to_str() const;
+ bool from_str(const std::string& s);
+
+ protected:
+ rados_object_list_cursor c_cursor;
+ };
+ CEPH_RADOS_API std::ostream& operator<<(std::ostream& os, const librados::ObjectCursor& oc);
+
class CEPH_RADOS_API NObjectIterator : public std::iterator <std::forward_iterator_tag, ListObject> {
public:
static const NObjectIterator __EndObjectIterator;
NObjectIteratorImpl *impl;
};
- class CEPH_RADOS_API ObjectCursor
- {
- public:
- ObjectCursor();
- ObjectCursor(const ObjectCursor &rhs);
- ~ObjectCursor();
- bool operator<(const ObjectCursor &rhs);
- void set(rados_object_list_cursor c);
-
- friend class IoCtx;
-
- protected:
- rados_object_list_cursor c_cursor;
- };
-
class CEPH_RADOS_API ObjectItem
{
public:
librados::ObjectCursor::ObjectCursor()
{
- c_cursor = new hobject_t();
+ c_cursor = (rados_object_list_cursor)new hobject_t();
}
librados::ObjectCursor::~ObjectCursor()
delete h;
}
-bool librados::ObjectCursor::operator<(const librados::ObjectCursor &rhs)
+librados::ObjectCursor::ObjectCursor(rados_object_list_cursor c)
{
- const hobject_t lhs_hobj = (c_cursor == nullptr) ? hobject_t() : *((hobject_t*)c_cursor);
- const hobject_t rhs_hobj = (rhs.c_cursor == nullptr) ? hobject_t() : *((hobject_t*)(rhs.c_cursor));
- return lhs_hobj < rhs_hobj;
+ if (!c) {
+ c_cursor = nullptr;
+ } else {
+ c_cursor = (rados_object_list_cursor)new hobject_t(*(hobject_t *)c);
+ }
}
-librados::ObjectCursor::ObjectCursor(const librados::ObjectCursor &rhs)
+librados::ObjectCursor& librados::ObjectCursor::operator=(const librados::ObjectCursor& rhs)
{
if (rhs.c_cursor != nullptr) {
hobject_t *h = (hobject_t*)rhs.c_cursor;
} else {
c_cursor = nullptr;
}
+ return *this;
+}
+
+bool librados::ObjectCursor::operator<(const librados::ObjectCursor &rhs) const
+{
+ const hobject_t lhs_hobj = (c_cursor == nullptr) ? hobject_t() : *((hobject_t*)c_cursor);
+ const hobject_t rhs_hobj = (rhs.c_cursor == nullptr) ? hobject_t() : *((hobject_t*)(rhs.c_cursor));
+ return lhs_hobj < rhs_hobj;
+}
+
+bool librados::ObjectCursor::operator==(const librados::ObjectCursor &rhs) const
+{
+ const hobject_t lhs_hobj = (c_cursor == nullptr) ? hobject_t() : *((hobject_t*)c_cursor);
+ const hobject_t rhs_hobj = (rhs.c_cursor == nullptr) ? hobject_t() : *((hobject_t*)(rhs.c_cursor));
+ return cmp(lhs_hobj, rhs_hobj) == 0;
+}
+librados::ObjectCursor::ObjectCursor(const librados::ObjectCursor &rhs)
+{
+ *this = rhs;
}
librados::ObjectCursor librados::IoCtx::object_list_begin()
c_cursor = c;
}
+string librados::ObjectCursor::to_str() const
+{
+ stringstream ss;
+ ss << *(hobject_t *)c_cursor;
+ return ss.str();
+}
+
+bool librados::ObjectCursor::from_str(const string& s)
+{
+ if (s.empty()) {
+ *(hobject_t *)c_cursor = hobject_t();
+ return true;
+ }
+ return ((hobject_t *)c_cursor)->parse(s);
+}
+
+CEPH_RADOS_API std::ostream& librados::operator<<(std::ostream& os, const librados::ObjectCursor& oc)
+{
+ if (oc.c_cursor) {
+ os << *(hobject_t *)oc.c_cursor;
+ } else {
+ os << hobject_t();
+ }
+ return os;
+}
+
bool librados::IoCtx::object_list_is_end(const ObjectCursor &oc)
{
hobject_t *h = (hobject_t *)oc.c_cursor;