ICAROUS
|
#include <SeparatedOutput.h>
Public Member Functions | |
SeparatedOutput () | |
SeparatedOutput (std::ostream *w) | |
SeparatedOutput & | operator= (const SeparatedOutput &x) |
void | close () |
std::string | getHeading (int i) |
long | length () |
long | size () |
void | setOutputUnits (bool output) |
void | setHeading (int i, const std::string &name, const std::string &unit) |
void | addHeading (const std::string &name, const std::string &unit) |
void | addHeading (const std::vector< std::string > &names, const std::vector< std::string > &units) |
void | addHeading (const std::vector< std::string > &names_and_units) |
int | findHeading (const std::string &heading, bool caseSensitive) |
int | findHeading (const std::string &heading1, const std::string &heading2, bool caseSensitive) |
int | findHeading (const std::string &heading1, const std::string &heading2, const std::string &heading3, bool caseSensitive) |
int | findHeading (const std::string &heading1, const std::string &heading2, const std::string &heading3, const std::string &heading4, bool caseSensitive) |
std::string | getUnit (int i) |
void | setColumn (int i, double val) |
void | setColumn (double val) |
void | setColumn (int i, const std::string &val) |
void | addColumn (const std::string &val) |
void | addColumn (const std::vector< std::string > &vals) |
void | setColumnDelimiterTab () |
void | setColumnDelimiterComma () |
void | setColumnDelimiterSpace () |
void | setColumnSpace (int num) |
void | setEmptyValue (std::string e) |
void | setCommentCharacter (const std::string &c) |
void | setParameters (const ParameterData &pr) |
void | setParameter (const std::string &key, const std::string &value) |
void | clearParameters () |
void | addComment (const std::string &c) |
void | writeLine () |
void | flush () |
std::string | toString () |
bool | hasError () const |
bool | hasMessage () const |
std::string | getMessage () |
std::string | getMessageNoClear () const |
Private Member Functions | |
void | init () |
void | print_line (std::vector< std::string > vals) |
Private Attributes | |
std::ostream * | writer |
ErrorLog | error |
bool | header |
std::vector< std::string > | header_str |
bool | bunits |
std::vector< std::string > | units_str |
std::vector< std::string > | line_str |
long | size_l |
int | column_count |
int | header_count |
char | delim |
std::string | space |
std::string | comment_char |
std::string | empty |
std::vector< std::string > | comments |
std::vector< std::string > | params |
A class to writes a separated value file (separated by commas, spaces, or tabs).
only one file can be created from an object.
Future: handle a memory buffer, standard output/error, file, socket?
larcfm::SeparatedOutput::SeparatedOutput | ( | ) |
Create an "empty" separated output
larcfm::SeparatedOutput::SeparatedOutput | ( | std::ostream * | w | ) |
Create a new SeparatedOutput from the given writer
w | writer object |
Create a new SeparatedInput from the given reader
void larcfm::SeparatedOutput::addColumn | ( | const std::string & | val | ) |
Adds the given value to the next column.
val | value |
Adds the given value to the next column.
void larcfm::SeparatedOutput::addColumn | ( | const std::vector< std::string > & | vals | ) |
Adds each of the given values to the next columns.
vals | list of values |
Adds each of the given values to the next columns.
void larcfm::SeparatedOutput::addComment | ( | const std::string & | c | ) |
Add the following line to the comments.
c | comment string |
Add the following line to the comments.
void larcfm::SeparatedOutput::addHeading | ( | const std::string & | name, |
const std::string & | unit | ||
) |
Add the given heading (and unit) to the next column
name | the name of this column heading |
unit | the unit for this column. If you don't know, then use "unspecified" |
void larcfm::SeparatedOutput::addHeading | ( | const std::vector< std::string > & | names, |
const std::vector< std::string > & | units | ||
) |
Add the given heading (and unit) to the next column
names | the name of this column heading |
units | the unit for this column. If you don't know, then use "unspecified" |
void larcfm::SeparatedOutput::addHeading | ( | const std::vector< std::string > & | names_and_units | ) |
Add the given heading (and unit) to the next column
names_and_units | an array containing an alternating list of heading names and heading units. The length of this list must be even. |
void larcfm::SeparatedOutput::clearParameters | ( | ) |
Clear all parameters.
int larcfm::SeparatedOutput::findHeading | ( | const std::string & | heading, |
bool | caseSensitive | ||
) |
Find the index of the column with given heading. If the heading is not found, then -1 is returned. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
heading | name of heading |
caseSensitive | false if ignoring case |
Find the index of the column with given heading. If the heading is not found, then -1 is returned. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
int larcfm::SeparatedOutput::findHeading | ( | const std::string & | heading1, |
const std::string & | heading2, | ||
bool | caseSensitive | ||
) |
Find the index of the column with any of the given headings. If none of the given headings is found, then -1 is returned. This tries to find the first heading, and if it finds it then returns that index. If it doesn't find it, it moves to the next heading, etc. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
heading1 | name of heading |
heading2 | alternate name of heading |
caseSensitive | false if ignore case |
Find the index of the column with any of the given headings. If none of the given headings is found, then -1 is returned. This tries to find the first heading, and if it finds it then returns that index. If it doesn't find it, it moves to the next heading, etc. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
int larcfm::SeparatedOutput::findHeading | ( | const std::string & | heading1, |
const std::string & | heading2, | ||
const std::string & | heading3, | ||
bool | caseSensitive | ||
) |
Find the index of the column with any of the given headings. If none of the given headings is found, then -1 is returned. This tries to find the first heading, and if it finds it then returns that index. If it doesn't find it, it moves to the next heading, etc. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
heading1 | name of heading |
heading2 | alternate name of heading |
heading3 | alternate name of heading |
caseSensitive | false if ignore heading |
Find the index of the column with any of the given headings. If none of the given headings is found, then -1 is returned. This tries to find the first heading, and if it finds it then returns that index. If it doesn't find it, it moves to the next heading, etc. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
int larcfm::SeparatedOutput::findHeading | ( | const std::string & | heading1, |
const std::string & | heading2, | ||
const std::string & | heading3, | ||
const std::string & | heading4, | ||
bool | caseSensitive | ||
) |
Find the index of the column with any of the given headings. If none of the given headings is found, then -1 is returned. This tries to find the first heading, and if it finds it then returns that index. If it doesn't find it, it moves to the next heading, etc. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
heading1 | name of heading |
heading2 | alternate name of heading |
heading3 | alternate name of heading |
heading4 | alternate name of heading |
caseSensitive | false if ignore heading |
Find the index of the column with any of the given headings. If none of the given headings is found, then -1 is returned. This tries to find the first heading, and if it finds it then returns that index. If it doesn't find it, it moves to the next heading, etc. Note: If you are getting some oddly large indexes, there are probably some nonstandard characters in the input.
std::string larcfm::SeparatedOutput::getHeading | ( | int | i | ) |
Return the heading for the given column
i | column index |
Return the heading for the given column
|
virtual |
Return a string representation of any errors or warnings. Calling this method will clear any messages and reset both the error and warning status to none.
Implements larcfm::ErrorReporter.
|
virtual |
Return a string representation of any errors or warnings. Calling this method will not clear the error or warning status (i.e., hasError() will return the same value before and after this call.)
Implements larcfm::ErrorReporter.
std::string larcfm::SeparatedOutput::getUnit | ( | int | i | ) |
Returns the units string for the i-th column. If an invalid column is entered, then "unspecified" is returned.
i | column index |
Returns the units string for the i-th column. If an invalid column is entered, then "unspecified" is returned.
|
virtual |
|
virtual |
Does this object have an error or a warning?
Implements larcfm::ErrorReporter.
long larcfm::SeparatedOutput::length | ( | ) |
Return the number of rows written
Return the number of rows written
SeparatedOutput & larcfm::SeparatedOutput::operator= | ( | const SeparatedOutput & | x | ) |
Assignment Operator.
void larcfm::SeparatedOutput::setColumn | ( | double | val | ) |
Sets the next column value equal to the given value. The value is in internal units.
void larcfm::SeparatedOutput::setColumn | ( | int | i, |
const std::string & | val | ||
) |
Sets the next column value equal to the given value.
i | index of column |
val | value |
Sets the next column value equal to the given value.
void larcfm::SeparatedOutput::setColumn | ( | int | i, |
double | val | ||
) |
Sets the next column value equal to the given value. The value is in internal units.
void larcfm::SeparatedOutput::setColumnDelimiterComma | ( | ) |
Sets the column delimiter to a comma
void larcfm::SeparatedOutput::setColumnDelimiterSpace | ( | ) |
Sets the column delimiter to a space. If a space is used as a separator then the empty value should be set (see setEmptyValue).
void larcfm::SeparatedOutput::setColumnDelimiterTab | ( | ) |
Sets the column delimiter to a tab
void larcfm::SeparatedOutput::setColumnSpace | ( | int | num | ) |
Sets the number of extra spaces after the delimiter
num | number of spaces |
Sets the number of extra spaces after the delimiter
void larcfm::SeparatedOutput::setCommentCharacter | ( | const std::string & | c | ) |
Set the code indicating the start of a comment.
c | comment character |
Set the code indicating the start of a comment.
void larcfm::SeparatedOutput::setEmptyValue | ( | std::string | e | ) |
The value to be displayed if a column is "skipped". Empty values are only added inside a line, not at the end.
e | value to indicate empty |
The value to be displayed if a column is "skipped". Empty values are only added inside a line, not at the end.
void larcfm::SeparatedOutput::setHeading | ( | int | i, |
const std::string & | name, | ||
const std::string & | unit | ||
) |
Set the heading for the given column number, columns begin at 0.
i | the column number |
name | the name of this column heading |
unit | the unit for this column. If you don't know, then use "unspecified" |
void larcfm::SeparatedOutput::setOutputUnits | ( | bool | output | ) |
Should the output units be placed in the output file?
output | if true, then the units should be displayed |
void larcfm::SeparatedOutput::setParameters | ( | const ParameterData & | pr | ) |
Additively set parameters. (This does not delete existing parameters, but will overwrite them.)
pr | parameter object |
Set parameters. Use all the parameters in the reader.
long larcfm::SeparatedOutput::size | ( | ) |
Return the number of columns
Return the number of columns
void larcfm::SeparatedOutput::writeLine | ( | ) |
Writes a line of the output. The first call to writeLine will write the column headings, units, etc.
Writes a line of the output. The first call to readLine will read the column headings, units, etc.