Skip to content

Commit dc2c93d

Browse files
author
me
committed
- removed (de)serialize_all() since usually you want to serialize a pack of data into a msgpack array or map explicitly. using std::tie, and therefore std::tuple, ensures that.
1 parent 8500750 commit dc2c93d

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

examples/example2.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ namespace mynamespace
1515
template<SINK_TYPE Sink>
1616
void serialize(Sink& out, const my_struct& obj)
1717
{
18-
serialize_all(out, obj.my_int, obj.my_float, obj.my_string, obj.my_audio);
18+
auto packed = std::tie(obj.my_int, obj.my_float, obj.my_string, obj.my_audio);
19+
serialize(out, packed);
1920
}
2021

2122
template<SOURCE_TYPE Source>
2223
void deserialize(Source& in, my_struct& obj)
2324
{
24-
deserialize_all(in, obj.my_int, obj.my_float, obj.my_string, obj.my_audio);
25+
auto packed = std::tie(obj.my_int, obj.my_float, obj.my_string, obj.my_audio);
26+
deserialize(in, packed);
2527
}
2628
}
2729

@@ -41,6 +43,7 @@ int main()
4143
auto in = source(buf);
4244
deserialize(in, b);
4345

46+
printf("Serialized buffer size %zu\n", buf.size());
4447
printf("%d %f %s [", b.my_int, b.my_float, b.my_string.c_str());
4548
for (auto s : b.my_audio) printf("%hd ", s);
4649
printf("]\n");

examples/example3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int main()
3333
auto in = source(buf);
3434
deserialize(in, b);
3535

36+
printf("Serialized buffer size %zu\n", buf.size());
3637
printf("%d %f %s [", b.my_int, b.my_float, b.my_string.c_str());
3738
for (auto s : b.my_audio) printf("%hd ", s);
3839
printf("]\n");

include/msgpack.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,6 @@ namespace msgpackcpp
317317
template<SOURCE_TYPE Source, class... Args>
318318
void deserialize(Source& in, std::tuple<Args...>& tpl);
319319

320-
//----------------------------------------------------------------------------------------------------------------
321-
322-
template<SINK_TYPE Sink, class... Args>
323-
void serialize_all(Sink& out, const Args&... args);
324-
325-
template<SOURCE_TYPE Source, class... Args>
326-
void deserialize_all(Source& in, Args&... args);
327-
328320
//----------------------------------------------------------------------------------------------------------------
329321
//----------------------------------------------------------------------------------------------------------------
330322
// DEFINITIONS
@@ -1231,20 +1223,6 @@ namespace msgpackcpp
12311223
}, tpl);
12321224
}
12331225

1234-
//----------------------------------------------------------------------------------------------------------------
1235-
1236-
template<SINK_TYPE Sink, class... Args>
1237-
void serialize_all(Sink& out, const Args&... args)
1238-
{
1239-
(serialize(out, args),...);
1240-
}
1241-
1242-
template<SOURCE_TYPE Source, class... Args>
1243-
void deserialize_all(Source& in, Args&... args)
1244-
{
1245-
(deserialize(in, args), ...);
1246-
}
1247-
12481226
//----------------------------------------------------------------------------------------------------------------
12491227

12501228
template<SINK_TYPE Sink>

0 commit comments

Comments
 (0)