commore  1.0.6-SNAPSHOT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
commore::Blob Class Reference

#include <Blob.h>

Public Types

enum  { DEFAULT_BLOB_SIZE = 4096, NOT_OWNED_DATA = 0xFFFFFFFF }
 

Public Member Functions

 Blob ()
 
 Blob (const Blob &blob)
 
 Blob (size_t size, size_t allocated_size=0)
 
 Blob (const char *content, size_t size, size_t allocated_size=0)
 
Bloboperator= (const Blob &blob)
 
 ~Blob ()
 
void splice (Blob &blob)
 
char * get_content ()
 
const char * get_content () const
 
size_t get_size () const
 
size_t get_allocated_size () const
 
char * set (const char *content, size_t size, size_t allocated_size=0)
 
char * set (size_t size, size_t allocated_size=0)
 
char * set_allocated_size (size_t allocated_size)
 
void clear ()
 
long write_xml (OBStream &) const
 
long read_xml (IBStream &)
 
AStringto_string (AString &s)
 
bool from_string (const char *s)
 
long write (OBStream &, int tab) const
 
long read (IBStream &)
 
int write (const Path &file) const
 
int read (const Path &file)
 
long write (CommBuffer &buffer) const
 
long read (const CommBuffer &buffer)
 
int compare (const Blob &b) const
 
bool operator== (const Blob &b) const
 
bool operator< (const Blob &b) const
 
bool operator> (const Blob &b) const
 

Detailed Description

Manage raw memory block in order to exange them in commore communication. Blob and list of Blob are member of Tuple. allocated_size is automaticaly computed. The value can be rounded to optimize memory allocation.

Member Enumeration Documentation

anonymous enum
Enumerator
DEFAULT_BLOB_SIZE 
NOT_OWNED_DATA 

Constructor & Destructor Documentation

Blob::Blob ( )
Blob::Blob ( const Blob blob)
Blob::Blob ( size_t  size,
size_t  allocated_size = 0 
)

Create a blob with a size and a preallocated size

Parameters
sizeinitial block size
allocated_sizetotal allocated size.
Blob::Blob ( const char *  content,
size_t  size,
size_t  allocated_size = 0 
)

Create a blob with a pre-assigned content

Parameters
contentpointer to raw data
sizeinitial block size
allocated_sizetotal allocated size. if allocated_size == NOT_OWNED_DATA data pointed by content are not copied inside blob and blob content will reference directly the specified content.
Blob::~Blob ( )
Remarks
if allocated_size == NOT_OWNED_DATA data pointed by blob are not released.

Member Function Documentation

void Blob::clear ( )

Free blob content. Not if allocated_size == NOT_OWNED_DATA

int Blob::compare ( const Blob b) const

Compare blob content

bool Blob::from_string ( const char *  s)

Parse a blob content from a string (Use B64 format)

Parameters
sinput string
size_t commore::Blob::get_allocated_size ( ) const
inline
Returns
current allocaded size Notice: size < allocated_size
char* commore::Blob::get_content ( )
inline
Returns
a pointer to blob content. Notice that only data between [0 get_size()] can be modify.
const char* commore::Blob::get_content ( ) const
inline
Returns
const pointer to blob content.
size_t commore::Blob::get_size ( ) const
inline
Returns
current blob size
bool commore::Blob::operator< ( const Blob b) const
inline
Blob & Blob::operator= ( const Blob blob)
bool commore::Blob::operator== ( const Blob b) const
inline
bool commore::Blob::operator> ( const Blob b) const
inline
long commore::Blob::read ( IBStream )
int commore::Blob::read ( const Path file)

Read blob content from a file (raw format)

Parameters
file
long commore::Blob::read ( const CommBuffer buffer)
long Blob::read_xml ( IBStream i)
char * Blob::set ( const char *  content,
size_t  size,
size_t  allocated_size = 0 
)

Set blob content // if allocated_size == NOT_OWNED_DATA the content is not copied inside blob

char * Blob::set ( size_t  size,
size_t  allocated_size = 0 
)

Set a new blob size. If new size need reallocation old content is copied in new content before released.

Parameters
sizenew data size
allocated_sizenew allocated size. Value taken into account only if higher than size.
char * Blob::set_allocated_size ( size_t  allocated_size)
void Blob::splice ( Blob blob)

Exchange content of Blobs

Parameters
bloban other blob
AString & Blob::to_string ( AString s)
Returns
a blob strig representation (Use B64 format)
Parameters
sstring recipient
long commore::Blob::write ( OBStream ,
int  tab 
) const

Read/Write using raw format

int commore::Blob::write ( const Path file) const

Write blob content to a file (raw format)

Parameters
file
Warning
not implemented
long commore::Blob::write ( CommBuffer buffer) const

Read/Write in communication buffer

long Blob::write_xml ( OBStream o) const

Read/Write XML Blob content Use B64 format


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