Main MRPT website > C++ reference
MRPT logo
Public Member Functions | Protected Member Functions | Private Attributes

mrpt::utils::CFileOutputStream Class Reference


Detailed Description

This CStream derived class allow using a file as a write-only, binary stream.

See also:
CStream, CFileStream, CFileGZOutputStream

Definition at line 46 of file CFileOutputStream.h.

#include <mrpt/utils/CFileOutputStream.h>

Inheritance diagram for mrpt::utils::CFileOutputStream:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CFileOutputStream (const std::string &fileName, bool append=false)
 Constructor.
 CFileOutputStream ()
 Default constructor.
bool open (const std::string &fileName, bool append=false)
 Open the given file for write.
void close ()
 Close the stream.
virtual ~CFileOutputStream ()
 Destructor.
bool fileOpenCorrectly ()
 Says if file was open successfully or not.
uint64_t Seek (long Offset, CStream::TSeekOrigin Origin=sFromBeginning)
 Method for moving to a specified position in the streamed resource.
uint64_t getTotalBytesCount ()
 Method for getting the total number of bytes writen to buffer.
uint64_t getPosition ()
 Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.

Protected Member Functions

size_t Read (void *Buffer, size_t Count)
 Method responsible for reading from the stream.
size_t Write (const void *Buffer, size_t Count)
 Method responsible for writing to the stream.

Private Attributes

std::ofstream m_of
 The actual output file stream.

Constructor & Destructor Documentation

mrpt::utils::CFileOutputStream::CFileOutputStream ( const std::string &  fileName,
bool  append = false 
)

Constructor.

Parameters:
fileNameThe file to be open in this stream
appendIf set to true, the file will be opened for writing and the current cursor position set at the end of the file. Otherwise, previous contents will be lost.
Exceptions:
std::exceptionif the file cannot be opened.
mrpt::utils::CFileOutputStream::CFileOutputStream (  )

Default constructor.

virtual mrpt::utils::CFileOutputStream::~CFileOutputStream (  ) [virtual]

Destructor.


Member Function Documentation

void mrpt::utils::CFileOutputStream::close (  )

Close the stream.

bool mrpt::utils::CFileOutputStream::fileOpenCorrectly (  )

Says if file was open successfully or not.

uint64_t mrpt::utils::CFileOutputStream::getPosition (  ) [virtual]

Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.

Implements mrpt::utils::CStream.

uint64_t mrpt::utils::CFileOutputStream::getTotalBytesCount (  ) [virtual]

Method for getting the total number of bytes writen to buffer.

Implements mrpt::utils::CStream.

bool mrpt::utils::CFileOutputStream::open ( const std::string &  fileName,
bool  append = false 
)

Open the given file for write.

Parameters:
fileNameThe file to be open in this stream
appendIf set to true, the file will be opened for writing and the current cursor position set at the end of the file. Otherwise, previous contents will be lost.
See also:
fileOpenCorrectly
Returns:
true on success.
size_t mrpt::utils::CFileOutputStream::Read ( void *  Buffer,
size_t  Count 
) [protected, virtual]

Method responsible for reading from the stream.

Implements mrpt::utils::CStream.

uint64_t mrpt::utils::CFileOutputStream::Seek ( long  Offset,
CStream::TSeekOrigin  Origin = sFromBeginning 
) [virtual]

Method for moving to a specified position in the streamed resource.

See documentation of CStream::Seek

Implements mrpt::utils::CStream.

size_t mrpt::utils::CFileOutputStream::Write ( const void *  Buffer,
size_t  Count 
) [protected, 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.

Implements mrpt::utils::CStream.


Member Data Documentation

std::ofstream mrpt::utils::CFileOutputStream::m_of [private]

The actual output file stream.

Definition at line 61 of file CFileOutputStream.h.




Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:46:17 UTC 2011