-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserialization.i
112 lines (112 loc) · 3.68 KB
/
serialization.i
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
///** @file
// *****************************************************************************
//
// Declaration of serialization routines and constants.
//
// *****************************************************************************
// * @author This file is part of libff, developed by SCIPR Lab
// * and contributors (see AUTHORS).
// * @copyright MIT license (see LICENSE file)
// *****************************************************************************/
//
//#ifndef SERIALIZATION_HPP_
//#define SERIALIZATION_HPP_
//
//#include <istream>
//#include <map>
//#include <ostream>
//#include <set>
//#include <vector>
//
namespace libff {
//
extern bool binary_output;
extern bool montgomery_output;
extern bool no_pt_compression;
//
///*
// * @todo
// * The serialization is fragile. Shoud be rewritten using a standard, portable-format
// * library like boost::serialize.
// *
// * However, for now the following conventions are used within the code.
// *
// * All algebraic objects support either binary or decimal output using
// * the standard C++ stream operators (operator<<, operator>>).
// *
// * The binary mode is activated by defining a BINARY_OUTPUT
// * preprocessor macro (e.g. g++ -DBINARY_OUTPUT ...).
// *
// * Binary output assumes that the stream is to be binary read at its
// * current position so any white space should be consumed beforehand.
// *
// * Consecutive algebraic objects are separated by OUTPUT_NEWLINE and
// * within themselves (e.g. X and Y coordinates for field elements) with
// * OUTPUT_SEPARATOR (as defined below).
// *
// * Therefore to dump two integers, two Fp elements and another integer
// * one would:
// *
// * out << 3 << "\n";
// * out << 4 << "\n";
// * out << FieldT(56) << OUTPUT_NEWLINE;
// * out << FieldT(78) << OUTPUT_NEWLINE;
// * out << 9 << "\n";
// *
// * Then reading back it its reader's responsibility (!) to consume "\n"
// * after 4, but Fp::operator<< will correctly consume OUTPUT_NEWLINE.
// *
// * The reader should also consume "\n" after 9, so that another field
// * element can be properly chained. This is especially important for
// * binary output.
// *
// * The binary serialization of algebraic objects is currently *not*
// * portable between machines of different word sizes.
// */
//
//#define OUTPUT_NEWLINE (libff::binary_output?"":"\n")
//#define OUTPUT_SEPARATOR (libff::binary_output?"":" ")
////#ifdef BINARY_OUTPUT
////#define OUTPUT_NEWLINE ""
////#define OUTPUT_SEPARATOR ""
////#else
////#define OUTPUT_NEWLINE "\n"
////#define OUTPUT_SEPARATOR " "
////#endif
//
//inline void consume_newline(std::istream &in);
//inline void consume_OUTPUT_NEWLINE(std::istream &in);
//inline void consume_OUTPUT_SEPARATOR(std::istream &in);
//
//inline void output_bool(std::ostream &out, const bool b);
//inline void input_bool(std::istream &in, bool &b);
//
//inline void output_bool_vector(std::ostream &out, const std::vector<bool> &v);
//inline void input_bool_vector(std::istream &in, std::vector<bool> &v);
//
//template<typename T>
//T reserialize(const T &obj);
//
//template<typename T>
//std::ostream& operator<<(std::ostream& out, const std::vector<T> &v);
//
//template<typename T>
//std::istream& operator>>(std::ostream& out, std::vector<T> &v);
//
//template<typename T1, typename T2>
//std::ostream& operator<<(std::ostream& out, const std::map<T1, T2> &m);
//
//template<typename T1, typename T2>
//std::istream& operator>>(std::istream& in, std::map<T1, T2> &m);
//
//template<typename T>
//std::ostream& operator<<(std::ostream& out, const std::set<T> &s);
//
//template<typename T>
//std::istream& operator>>(std::istream& in, std::set<T> &s);
//
} // libff
//
//#include <libff/common/serialization.tcc>
//
//#endif // SERIALIZATION_HPP_