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
95
96
|
#pragma once
#include <forstio/core/common.h>
#include "schema.h"
namespace saw {
namespace encode {
struct Native {};
}
/*
* Helper for the basic message container, so the class doesn't have to be
* specialized 10 times.
*/
template <class T> struct native_data_type;
template <>
struct native_data_type<schema::Primitive<schema::SignedInteger, 1>> {
using type = int8_t;
};
template <>
struct native_data_type<schema::Primitive<schema::SignedInteger, 2>> {
using type = int16_t;
};
template <>
struct native_data_type<schema::Primitive<schema::SignedInteger, 4>> {
using type = int32_t;
};
template <>
struct native_data_type<schema::Primitive<schema::SignedInteger, 8>> {
using type = int64_t;
};
template <>
struct native_data_type<schema::Primitive<schema::UnsignedInteger, 1>> {
using type = uint8_t;
};
template <>
struct native_data_type<schema::Primitive<schema::UnsignedInteger, 2>> {
using type = uint16_t;
};
template <>
struct native_data_type<schema::Primitive<schema::UnsignedInteger, 4>> {
using type = uint32_t;
};
template <>
struct native_data_type<schema::Primitive<schema::UnsignedInteger, 8>> {
using type = uint64_t;
};
template <>
struct native_data_type<schema::Primitive<schema::FloatingPoint, 4>> {
using type = float;
};
template <>
struct native_data_type<schema::Primitive<schema::FloatingPoint, 8>> {
using type = double;
};
template<typename T, typename Encoding = encode::Native>
class data {
private:
static_assert(always_false<T>, "Type not supported");
};
template<>
class data<schema::String, encode::Native> {
private:
std::string value_;
public:
SAW_FORBID_COPY(data);
data(std::string&& value__):value_{std::move(value__)}{}
std::size_t size() const {
return value_.size();
}
bool operator==(const data<schema::String, encode::Native>& data){
return value_ == data.value_;
}
};
template<typename T, size_t N>
class data<schema::Primitive<T,N>, encode::Native> {
private:
};
}
|