commore
1.0.6-SNAPSHOT
|
#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) | |
Blob & | operator= (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 &) |
AString & | to_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 |
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.
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
size | initial block size |
allocated_size | total allocated size. |
Blob::Blob | ( | const char * | content, |
size_t | size, | ||
size_t | allocated_size = 0 |
||
) |
Create a blob with a pre-assigned content
content | pointer to raw data |
size | initial block size |
allocated_size | total 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 | ( | ) |
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)
s | input string |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
long commore::Blob::read | ( | IBStream & | ) |
int commore::Blob::read | ( | const Path & | file | ) |
Read blob content from a file (raw format)
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.
size | new data size |
allocated_size | new 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
blob | an other blob |
s | string 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)
file |
long commore::Blob::write | ( | CommBuffer & | buffer | ) | const |
Read/Write in communication buffer