#include <ored/utilities/csvfilereader.hpp>
Public Member Functions | |
CSVReader (const bool firstLineContainsHeaders, const std::string &delimiters=",;\t", const std::string &escapeCharacters="\\", const std::string "eCharacters="\"", const char eolMarker='\n') | |
virtual | ~CSVReader () |
void | setStream (std::istream *stream) |
const std::vector< std::string > & | fields () const |
const bool | hasField (const std::string &field) const |
Size | numberOfColumns () const |
bool | next () |
Size | currentLine () const |
std::string | get (const std::string &field) const |
std::string | get (const Size column) const |
virtual void | close () |
Private Attributes | |
std::istream * | stream_ |
const bool | hasHeaders_ |
const char | eolMarker_ |
Size | currentLine_ |
Size | numberOfColumns_ |
boost::tokenizer< boost::escaped_list_separator< char > > | tokenizer_ |
std::vector< std::string > | headers_ |
std::vector< std::string > | data_ |
Definition at line 38 of file csvfilereader.hpp.
CSVReader | ( | const bool | firstLineContainsHeaders, |
const std::string & | delimiters = ",;\t" , |
||
const std::string & | escapeCharacters = "\\" , |
||
const std::string & | quoteCharacters = "\"" , |
||
const char | eolMarker = '\n' |
||
) |
Ctor
Definition at line 31 of file csvfilereader.cpp.
|
virtual |
Definition at line 45 of file csvfilereader.hpp.
void setStream | ( | std::istream * | stream | ) |
Set stream for function
Definition at line 38 of file csvfilereader.cpp.
const std::vector< std::string > & fields | ( | ) | const |
Returns the fields, if a header line is present, otherwise throws
Definition at line 52 of file csvfilereader.cpp.
const bool hasField | ( | const std::string & | field | ) | const |
Return true if a field is present
Definition at line 57 of file csvfilereader.cpp.
Size numberOfColumns | ( | ) | const |
Returns the number of columns
Definition at line 61 of file csvfilereader.cpp.
bool next | ( | ) |
Go to next line in file, returns false if there are no more lines
Definition at line 66 of file csvfilereader.cpp.
Size currentLine | ( | ) | const |
Number of the current data line
Definition at line 94 of file csvfilereader.cpp.
std::string get | ( | const std::string & | field | ) | const |
Get content of field in current data line, throws if field is not present
Definition at line 99 of file csvfilereader.cpp.
std::string get | ( | const Size | column | ) | const |
Get content of column in current data line, throws if column is out of range
Definition at line 110 of file csvfilereader.cpp.
|
virtual |
Close the file
Reimplemented in CSVFileReader.
Definition at line 65 of file csvfilereader.hpp.
|
private |
Definition at line 68 of file csvfilereader.hpp.
|
private |
Definition at line 69 of file csvfilereader.hpp.
|
private |
Definition at line 70 of file csvfilereader.hpp.
|
private |
Definition at line 71 of file csvfilereader.hpp.
|
private |
Definition at line 71 of file csvfilereader.hpp.
|
private |
Definition at line 72 of file csvfilereader.hpp.
|
private |
Definition at line 73 of file csvfilereader.hpp.
|
private |
Definition at line 73 of file csvfilereader.hpp.