23 if (!
open(fileName, append))
25 "Error creating/opening for write file: '%s'", fileName.c_str());
36 ios_base::openmode openMode = ios_base::binary |
ios_base::out;
37 if (append) openMode |= ios_base::app;
39 m_of.open(fileName.c_str(), openMode);
40 return m_of.is_open();
50 [[maybe_unused]]
void* Buffer, [[maybe_unused]]
size_t Count)
57 if (!
m_of.is_open())
return 0;
59 m_of.write(static_cast<const char*>(Buffer), Count);
60 return m_of.fail() ? 0 : Count;
65 if (!
m_of.is_open())
return 0;
67 ofstream::off_type offset = Offset;
68 ofstream::seekdir way;
85 m_of.seekp(offset, way);
93 auto& f =
const_cast<std::ofstream&
>(
m_of);
95 const uint64_t previousPos = f.tellp();
97 uint64_t fileSize = f.tellp();
98 f.seekp(previousPos, ios_base::beg);
104 auto& f =
const_cast<std::ofstream&
>(
m_of);
TSeekOrigin
Used in CStream::Seek.
uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
#define THROW_EXCEPTION(msg)
uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource...
CFileOutputStream()
Default constructor.
std::ofstream m_of
The actual output file stream.
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
bool open(const std::string &fileName, bool append=false)
Open the given file for write.
const_iterator end() const
~CFileOutputStream() override
Destructor.
uint64_t getTotalBytesCount() const override
Method for getting the total number of bytes writen to buffer.
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
mrpt::vision::TStereoCalibResults out
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
void close()
Close the stream.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)