|
8 | 8 | #define PIVX_SERIALIZE_H |
9 | 9 |
|
10 | 10 | #include <algorithm> |
| 11 | +#include <array> |
11 | 12 | #include <assert.h> |
12 | 13 | #include <ios> |
13 | 14 | #include <limits> |
@@ -550,6 +551,43 @@ template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& |
550 | 551 | template<typename Stream, typename T, typename A, typename V> void Unserialize_impl(Stream& is, std::vector<T, A>& v, const V&); |
551 | 552 | template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v); |
552 | 553 |
|
| 554 | +/** |
| 555 | + * array |
| 556 | + */ |
| 557 | +template<typename T, std::size_t N> unsigned int GetSerializeSize(const std::array<T, N> &item, int nType, int nVersion); |
| 558 | +template<typename Stream, typename T, std::size_t N> void Serialize(Stream& os, const std::array<T, N>& item, int nType, int nVersion); |
| 559 | +template<typename Stream, typename T, std::size_t N> void Unserialize(Stream& is, std::array<T, N>& item, int nType, int nVersion); |
| 560 | + |
| 561 | +/** |
| 562 | + * array |
| 563 | + */ |
| 564 | +template<typename T, std::size_t N> |
| 565 | +unsigned int GetSerializeSize(const std::array<T, N> &item, int nType, int nVersion) |
| 566 | +{ |
| 567 | + unsigned int size = 0; |
| 568 | + for (size_t i = 0; i < N; i++) { |
| 569 | + size += GetSerializeSize(item[0], nType, nVersion); |
| 570 | + } |
| 571 | + return size; |
| 572 | +} |
| 573 | + |
| 574 | +template<typename Stream, typename T, std::size_t N> |
| 575 | +void Serialize(Stream& os, const std::array<T, N>& item, int nType, int nVersion) |
| 576 | +{ |
| 577 | + for (size_t i = 0; i < N; i++) { |
| 578 | + Serialize(os, item[i], nType, nVersion); |
| 579 | + } |
| 580 | +} |
| 581 | + |
| 582 | +template<typename Stream, typename T, std::size_t N> |
| 583 | +void Unserialize(Stream& is, std::array<T, N>& item, int nType, int nVersion) |
| 584 | +{ |
| 585 | + for (size_t i = 0; i < N; i++) { |
| 586 | + Unserialize(is, item[i], nType, nVersion); |
| 587 | + } |
| 588 | +} |
| 589 | + |
| 590 | + |
553 | 591 | /** |
554 | 592 | * pair |
555 | 593 | */ |
|
0 commit comments