OpenWalnut  1.5.0dev
Public Member Functions | Private Member Functions | Friends | List of all members
WReaderCSV Class Reference

Read content from a CSV file. More...

#include <WReaderCSV.h>

+ Inheritance diagram for WReaderCSV:
+ Collaboration diagram for WReaderCSV:

Public Member Functions

 WReaderCSV (std::string fname)
 Constructs a CSV reader object. More...
 
virtual ~WReaderCSV () throw ()
 Destroys this instance. More...
 
virtual std::shared_ptr< WDataSetCSVread ()
 Read the file and create a dataset as a vector. More...
 

Private Member Functions

std::vector< std::string > transformLineToVector (std::string line)
 Transforms a given string into a string vector, by a predefined delimiter. More...
 
- Private Member Functions inherited from WReader
 WReader (std::string fname)
 Creates a read object for file reading. More...
 
OW_API_DEPRECATED void setFileName (std::string fname)
 Reset the file name and checks if it exists. More...
 
void setFilename (std::string fname)
 Reset the file name and checks if it exists. More...
 

Friends

class WReaderCSVTest
 Only WReaderCSVTest class may be friend. More...
 

Additional Inherited Members

- Private Attributes inherited from WReader
std::string m_fname
 Absolute path of the file to read from. More...
 

Detailed Description

Read content from a CSV file.

Definition at line 42 of file WReaderCSV.h.

Constructor & Destructor Documentation

◆ WReaderCSV()

WReaderCSV::WReaderCSV ( std::string  fname)
explicit

Constructs a CSV reader object.

Parameters
fnamepath of the file to load.

Definition at line 32 of file WReaderCSV.cpp.

◆ ~WReaderCSV()

WReaderCSV::~WReaderCSV ( )
throw (
)
virtual

Destroys this instance.

Definition at line 37 of file WReaderCSV.cpp.

Member Function Documentation

◆ read()

std::shared_ptr< WDataSetCSV > WReaderCSV::read ( )
virtual

Read the file and create a dataset as a vector.

Returns
pointer to a WDataSetCSV.
Exceptions
WExceptionIf the file could not be opened.

Definition at line 74 of file WReaderCSV.cpp.

References WReader::m_fname, and transformLineToVector().

Referenced by WCsvConverterTest::setUp(), WReaderCSVTest::testCRLFLineEnding(), WReaderCSVTest::testCRLineEnding(), WReaderCSVTest::testEmptyColumns(), WReaderCSVTest::testLFLineEnding(), and WReaderCSVTest::testValidCSV().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformLineToVector()

std::vector< std::string > WReaderCSV::transformLineToVector ( std::string  line)
private

Transforms a given string into a string vector, by a predefined delimiter.

Parameters
lineThe line, which shell be split into a string vector
Returns
The splitted string as a string vector

Definition at line 135 of file WReaderCSV.cpp.

Referenced by read().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WReaderCSVTest

friend class WReaderCSVTest
friend

Only WReaderCSVTest class may be friend.

Definition at line 47 of file WReaderCSV.h.


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