Class FileReader
Defined in File FileReader.h
Class Documentation
-
class FileReader
Facilitates reading the data and weights files written by the FileWriter class.
Public Functions
-
FileReader(const std::string &file_path)
Construct a new FileReader object.
- Parameters
file_path – path to file to open for reading
-
~FileReader()
Destroy the FileReader object.
-
void open_file(const std::string &file_path)
Open the file.
- Parameters
file_path – path to file to open for reading
-
void close_file()
Close the currently opened file.
-
ssize_t read_header()
Read the ascii header from the currently open file.
- Returns
ssize_t number of bytes read from file
-
ssize_t read_data(char *data_ptr, uint64_t data_size)
Read data from the currently opened file.
- Parameters
data_ptr – pointer to the data to read from file
data_size – number of bytes to read into the pointer
- Returns
ssize_t number of bytes read from file
-
inline const ska::pst::common::AsciiHeader &get_header()
Get a const reference to the AsciiHeader that is populated when read_header is called.
- Returns
const ska::pst::common::AsciiHeader& header of the opened file
-
inline std::uintmax_t get_file_size()
Get the size of the file in bytes.
- Returns
std::uintmax_t size of the file in bytes
-
inline std::size_t get_obs_offset()
Get the obs offset of the current file, 0 if it is not specified in the header.
- Returns
std::size_t the offset, in bytes, from the start of the data stream
-
inline void _set_fd(int _fd)
Set the file descriptor to the specified value.
- Parameters
_fd – file descriptor to use to over-write the actual fd
-
inline int _get_fd()
Return the file descriptor of the opened file.
- Returns
int file descriptor of the opened file
-
FileReader(const std::string &file_path)