PhoenixDataStream
1.3.0
Framework to save/load/serialize/deserialize data
Toggle main menu visibility
Loading...
Searching...
No Matches
data_stream_write_file.h
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : CeCILL-C
5
****************************************/
6
7
#ifndef __DATA_STREAM_WRITE_FILE_H__
8
#define __DATA_STREAM_WRITE_FILE_H__
9
10
#include "
data_stream_include.h
"
11
#include "
data_stream_isSimpleType.h
"
12
14
template
<
typename
T>
15
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::vector<T> >{
17
21
static
bool
data_stream
(FILE* & ds, std::vector<T> & data){
22
//Save the size of the data
23
size_t
nbElement(data.size());
24
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, nbElement);
25
if
(nbElement == 0lu || !b){
return
b;}
//If there is no element, quit now
26
27
// if(data_stream_isSimpleType<T>()){
28
// b &= DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream_tab(ds, (T*)data.data(), nbElement);
29
// }else{
30
for
(
typename
std::vector<T>::iterator it(data.begin()); it != data.end(); ++it){
31
b &=
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, *it);
32
}
33
// }
34
return
b;
35
}
36
};
37
39
template
<
typename
T>
40
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::list<T> >{
42
46
static
bool
data_stream
(FILE* & ds, std::list<T> & data){
47
//Save the size of the data
48
size_t
nbElement(data.size());
49
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, nbElement);
50
if
(nbElement == 0lu || !b){
return
b;}
//If there is no element, quit now
51
for
(
typename
std::list<T>::iterator it(data.begin()); it != data.end(); ++it){
52
b &=
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, *it);
53
}
54
return
b;
55
}
56
};
57
59
template
<
typename
T,
typename
U>
60
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::map<T, U> >{
62
66
static
bool
data_stream
(FILE* & ds, std::map<T, U> & data){
67
//Save the size of the data
68
size_t
nbElement(data.size());
69
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, nbElement);
70
if
(nbElement == 0lu || !b){
return
b;}
//If there is no element, quit now
71
for
(
typename
std::map<T, U>::iterator it(data.begin()); it != data.end(); ++it){
72
b &=
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, (T&)it->first);
73
b &=
DataStream<FILE*, DataStreamMode::WRITE, U>::data_stream
(ds, it->second);
74
}
75
return
b;
76
}
77
};
78
80
template
<
typename
T,
typename
U>
81
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::pair<T, U> >{
83
87
static
bool
data_stream
(FILE* & ds, std::pair<T, U> & data){
88
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, (T&)data.first);
89
b &=
DataStream<FILE*, DataStreamMode::WRITE, U>::data_stream
(ds, data.second);
90
return
b;
91
}
92
};
93
94
95
96
#endif
97
98
data_stream_include.h
data_stream_isSimpleType.h
DataStreamMode::WRITE
@ WRITE
Definition
data_stream_include.h:22
DataStream< FILE *, DataStreamMode::WRITE, std::list< T > >::data_stream
static bool data_stream(FILE *&ds, std::list< T > &data)
Get the size of a class std::list T.
Definition
data_stream_write_file.h:46
DataStream< FILE *, DataStreamMode::WRITE, std::map< T, U > >::data_stream
static bool data_stream(FILE *&ds, std::map< T, U > &data)
Get the size of a class std::list T.
Definition
data_stream_write_file.h:66
DataStream< FILE *, DataStreamMode::WRITE, std::pair< T, U > >::data_stream
static bool data_stream(FILE *&ds, std::pair< T, U > &data)
Get the size of a class std::list T.
Definition
data_stream_write_file.h:87
DataStream< FILE *, DataStreamMode::WRITE, std::vector< T > >::data_stream
static bool data_stream(FILE *&ds, std::vector< T > &data)
Get the size of a class std::vector T.
Definition
data_stream_write_file.h:21
DataStream
Generic DataStream class.
Definition
data_stream_include.h:32
DataStream::data_stream
static bool data_stream(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.
Definition
data_stream_include.h:37
src
data_stream_write_file.h
Generated by
1.17.0