The class for file input streams.
More...
#include "nn/nlib/FileInputStream.h"
|
errno_t | Init () noexcept |
| Initializes the stream with the default settings. More...
|
|
errno_t | Init (const FileInputStreamSettings &settings) noexcept |
| Initializes a stream. More...
|
|
errno_t | Open (const char *filename) noexcept |
| Opens the file in read-only mode. More...
|
|
errno_t | Open (const wchar_t *filename) noexcept |
| Opens the file in read-only mode. More...
|
|
errno_t | FdOpen (nlib_fd fd) noexcept |
| Makes an already-open file available for use by FileInputStream . More...
|
|
nlib_fd | GetFd () const noexcept |
| Returns the file descriptor. More...
|
|
|
constexpr | FileInputStream () noexcept |
| Instantiates the object with default parameters (default constructor). The buffer must be set and initialized by the Init function ahead of time.
|
|
virtual | ~FileInputStream () noexcept override |
| Destructor. Closes the file if it is open.
|
|
errno_t | GetErrorValue () const noexcept |
| Gets the error value. More...
|
|
size_t | Pos () const noexcept |
| Returns the current position in the stream. More...
|
|
uint64_t | Pos64 () const noexcept |
| Returns the current position in the stream as a 64-bit value. More...
|
|
bool | IsEos () noexcept |
| Returns true if the stream is finished being read through to the end. If the stream has not been read through to the end, or if an error occurs, the function returns false . More...
|
|
int | Read () noexcept |
| Reads one byte of data from the stream. More...
|
|
int | Peek () noexcept |
| Reads the next byte without consuming the stream. More...
|
|
size_t | Skip (size_t nbytes) noexcept |
| Skips over the number of bytes specified by nbytes. More...
|
|
size_t | Read (void *ptr, size_t nbytes) noexcept |
| Reads the number of bytes of data specified by nbytes into the memory region specified by ptr. More...
|
|
bool | Close () noexcept |
| Closes the stream. Returns true if successful. More...
|
|
| operator bool () const |
| Returns true if no internal error has occurred.
|
|
constexpr | InputStream () noexcept |
| Instantiates the object. This function is called from the derived class.
|
|
virtual | ~InputStream () noexcept |
| Destructor. This function is called from the derived class.
|
|
The class for file input streams.
- Description
- Supports only synchronous and sequential access. The class wraps the file API of each environment and has its own buffer.
- The transition of the object state.
- The overview of the object state transitions is described below:
- Examples:
- misc/readfile/readfile.cpp, misc/writefile/writefile.cpp, succinct/detection/detection.cpp, and succinct/kwlink/kwlink.cpp.
Definition at line 34 of file FileInputStream.h.
◆ FdOpen()
nn::nlib::FileInputStream::FdOpen |
( |
nlib_fd |
fd | ) |
|
|
noexcept |
Makes an already-open file available for use by FileInputStream
.
- Parameters
-
[in] | fd | An already-open nlib_fd -type value. |
- Returns
- Returns
0
on success. Any other value indicates an error.
- Description
- If the
Init
function was not called ahead of time, it is called internally here.
◆ GetFd()
nn::nlib::FileInputStream::GetFd |
( |
| ) |
const |
|
inlinenoexcept |
Returns the file descriptor.
- Returns
- The file descriptor.
Definition at line 47 of file FileInputStream.h.
◆ Init() [1/2]
nn::nlib::FileInputStream::Init |
( |
| ) |
|
|
inlinenoexcept |
Initializes the stream with the default settings.
- Returns
- Returns
0
on success. Any other value indicates an error.
- Description
- The buffer that is used internally by the
FileInputStream
object is allocated from the heap in the default size.
Definition at line 39 of file FileInputStream.h.
◆ Init() [2/2]
Initializes a stream.
- Parameters
-
[in] | settings | The default options. |
- Returns
- Returns
0
on success. Any other value indicates an error.
- Description
- If the only the buffer size has been specified, the buffer is allocated from the heap.
◆ Open() [1/2]
nn::nlib::FileInputStream::Open |
( |
const char * |
filename | ) |
|
|
noexcept |
Opens the file in read-only mode.
- Parameters
-
[in] | filename | The path to the file. |
- Returns
- Returns
0
on success. Any other value indicates an error.
- Description
- If the
Init
function was not called ahead of time, it is called internally here.
◆ Open() [2/2]
nn::nlib::FileInputStream::Open |
( |
const wchar_t * |
filename | ) |
|
|
noexcept |
Opens the file in read-only mode.
- Parameters
-
[in] | filename | The path to the file. |
- Returns
- Returns
0
on success. Any other value indicates an error.
- Description
- If the
Init
function was not called ahead of time, it is called internally here.
The documentation for this class was generated from the following files: