Kinetic C/C++ Client
 All Classes Functions Variables Pages
key_range_iterator.h
1 /*
2  * kinetic-cpp-client
3  * Copyright (C) 2014 Seagate Technology.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef KINETIC_CPP_CLIENT_KEY_RANGE_ITERATOR_H_
22 #define KINETIC_CPP_CLIENT_KEY_RANGE_ITERATOR_H_
23 
24 #include <string>
25 #include <vector>
26 #include <memory>
27 
28 #include "kinetic/blocking_kinetic_connection.h"
29 
30 namespace kinetic {
31 
32 using std::string;
33 using std::vector;
34 using std::unique_ptr;
35 
36 class BlockingKineticConnection;
37 
38 class KeyRangeIterator : public std::iterator<std::forward_iterator_tag, string> {
39  public:
42  unsigned int framesz,
43  string start,
44  bool start_inclusive,
45  string end,
46  bool end_inclusive);
47  KeyRangeIterator(KeyRangeIterator const& rhs); // NOLINT
48  KeyRangeIterator& operator=(KeyRangeIterator const& rhs);
50 
51  bool operator==(KeyRangeIterator const& rhs) const;
52  bool operator!=(KeyRangeIterator const& rhs) const;
53 
54  KeyRangeIterator& operator++();
55  KeyRangeIterator operator++(int);
56 
57  const string& operator*() const;
58  string* operator->();
59 
60  private:
62  string first_;
63  bool first_inc_;
64  string last_;
65  bool last_inc_;
66  unsigned int framesz_;
67  bool reverse_order_;
68  int relpos_;
69  bool eol_;
70  unique_ptr<vector<string>> keys_;
71 
72  void next_frame();
73  void advance();
74 };
75 
76 KeyRangeIterator KeyRangeEnd();
77 
78 } // namespace kinetic
79 
80 #endif // KINETIC_CPP_CLIENT_KEY_RANGE_ITERATOR_H_