AuxPort 0.2
Modules for Audio Software Development
Loading...
Searching...
No Matches
AuxPort::TextFile Class Reference

Abstraction over C++ Standard File Handling for ASCII based Text Files. More...

#include <AuxFile.h>

Inheritance diagram for AuxPort::TextFile:
AuxPort::File AuxPort::ILog AuxPort::AuxPascal AuxPort::AuxSeries AuxPort::CSV AuxPort::AuxSeriesEngine

Public Member Functions

 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.
 
- Public Member Functions inherited from AuxPort::File
 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.
 

Additional Inherited Members

- Public Types inherited from AuxPort::File
enum  Mode { Idle = 0 , Read = 1 , Write = 2 }
 Easy way to specify the Read/Write behavior of the File Stream. More...
 
- Protected Member Functions inherited from AuxPort::ILog
void setColour (const ColourType &colourType)
 This function allows you to set text colour for the text to be printed onto the console.
 
- Protected Attributes inherited from AuxPort::File
std::unique_ptr< std::ofstream > fileWriter
 
std::unique_ptr< std::ifstream > fileReader
 
std::string fileName
 
std::string fileExtension
 
std::string errorMessage
 
Mode mode
 

Detailed Description

Abstraction over C++ Standard File Handling for ASCII based Text Files.

For Example :

AuxPort::TextFile textFile();
Abstraction over C++ Standard File Handling for ASCII based Text Files.
Definition AuxFile.h:240

Definition at line 239 of file AuxFile.h.

Member Function Documentation

◆ close()

bool AuxPort::TextFile::close ( bool log = false)
overridevirtual

Closes current text file stream.

Implements AuxPort::File.

Definition at line 158 of file AuxFile.cpp.

◆ open()

bool AuxPort::TextFile::open ( const std::string & fileName,
const Mode & mode = Mode::Read,
bool log = false )
overridevirtual

Opens the given file as a text file.

Implements AuxPort::File.

Definition at line 102 of file AuxFile.cpp.

◆ readFileAsString()

std::string & AuxPort::TextFile::readFileAsString ( )

Reads the entire text file and saves it in a String.

Definition at line 191 of file AuxFile.cpp.

◆ readLineFromFile()

bool AuxPort::TextFile::readLineFromFile ( std::string & line,
bool log = false )

Reads a line to the Text File.

Definition at line 212 of file AuxFile.cpp.

◆ writeLineToFile()

void AuxPort::TextFile::writeLineToFile ( const std::string & data,
bool log = false )

Writes a line to the Text File.

Definition at line 203 of file AuxFile.cpp.


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