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