zz::fs::FileReader Class Reference
The FileReader class for read-only operations. This class is derived from UnCopyable, so no copy operation. Move operation is allowed by std::move();. More...
#include <zupply.hpp>
Inheritance diagram for zz::fs::FileReader:
Public Member Functions | |
FileReader (std::string filename, int retryTimes=consts::kDefaultFileOpenRetryTimes, int retryInterval=consts::kDefaultFileOpenRetryInterval) | |
FileReader constructor. More... | |
std::string | filename () const |
FileReader move constructor. More... | |
bool | is_open () const |
Check if is opened. More... | |
bool | is_valid () const |
Check if valid filename is set. More... | |
void | close () |
Close file handler. | |
std::size_t | file_size () |
Get file size in byte, member function. More... | |
std::size_t | count_lines () |
Count number of lines in text file. More... | |
std::string | next_line (bool trimWhiteSpaces=false) |
Get next line. More... | |
int | goto_line (int n) |
Count number of lines in text file If reached end of file, will return the number of lines. More... | |
Detailed Description
The FileReader class for read-only operations. This class is derived from UnCopyable, so no copy operation. Move operation is allowed by std::move();.
Constructor & Destructor Documentation
zz::fs::FileReader::FileReader | ( | std::string | filename, |
int | retryTimes = consts::kDefaultFileOpenRetryTimes , |
||
int | retryInterval = consts::kDefaultFileOpenRetryInterval |
||
) |
FileReader constructor.
- Parameters
-
filename retryTimes Retry open times retryInterval Retry interval in ms
Member Function Documentation
std::size_t zz::fs::FileReader::count_lines | ( | ) |
Count number of lines in text file.
- Returns
- Number of lines
std::size_t zz::fs::FileReader::file_size | ( | ) |
Get file size in byte, member function.
- Returns
- File size in byte
|
inline |
int zz::fs::FileReader::goto_line | ( | int | n | ) |
Count number of lines in text file If reached end of file, will return the number of lines.
- Parameters
-
n Line # to jump to
- Returns
- -1 if failed, otherwise return the position actually jumped to
|
inline |
Check if is opened.
- Returns
- True if opened
|
inline |
Check if valid filename is set.
- Returns
- True if valid
std::string zz::fs::FileReader::next_line | ( | bool | trimWhiteSpaces = false | ) |
Get next line.
- Parameters
-
trimWhitespaces Whether or not trim whitespaces
- Returns
- A std::string of the line
The documentation for this class was generated from the following files:
- zupply.hpp
- zupply.cpp