Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
id-cursor.hpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2011 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef GRN_DAT_ID_CURSOR_HPP_
19 #define GRN_DAT_ID_CURSOR_HPP_
20 
21 #include "cursor.hpp"
22 
23 namespace grn {
24 namespace dat {
25 
26 class Trie;
27 
28 class GRN_DAT_API IdCursor : public Cursor {
29  public:
30  IdCursor();
31  ~IdCursor();
32 
33  void open(const Trie &trie,
34  const String &min_str,
35  const String &max_str,
36  UInt32 offset = 0,
37  UInt32 limit = MAX_UINT32,
38  UInt32 flags = 0);
39 
40  void open(const Trie &trie,
41  UInt32 min_id,
42  UInt32 max_id,
43  UInt32 offset = 0,
44  UInt32 limit = MAX_UINT32,
45  UInt32 flags = 0);
46 
47  void close();
48 
49  const Key &next();
50 
51  UInt32 offset() const {
52  return offset_;
53  }
54  UInt32 limit() const {
55  return limit_;
56  }
57  UInt32 flags() const {
58  return flags_;
59  }
60 
61  private:
62  const Trie *trie_;
63  UInt32 offset_;
64  UInt32 limit_;
65  UInt32 flags_;
66 
67  UInt32 cur_;
68  UInt32 end_;
69  UInt32 count_;
70 
71  IdCursor(const Trie &trie, UInt32 offset, UInt32 limit, UInt32 flags);
72 
73  UInt32 fix_flags(UInt32 flags) const;
74  void init(UInt32 min_id, UInt32 max_id);
75  void swap(IdCursor *cursor);
76 
77  // Disallows copy and assignment.
78  IdCursor(const IdCursor &);
79  IdCursor &operator=(const IdCursor &);
80 };
81 
82 } // namespace dat
83 } // namespace grn
84 
85 #endif // GRN_DAT_ID_CURSOR_HPP_