Class CFileInputStream
Defined in File CFileInputStream.h
Inheritance Relationships
Base Type
public mrpt::io::CStream(Class CStream)
Class Documentation
-
class CFileInputStream : public mrpt::io::CStream
This CStream derived class allow using a file as a read-only, binary stream.
See also
Public Functions
-
CFileInputStream(const std::string &fileName)
Constructor
- Parameters:
fileName – The file to be open in this stream
- Throws:
std::exception – On error trying to open the file.
-
CFileInputStream()
Default constructor
-
CFileInputStream(const CFileInputStream&) = delete
-
CFileInputStream &operator=(const CFileInputStream&) = delete
-
~CFileInputStream() override
-
bool open(const std::string &fileName)
Open a file for reading
- Parameters:
fileName – The file to be open in this stream
- Returns:
true on success.
-
void close()
Close the stream
-
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
-
inline bool is_open()
Returns true if the file was open without errors.
-
bool checkEOF()
Will be true if EOF has been already reached.
-
void clearError()
Resets stream error status bits (e.g. after an EOF)
-
virtual std::string getStreamDescription() const override
Returns a human-friendly description of the stream, e.g. a filename.
-
virtual uint64_t Seek(int64_t off, CStream::TSeekOrigin Origin = sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource. he Origin parameter indicates how to interpret the Offset parameter. Origin should be one of the following values:
sFromBeginning (Default) Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0.
sFromCurrent Offset is from the current position in the resource. Seek moves to Position + Offset.
sFromEnd Offset is from the end of the resource. Offset must be <= 0 to indicate a number of bytes before the end of the file.
- Returns:
Seek returns the new value of the Position property.
-
virtual uint64_t getTotalBytesCount() const override
Returns the total amount of bytes in the stream.
-
virtual uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.
-
bool readLine(std::string &str)
Reads one string line from the file (until a new-line character)
- Returns:
true if a line has been read, false on EOF or error.
-
virtual size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
-
virtual size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream. Write attempts to write up to Count bytes to Buffer, and returns the number of bytes actually written.
-
CFileInputStream(const std::string &fileName)