![]() |
Diana Software
|
Class to handle input and output for text files. More...
Public Member Functions | |
| QGTextFileHandler () | |
| Constructor. More... | |
| virtual | ~QGTextFileHandler () |
| Destructor. More... | |
| void | AppendLine (std::string key="", std::string value="") |
| Append a key and value to the file. More... | |
| void | AppendLine (std::string key, Double_t value) |
| Append a key and (Double_t) value to the file. More... | |
| void | AppendLine (std::string key, Int_t value) |
| Append a key and (Int_t) value to the file. More... | |
| bool | DoesKeyExist (std::string key) |
| Return true if key exists. More... | |
| const std::vector< std::pair< std::string, std::string > > & | GetLines () |
| Get the lines of the file as key, value pairs. More... | |
| std::string | GetValue (std::string key) |
| Retrieve value associated with a key. More... | |
| bool | ReadFile (std::string filename) |
| Read file, returns true if successful. More... | |
| bool | WriteFile (std::string filename) |
| Write file, returns true if successful. More... | |
Private Member Functions | |
| std::pair< std::string, std::string > | ParseLine (const std::string &line) |
| Parse a line of a text file, splitting at a delimiter. More... | |
| std::string | BuildLine (const std::pair< std::string, std::string > &parsedLine) |
| Build a line from a key and value, inserting a delimiter. More... | |
Private Attributes | |
| std::map< std::string, std::string > | fFileMap |
| Contents of text file, useful for unique keys. More... | |
| std::vector< std::pair< std::string, std::string > > | fFileLines |
| Contents of text file, line by line. More... | |
Class to handle input and output for text files.
Definition at line 17 of file QGTextFileHandler.hh.
| QGTextFileHandler::QGTextFileHandler | ( | ) |
Constructor.
Definition at line 17 of file QGTextFileHandler.cc.
|
virtual |
Destructor.
Definition at line 21 of file QGTextFileHandler.cc.
| void QGTextFileHandler::AppendLine | ( | std::string | key, |
| Double_t | value | ||
| ) |
Append a key and (Double_t) value to the file.
| void QGTextFileHandler::AppendLine | ( | std::string | key, |
| Int_t | value | ||
| ) |
Append a key and (Int_t) value to the file.
| void QGTextFileHandler::AppendLine | ( | std::string | key = "", |
| std::string | value = "" |
||
| ) |
Append a key and value to the file.
Referenced by QGCutsEditorWindow::Save(), and QGDefaultsHandler::SaveToFile().
|
private |
Build a line from a key and value, inserting a delimiter.
Definition at line 108 of file QGTextFileHandler.cc.
Referenced by WriteFile().
| bool QGTextFileHandler::DoesKeyExist | ( | std::string | key | ) |
Return true if key exists.
Definition at line 59 of file QGTextFileHandler.cc.
References fFileMap.
Referenced by GetValue(), QGDefaultsHandler::LoadFromFile(), and QGFileHandler::ParseFileList().
|
inline |
Get the lines of the file as key, value pairs.
Definition at line 38 of file QGTextFileHandler.hh.
References fFileLines.
Referenced by QGFileHandler::ParseFileList().
| string QGTextFileHandler::GetValue | ( | std::string | key | ) |
Retrieve value associated with a key.
Definition at line 64 of file QGTextFileHandler.cc.
References DoesKeyExist(), and fFileMap.
Referenced by QGDefaultsHandler::LoadFromFile(), and QGFileHandler::ParseFileList().
|
private |
Parse a line of a text file, splitting at a delimiter.
Definition at line 94 of file QGTextFileHandler.cc.
Referenced by ReadFile().
| bool QGTextFileHandler::ReadFile | ( | std::string | filename | ) |
Read file, returns true if successful.
Definition at line 25 of file QGTextFileHandler.cc.
References fFileLines, fFileMap, ParseLine(), and success.
Referenced by QGDefaultsHandler::LoadFromFile(), and QGFileHandler::ParseFileList().
| bool QGTextFileHandler::WriteFile | ( | std::string | filename | ) |
Write file, returns true if successful.
Definition at line 44 of file QGTextFileHandler.cc.
References BuildLine(), fFileLines, and success.
Referenced by QGCutsEditorWindow::Save(), and QGDefaultsHandler::SaveToFile().
|
private |
Contents of text file, line by line.
Definition at line 60 of file QGTextFileHandler.hh.
Referenced by GetLines(), ReadFile(), and WriteFile().
|
private |
Contents of text file, useful for unique keys.
Definition at line 57 of file QGTextFileHandler.hh.
Referenced by DoesKeyExist(), GetValue(), and ReadFile().