Loading...
Searching...
No Matches
binaryUtils.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit 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 * bitpit 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 bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24#ifndef __BITPIT_COMMON_BINARY_UTILS_HPP__
25#define __BITPIT_COMMON_BINARY_UTILS_HPP__
26
27#include <array>
28#include <iostream>
29#include <iterator>
30#include <limits>
31#include <vector>
32
33#include "commonUtils.hpp"
34#include "commonUtils.tpp"
35
36namespace bitpit {
37
38namespace utils {
39
45namespace binary {
46
47template<typename T, typename std::enable_if<std::is_pod<T>::value>::type* = nullptr>
48void write(std::ostream &stream, const std::vector<T> &value);
49
50template<typename T, std::size_t dim, typename std::enable_if<std::is_pod<T>::value>::type* = nullptr>
51void write(std::ostream &stream, const std::array<T, dim> &value);
52
53template<typename T, std::size_t dim, typename std::enable_if<!std::is_pod<T>::value>::type* = nullptr>
54void write(std::ostream &stream, const std::array<T, dim> &value);
55
56template<typename T, typename std::enable_if<utils::is_iterable<T>::value>::type* = nullptr>
57void write(std::ostream &stream, const T &value);
58
59template<typename T, typename std::enable_if<std::is_pod<T>::value>::type* = nullptr>
60void write(std::ostream &stream, const T &value);
61
62template<typename T>
63void write(std::ostream &stream, const T &value, size_t size);
64
65template<typename T>
66void write(std::ostream &stream, const T *value, size_t size);
67
68template<typename T>
69void write(std::ostream &stream, T *value, size_t size);
70
71void write(std::ostream &stream, const std::vector<bool> &container);
72
73void write(std::ostream &stream, const std::string &string);
74
75template<typename T, typename std::enable_if<std::is_pod<T>::value>::type* = nullptr>
76void read(std::istream &stream, std::vector<T> &value);
77
78template<typename T, std::size_t dim, typename std::enable_if<std::is_pod<T>::value>::type* = nullptr>
79void read(std::istream &stream, std::array<T, dim> &value);
80
81template<typename T, std::size_t dim, typename std::enable_if<!std::is_pod<T>::value>::type* = nullptr>
82void read(std::istream &stream, std::array<T, dim> &value);
83
84template<typename T, typename std::enable_if<utils::is_iterable<T>::value>::type* = nullptr>
85void read(std::istream &stream, T &value);
86
87template<typename T, typename std::enable_if<std::is_pod<T>::value>::type* = nullptr>
88void read(std::istream &stream, T &value);
89
90template<typename T>
91void read(std::istream &stream, T &value, size_t size);
92
93template<typename T>
94void read(std::istream &stream, T *value, size_t size);
95
96void read(std::istream &stream, std::vector<bool> &container);
97
98void read(std::istream &stream, std::vector<bool>::reference value);
99
100void read(std::istream &stream, std::string &string);
101
102}
103
104}
105
106}
107
108// Include templates' implementation
109#include "binaryUtils.tpp"
110
111#endif
void write(std::ostream &stream, const std::vector< bool > &container)
void read(std::istream &stream, std::vector< bool > &container)
--- layout: doxygen_footer ---