]> git.proxmox.com Git - ceph.git/blame - ceph/src/librados/ListObjectImpl.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / librados / ListObjectImpl.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 David Zafman <dzafman@redhat.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
7c673cae
FG
14
15#ifndef CEPH_LIBRADOS_LISTOBJECTIMPL_H
16#define CEPH_LIBRADOS_LISTOBJECTIMPL_H
17
f67539c2 18#include <string>
7c673cae
FG
19#include <include/rados/librados.hpp>
20
21namespace librados {
22struct ListObjectImpl {
23 std::string nspace;
24 std::string oid;
25 std::string locator;
26
27 ListObjectImpl() {}
28 ListObjectImpl(std::string n, std::string o, std::string l):
29 nspace(n), oid(o), locator(l) {}
30
1e59de90
TL
31 auto operator<=>(const ListObjectImpl&) const = default;
32
7c673cae
FG
33 const std::string& get_nspace() const { return nspace; }
34 const std::string& get_oid() const { return oid; }
35 const std::string& get_locator() const { return locator; }
36};
7c673cae
FG
37inline std::ostream& operator<<(std::ostream& out, const struct ListObjectImpl& lop) {
38 out << (lop.nspace.size() ? lop.nspace + "/" : "") << lop.oid
39 << (lop.locator.size() ? "@" + lop.locator : "");
40 return out;
41}
42
7c673cae
FG
43class NObjectIteratorImpl {
44 public:
45 NObjectIteratorImpl() {}
46 ~NObjectIteratorImpl();
47 NObjectIteratorImpl(const NObjectIteratorImpl &rhs);
48 NObjectIteratorImpl& operator=(const NObjectIteratorImpl& rhs);
49
50 bool operator==(const NObjectIteratorImpl& rhs) const;
51 bool operator!=(const NObjectIteratorImpl& rhs) const;
52 const ListObject& operator*() const;
53 const ListObject* operator->() const;
54 NObjectIteratorImpl &operator++(); // Preincrement
55 NObjectIteratorImpl operator++(int); // Postincrement
56 const ListObject *get_listobjectp() { return &cur_obj; }
7c673cae
FG
57
58 /// get current hash position of the iterator, rounded to the current pg
59 uint32_t get_pg_hash_position() const;
60
61 /// move the iterator to a given hash position. this may (will!) be rounded to the nearest pg.
62 uint32_t seek(uint32_t pos);
63
64 /// move the iterator to a given cursor position
65 uint32_t seek(const librados::ObjectCursor& cursor);
66
67 /// get current cursor position
68 librados::ObjectCursor get_cursor();
69
70 void set_filter(const bufferlist &bl);
71
7c673cae
FG
72 NObjectIteratorImpl(ObjListCtx *ctx_);
73 void get_next();
11fdf7f2 74 std::shared_ptr < ObjListCtx > ctx;
7c673cae
FG
75 ListObject cur_obj;
76};
77
78}
79#endif