14 using std::stringstream;
29 ifstream file(filename.c_str());
34 while (getline(file, line)) {
35 pair<string, string> parsedLine =
ParseLine(line);
46 ofstream file(filename.c_str());
50 vector<pair<string, string> >::const_iterator lineIter;
81 stringstream valueStream;
82 valueStream.precision(16);
83 valueStream << value << flush;
89 stringstream valueStream;
90 valueStream << value << flush;
97 string::size_type delimiter = line.find_first_of(
" ");
98 if (delimiter != string::npos) {
99 key = line.substr(0, delimiter);
100 value = line.substr(delimiter + 1);
105 return make_pair(key, value);
110 string line = parsedLine.first +
" " + parsedLine.second;
Class to handle input and output for text files.
std::string GetValue(std::string key)
Retrieve value associated with a key.
std::pair< std::string, std::string > ParseLine(const std::string &line)
Parse a line of a text file, splitting at a delimiter.
bool ReadFile(std::string filename)
Read file, returns true if successful.
std::vector< std::pair< std::string, std::string > > fFileLines
Contents of text file, line by line.
std::string BuildLine(const std::pair< std::string, std::string > &parsedLine)
Build a line from a key and value, inserting a delimiter.
std::map< std::string, std::string > fFileMap
Contents of text file, useful for unique keys.
bool WriteFile(std::string filename)
Write file, returns true if successful.
bool DoesKeyExist(std::string key)
Return true if key exists.
void AppendLine(std::string key="", std::string value="")
Append a key and value to the file.
QGTextFileHandler()
Constructor.
virtual ~QGTextFileHandler()
Destructor.