ASCII spreadsheet API¶
pni::spreadsheet_reader
¶
-
class
pni
::
spreadsheet_reader
: public pni::data_reader¶ base class for spreadsheet reader
This class is the basement for all readers dealing with spreadsheet like data files. Most of the ASCII formats written following this storage convention.
Subclassed by pni::fio_reader
Public Types
-
typedef std::vector<column_info>::iterator
iterator
¶ iterator type
-
typedef std::vector<column_info>::const_iterator
const_iterator
¶ const iterator type
Public Functions
-
~spreadsheet_reader
()¶ destructor
-
spreadsheet_reader &
operator=
(const spreadsheet_reader&) = delete¶ copy assignment operator is deleted
-
spreadsheet_reader &
operator=
(spreadsheet_reader &&r)¶ move assignment operator
-
size_t
ncolumns
() const¶ get column number
Returns the number of columns.
- Return
number of columns
-
size_t
nrecords
() const¶ get record number
Return the number of records in the spreadsheet.
- Return
number of records
-
iterator
begin
()¶ get iterator to first column
Return an iterator pointing to the first column in the file.
- Return
iterator
-
const_iterator
begin
() const¶ get const first iterator
Return a const iterator to the first column in the file.
- Return
const iterator
-
const_iterator
end
() const¶ get const last iterator
Returns a const iterator to the last column in the file.
- Return
const iterator
-
bool
has_column
(const pni::string &name) const¶ checks if a particular column exists
Returns true if the spreadsheet contains a column of the requested name and false otherwise.
- Return
true if column exists, false otherwise
- Parameters
name
: of the column
-
typedef std::vector<column_info>::iterator
pni::column_info
¶
-
class
pni
::
column_info
¶ Spreadsheet column information.
This class holds the basic information about a column stored in a spreadsheet. This includes the following parameters: the name of the column, its TypeID and the shape of each cell. The latter parameter allows even the storage of multidimensional data in such a structure.
Public Functions
-
column_info
()¶ default constructor
-
column_info
(const column_info &ci)¶ copy constructor
-
column_info
(column_info &&ci)¶ move constructor
-
column_info
(const pni::string &n, pni::type_id_t tid, const std::vector<size_t> &s)¶ constructor
A column can hold a scalar or a multidimensional data entry. In the former case the type id is that of the element stored in the latter case it is the id of a single element in the array stored in each column element.
- Parameters
n
: name of the columntid
: ID of the type stored in the columns
: shape of the column
-
~column_info
()¶ destructor
-
column_info &
operator=
(const column_info &ci)¶ copy assignment operator
-
column_info &
operator=
(column_info &&ci)¶ move assignment operator
-
const std::vector<size_t> &
shape
() const¶ get cell shape
Returns the shape object from a column.
- Return
shape object.
-
pni::type_id_t
type_id
() const¶ get cells type ID
Return the TypeID of the column if available. This is only valid for systems where type information is stored in the file (like for FIO).
- Return
type id of the column data
-
pni::string
name
() const¶ get name
Return the name of the column.
- Return
name
-
pni::fio_reader
¶
-
class
pni
::
fio_reader
: public pni::spreadsheet_reader¶ FIO data reader.
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.
Public Functions
-
fio_reader
()¶ default constructor
-
fio_reader
(const fio_reader &r) = delete¶ copy construction is deleted
-
fio_reader
(fio_reader &&r) = default¶ move constructor
-
fio_reader
(const pni::string &n)¶ standard constructor
-
~fio_reader
()¶ destructor
-
fio_reader &
operator=
(const fio_reader &r) = delete¶ copy assignment is deleted
-
fio_reader &
operator=
(fio_reader &&r) = default¶ move assignemnt operator
-
size_t
nparameters
() const¶ get number of parameters
Return the number of parameters stored in the file.
- Return
number of parameters
-
std::vector<std::string>
parameter_names
() const¶ get parameter names
Returns a vector of Strings holding the parameter names stored in the file.
- Return
parameter names
-
template<typename
T
>
Tparameter
(const std::string &name) const¶ get parameter by name
Return the value of a parameter stored in the FIO file by name.
- Return
parameter value as type T
- Exceptions
key_errror
: if parameter name does not exist
- Parameters
name
: parameter name
-
template<typename
CTYPE
>
CTYPEcolumn
(const std::string &n) const¶ get single column
Returns a single column and stores the data into an array object. If the column name does not exist an exception is thrown.
- Return
instance of ATYPE holding the data.
- Exceptions
key_error
: if column does not existfile_error
: if EOF is reached before end of data
- Parameters
n
: name of the column
-
template<typename
CTYPE
>
voidcolumn
(const std::string &n, CTYPE &c) const¶ read single column
Read a single column and stores the result in an appropriate container. The method assumes that the container is of appropriate size and shape.
- Exceptions
key_error
: if the requested column does not existfile_error
: in any other case of error
- Template Parameters
CTYPE
: container type
- Parameters
n
: name of the columnc
: instance of CTYPE that will in the end contain the data
-