libUTL++
ExtArray.h
1 #pragma once
2 
4 
5 #include <libutl/BufferedFileStream.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
23 
25 class ExtArray : public Object
26 {
28 
29 public:
36  ExtArray(const String& baseName,
37  const RunTimeClass* rtc = nullptr,
38  uint_t serializeMode = uint_t_max)
39  {
40  init();
41  open(baseName, rtc, serializeMode);
42  }
43 
45  size_t
46  items() const
47  {
48  return _items;
49  }
50 
57  void open(const String& baseName,
58  const RunTimeClass* rtc = nullptr,
59  uint_t serializeMode = ser_default);
60 
62  void close();
63 
68  void add(const Object& object);
69 
76  Object* get(size_t idx) const;
77 
83  Object* operator[](size_t idx) const
84  {
85  return get(idx);
86  }
87 
88 private:
89  void
90  init()
91  {
92  _items = size_t_max;
93  }
94  void
95  deInit()
96  {
97  }
98  bool
99  isOpen() const
100  {
101  return (_items != size_t_max);
102  }
103 
104 private:
105  size_t _items;
106  mutable BufferedFileStream _idxFile;
107  mutable BufferedFileStream _objectFile;
108  const RunTimeClass* _rtc;
109  uint_t _serializeMode;
110 };
111 
113 
114 UTL_NS_END;
void deInit()
De-initialize UTL++.
default representation (via getSerializeMode())
Definition: util.h:75
Store information about a class.
Definition: RunTimeClass.h:23
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
size_t items() const
Get number of items.
Definition: ExtArray.h:46
Character string.
Definition: String.h:31
const size_t size_t_max
Maximum size_t value.
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
Object * operator[](size_t idx) const
Get the object at the given index.
Definition: ExtArray.h:83
const uint_t uint_t_max
Maximum uint_t value.
Externally stored array of objects.
Definition: ExtArray.h:25
Buffered disk file stream.
ExtArray(const String &baseName, const RunTimeClass *rtc=nullptr, uint_t serializeMode=uint_t_max)
Constructor.
Definition: ExtArray.h:36
Root of UTL++ class hierarchy.
Definition: Object.h:52
void init()
Initialize UTL++.