Xpace
store.h
Go to the documentation of this file.
1 
2 /**************************************************************
3  **
4  ** @file data/Store/store.h
5  **
6  ** Copyright (C) 2012 Xpace, LLC. All rights reserved
7  **
8  ** www.xpace.net
9  **
10  **************************************************************/
11 
12 
13 #ifndef XPACE_STORE_H
14 #define XPACE_STORE_H
15 
16 #include <vector>
17 
18 #include "data/data.h"
19 
20 #include "base/sharedimpl.h"
21 
22 namespace Xpace
23 {
24  /// A Store is a hierarchically organized dataset, suitable for managing
25  /// structured text and multidimensional (OLAP) data
27  {
28  public:
29  static const char* TAG(); ///< Configuration tag for a Store
30  static const char* CLASSTREE_TAG; ///< Configuration tag for a ClassTree
31  static const char* NAME_TAG; ///< Configuration tag for a Store's name
32 
33  /// @param config the Store's Configuration
34  /// @param access how the Store will be opened
35  /// @throw File_Cant_Open
36  /// @throw File_Cant_Read
37  explicit Store
38  (const String& config,
40 
41  /// @return true if the store is empty or does not exist
42  bool operator!
43  ()
44  const;
45 
46  /// @return the Store's name
47  String getName
48  ()
49  const;
50 
51  /// @return the Store's configuration
52  String getConfig
53  ()
54  const;
55 
56  /// @return the number of Documents in the store
57  uint64 getDocCount
58  ()
59  const;
60 
61  // ------------------------------ Location and Status -----
62 
63  /// A location within a source
64  typedef std::vector<uint> Location; ///< IDs of ancestor nodes and self/target
65 
66  /// The result of getting data from a node
67  enum Status
68  {
69  Continue, ///< in the middle of content
70  Parent, ///< end of this content and children, parent next
71  Child, ///< end of this content, child next
72  Sibling, ///< end of this content and children, sibling next
73  Done ///< (sub)tree has been traversed; no further movement possible
74  };
75 
76  // ------------------------------ Sink --------------------
77 
78  /// A write-only, forward (by document) cursor into a Store
79  class Sink : public Xpace::Sink<const Location&>, ///< random access, move to Location before writing
80  public Xpace::Sink<const String8&>, ///< move to child before writing
81  public Xpace::Sink<int> ///< move to child before writing
82  {
83  public:
90  };
91 
92  /// @return the (only) Sink to this table
93  Sink* getSink
94  ();
95 
96  /// The LOC param to Sink
97  enum AddressBy
98  {
99  AB_location, ///< LOC = Location
100  AB_childName, ///< LOC = const String&: the node's name (relative to parent)
101  AB_childNum ///< LOC = uint: the node's number (relative to parent)
102  };
103 
104  /// Call a Sink for each node in Store order
105  /// @param sink called for each node
106  /// @param addressBy use this set of callbacks to Sink
107  /// @param nodes if not empty, return these nodes in store order
108  /// @return true iff sink always returned true, false otherwise
109  bool forEach
110  (Sink* sink,
111  Store::AddressBy addressBy,
112  const std::vector<Store::Location>& nodes = std::vector<Store::Location>())
113  const;
114 
116 
117  class cantOpen : public Exception
118  {
119  public :
120  cantOpen
121  (const String name,
122  const String& config,
123  const Exception reason = Exception());
124  };
125  }; // Store
126 } // namespace Xpace
127 
128 #endif
129 
static const char * NAME_TAG
Configuration tag for a Store&#39;s name.
Definition: store.h:31
end of this content and children, sibling next
Definition: store.h:72
A write-only, forward (by document) cursor into a Store.
Definition: store.h:79
LOC = Location.
Definition: store.h:99
A low-level data holder.
Definition: types_c.h:82
LOC = const String&: the node&#39;s name (relative to parent)
Definition: store.h:100
A string, Unicode UTF-16 and reference-counted.
Definition: types.h:269
in the middle of content
Definition: store.h:69
end of this content and children, parent next
Definition: store.h:70
#define DECLARE_IMPL(className)
Definition: sharedimpl.h:305
AddressBy
The LOC param to Sink.
Definition: store.h:97
unsigned long long uint64
Definition: types.h:87
Xpace_StoreAccess access
Definition: table_c.h:42
const Xpace_Char16 * name
Sink callbacks for table data.
Definition: table_c.h:141
Copyright (C) 2012 Xpace, LLC.
StoreAccess
Definition: data.h:136
end of this content, child next
Definition: store.h:71
uint uint64 Xpace_Table_Sink * sink
Definition: table_c.h:340
static const char * CLASSTREE_TAG
Configuration tag for a ClassTree.
Definition: store.h:30
Status
The result of getting data from a node.
Definition: store.h:67
Xpace project main namespace
Definition: datetime.h:18
std::vector< uint > Location
A location within a source.
Definition: store.h:64
A Store is a hierarchically organized dataset, suitable for managing structured text and multidimensi...
Definition: store.h:26

current as of Wed Jun 10 2026 12:00:05