PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
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 : CeCILL-C
5 ****************************************/
6 
7 #ifndef __DATA_STREAM_READ_FILE_H__
8 #define __DATA_STREAM_READ_FILE_H__
9 
10 #include "data_stream_include.h"
11 
13 template<typename T>
14 struct DataStream<FILE*,DataStreamMode::READ, std::vector<T> >{
16 
20  static bool data_stream(FILE* & ds, std::vector<T> & data){
21  //Get the number of elements
22  size_t nbElement(0lu);
24  if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
25  for(size_t i(0lu); i < nbElement && b; ++i){
26  T tmp;
28  data.push_back(tmp);
29  }
30  return b;
31  }
32 };
33 
35 template<typename T>
36 struct DataStream<FILE*,DataStreamMode::READ, std::list<T> >{
38 
42  static bool data_stream(FILE* & ds, std::list<T> & data){
43  //Get the number of elements
44  size_t nbElement(0lu);
46  if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
47  for(size_t i(0lu); i < nbElement && b; ++i){
48  T tmp;
50  data.push_back(tmp);
51  }
52  return b;
53  }
54 };
55 
57 template<typename T, typename U>
58 struct DataStream<FILE*,DataStreamMode::READ, std::map<T, U> >{
60 
64  static bool data_stream(FILE* & ds, std::map<T, U> & data){
65  //Get the number of elements
66  size_t nbElement(0lu);
68  if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
69  for(size_t i(0lu); i < nbElement && b; ++i){
70  T tmpFirst;
72  U tmpSecond;
74  data[tmpFirst] = tmpSecond; //Add data in map
75  }
76  return b;
77  }
78 };
79 
81 template<typename T, typename U>
82 struct DataStream<FILE*,DataStreamMode::READ, std::pair<T, U> >{
84 
88  static bool data_stream(FILE* & ds, std::pair<T, U> & data){
89  T tmpFirst;
91  U tmpSecond;
93  data = std::pair<T, U>(tmpFirst, tmpSecond);
94  return b;
95  }
96 };
97 
98 
99 
100 #endif
101 
102 
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.