summaryrefslogtreecommitdiff
path: root/modules/codec/c++/forst.hpp
blob: 16f55c995230b917786049800e5a69e21c2cd229 (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once

#include <forstio/buffer.hpp>

#include "data.hpp"


namespace saw {
namespace encode {
struct KelForst {};
}
}

#include "forst.tmpl.hpp"

namespace saw {
template <>
class data<schema::String, encode::KelForst> {
private:
	own<buffer> buff_;
public:
	data(own<buffer> buff):
		buff_{std::move(buff)}
	{}
};

template<typename T, uint64_t N>
class data<schema::Primitive<T,N>, encode::KelForst> {
public:
	using Schema = schema::Primitive<T,N>;
private:
	our<buffer> buff_;
	uint64_t displacement_;
public:
	/**
	 * Constructor for root elements
	 */
	data(our<buffer> buff):
		buff_{std::move(buff)},
		displacement_{0u}
	{}
	
	/**
	 * Constructor for child elements
	 */
	data(our<buffer> buff, uint64_t dsp):
		buff_{std::move(buff)},
		displacement_{dsp}
	{}

	/**
	 * Get values
	 */
	typename native_data_type<Schema>::type get(){
		return {};
	}

	/**
	 * Set values
	 */
	void set(typename native_data_type<Schema>::type val){
		(void) val;
	}
};

template<typename... T, string_literal... Keys>
class data<schema::Struct<schema::Member<T,Keys>...>, encode::KelForst> {
private:
	/**
	 * Buffer holding the whole packet
	 */
	our<buffer> buff_;
	/**
	 * Displacement to show the starting point
	 */
	uint64_t displacement_;
public:
	/**
	 * Constructor for root elements
	 */
	data(our<buffer> buff):
		buff_{std::move(buff)},
		displacement_{0u}
	{}

	/**
	 * Constructor for child elements
	 */
	data(our<buffer> buff, uint64_t dsp):
		buff_{std::move(buff)},
		displacement_{dsp}
	{}
};
}