22 #include <QtCore/qglobal.h>
23 #include <QtCore/QDataStream>
27 #if defined(CASS_LIBRARY)
28 # define CASSSHARED_EXPORT Q_DECL_EXPORT
30 # define CASSSHARED_EXPORT Q_DECL_IMPORT
36 #define VERBOSEOUT(a) (a)
38 #define VERBOSEOUT(a) {}
42 #define DEBUGOUT(a) (a)
44 #define DEBUGOUT(a) {}
62 template <
typename Type>
78 inline T
square(
const T& val) {
return val * val; }
98 _filestream->seekg(_pos);
99 return *_filestream.get();
121 vector<string> lines;
127 if(line[line.length()-1] ==
'\n')
129 line.resize(line.length()-1);
132 if(line[line.length()-1] ==
'\r')
134 line.resize(line.length()-1);
137 if(line.empty() || line[0] ==
'\n')
142 if(line.find(
';') != string::npos || line.find(
'#') != string::npos)
146 lines.push_back(line);
164 void operator()(
const std::string &line, std::vector<double> &elems,
char delim)
167 stringstream ss(line);
169 while(getline(ss, str, delim))
171 if ((str.size() == 1 && !(isalpha(str[0]))) || str.empty())
173 stringstream ssvalue(str);
176 elems.push_back(value);
186 void operator()(
const std::string &line, std::vector<std::string> &elems,
char delim)
189 stringstream ss(line);
191 while(getline(ss, str, delim))
193 if ((str.size() == 1 && !(isalpha(str[0]))) || str.empty())
195 elems.push_back(str);
208 template <
typename T>
212 file.read(reinterpret_cast<char*>(&var),
sizeof(T));
224 template <
typename T>
228 std::streampos currentpos(file.tellg());
229 file.read(reinterpret_cast<char*>(&var),
sizeof(T));
230 file.seekg(currentpos);
246 if(stream.
readRawData(reinterpret_cast<char*>(&evt),
sizeof(T)) !=
sizeof(T))
247 throw std::runtime_error(
"operator>>(QDdataStream&,T&): could not retrieve all requested bytes");
263 stream.read(reinterpret_cast<char*>(&evt),
sizeof(T));
264 if(stream.rdstate() != std::ios_base::goodbit)
265 throw std::runtime_error(
"operator>>(ifstream&,T&): could not retrieve all requested bytes");
std::vector< std::string > operator()(std::ifstream &file)
the operator
filestream_t _filestream
the stream to the file
T peek(std::ifstream &file)
retrieve a variable from a file stream without extracting it
A resource that will point at a specific location within a file.
base class for all file readers
readRawData(char *s, int len)
std::ifstream & getStream()
T square(const T &val)
multiply number by itself
std::vector< filereaderpointerpair_t > positionreaders_t
map file name to the filepointer
std::streampos _pos
the position with the file
tokenize to return all lines of an ascii file in a vector
split the line into the values in that line
std::string toString(const Type &t)
convert any type to a string
std::pair< std::tr1::shared_ptr< FileReader >, FilePointer > filereaderpointerpair_t
pair of a file pointer with the associated file reader
std::tr1::shared_ptr< std::ifstream > filestream_t
defining a shared pointer to the stream
SerializerBackend & operator>>(SerializerBackend &serializer, Axis< T > &axis)
read an Axis from a stream
std::map< uint64_t, positionreaders_t > event2positionreaders_t
the list of events contained in a file with the associated position and reader
const size_t NbrOfWorkers
global variable to set the number of worker threads
void operator()(const std::string &line, std::vector< double > &elems, char delim)
the operator for splitting a line of values
check if there is some light in the chamber based upon the GMD value
T retrieve(std::ifstream &file)
retrieve a variable from a file stream
void operator()(const std::string &line, std::vector< std::string > &elems, char delim)
the operator for splitting into substrings
const size_t RingBufferSize
global variable to set the ring buffer size