PhoenixDataStream  2.1.0
PhoenixDataStream is a framework to save/load/serialize/deserialize data
Loading...
Searching...
No Matches
data_stream_read_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_READ_FILE_H__
8#define __DATA_STREAM_READ_FILE_H__
9
10#include "data_stream_include.h"
11
13template<typename T>
14struct DataStream<FILE*, DataStreamMode::READ, T* >{
16
20 static bool data_stream(FILE* & ds, T* & data){
21 size_t pointerAddress = 0lu;
23 data = (T*)pointerAddress;
24 return b;
25 }
26};
27
29template<typename T>
30struct DataStream<FILE*,DataStreamMode::READ, std::vector<T> >{
32
36 static bool data_stream(FILE* & ds, std::vector<T> & data){
37 //Get the number of elements
38 size_t nbElement(0lu);
40 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
41 for(size_t i(0lu); i < nbElement && b; ++i){
42 T tmp;
44 data.push_back(tmp);
45 }
46 return b;
47 }
48};
49
51template<typename T>
52struct DataStream<FILE*,DataStreamMode::READ, std::list<T> >{
54
58 static bool data_stream(FILE* & ds, std::list<T> & data){
59 //Get the number of elements
60 size_t nbElement(0lu);
62 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
63 for(size_t i(0lu); i < nbElement && b; ++i){
64 T tmp;
66 data.push_back(tmp);
67 }
68 return b;
69 }
70};
71
73template<typename T, typename U>
74struct DataStream<FILE*,DataStreamMode::READ, std::map<T, U> >{
76
80 static bool data_stream(FILE* & ds, std::map<T, U> & data){
81 //Get the number of elements
82 size_t nbElement(0lu);
84 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
85 for(size_t i(0lu); i < nbElement && b; ++i){
86 T tmpFirst;
88 U tmpSecond;
90 data[tmpFirst] = tmpSecond; //Add data in map
91 }
92 return b;
93 }
94};
95
97template<typename T, typename U>
98struct DataStream<FILE*,DataStreamMode::READ, std::pair<T, U> >{
100
104 static bool data_stream(FILE* & ds, std::pair<T, U> & data){
105 T tmpFirst;
107 U tmpSecond;
109 data = std::pair<T, U>(tmpFirst, tmpSecond);
110 return b;
111 }
112};
113
114
115
116#endif
117
118
static bool data_stream(FILE *&ds, T *&data)
READ a pointer address in a file.
static bool data_stream(FILE *&ds, std::list< T > &data)
Get the size of a class std::list T.
static bool data_stream(FILE *&ds, std::map< T, U > &data)
Get the size of a class std::list T.
static bool data_stream(FILE *&ds, std::pair< T, U > &data)
Get the size of a class std::list T.
static bool data_stream(FILE *&ds, std::vector< T > &data)
Get the size of a class std::vector T.
Generic DataStream class.
static bool data_stream(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.