17 #include <type_traits>
20 #include <helib/assertions.h>
21 #include <helib/version.h>
23 #include <NTL/xdouble.h>
24 #include <NTL/vec_long.h>
38 static constexpr
int SIZE = 4;
40 static constexpr std::array<char, SIZE>
HEADER_BEGIN = {
'|',
'H',
'E',
'['};
41 static constexpr std::array<char, SIZE>
HEADER_END = {
']',
'H',
'E',
'|'};
42 static constexpr std::array<char, SIZE>
CONTEXT_BEGIN = {
'|',
'C',
'N',
'['};
43 static constexpr std::array<char, SIZE>
CONTEXT_END = {
']',
'C',
'N',
'|'};
44 static constexpr std::array<char, SIZE>
CTXT_BEGIN = {
'|',
'C',
'X',
'['};
45 static constexpr std::array<char, SIZE>
CTXT_END = {
']',
'C',
'X',
'|'};
46 static constexpr std::array<char, SIZE>
PK_BEGIN = {
'|',
'P',
'K',
'['};
47 static constexpr std::array<char, SIZE>
PK_END = {
']',
'P',
'K',
'|'};
48 static constexpr std::array<char, SIZE>
SK_BEGIN = {
'|',
'S',
'K',
'['};
49 static constexpr std::array<char, SIZE>
SK_END = {
']',
'S',
'K',
'|'};
50 static constexpr std::array<char, SIZE>
SKM_BEGIN = {
'|',
'K',
'M',
'['};
51 static constexpr std::array<char, SIZE>
SKM_END = {
']',
'K',
'M',
'|'};
58 static_assert(
true,
"Type without a struct id.");
112 os.write(
reinterpret_cast<const char*
>(
this),
sizeof(*
this));
121 is.read(
reinterpret_cast<char*
>(&header),
sizeof(header));
127 std::ostringstream oss;
128 oss <<
"Eye catchers for header mismatch '";
132 oss <<
"' (begin, end).";
142 return std::to_string(
version[0]) +
"." + std::to_string(
version[1]) +
"." +
150 const std::array<char, EyeCatcher::SIZE>& expect);
152 const std::array<char, EyeCatcher::SIZE>& eye);
155 const NTL::vec_long& vl,
170 void write_raw_ZZ(std::ostream& str,
const NTL::ZZ& zz);
173 template <
typename T>
178 for (
const T& n : v) {
192 template <
typename T>
205 template <
typename T,
typename CTy>
212 for (
long i = 0; i < sz; i++) {
213 v.emplace_back(T::readFrom(str, ctx));
219 template <
typename T>
222 read_raw_vector<T>(str, v, T());
Inherits from Exception and std::runtime_error.
Definition: exceptions.h:123
Definition: apiAttributes.h:21
bool readEyeCatcher(std::istream &str, const std::array< char, EyeCatcher::SIZE > &expect)
Definition: binio.cpp:19
void writeEyeCatcher(std::ostream &str, const std::array< char, EyeCatcher::SIZE > &eye)
Definition: binio.cpp:27
constexpr char nameToStructId< SecKey >()
Definition: binio.h:78
void write_raw_vector< double >(std::ostream &str, const std::vector< double > &v)
Definition: binio.cpp:242
constexpr char nameToStructId< Context >()
Definition: binio.h:68
int read_raw_int32(std::istream &str)
Definition: binio.cpp:54
void read_raw_vector< double >(std::istream &str, std::vector< double > &v)
Definition: binio.cpp:231
void write_ntl_vec_long(std::ostream &str, const NTL::vec_long &vl, long intSize)
Definition: binio.cpp:103
void read_raw_vector< long >(std::istream &str, std::vector< long > &v)
Definition: binio.cpp:210
void write_raw_vector< long >(std::ostream &str, const std::vector< long > &v)
Definition: binio.cpp:221
void write_raw_ZZ(std::ostream &str, const NTL::ZZ &zz)
Definition: binio.cpp:180
void write_raw_int32(std::ostream &str, int num)
Definition: binio.cpp:89
constexpr char nameToStructId< PubKey >()
Definition: binio.h:73
void read_raw_vector(std::istream &str, std::vector< T > &v, T &init)
Definition: binio.h:193
double read_raw_double(std::istream &str)
Definition: binio.cpp:157
void write_raw_int(std::ostream &str, long num)
Definition: binio.cpp:75
NTL::xdouble read_raw_xdouble(std::istream &str)
Definition: binio.cpp:173
void write_raw_vector(std::ostream &str, const std::vector< T > &v)
Definition: binio.h:174
void write_raw_double(std::ostream &str, const double d)
Definition: binio.cpp:148
long read_raw_int(std::istream &str)
Definition: binio.cpp:34
constexpr char nameToStructId()
Definition: binio.h:56
void read_raw_ZZ(std::istream &str, NTL::ZZ &zz)
Definition: binio.cpp:193
void write_raw_xdouble(std::ostream &str, const NTL::xdouble xd)
Definition: binio.cpp:165
void read_ntl_vec_long(std::istream &str, NTL::vec_long &vl)
Definition: binio.cpp:124
constexpr char nameToStructId< Ctxt >()
Definition: binio.h:83
static constexpr std::array< char, 4 > VERSION_0_0_1_0
Definition: binio.h:33
static constexpr int BIT64
Definition: binio.h:31
static constexpr int BIT32
Definition: binio.h:30
static constexpr std::array< char, SIZE > PK_END
Definition: binio.h:47
static constexpr std::array< char, SIZE > SK_END
Definition: binio.h:49
static constexpr std::array< char, SIZE > HEADER_BEGIN
Definition: binio.h:40
static constexpr std::array< char, SIZE > PK_BEGIN
Definition: binio.h:46
static constexpr std::array< char, SIZE > SK_BEGIN
Definition: binio.h:48
static constexpr std::array< char, SIZE > CTXT_END
Definition: binio.h:45
static constexpr std::array< char, SIZE > CONTEXT_BEGIN
Definition: binio.h:42
static constexpr std::array< char, SIZE > HEADER_END
Definition: binio.h:41
static constexpr std::array< char, SIZE > SKM_BEGIN
Definition: binio.h:50
static constexpr std::array< char, SIZE > SKM_END
Definition: binio.h:51
static constexpr std::array< char, SIZE > CTXT_BEGIN
Definition: binio.h:44
static constexpr std::array< char, SIZE > CONTEXT_END
Definition: binio.h:43
static constexpr int SIZE
Definition: binio.h:38
The class acts as a namespace with all members static. Holds the version number for this code of HEli...
Definition: version.in.h:24
static constexpr long minor
The minor number of this version of HElib.
Definition: version.in.h:34
static constexpr long patch
The patch number of this version of HElib.
Definition: version.in.h:38
static constexpr long major
The major number of this version of HElib.
Definition: version.in.h:30