mimmo_binary_stream.hpp
1 /*---------------------------------------------------------------------------*\
2 *
3 * mimmo
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of mimmo.
10 *
11 * mimmo is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * mimmo is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22 *
23 \*---------------------------------------------------------------------------*/
24 #ifndef __MIMMOBINARYSTREAM_HPP__
25 #define __MIMMOBINARYSTREAM_HPP__
26 
27 #include <binary_stream.hpp>
28 #include <array>
29 #include <vector>
30 #include <utility>
31 #include <map>
32 #include <unordered_map>
33 
34 namespace mimmo{
35 
41  class IBinaryStream : public bitpit::IBinaryStream {
42 
43  public:
44  IBinaryStream(void);
45  IBinaryStream(std::size_t size);
46  IBinaryStream(const char *buffer, std::size_t size);
47  IBinaryStream(const std::vector<char> &buffer);
48  };
49 
55  class OBinaryStream : public bitpit::OBinaryStream {
56 
57  public:
58  OBinaryStream();
59  OBinaryStream(std::size_t size);
60  };
61 
62 
63 }
64 
69 //BASIC TYPES
70 mimmo::IBinaryStream& operator>>(mimmo::IBinaryStream &buf, std::string & element);
71 mimmo::OBinaryStream& operator<<(mimmo::OBinaryStream &buf, const std::string & element);
72 
73 //TEMPLATE STRUCTURES
74 
75 template<typename T>
76 mimmo::IBinaryStream& operator>>(mimmo::IBinaryStream &buf,std::vector<T>& element);
77 template<typename T>
78 mimmo::OBinaryStream& operator<<(mimmo::OBinaryStream &buf, const std::vector<T>& element);
79 
80 template<typename T, std::size_t d>
81 mimmo::IBinaryStream& operator>>(mimmo::IBinaryStream &buf, std::array<T,d>& element);
82 template<typename T, std::size_t d>
83 mimmo::OBinaryStream& operator<<(mimmo::OBinaryStream &buf, const std::array<T,d>& element);
84 
85 template<typename T, typename Q>
86 mimmo::IBinaryStream& operator>>(mimmo::IBinaryStream &buf, std::pair<T, Q>& element);
87 template<typename T, typename Q>
88 mimmo::OBinaryStream& operator<<(mimmo::OBinaryStream &buf, const std::pair<T, Q>& element);
89 
90 template<typename T, typename Q>
91 mimmo::IBinaryStream& operator>>(mimmo::IBinaryStream &buf, std::unordered_map<T, Q>& element);
92 template<typename T, typename Q>
93 mimmo::OBinaryStream& operator<<(mimmo::OBinaryStream &buf, const std::unordered_map<T, Q >& element);
94 
95 template<typename T, typename Q>
96 mimmo::IBinaryStream& operator>>(mimmo::IBinaryStream &buf, std::map<T,Q>& element);
97 template<typename T, typename Q>
98 mimmo::OBinaryStream& operator<<(mimmo::OBinaryStream &buf, const std::map<T, Q>& element);
99 
104 #include "mimmo_binary_stream.tpp"
105 
106 
107 
108 #endif /* __MIMMOBINARYSTREAM_HPP__ */
mimmo custom derivation of bitpit OBinaryStream (see relative doc)
mimmo::OBinaryStream & operator<<(mimmo::OBinaryStream &buf, const std::string &element)
mimmo::IBinaryStream & operator>>(mimmo::IBinaryStream &buf, std::string &element)
mimmo custom derivation of bitpit IBinaryStream (see relative doc)