libpniio
|
FIO data reader. More...
#include <fio_reader.hpp>
Public Member Functions | |
fio_reader () | |
default constructor More... | |
fio_reader (const fio_reader &r)=delete | |
copy construction is deleted More... | |
fio_reader (fio_reader &&r) | |
move constructor More... | |
fio_reader (const pni::core::string &n) | |
standard constructor More... | |
~fio_reader () | |
destructor More... | |
fio_reader & | operator= (const fio_reader &r)=delete |
copy assignment is deleted More... | |
fio_reader & | operator= (fio_reader &&r) |
move assignemnt operator More... | |
size_t | nparameters () const |
get number of parameters More... | |
std::vector< pni::core::string > | parameter_names () const |
get parameter names More... | |
template<typename T > | |
T | parameter (const pni::core::string &name) const |
get parameter by name More... | |
template<typename CTYPE > | |
CTYPE | column (const pni::core::string &n) const |
get single column More... | |
template<typename CTYPE > | |
void | column (const pni::core::string &n, CTYPE &c) const |
read single column More... | |
![]() | |
virtual | ~spreadsheet_reader () |
destructor More... | |
spreadsheet_reader & | operator= (const spreadsheet_reader &)=delete |
copy assignment operator is deleted More... | |
spreadsheet_reader & | operator= (spreadsheet_reader &&r) |
move assignment operator More... | |
size_t | ncolumns () const |
get column number More... | |
size_t | nrecords () const |
get record number More... | |
iterator | begin () |
get iterator to first column More... | |
const_iterator | begin () const |
get const first iterator More... | |
iterator | end () |
get last iterator More... | |
const_iterator | end () const |
get const last iterator More... | |
bool | has_column (const pni::core::string &name) const |
checks if a particular column exists More... | |
size_t | column_index (const pni::core::string &name) const |
get column index More... | |
![]() | |
virtual | ~data_reader () |
destructor More... | |
pni::core::string | filename () const |
get filename More... | |
void | filename (const pni::core::string &fname) |
set filename More... | |
virtual void | close () |
close the file More... | |
virtual void | open () |
open file More... | |
Private Member Functions | |
void | _parse_file (std::ifstream &stream) |
initial file parseing More... | |
void | _parse_parameters (std::ifstream &stream) |
parse parameter section More... | |
void | _parse_data (std::ifstream &stream) |
parse the data section More... | |
template<typename T > | |
void | _get_parameter_data (std::ifstream &stream, T &value) const |
read parameter data More... | |
void | _get_parameter_data (std::ifstream &stream, pni::core::string &value) const |
read string parameter More... | |
template<typename CTYPE > | |
void | _read_column (size_t index, CTYPE &array) const |
read column data More... | |
Static Private Member Functions | |
static pni::core::type_id_t | _typestr2id (const pni::core::string &tstr) |
type id from type string More... | |
static column_info | _read_column_info (const pni::core::string &line) |
get ColumnInfo from line More... | |
static std::vector < pni::core::string > | _read_data_line (const pni::core::string &line) |
read data line More... | |
Private Attributes | |
std::map< pni::core::string, std::streampos > | _param_map |
parameter stream positions More... | |
std::streampos | _data_offset |
offset where real data starts More... | |
Additional Inherited Members | |
![]() | |
typedef std::vector < column_info >::iterator | iterator |
iterator type More... | |
typedef std::vector < column_info > ::const_iterator | const_iterator |
const iterator type More... | |
![]() | |
spreadsheet_reader () | |
default constructor More... | |
spreadsheet_reader (const spreadsheet_reader &)=delete | |
copy constructor is deleted More... | |
spreadsheet_reader (spreadsheet_reader &&o) | |
move constructor More... | |
spreadsheet_reader (const pni::core::string &n) | |
standard constructor More... | |
virtual void | _append_column (const column_info &i) |
append a column More... | |
virtual column_info | _get_column (size_t i) const |
get column information More... | |
virtual column_info | _get_column (const pni::core::string &n) const |
get column information More... | |
void | _nrecords (size_t n) |
set number of records More... | |
![]() | |
std::ifstream & | _get_stream () const |
get stream More... | |
void | _set_binary () |
set binary mode More... | |
data_reader () | |
default constructor More... | |
data_reader (const pni::core::string &fname, bool binary=false) | |
standard constructor More... | |
data_reader (data_reader &&r) | |
move constructor More... | |
data_reader (const data_reader &r)=delete | |
copy constructor is deleted More... | |
data_reader & | operator= (const data_reader &r)=delete |
copy assigment is deleted More... | |
data_reader & | operator= (data_reader &&r) |
move assignment More... | |
FIO files are written by ONLINE a data acquisition and experiment control software used at DESY. FIO files are basically ACII files where data is stored in columns. Thus such files correspond to the family of spreadsheet style files.
pni::io::fio_reader::fio_reader | ( | ) |
|
delete |
pni::io::fio_reader::fio_reader | ( | fio_reader && | r | ) |
pni::io::fio_reader::fio_reader | ( | const pni::core::string & | n | ) |
pni::io::fio_reader::~fio_reader | ( | ) |
|
private |
This template is used internally to extract parameter data from the input stream and store the result in a variable of type T.
stream | input stream |
value | where to store data |
|
private |
Overloaded version of the _get_parameter_data template method to handle string data.
stream | input stream |
value | string value where to store parameter data |
|
private |
Private function which execudes parser code for the data section of the FIO file. It collects all the information about columns present in the file.
stream | input stream from which to read data |
|
private |
This private method runs through the entire file once and calles the appropriate parses.
stream | input stream from which to read data |
|
private |
Method parses the parameter section of a file. It sets up the _param_map member variable.
stream | input stream from which to read data |
|
private |
Private template method to read column data and store it to an array object. If EOF is reached before all data was read an exception will be thrown.
file_error | if EOF is reached before end of data |
index | index of the column in the file |
array | instance of the Array template where to store the data |
|
staticprivate |
Method retrievs column information from a line.
line | string object holding the lines content |
|
staticprivate |
Reads a data line and splits the line into its cells. The method returns a vector of Strings where each elements corresponds to a particular cell.
line | input line |
|
staticprivate |
Method converts a FIO type string to a TypeID as provided by libpniio.
tstr | type string |
CTYPE pni::io::fio_reader::column | ( | const pni::core::string & | n | ) | const |
Returns a single column and stores the data into an array object. If the column name does not exist an exception is thrown.
key_error | if column does not exist |
file_error | if EOF is reached before end of data |
n | name of the column |
void pni::io::fio_reader::column | ( | const pni::core::string & | n, |
CTYPE & | c | ||
) | const |
Read a single column and stores the result in an appropriate container. The method assumes that the container is of appropriate size and shape.
key_error | if the requested column does not exist |
file_error | in any other case of error |
CTYPE | container type |
n | name of the column |
c | instance of CTYPE that will in the end contain the data |
size_t pni::io::fio_reader::nparameters | ( | ) | const |
Return the number of parameters stored in the file.
|
delete |
fio_reader & pni::io::fio_reader::operator= | ( | fio_reader && | r | ) |
T pni::io::fio_reader::parameter | ( | const pni::core::string & | name | ) | const |
Return the value of a parameter stored in the FIO file by name.
key_errror | if parameter name does not exist |
name | parameter name |
std::vector< pni::core::string > pni::io::fio_reader::parameter_names | ( | ) | const |
Returns a vector of Strings holding the parameter names stored in the file.
|
private |
|
private |