DGtal  0.9.3beta
Static Public Member Functions
DGtal::TableReader< TQuantity > Struct Template Reference

#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)
 

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. 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<Z2i::Point> vectPoints = TableReader<unsigned int>::getColumnElementsFromFile(filename);

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 83 of file TableReader.h.

Member Function Documentation

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. 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.
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. 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.

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