PhoenixDataStream
2.1.0
PhoenixDataStream is a 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 : LGPL-3.0-only
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
, T* >{
17
21
static
bool
data_stream
(FILE* & ds, T* & data){
22
size_t
value = (size_t)data;
23
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, value);
24
return
b;
25
}
26
};
27
29
template
<
typename
T>
30
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::vector<T> >{
32
36
static
bool
data_stream
(FILE* & ds, std::vector<T> & data){
37
//Save the size of the data
38
size_t
nbElement(data.size());
39
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, nbElement);
40
if
(nbElement == 0lu || !b){
return
b;}
//If there is no element, quit now
41
42
// if(data_stream_isSimpleType<T>()){
43
// b &= DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream_tab(ds, (T*)data.data(), nbElement);
44
// }else{
45
for
(
typename
std::vector<T>::iterator it(data.begin()); it != data.end(); ++it){
46
b &=
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, *it);
47
}
48
// }
49
return
b;
50
}
51
};
52
54
template
<
typename
T>
55
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::list<T> >{
57
61
static
bool
data_stream
(FILE* & ds, std::list<T> & data){
62
//Save the size of the data
63
size_t
nbElement(data.size());
64
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, nbElement);
65
if
(nbElement == 0lu || !b){
return
b;}
//If there is no element, quit now
66
for
(
typename
std::list<T>::iterator it(data.begin()); it != data.end(); ++it){
67
b &=
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, *it);
68
}
69
return
b;
70
}
71
};
72
74
template
<
typename
T,
typename
U>
75
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::map<T, U> >{
77
81
static
bool
data_stream
(FILE* & ds, std::map<T, U> & data){
82
//Save the size of the data
83
size_t
nbElement(data.size());
84
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream
(ds, nbElement);
85
if
(nbElement == 0lu || !b){
return
b;}
//If there is no element, quit now
86
for
(
typename
std::map<T, U>::iterator it(data.begin()); it != data.end(); ++it){
87
b &=
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, (T&)it->first);
88
b &=
DataStream<FILE*, DataStreamMode::WRITE, U>::data_stream
(ds, it->second);
89
}
90
return
b;
91
}
92
};
93
95
template
<
typename
T,
typename
U>
96
struct
DataStream
<FILE*,
DataStreamMode::WRITE
, std::pair<T, U> >{
98
102
static
bool
data_stream
(FILE* & ds, std::pair<T, U> & data){
103
bool
b =
DataStream<FILE*, DataStreamMode::WRITE, T>::data_stream
(ds, (T&)data.first);
104
b &=
DataStream<FILE*, DataStreamMode::WRITE, U>::data_stream
(ds, data.second);
105
return
b;
106
}
107
};
108
109
110
111
#endif
112
113
data_stream_include.h
data_stream_isSimpleType.h
DataStreamMode::WRITE
@ WRITE
Definition
data_stream_include.h:22
DataStream< FILE *, DataStreamMode::WRITE, T * >::data_stream
static bool data_stream(FILE *&ds, T *&data)
Write a pointer address in a file.
Definition
data_stream_write_file.h:21
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:61
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:81
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:102
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:36
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