STIRA  0.1
Public Member Functions | Static Public Member Functions | List of all members
stira::common::TextFileUtils Class Reference

A class with some handy functions to manipulate ASCII text files. More...

#include <TextFileUtils.h>

Public Member Functions

 TextFileUtils ()
 Constructor.
 
 ~TextFileUtils ()
 Constructor.
 

Static Public Member Functions

static Rows ReadTabSeparatedLineFromTextFile (std::string inFileName)
 Reads a text file where fields on a line are separated by tabs Reference http://stackoverflow.com/questions/1075712/reading-delimited-files-in-c. More...
 
static std::vector< std::string > ReadLinesFromTextFile (std::string inFileName)
 Reads single-word lines from a text file. More...
 
static bool FilterText (std::string inFileName, std::string outFileName, int *pFilterValues, int filterLength, int nrColumnsToFilter, int nrOtherColumns)
 Filters a text file with numbers, keeping only valid rows The first columns contain values to be filtered; only if all those values in these columns are valid, the row is kept. More...
 
static bool SaveVectorOfValuesToTextFile (std::vector< double > inVector, std::string outFileName)
 Saves the values in a vector of doubles to a text file. More...
 
static bool SaveVectorOfValuesToTextFile (std::vector< int > inVector, std::string outFileName)
 Saves the values in a vector of integers to a text file. More...
 
static bool SaveVectorOfIntensityPointsToTextFile (std::vector< common::IntensityPoint > inVector, std::string outFileName)
 Saves the values in a vector of doubles to a text file. More...
 

Detailed Description

A class with some handy functions to manipulate ASCII text files.

Member Function Documentation

bool stira::common::TextFileUtils::FilterText ( std::string  inFileName,
std::string  outFileName,
int *  pFilterValues,
int  filterLength,
int  nrColumnsToFilter,
int  nrOtherColumns 
)
static

Filters a text file with numbers, keeping only valid rows The first columns contain values to be filtered; only if all those values in these columns are valid, the row is kept.

Parameters
inFileNamefile name for input data
outFileNamefile name for output datap
pFilterValuesarray with the valid values: if all of the first nrColumnsToFilter have values that are also in the array, the row is kept
filterLengthlength of array with valid values
nrColumnsToFilterhow many columns must contain values that are in pFilterValue
nrOtherColumnsnr of other columns to copy when a row is valid
std::vector< std::string > stira::common::TextFileUtils::ReadLinesFromTextFile ( std::string  inFileName)
static

Reads single-word lines from a text file.

Parameters
inFileNamefile name to read from
Returns
vector of strings per line
Rows stira::common::TextFileUtils::ReadTabSeparatedLineFromTextFile ( std::string  inFileName)
static

Reads a text file where fields on a line are separated by tabs Reference http://stackoverflow.com/questions/1075712/reading-delimited-files-in-c.

Parameters
inFileNameinput text file
bool stira::common::TextFileUtils::SaveVectorOfIntensityPointsToTextFile ( std::vector< common::IntensityPoint inVector,
std::string  outFileName 
)
static

Saves the values in a vector of doubles to a text file.

Parameters
inVectorvector with values to be written
outFileNamefile name for output data
bool stira::common::TextFileUtils::SaveVectorOfValuesToTextFile ( std::vector< double >  inVector,
std::string  outFileName 
)
static

Saves the values in a vector of doubles to a text file.

Parameters
inVectorvector with values to be written
outFileNamefile name for output data
bool stira::common::TextFileUtils::SaveVectorOfValuesToTextFile ( std::vector< int >  inVector,
std::string  outFileName 
)
static

Saves the values in a vector of integers to a text file.

Parameters
inVectorvector with values to be written
outFileNamefile name for output data

The documentation for this class was generated from the following files: