Fenix @develop
 
Loading...
Searching...
No Matches
serializer.hpp
1#ifndef FENIX_DATA_UTIL_SERIALIZER_HPP
2#define FENIX_DATA_UTIL_SERIALIZER_HPP
3
4#include <memory>
5#include <optional>
6
7#include "fenix.hpp"
8#include "fenix/data/util/data_ref.hpp"
9#include "fenix/data/util/mfile.hpp"
10#include "fenix/data/util/mstream.hpp"
11
12namespace fenix::data::util {
13
15 public:
17 DataBuffer& stage_buf, std::optional<SerializeFunc>& f,
18 const DataRef& user_buf, int direction, int element_size
19 );
20
21 void serialize_elements(int first, int last) const;
22
23 size_t size() const;
24
25 size_t max_element() const;
26
28
29 bool has_file() { return file != nullptr; }
30 FILE* get_file();
31
32 bool has_stream() { return !!strm; }
33 std::iostream* get_stream();
34
35 int get_dir() const { return dir; }
36
38
39 private:
40 bool use_file_func = false;
41 SerializeFileFunc file_func;
42 mutable std::unique_ptr<MFile> file;
43
44 bool use_strm_func = false;
45 SerializeStreamFunc strm_func;
46 mutable std::optional<MStream> strm;
47
48 DataBuffer& stage;
49 DataRef user;
50 int dir;
51 bool dynamic;
52 int elm_size;
53};
54
55} //namespace fenix::data::util
56
57#endif
Definition buffer.hpp:68
Definition data_ref.hpp:50
Definition serializer.hpp:14