-
Notifications
You must be signed in to change notification settings - Fork 15
/
binaryio.hpp
54 lines (38 loc) · 1.05 KB
/
binaryio.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
#ifndef DYNEARTHSOL3D_BINARYIO_HPP
#define DYNEARTHSOL3D_BINARYIO_HPP
#include <map>
#include "array2d.hpp"
class BinaryOutput
{
private:
long eof_pos;
char *header;
char *hd_pos;
std::FILE* f;
void write_header(const char *name);
public:
BinaryOutput(const char *filename);
~BinaryOutput();
void close();
template <typename T>
void write_array(const std::vector<T>& A, const char *name, std::size_t size);
void write_array(const std::vector<uint>& A, const char *name, std::size_t size);
template <typename T, int N>
void write_array(const Array2D<T,N>& A, const char *name, std::size_t size);
};
class BinaryInput
{
private:
std::FILE* f;
std::map<std::string, std::size_t> offset;
void read_header();
void seek_to_array(const char *name);
public:
BinaryInput(const char *filename);
~BinaryInput();
template <typename T>
void read_array(std::vector<T>& A, const char *name);
template <typename T, int N>
void read_array(Array2D<T,N>& A, const char *name);
};
#endif