Empirical
|
A class to maintin files for loading, writing, storing, and easy access to components. More...
#include <File.h>
Public Member Functions | |
File () | |
File (std::istream &input) | |
File (const std::string &filename) | |
File (const File &)=default | |
File (File &&)=default | |
~File () | |
File & | operator= (const File &)=default |
File & | operator= (File &&)=default |
auto | begin () const |
Return const iterator to beginning of file. More... | |
auto | end () const |
Return const iterator to end of file. More... | |
auto | begin () |
Return iterator to beginning of file. More... | |
auto | end () |
Return iterator to end of file. More... | |
size_t | GetNumLines () const |
How many lines are in this file? More... | |
size_t | size () const |
Compatibility with size() More... | |
std::string & | operator[] (size_t pos) |
Index into a specific line in this file. More... | |
const std::string & | operator[] (size_t pos) const |
Const index into a specific line in this file. More... | |
std::string & | front () |
Return the first line in the file. More... | |
const std::string & | front () const |
Return a const reference to to the first line in the file. More... | |
std::string & | back () |
Return the last line in the file. More... | |
const std::string & | back () const |
Return a const reference to the last line in the file. More... | |
File & | Append (const std::string &line) |
Append a new line to the end of the file. More... | |
File & | Append (const emp::vector< std::string > &in_lines) |
Append a vector of lines to the end of the file. More... | |
File & | Append (const File &in_file) |
Join two files. More... | |
template<typename T > | |
File & | operator+= (T &&in) |
Append to the end of a file. More... | |
template<typename T > | |
auto | operator<< (T &&in) |
auto | operator>> (std::string &out) |
Extract first line from file. More... | |
bool | operator== (const File in) |
Test if two files are identical. More... | |
bool | operator!= (const File in) |
Test if two files are different. More... | |
File & | LoadLine (std::istream &input) |
Load a line from an input stream into a file. More... | |
File & | Load (std::istream &input) |
Load an entire input stream into a file. More... | |
File & | Load (const std::string &filename) |
File & | Write (std::ostream &output) |
Write this file to a provided output stream. More... | |
File & | Write (const std::string &filename) |
Write this file to a file of the provided name. More... | |
std::set< std::string > | AsSet () const |
Convert this file into an std::set of lines (loses line ordering). More... | |
File & | Apply (const std::function< void(std::string &)> &fun) |
Apply a string manipulation function to all lines in the file. More... | |
File & | KeepIf (const std::function< bool(const std::string &)> &fun) |
Purge functions that don't meet a certain criterion. More... | |
File & | RemoveEmpty () |
Remove all lines that are empty strings. More... | |
File & | CompressWhitespace () |
File & | RemoveWhitespace (bool keep_newlines=true) |
Delete all whitespace; by default keep newlines. More... | |
File & | RemoveComments (const std::string &marker) |
A technique to remove all comments in a file. More... | |
template<typename T > | |
emp::vector< T > | Process (const std::function< T(std::string &)> &fun) |
emp::vector< std::string > | ExtractCol (char delim=',') |
template<typename T > | |
emp::vector< T > | ExtractColAs (char delim=',') |
Protected Attributes | |
emp::vector< std::string > | lines |
A class to maintin files for loading, writing, storing, and easy access to components.
|
inline |
|
inline |
|
inline |
|
default |
|
default |
|
inline |
|
inline |
Append a new line to the end of the file.
|
inline |
Append a vector of lines to the end of the file.
|
inline |
Apply a string manipulation function to all lines in the file.
|
inline |
Convert this file into an std::set of lines (loses line ordering).
|
inline |
Return the last line in the file.
|
inline |
Return a const reference to the last line in the file.
|
inline |
Return const iterator to beginning of file.
|
inline |
Return iterator to beginning of file.
|
inline |
Any time multiple whitespaces are next to each other, collapse to a single WS char. Prefer '
' if in whitespace collapsed, otherwise use ' '.
|
inline |
Return const iterator to end of file.
|
inline |
Return iterator to end of file.
|
inline |
|
inline |
|
inline |
Return the first line in the file.
|
inline |
Return a const reference to to the first line in the file.
|
inline |
How many lines are in this file?
|
inline |
Purge functions that don't meet a certain criterion.
|
inline |
Load an entire input stream into a file.
|
inline |
Load a file from disk using the provided name. If file does not exist, this is a nop
|
inline |
Load a line from an input stream into a file.
|
inline |
Test if two files are different.
|
inline |
Append to the end of a file.
|
inline |
Insert formatted data into file This is exactly the same as operator+=
|
inline |
Test if two files are identical.
|
inline |
Extract first line from file.
|
inline |
Index into a specific line in this file.
|
inline |
Const index into a specific line in this file.
|
inline |
Run a function on each line of a file and return the restults as a vector. Note: Function is allowed to modify string.
|
inline |
A technique to remove all comments in a file.
|
inline |
Remove all lines that are empty strings.
|
inline |
Delete all whitespace; by default keep newlines.
|
inline |
Compatibility with size()
|
inline |
Write this file to a provided output stream.
|
inline |
Write this file to a file of the provided name.
|
protected |