28 typedef std::vector<std::string>::iterator
Iterator;
54 TextFile(
const std::string& filename,
bool trim_lines =
false,
Int first_n = -1,
bool skip_empty_lines =
false,
const std::string& comment_symbol =
"");
69 void load(
const std::string& filename,
bool trim_lines =
false,
Int first_n = -1,
bool skip_empty_lines =
false,
const std::string& comment_symbol =
"");
80 void store(
const std::string& filename);
83 template <
typename StringType>
86 buffer_.push_back(
static_cast<std::string
>(
string));
90 template <
typename StringType>
93 buffer_.push_back(
static_cast<std::string
>(line));
102 static std::istream&
getLine(std::istream& is, std::string& t);
void addLine(const StringType &line)
Definition TextFile.h:91
ConstIterator end() const
Gives access to the underlying text buffer.
std::vector< std::string >::reverse_iterator ReverseIterator
Mutable reverse iterator.
Definition TextFile.h:32
std::vector< std::string >::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition TextFile.h:34
std::vector< std::string >::const_iterator ConstIterator
Non-mutable iterator.
Definition TextFile.h:30
void store(const std::string &filename)
Writes the data to a file.
std::vector< std::string > buffer_
Internal buffer storing the lines before writing them to the file.
Definition TextFile.h:119
TextFile & operator<<(const StringType &string)
Operator for appending entries with less code.
Definition TextFile.h:84
static std::istream & getLine(std::istream &is, std::string &t)
Platform-agnostic getline() which can deal with all line endings (\r, \r\n, \n)
ConstIterator begin() const
Gives access to the underlying text buffer.
TextFile(const std::string &filename, bool trim_lines=false, Int first_n=-1, bool skip_empty_lines=false, const std::string &comment_symbol="")
Constructor with filename.
void load(const std::string &filename, bool trim_lines=false, Int first_n=-1, bool skip_empty_lines=false, const std::string &comment_symbol="")
Loads data from a text file into the internal buffer.
std::vector< std::string >::iterator Iterator
Mutable iterator.
Definition TextFile.h:28