MPEG CDVA Experimentation Model (CXM)  1.0
Compact Descriptors for Visual Analisys
Public Member Functions
mpeg7cdva::Buffer Class Reference

A container class for a byte array, intended to replace all malloc() and new() instructions in the main code. More...

#include <Buffer.h>

Public Member Functions

 Buffer ()
 
virtual ~Buffer ()
 
 Buffer (size_t size)
 create a buffer of the given size More...
 
 Buffer (unsigned char *data, size_t size)
 copy the given array into this Buffer More...
 
 Buffer (const Buffer &)
 copy the given Buffer into this Buffer More...
 
Bufferoperator= (const Buffer &)
 assign a Buffer to another More...
 
void swap (Buffer &x)
 swap the content of two Buffer(s) More...
 
void fill (unsigned char value=0)
 fill a Buffer with the given value More...
 
size_t size () const
 return the current size of the Buffer More...
 
bool resize (size_t newsize)
 change buffer size; content is lost if newsize if less than the current size More...
 
bool empty () const
 return true if the Buffer is empty More...
 
void clear ()
 clear the Buffer More...
 
bool assign (const unsigned char *data, size_t size)
 assign the given data to Buffer More...
 
bool equals (Buffer &buffer)
 compare if two Buffer(s) are equal (i.e. if they have the same size and contain the same data) More...
 
unsigned char * data ()
 access to Buffer's data as unsigned char (writable) More...
 
const unsigned char * data () const
 access to Buffer's data as unsigned char (read only) More...
 
char * sdata ()
 access to Buffer's data as signed char (writable) More...
 
const char * sdata () const
 access to Buffer's data as signed char (read only) More...
 
void read (const char *fname)
 read Buffer from a file More...
 
void write (const char *fname) const
 write Buffer to file More...
 
int compare (const Buffer &other) const
 Compare this buffer with another; return the number of different bytes. More...
 
bool operator== (const Buffer &other) const
 compare if two Buffer(s) are equal (i.e. if they have the same size and contain the same data) More...
 

Detailed Description

A container class for a byte array, intended to replace all malloc() and new() instructions in the main code.

This class properly deallocates memory when an exception is thrown.

Author
Massimo Balestri
Date
2013

Constructor & Destructor Documentation

◆ Buffer() [1/4]

mpeg7cdva::Buffer::Buffer ( )

◆ ~Buffer()

virtual mpeg7cdva::Buffer::~Buffer ( )
virtual

◆ Buffer() [2/4]

mpeg7cdva::Buffer::Buffer ( size_t  size)

create a buffer of the given size

◆ Buffer() [3/4]

mpeg7cdva::Buffer::Buffer ( unsigned char *  data,
size_t  size 
)

copy the given array into this Buffer

◆ Buffer() [4/4]

mpeg7cdva::Buffer::Buffer ( const Buffer )

copy the given Buffer into this Buffer

Member Function Documentation

◆ assign()

bool mpeg7cdva::Buffer::assign ( const unsigned char *  data,
size_t  size 
)

assign the given data to Buffer

◆ clear()

void mpeg7cdva::Buffer::clear ( )

clear the Buffer

◆ compare()

int mpeg7cdva::Buffer::compare ( const Buffer other) const

Compare this buffer with another; return the number of different bytes.

Parameters
otherthe other Buffer
Returns
the number of differences; zero if no difference is found.

◆ data() [1/2]

unsigned char* mpeg7cdva::Buffer::data ( )

access to Buffer's data as unsigned char (writable)

◆ data() [2/2]

const unsigned char* mpeg7cdva::Buffer::data ( ) const

access to Buffer's data as unsigned char (read only)

◆ empty()

bool mpeg7cdva::Buffer::empty ( ) const

return true if the Buffer is empty

◆ equals()

bool mpeg7cdva::Buffer::equals ( Buffer buffer)

compare if two Buffer(s) are equal (i.e. if they have the same size and contain the same data)

◆ fill()

void mpeg7cdva::Buffer::fill ( unsigned char  value = 0)

fill a Buffer with the given value

◆ operator=()

Buffer& mpeg7cdva::Buffer::operator= ( const Buffer )

assign a Buffer to another

◆ operator==()

bool mpeg7cdva::Buffer::operator== ( const Buffer other) const

compare if two Buffer(s) are equal (i.e. if they have the same size and contain the same data)

◆ read()

void mpeg7cdva::Buffer::read ( const char *  fname)

read Buffer from a file

◆ resize()

bool mpeg7cdva::Buffer::resize ( size_t  newsize)

change buffer size; content is lost if newsize if less than the current size

◆ sdata() [1/2]

char* mpeg7cdva::Buffer::sdata ( )

access to Buffer's data as signed char (writable)

◆ sdata() [2/2]

const char* mpeg7cdva::Buffer::sdata ( ) const

access to Buffer's data as signed char (read only)

◆ size()

size_t mpeg7cdva::Buffer::size ( ) const

return the current size of the Buffer

◆ swap()

void mpeg7cdva::Buffer::swap ( Buffer x)

swap the content of two Buffer(s)

◆ write()

void mpeg7cdva::Buffer::write ( const char *  fname) const

write Buffer to file


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