Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
rosbag::ChunkedFile Class Reference

ChunkedFile reads and writes files which contain interleaved chunks of compressed and uncompressed data. More...

#include <chunked_file.h>

Public Member Functions

 ChunkedFile ()
 
void close ()
 close the file More...
 
void decompress (CompressionType compression, uint8_t *dest, unsigned int dest_len, uint8_t *source, unsigned int source_len)
 
uint32_t getCompressedBytesIn () const
 return the number of bytes written to current compressed stream More...
 
std::string getFileName () const
 return path of currently open file More...
 
std::string getline ()
 
uint64_t getOffset () const
 return current offset from the beginning of the file More...
 
bool good () const
 return true if hasn't reached end-of-file and no error More...
 
bool isOpen () const
 return true if file is open for reading or writing More...
 
void openRead (std::string const &filename)
 open file for reading More...
 
void openReadWrite (std::string const &filename)
 open file for reading & writing More...
 
void openWrite (std::string const &filename)
 open file for writing More...
 
void read (void *ptr, size_t size)
 read size bytes from the file into ptr More...
 
void seek (uint64_t offset, int origin=std::ios_base::beg)
 seek to given offset from origin More...
 
void setReadMode (CompressionType type)
 
void setWriteMode (CompressionType type)
 
void swap (ChunkedFile &other)
 
bool truncate (uint64_t length)
 
void write (std::string const &s)
 
void write (void *ptr, size_t size)
 write size bytes from ptr to the file More...
 
 ~ChunkedFile ()
 

Private Member Functions

 ChunkedFile (const ChunkedFile &)
 
void clearUnused ()
 
void open (std::string const &filename, std::string const &mode)
 
ChunkedFileoperator= (const ChunkedFile &)
 

Private Attributes

uint64_t compressed_in_
 number of bytes written to current compressed stream More...
 
FILE * file_
 file pointer More...
 
std::string filename_
 path to file More...
 
int nUnused_
 number of bytes of extra data read by compressed stream More...
 
uint64_t offset_
 current position in the file More...
 
boost::shared_ptr< Streamread_stream_
 
boost::shared_ptr< StreamFactorystream_factory_
 
char * unused_
 extra data read by compressed stream More...
 
boost::shared_ptr< Streamwrite_stream_
 

Friends

class Stream
 

Detailed Description

ChunkedFile reads and writes files which contain interleaved chunks of compressed and uncompressed data.

Definition at line 51 of file chunked_file.h.

Constructor & Destructor Documentation

◆ ChunkedFile() [1/2]

rosbag::ChunkedFile::ChunkedFile ( )

Definition at line 64 of file chunked_file.cpp.

◆ ~ChunkedFile()

rosbag::ChunkedFile::~ChunkedFile ( )

Definition at line 74 of file chunked_file.cpp.

◆ ChunkedFile() [2/2]

rosbag::ChunkedFile::ChunkedFile ( const ChunkedFile )
private

Member Function Documentation

◆ clearUnused()

void rosbag::ChunkedFile::clearUnused ( )
private

Definition at line 225 of file chunked_file.cpp.

◆ close()

void rosbag::ChunkedFile::close ( )

close the file

Definition at line 137 of file chunked_file.cpp.

◆ decompress()

void rosbag::ChunkedFile::decompress ( CompressionType  compression,
uint8_t *  dest,
unsigned int  dest_len,
uint8_t *  source,
unsigned int  source_len 
)

Definition at line 221 of file chunked_file.cpp.

◆ getCompressedBytesIn()

uint32_t rosbag::ChunkedFile::getCompressedBytesIn ( ) const

return the number of bytes written to current compressed stream

Definition at line 197 of file chunked_file.cpp.

◆ getFileName()

string rosbag::ChunkedFile::getFileName ( ) const

return path of currently open file

Definition at line 135 of file chunked_file.cpp.

◆ getline()

string rosbag::ChunkedFile::getline ( )
Todo:
add error handling

Definition at line 209 of file chunked_file.cpp.

◆ getOffset()

uint64_t rosbag::ChunkedFile::getOffset ( ) const

return current offset from the beginning of the file

Definition at line 196 of file chunked_file.cpp.

◆ good()

bool rosbag::ChunkedFile::good ( ) const

return true if hasn't reached end-of-file and no error

Definition at line 130 of file chunked_file.cpp.

◆ isOpen()

bool rosbag::ChunkedFile::isOpen ( ) const

return true if file is open for reading or writing

Definition at line 134 of file chunked_file.cpp.

◆ open()

void rosbag::ChunkedFile::open ( std::string const &  filename,
std::string const &  mode 
)
private

Definition at line 82 of file chunked_file.cpp.

◆ openRead()

void rosbag::ChunkedFile::openRead ( std::string const &  filename)

open file for reading

Definition at line 80 of file chunked_file.cpp.

◆ openReadWrite()

void rosbag::ChunkedFile::openReadWrite ( std::string const &  filename)

open file for reading & writing

Definition at line 78 of file chunked_file.cpp.

◆ openWrite()

void rosbag::ChunkedFile::openWrite ( std::string const &  filename)

open file for writing

Definition at line 79 of file chunked_file.cpp.

◆ operator=()

ChunkedFile& rosbag::ChunkedFile::operator= ( const ChunkedFile )
private

◆ read()

void rosbag::ChunkedFile::read ( void *  ptr,
size_t  size 
)

read size bytes from the file into ptr

Definition at line 201 of file chunked_file.cpp.

◆ seek()

void rosbag::ChunkedFile::seek ( uint64_t  offset,
int  origin = std::ios_base::beg 
)

seek to given offset from origin

Definition at line 183 of file chunked_file.cpp.

◆ setReadMode()

void rosbag::ChunkedFile::setReadMode ( CompressionType  type)

Definition at line 171 of file chunked_file.cpp.

◆ setWriteMode()

void rosbag::ChunkedFile::setWriteMode ( CompressionType  type)

Definition at line 159 of file chunked_file.cpp.

◆ swap()

void rosbag::ChunkedFile::swap ( ChunkedFile other)

Definition at line 230 of file chunked_file.cpp.

◆ truncate()

bool rosbag::ChunkedFile::truncate ( uint64_t  length)

Definition at line 203 of file chunked_file.cpp.

◆ write() [1/2]

void rosbag::ChunkedFile::write ( std::string const &  s)

◆ write() [2/2]

void rosbag::ChunkedFile::write ( void *  ptr,
size_t  size 
)

write size bytes from ptr to the file

Definition at line 200 of file chunked_file.cpp.

Friends And Related Function Documentation

◆ Stream

friend class Stream
friend

Definition at line 53 of file chunked_file.h.

Member Data Documentation

◆ compressed_in_

uint64_t rosbag::ChunkedFile::compressed_in_
private

number of bytes written to current compressed stream

Definition at line 95 of file chunked_file.h.

◆ file_

FILE* rosbag::ChunkedFile::file_
private

file pointer

Definition at line 93 of file chunked_file.h.

◆ filename_

std::string rosbag::ChunkedFile::filename_
private

path to file

Definition at line 92 of file chunked_file.h.

◆ nUnused_

int rosbag::ChunkedFile::nUnused_
private

number of bytes of extra data read by compressed stream

Definition at line 97 of file chunked_file.h.

◆ offset_

uint64_t rosbag::ChunkedFile::offset_
private

current position in the file

Definition at line 94 of file chunked_file.h.

◆ read_stream_

boost::shared_ptr<Stream> rosbag::ChunkedFile::read_stream_
private

Definition at line 101 of file chunked_file.h.

◆ stream_factory_

boost::shared_ptr<StreamFactory> rosbag::ChunkedFile::stream_factory_
private

Definition at line 99 of file chunked_file.h.

◆ unused_

char* rosbag::ChunkedFile::unused_
private

extra data read by compressed stream

Definition at line 96 of file chunked_file.h.

◆ write_stream_

boost::shared_ptr<Stream> rosbag::ChunkedFile::write_stream_
private

Definition at line 102 of file chunked_file.h.


The documentation for this class was generated from the following files:


rosbag_storage
Author(s): Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:55