@@ -30,28 +30,19 @@ class Writer {
3030 using OutputUnionType = BoostOutputUnion;
3131 using OutputVarType = BoostOutputVar;
3232
33- Writer (OArchive* _ar) : ar_(_ar) {}
33+ Writer (OArchive* _ar);
3434
3535 ~Writer () = default ;
3636
37- OutputArrayType array_as_root (const size_t _size) const {
38- *ar_ << static_cast <std::uint64_t >(_size);
39- return OutputArrayType{};
40- }
37+ OutputArrayType array_as_root (const size_t _size) const ;
4138
42- OutputMapType map_as_root (const size_t _size) const {
43- *ar_ << static_cast <std::uint64_t >(_size);
44- return OutputMapType{};
45- }
39+ OutputMapType map_as_root (const size_t _size) const ;
4640
47- OutputObjectType object_as_root (const size_t _size) const {
48- *ar_ << static_cast <std::uint64_t >(_size);
49- return OutputObjectType{};
50- }
41+ OutputObjectType object_as_root (const size_t _size) const ;
5142
52- OutputVarType null_as_root () const { return OutputVarType{}; }
43+ OutputVarType null_as_root () const ;
5344
54- OutputUnionType union_as_root () const { return OutputUnionType{}; }
45+ OutputUnionType union_as_root () const ;
5546
5647 template <class T >
5748 OutputVarType value_as_root (const T& _var) const {
@@ -60,109 +51,57 @@ class Writer {
6051 }
6152
6253 OutputArrayType add_array_to_array (const size_t _size,
63- OutputArrayType* /* _parent*/ ) const {
64- *ar_ << static_cast <std::uint64_t >(_size);
65- return OutputArrayType{};
66- }
54+ OutputArrayType* _parent) const ;
6755
6856 OutputArrayType add_array_to_map (const std::string_view& _name,
6957 const size_t _size,
70- OutputMapType* /* _parent*/ ) const {
71- *ar_ << std::string (_name);
72- *ar_ << static_cast <std::uint64_t >(_size);
73- return OutputArrayType{};
74- }
58+ OutputMapType* _parent) const ;
7559
76- OutputArrayType add_array_to_object (const std::string_view& /* _name*/ ,
60+ OutputArrayType add_array_to_object (const std::string_view& _name,
7761 const size_t _size,
78- OutputObjectType* /* _parent*/ ) const {
79- *ar_ << static_cast <std::uint64_t >(_size);
80- return OutputArrayType{};
81- }
62+ OutputObjectType* _parent) const ;
8263
8364 OutputArrayType add_array_to_union (const size_t _index, const size_t _size,
84- OutputUnionType* /* _parent*/ ) const {
85- *ar_ << static_cast <std::uint64_t >(_index);
86- *ar_ << static_cast <std::uint64_t >(_size);
87- return OutputArrayType{};
88- }
65+ OutputUnionType* _parent) const ;
8966
9067 OutputMapType add_map_to_array (const size_t _size,
91- OutputArrayType* /* _parent*/ ) const {
92- *ar_ << static_cast <std::uint64_t >(_size);
93- return OutputMapType{};
94- }
68+ OutputArrayType* _parent) const ;
9569
9670 OutputMapType add_map_to_map (const std::string_view& _name,
9771 const size_t _size,
98- OutputMapType* /* _parent*/ ) const {
99- *ar_ << std::string (_name);
100- *ar_ << static_cast <std::uint64_t >(_size);
101- return OutputMapType{};
102- }
72+ OutputMapType* _parent) const ;
10373
104- OutputMapType add_map_to_object (const std::string_view& /* _name*/ ,
74+ OutputMapType add_map_to_object (const std::string_view& _name,
10575 const size_t _size,
106- OutputObjectType* /* _parent*/ ) const {
107- *ar_ << static_cast <std::uint64_t >(_size);
108- return OutputMapType{};
109- }
76+ OutputObjectType* _parent) const ;
11077
11178 OutputMapType add_map_to_union (const size_t _index, const size_t _size,
112- OutputUnionType* /* _parent*/ ) const {
113- *ar_ << static_cast <std::uint64_t >(_index);
114- *ar_ << static_cast <std::uint64_t >(_size);
115- return OutputMapType{};
116- }
79+ OutputUnionType* _parent) const ;
11780
11881 OutputObjectType add_object_to_array (const size_t _size,
119- OutputArrayType* /* _parent*/ ) const {
120- *ar_ << static_cast <std::uint64_t >(_size);
121- return OutputObjectType{};
122- }
82+ OutputArrayType* _parent) const ;
12383
12484 OutputObjectType add_object_to_map (const std::string_view& _name,
12585 const size_t _size,
126- OutputMapType* /* _parent*/ ) const {
127- *ar_ << std::string (_name);
128- *ar_ << static_cast <std::uint64_t >(_size);
129- return OutputObjectType{};
130- }
86+ OutputMapType* _parent) const ;
13187
132- OutputObjectType add_object_to_object (const std::string_view& /* _name*/ ,
88+ OutputObjectType add_object_to_object (const std::string_view& _name,
13389 const size_t _size,
134- OutputObjectType* /* _parent*/ ) const {
135- *ar_ << static_cast <std::uint64_t >(_size);
136- return OutputObjectType{};
137- }
90+ OutputObjectType* _parent) const ;
13891
13992 OutputObjectType add_object_to_union (const size_t _index, const size_t _size,
140- OutputUnionType* /* _parent*/ ) const {
141- *ar_ << static_cast <std::uint64_t >(_index);
142- *ar_ << static_cast <std::uint64_t >(_size);
143- return OutputObjectType{};
144- }
93+ OutputUnionType* _parent) const ;
14594
146- OutputUnionType add_union_to_array (OutputArrayType* /* _parent*/ ) const {
147- return OutputUnionType{};
148- }
95+ OutputUnionType add_union_to_array (OutputArrayType* _parent) const ;
14996
15097 OutputUnionType add_union_to_map (const std::string_view& _name,
151- OutputMapType* /* _parent*/ ) const {
152- *ar_ << std::string (_name);
153- return OutputUnionType{};
154- }
98+ OutputMapType* _parent) const ;
15599
156- OutputUnionType add_union_to_object (const std::string_view& /* _name*/ ,
157- OutputObjectType* /* _parent*/ ) const {
158- return OutputUnionType{};
159- }
100+ OutputUnionType add_union_to_object (const std::string_view& _name,
101+ OutputObjectType* _parent) const ;
160102
161103 OutputUnionType add_union_to_union (const size_t _index,
162- OutputUnionType* /* _parent*/ ) const {
163- *ar_ << static_cast <std::uint64_t >(_index);
164- return OutputUnionType{};
165- }
104+ OutputUnionType* _parent) const ;
166105
167106 template <class T >
168107 OutputVarType add_value_to_array (const T& _var,
@@ -174,7 +113,7 @@ class Writer {
174113 template <class T >
175114 OutputVarType add_value_to_map (const std::string_view& _name, const T& _var,
176115 OutputMapType* /* _parent*/ ) const {
177- *ar_ << std::string (_name);
116+ write_key (_name);
178117 new_value (_var);
179118 return OutputVarType{};
180119 }
@@ -190,39 +129,35 @@ class Writer {
190129 template <class T >
191130 OutputVarType add_value_to_union (const size_t _index, const T& _var,
192131 OutputUnionType* /* _parent*/ ) const {
193- *ar_ << static_cast <std:: uint64_t > (_index);
132+ write_index (_index);
194133 new_value (_var);
195134 return OutputVarType{};
196135 }
197136
198- OutputVarType add_null_to_array (OutputArrayType* /* _parent*/ ) const {
199- return OutputVarType{};
200- }
137+ OutputVarType add_null_to_array (OutputArrayType* _parent) const ;
201138
202139 OutputVarType add_null_to_map (const std::string_view& _name,
203- OutputMapType* /* _parent*/ ) const {
204- *ar_ << std::string (_name);
205- return OutputVarType{};
206- }
140+ OutputMapType* _parent) const ;
207141
208- OutputVarType add_null_to_object (const std::string_view& /* _name*/ ,
209- OutputObjectType* /* _parent*/ ) const {
210- return OutputVarType{};
211- }
142+ OutputVarType add_null_to_object (const std::string_view& _name,
143+ OutputObjectType* _parent) const ;
212144
213145 OutputVarType add_null_to_union (const size_t _index,
214- OutputUnionType* /* _parent*/ ) const {
215- *ar_ << static_cast <std::uint64_t >(_index);
216- return OutputVarType{};
217- }
146+ OutputUnionType* _parent) const ;
218147
219- void end_array (OutputArrayType* /* _arr*/ ) const {}
148+ void end_array (OutputArrayType* _arr) const ;
220149
221- void end_map (OutputMapType* /* _obj*/ ) const {}
150+ void end_map (OutputMapType* _obj) const ;
222151
223- void end_object (OutputObjectType* /* _obj*/ ) const {}
152+ void end_object (OutputObjectType* _obj) const ;
224153
225154 private:
155+ void write_size (const size_t _size) const ;
156+
157+ void write_index (const size_t _index) const ;
158+
159+ void write_key (const std::string_view& _name) const ;
160+
226161 template <class T >
227162 void new_value (const T& _var) const {
228163 using Type = std::remove_cvref_t <T>;
0 commit comments