uzuki2
Recovering R lists faithfully from HDF5 or JSON
Loading...
Searching...
No Matches
Dummy.hpp
Go to the documentation of this file.
1#ifndef UZUKI2_DUMMY_HPP
2#define UZUKI2_DUMMY_HPP
3
4#include <vector>
5#include <memory>
6#include <string>
7#include <cstdint>
8
9#include "interfaces.hpp"
10
16namespace uzuki2 {
17
22class DummyIntegerVector final : public IntegerVector {
23public:
24 DummyIntegerVector(size_t l, bool, bool) : my_length(l) {}
25 size_t size() const { return my_length; }
26 void set(size_t, int32_t) {}
27 void set_missing(size_t) {}
28 void set_name(size_t, std::string) {}
29private:
30 size_t my_length;
31};
32
33class DummyNumberVector final : public NumberVector {
34public:
35 DummyNumberVector(size_t l, bool, bool) : my_length(l) {}
36 size_t size() const { return my_length; }
37 void set(size_t, double) {}
38 void set_missing(size_t) {}
39 void set_name(size_t, std::string) {}
40private:
41 size_t my_length;
42};
43
44class DummyStringVector final : public StringVector {
45public:
46 DummyStringVector(size_t l, bool, bool, StringVector::Format) : my_length(l) {}
47 size_t size() const { return my_length; }
48 void set(size_t, std::string) {}
49 void set_missing(size_t) {}
50 void set_name(size_t, std::string) {}
51private:
52 size_t my_length;
53};
54
55class DummyBooleanVector final : public BooleanVector {
56public:
57 DummyBooleanVector(size_t l, bool, bool) : my_length(l) {}
58 size_t size() const { return my_length; }
59 void set(size_t, bool) {}
60 void set_missing(size_t) {}
61 void set_name(size_t, std::string) {}
62private:
63 size_t my_length;
64};
65
66class DummyFactor final : public Factor {
67public:
68 DummyFactor(size_t l, bool, bool, size_t, bool) : my_length(l) {}
69 size_t size() const { return my_length; }
70 void set(size_t, size_t) {}
71 void set_missing(size_t) {}
72 void set_name(size_t, std::string) {}
73 void set_level(size_t, std::string) {}
74private:
75 size_t my_length;
76};
77
80class DummyNothing final : public Nothing {};
81
82class DummyExternal final : public External {};
83
84class DummyList final : public List {
85public:
86 DummyList(size_t n, bool) : my_length(n) {}
87 size_t size() const { return my_length; }
88 void set(size_t, std::shared_ptr<Base>) {}
89 void set_name(size_t, std::string) {}
90private:
91 size_t my_length;
92};
93
96struct DummyProvisioner {
97 static Nothing* new_Nothing() { return (new DummyNothing); }
98
99 static External* new_External(void*) { return (new DummyExternal); }
100
101 template<class ... Args_>
102 static List* new_List(Args_&& ... args) { return (new DummyList(std::forward<Args_>(args)...)); }
103
104 template<class ... Args_>
105 static IntegerVector* new_Integer(Args_&& ... args) { return (new DummyIntegerVector(std::forward<Args_>(args)...)); }
106
107 template<class ... Args_>
108 static NumberVector* new_Number(Args_&& ... args) { return (new DummyNumberVector(std::forward<Args_>(args)...)); }
109
110 template<class ... Args_>
111 static StringVector* new_String(Args_&& ... args) { return (new DummyStringVector(std::forward<Args_>(args)...)); }
112
113 template<class ... Args_>
114 static BooleanVector* new_Boolean(Args_&& ... args) { return (new DummyBooleanVector(std::forward<Args_>(args)...)); }
115
116 template<class ... Args_>
117 static Factor* new_Factor(Args_&& ... args) { return (new DummyFactor(std::forward<Args_>(args)...)); }
118};
131public:
133
134private:
135 size_t my_number;
136
137public:
141 DummyExternals(size_t n) : my_number(n) {}
142
143 void* get(size_t) const {
144 return nullptr;
145 }
146
147 size_t size() const {
148 return my_number;
149 }
153};
154
155}
156
157#endif
Dummy class satisfying the Externals_ interface of hdf5::parse().
Definition Dummy.hpp:130
Defines the interfaces to use in HDF5 parsing.
Parse an R list from a HDF5 or JSON file.
Definition parse_json.hpp:28