DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::TableReader< TQuantity > Struct Template Reference

Aim: Implements method to read a set of numbers represented in each line of a file. More...

#include <DGtal/io/readers/TableReader.h>

Static Public Member Functions

static std::vector< TQuantity > getColumnElementsFromFile (const std::string &aFilename, unsigned int aPosition)
 
static std::vector< TQuantity > getColumnElementsFromInputStream (std::istream &in, unsigned int aPosition)
 
static std::vector< std::vector< TQuantity > > getLinesElementsFromFile (const std::string &aFilename)
 
static std::vector< std::vector< TQuantity > > getLinesElementsFromInputStream (std::istream &in)
 

Detailed Description

template<typename TQuantity>
struct DGtal::TableReader< TQuantity >

Aim: Implements method to read a set of numbers represented in each line of a file.

Description of class 'TableReader'

The main method to read a set of numbers where each number is given in a single line. Each elements are identified between space or tab characters. Blank line or line beginning with "#" are skipped.

Simple example:

#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/TableReader.h"
....
string filename= "testFile.dat";
vector<unsigned int> vectPoints = TableReader<unsigned
Aim: Implements method to read a set of numbers represented in each line of a file.
Definition TableReader.h:87
static std::vector< TQuantity > getColumnElementsFromFile(const std::string &aFilename, unsigned int aPosition)

and you can specifying the point position:

vector<unsigned int> vectPoints = TableReader<unsigned
*int>::getColumnElementsFromFile(filename, 2);
See also
testTableReader.cpp
Template Parameters
TQuantitythe type fo the integer to be read.

Definition at line 86 of file TableReader.h.

Member Function Documentation

◆ getColumnElementsFromFile()

template<typename TQuantity >
static std::vector< TQuantity > DGtal::TableReader< TQuantity >::getColumnElementsFromFile ( const std::string & aFilename,
unsigned int aPosition )
static

Method to import a vector containing a list of elements given in an input stream. One element is extracted on each line of the input stream. Each elements are identified between space or tab characters. Blank line or line beginning with "#" are skipped.

Parameters
aFilenamea file name
aPositionthe position of indices where the element has to be extracted.
Returns
a vector containing the set of elements.

Referenced by testNumberReader().

◆ getColumnElementsFromInputStream()

template<typename TQuantity >
static std::vector< TQuantity > DGtal::TableReader< TQuantity >::getColumnElementsFromInputStream ( std::istream & in,
unsigned int aPosition )
static

Method to import a vector containing a list of elements given in a file. One element is extracted on each line of the input file. Each elements are identified between space or tab characters. Blank line or line beginning with "#" are skipped.

Parameters
inthe input file.
aPositionthe position of indices where the elements has to be extracted.
Returns
a vector containing the set of elements.

◆ getLinesElementsFromFile()

template<typename TQuantity >
static std::vector< std::vector< TQuantity > > DGtal::TableReader< TQuantity >::getLinesElementsFromFile ( const std::string & aFilename)
static

Method to import a vector where each element contains the line elements of a given file. Each elements are identified between space or tab characters. Blank line or line beginning with "#" are skipped.

Parameters
aFilenamethe input file.
Returns
a vector containing a vector which contains each line elements.

Referenced by testNumberReader().

◆ getLinesElementsFromInputStream()

template<typename TQuantity >
static std::vector< std::vector< TQuantity > > DGtal::TableReader< TQuantity >::getLinesElementsFromInputStream ( std::istream & in)
static

Method to import a vector where each element contains the line elements of a given file. Each elements are identified between space or tab characters. Blank line or line beginning with "#" are skipped.

Parameters
inthe input file.
Returns
a vector containing a vector which contains each line elements.

The documentation for this struct was generated from the following file: