#include <DataOperations.h>
Classes | |
class | Value |
Class for storing values It can store number or blank wich allows to display missing data. More... | |
Public Member Functions | |
DataOperations () | |
virtual void | swap (string command) |
virtual void | parseFiles (string names) |
virtual void | load () |
virtual void | join () |
virtual void | merge () |
This function merge all input data. | |
virtual void | col () |
This function makes all calculations to be made by columns in stead of by lines. | |
virtual void | tab () |
This function switch spaces into tabulators. | |
virtual void | printOut () |
virtual void | setCommand (string cmd) |
virtual void | blanks (string arg) |
virtual void | tol (double t) |
virtual void | prec (int p) |
virtual void | setFilter (string arg) |
virtual void | setOutputFiles (string names) |
virtual void | group (string arg) |
virtual void | comments (string arg) |
virtual void | calculate (string arg) |
virtual void | print (string arg) |
Private Member Functions | |
DataOperations (DataOperations &) | |
Private copy constructor prevents from creating two same objects. | |
void | printToStd () |
Function to print data on standard output. | |
void | printToFile () |
Function to print data to one file. | |
void | printToFiles () |
Function to print data to many files. | |
size_t | startFiltering () |
void | mean () |
void | count () |
void | sum () |
void | median () |
void | deviation () |
void | fillInBlanks () |
void | commOut (ostream *out) |
This funtion inserts comments before data. | |
void | commIn (ostream *out, int i) |
This funtion inserts comments before data of each file. | |
void | parseComments () |
This funtion parses comments, finds all parameters and put it in map. | |
Private Attributes | |
size_t | col_cond |
variable used in filters functions to store information wich column is with condition. | |
bool | isJoined |
if true input files are treated as one. | |
bool | isMerged |
if true input files are merged. | |
bool | tabulator |
if true tabulators are used to separate values | |
bool | columns |
if true all calculations are made on columns | |
char | c |
T | tolerance |
stores size of tolerance used in filters functions (0 - default) | |
int | precision |
string | blank |
stores string that will be put where data is missing | |
int | commentMode |
stores information about comments mode (-1 off, 0 default, 1 one, 2 all) | |
vector< string > | file_names |
stores names of input files | |
vector< string > | file_out |
stores names of output files | |
vector< vector< vector< Value > > > | all_values |
main data structure, stores all values, it's 3D vector: all_values[files][lines][columns] | |
vector< vector< string > > | all_comments |
2D vector for storing comments | |
vector< map< string, double > > | all_param |
vector of maps for storing parameters fuond in comments | |
vector< vector< Value > > | tab_tmp |
temporary 2D vector for storing values | |
vector< Value > | vall_tmp |
temporary vector for storing values | |
vector< double > | conditions |
vector of numbers used in filters functions for comparations | |
vector< string > | kind_of_cond |
vector of condidions used in filters functions | |
vector< size_t > | out |
vector for storing numbers of columns that will be printed, used in filters functions | |
vector< vector< size_t > > | dim |
2D vector for storing current dimmention of data, used in calculations functions | |
string | command |
stores command that started the program |
DataOperations< T >::DataOperations | ( | ) | [inline] |
This is the class constructor. It takes no arguments and it's basicly doing nothing exept setting default values to some variables.
DataOperations< T >::DataOperations | ( | DataOperations< T > & | ) | [inline, private] |
Private copy constructor prevents from creating two same objects.
virtual void DataOperations< T >::blanks | ( | string | arg | ) | [inline, virtual] |
Setter for blanks.
arg | is a string containing symbols putted where invalid value is found . |
Implements DataHandler.
void DataOperations< T >::calculate | ( | string | arg | ) | [inline, virtual] |
This function parses the calculate option and accordingly to it performs selected operations.
arg | is a command line argument of -c (--calculate) option. |
Implements DataHandler.
virtual void DataOperations< T >::col | ( | ) | [inline, virtual] |
This function makes all calculations to be made by columns in stead of by lines.
Implements DataHandler.
void DataOperations< T >::comments | ( | string | arg | ) | [inline, virtual] |
This function parses the comments option and accordingly to it sets level of coping comments from input to output.
arg | is a command line argument of --comments option. |
Implements DataHandler.
void DataOperations< T >::commIn | ( | ostream * | out, | |
int | i | |||
) | [inline, private] |
This funtion inserts comments before data of each file.
void DataOperations< T >::commOut | ( | ostream * | out | ) | [inline, private] |
This funtion inserts comments before data.
void DataOperations< T >::count | ( | ) | [inline, private] |
Funtion to count values. It can works on columns or rows.
void DataOperations< T >::deviation | ( | ) | [inline, private] |
Funtion to calculate standard deviation. It can works on columns or rows.
void DataOperations< T >::fillInBlanks | ( | ) | [inline, private] |
Funtion to search for missing data and fill in blanks when needed. This is made because the same number of columns in every line in needed.
void DataOperations< T >::group | ( | string | arg | ) | [inline, virtual] |
This function parses the group option and accordingly to it groups data.
arg | is a command line argument of -g (--group) option. |
Implements DataHandler.
virtual void DataOperations< T >::join | ( | ) | [inline, virtual] |
This function joins all input to one output. Actually it works only when two or more files were specified on the input
Implements DataHandler.
void DataOperations< T >::load | ( | ) | [inline, virtual] |
This function loads data to memory. If input files have been set, this function will open each of them and read content. Otherwise it will start reading standard input. The EOF symbol ends reading.
Implements DataHandler.
void DataOperations< T >::mean | ( | ) | [inline, private] |
Funtion to calculate mean. It can works on columns or rows.
void DataOperations< T >::median | ( | ) | [inline, private] |
Funtion to calculate median. It can works on columns or rows.
void DataOperations< T >::merge | ( | ) | [inline, virtual] |
void DataOperations< T >::parseComments | ( | ) | [inline, private] |
This funtion parses comments, finds all parameters and put it in map.
void DataOperations< T >::parseFiles | ( | string | names | ) | [inline, virtual] |
Function to collect input file names.
names | is a list of files separated by ',' |
Implements DataHandler.
virtual void DataOperations< T >::prec | ( | int | p | ) | [inline, virtual] |
Setter for printing precision.
p | precision (number of digits after '.'). |
Implements DataHandler.
void DataOperations< T >::print | ( | string | arg | ) | [inline, virtual] |
This function parses the print option and accordingly to it prints only selected data.
arg | is a command line argument of -p (--print) option. |
Implements DataHandler.
void DataOperations< T >::printOut | ( | ) | [inline, virtual] |
This function is called on the end, when we want to print all. Function will decide where to save the data one file, many files or print to standard output.
Implements DataHandler.
void DataOperations< T >::printToFile | ( | ) | [inline, private] |
Function to print data to one file.
void DataOperations< T >::printToFiles | ( | ) | [inline, private] |
Function to print data to many files.
void DataOperations< T >::printToStd | ( | ) | [inline, private] |
Function to print data on standard output.
virtual void DataOperations< T >::setCommand | ( | string | cmd | ) | [inline, virtual] |
Setter for command that started the program.
cmd | is a string containing command that started the program. |
Implements DataHandler.
void DataOperations< T >::setFilter | ( | string | arg | ) | [inline, virtual] |
This function parses the filtr option.
arg | is a command line argument of -f (--filtr) option. |
Implements DataHandler.
void DataOperations< T >::setOutputFiles | ( | string | names | ) | [inline, virtual] |
Sets the output file names.
names | is a list of output files specified by -o (--output-files) option and separated by ','. |
Implements DataHandler.
size_t DataOperations< T >::startFiltering | ( | ) | [inline, private] |
This function starts filtering data with condidions given in setFilter
void DataOperations< T >::sum | ( | ) | [inline, private] |
Funtion to calculate sum of values. It can works on columns or rows.
void DataOperations< T >::swap | ( | string | command | ) | [inline, virtual] |
This function swaps two columns in selected file.
command | is a command line argument of -s (--swap) option |
Implements DataHandler.
virtual void DataOperations< T >::tab | ( | ) | [inline, virtual] |
virtual void DataOperations< T >::tol | ( | double | t | ) | [inline, virtual] |
Setter for tolerance used in comparations made by filter function.
t | value of tolerance. |
Implements DataHandler.
vector< vector<string> > DataOperations< T >::all_comments [private] |
2D vector for storing comments
vector< map<string, double> > DataOperations< T >::all_param [private] |
vector of maps for storing parameters fuond in comments
vector< vector< vector<Value> > > DataOperations< T >::all_values [private] |
main data structure, stores all values, it's 3D vector: all_values[files][lines][columns]
string DataOperations< T >::blank [private] |
stores string that will be put where data is missing
char DataOperations< T >::c [private] |
variable used in filters functions to store information about condidions (0 - means only one condition, a - means and, o - means or).
size_t DataOperations< T >::col_cond [private] |
variable used in filters functions to store information wich column is with condition.
bool DataOperations< T >::columns [private] |
if true all calculations are made on columns
string DataOperations< T >::command [private] |
stores command that started the program
int DataOperations< T >::commentMode [private] |
stores information about comments mode (-1 off, 0 default, 1 one, 2 all)
vector<double> DataOperations< T >::conditions [private] |
vector of numbers used in filters functions for comparations
vector< vector <size_t> > DataOperations< T >::dim [private] |
2D vector for storing current dimmention of data, used in calculations functions
vector<string> DataOperations< T >::file_names [private] |
stores names of input files
vector<string> DataOperations< T >::file_out [private] |
stores names of output files
bool DataOperations< T >::isJoined [private] |
if true input files are treated as one.
bool DataOperations< T >::isMerged [private] |
if true input files are merged.
vector<string> DataOperations< T >::kind_of_cond [private] |
vector of condidions used in filters functions
vector<size_t> DataOperations< T >::out [private] |
vector for storing numbers of columns that will be printed, used in filters functions
int DataOperations< T >::precision [private] |
stores number of digits to display after comma (0 - default: means there wasn't --prec option in command, 6 digits are used)
vector< vector<Value> > DataOperations< T >::tab_tmp [private] |
temporary 2D vector for storing values
bool DataOperations< T >::tabulator [private] |
if true tabulators are used to separate values
T DataOperations< T >::tolerance [private] |
stores size of tolerance used in filters functions (0 - default)
vector<Value> DataOperations< T >::vall_tmp [private] |
temporary vector for storing values