/
bool.hpp
57 lines (42 loc) · 1.26 KB
/
bool.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef GRNXX_IMPL_COLUMN_SCALAR_BOOL_HPP
#define GRNXX_IMPL_COLUMN_SCALAR_BOOL_HPP
#include "grnxx/impl/column/base.hpp"
namespace grnxx {
namespace impl {
template <typename T> class Column;
template <>
class Column<Bool> : public ColumnBase {
public:
// -- Public API (grnxx/column.hpp) --
Column(Table *table, const String &name, const ColumnOptions &options);
~Column();
void set(Int row_id, const Datum &datum);
void get(Int row_id, Datum *datum) const;
bool contains(const Datum &datum) const;
Int find_one(const Datum &datum) const;
// -- Internal API (grnxx/impl/column/base.hpp) --
// Unset the value.
void unset(Int row_id);
// -- Internal API --
// Return a value.
//
// If "row_id" is valid, returns the stored value.
// If "row_id" is invalid, returns N/A.
Bool get(Int row_id) const {
size_t value_id = row_id.value();
if (value_id >= values_.size()) {
return Bool::na();
}
return values_[value_id];
}
// Read values.
//
// On failure, throws an exception.
void read(ArrayCRef<Record> records, ArrayRef<Bool> values) const;
protected:
Array<Bool> values_;
static Bool parse_datum(const Datum &datum);
};
} // namespace impl
} // namespace grnxx
#endif // GRNXX_IMPL_COLUMN_SCALAR_BOOL_HPP