AuxPort 0.2
Modules for Audio Software Development
|
This class provides functionality to read and write CSV Files. More...
#include <AuxFile.h>
Public Member Functions | |
CSV (const CSV &csv)=default | |
bool | open (const std::string &fileName, const Mode &mode=Mode::Read, bool containsHeader=false, const char &delimiter=',', bool log=false) |
Opens a CSV File. | |
bool | close (bool log=false) |
Closes the stream to currently opened CSV File. | |
void | read (std::vector< std::vector< std::string > > &data) |
Reads data from a CSV file and stores it in the 2-d Vector. | |
void | read (std::vector< std::vector< std::string > > &data, std::vector< std::string > &headers) |
Reads data from a CSV file. | |
bool | getDataRow (std::vector< std::string > &dataRow, size_t rowNum) |
Reads a specific data row from the file. | |
void | setHeader (const std::vector< std::string > &header) |
Sets the header row to be written to the CSV File. | |
void | addDataRow (const std::vector< std::string > &dataRow) |
Adds a data row to be written to the CSV File. | |
void | write () |
Writes a CSV file using information set through addDataRow(), setHeader() functions. | |
void | write (const std::vector< std::vector< std::string > > &data, const std::vector< std::string > &header=std::vector< std::string >()) |
Writes a CSV file with the given data and header rows. | |
void | Log () override |
Logs the file info. | |
![]() | |
TextFormat (const TextFormat &textFormat)=default | |
void | Log () override |
Implement this method in the derived class to specify logging behaviour. | |
std::string & | getFormatName () |
Return the format name. | |
std::string & | getUniqueIdentifier () |
Return the unique identifier for the text format. | |
std::string & | getExtensionName () |
Returns the extension name. | |
void | setExtensionName (const std::string &extensionName) |
Sets the extension name. | |
void | setUniqueIdentifier (const std::string &uniqueIdentifier) |
Sets the unique identifier for the text format. | |
void | setFormatName (const std::string &formatName) |
Sets the format name. | |
Additional Inherited Members | |
![]() | |
enum | Mode { Idle = 0 , Read = 1 , Write = 2 } |
Easy way to specify the Read/Write behavior of the File Stream. More... | |
![]() | |
TextFile ()=default | |
Default Constructor, Initializes the TextFile API. | |
~TextFile ()=default | |
Default Destructor. | |
std::string & | readFileAsString () |
Reads the entire text file and saves it in a String. | |
void | writeLineToFile (const std::string &data, bool log=false) |
Writes a line to the Text File. | |
bool | readLineFromFile (std::string &line, bool log=false) |
Reads a line to the Text File. | |
bool | open (const std::string &fileName, const Mode &mode=Mode::Read, bool log=false) override |
Opens the given file as a text file. | |
bool | close (bool log=false) override |
Closes current text file stream. | |
![]() | |
File (const File &file)=default | |
std::string | getCurrentDirectory () |
Returns the current directory, the program is running in. | |
std::vector< std::string > & | getListOfFiles (const std::string &extension="") |
Returns list of files present in the current directory. | |
void | Log () override |
Override this function to specify logging behavior. | |
![]() | |
void | setColour (const ColourType &colourType) |
This function allows you to set text colour for the text to be printed onto the console. | |
![]() | |
TextFormat (const TextFormat &textFormat)=default | |
void | Log () override |
Implement this method in the derived class to specify logging behaviour. | |
std::string & | getFormatName () |
Return the format name. | |
std::string & | getUniqueIdentifier () |
Return the unique identifier for the text format. | |
std::string & | getExtensionName () |
Returns the extension name. | |
void | setExtensionName (const std::string &extensionName) |
Sets the extension name. | |
void | setUniqueIdentifier (const std::string &uniqueIdentifier) |
Sets the unique identifier for the text format. | |
void | setFormatName (const std::string &formatName) |
Sets the format name. | |
![]() | |
std::unique_ptr< std::ofstream > | fileWriter |
std::unique_ptr< std::ifstream > | fileReader |
std::string | fileName |
std::string | fileExtension |
std::string | errorMessage |
Mode | mode |
![]() | |
std::string | formatName |
std::string | uniqueIdentifier |
std::string | extensionName |
This class provides functionality to read and write CSV Files.
AuxPort::CSV::CSV | ( | ) |
Definition at line 278 of file AuxFile.cpp.
void AuxPort::CSV::addDataRow | ( | const std::vector< std::string > & | dataRow | ) |
|
virtual |
Closes the stream to currently opened CSV File.
Implements AuxPort::File.
Definition at line 292 of file AuxFile.cpp.
bool AuxPort::CSV::getDataRow | ( | std::vector< std::string > & | dataRow, |
size_t | rowNum ) |
Reads a specific data row from the file.
Definition at line 322 of file AuxFile.cpp.
|
overridevirtual |
bool AuxPort::CSV::open | ( | const std::string & | fileName, |
const Mode & | mode = Mode::Read, | ||
bool | containsHeader = false, | ||
const char & | delimiter = ',', | ||
bool | log = false ) |
Definition at line 285 of file AuxFile.cpp.
void AuxPort::CSV::read | ( | std::vector< std::vector< std::string > > & | data | ) |
Reads data from a CSV file and stores it in the 2-d Vector.
Definition at line 297 of file AuxFile.cpp.
void AuxPort::CSV::read | ( | std::vector< std::vector< std::string > > & | data, |
std::vector< std::string > & | headers ) |
Reads data from a CSV file.
Definition at line 304 of file AuxFile.cpp.
void AuxPort::CSV::setHeader | ( | const std::vector< std::string > & | header | ) |
void AuxPort::CSV::write | ( | ) |
Writes a CSV file using information set through addDataRow(), setHeader() functions.
Definition at line 341 of file AuxFile.cpp.
void AuxPort::CSV::write | ( | const std::vector< std::vector< std::string > > & | data, |
const std::vector< std::string > & | header = std::vector<std::string>() ) |
Writes a CSV file with the given data and header rows.
Definition at line 366 of file AuxFile.cpp.