moab
|
Class for storing variable-length tag data. More...
#include <VarLenTag.hpp>
Public Member Functions | |
VarLenTag () | |
VarLenTag (unsigned size) | |
~VarLenTag () | |
VarLenTag (const VarLenTag ©) | |
VarLenTag (unsigned size, const void *data) | |
unsigned | size () const |
unsigned char * | data () |
unsigned long | mem () const |
const unsigned char * | data () const |
unsigned char * | resize (unsigned size) |
void | clear () |
void | set (const void *dat, unsigned sz) |
VarLenTag & | operator= (const VarLenTag &other) |
Protected Attributes | |
VarLenTagData | mData |
Class for storing variable-length tag data.
Class for managing variable-length tag data. This class must behave as if it were initialized to empty if it is memset to zero w/out invoking any constructor.
Definition at line 129 of file VarLenTag.hpp.
moab::VarLenTag::VarLenTag | ( | ) | [inline] |
Definition at line 133 of file VarLenTag.hpp.
moab::VarLenTag::VarLenTag | ( | unsigned | size | ) | [inline] |
Definition at line 199 of file VarLenTag.hpp.
moab::VarLenTag::~VarLenTag | ( | ) | [inline] |
Definition at line 135 of file VarLenTag.hpp.
{ clear(); }
moab::VarLenTag::VarLenTag | ( | const VarLenTag & | copy | ) | [inline] |
Definition at line 219 of file VarLenTag.hpp.
moab::VarLenTag::VarLenTag | ( | unsigned | size, |
const void * | data | ||
) | [inline] |
void moab::VarLenTag::clear | ( | ) | [inline] |
unsigned char* moab::VarLenTag::data | ( | ) | [inline] |
Definition at line 141 of file VarLenTag.hpp.
const unsigned char* moab::VarLenTag::data | ( | ) | const [inline] |
Definition at line 157 of file VarLenTag.hpp.
unsigned long moab::VarLenTag::mem | ( | ) | const [inline] |
Definition at line 150 of file VarLenTag.hpp.
{ return size() <= VarLenTagData::INLINE_COUNT ? 0 : size(); }
Definition at line 167 of file VarLenTag.hpp.
{ set( other.data(), other.size() ); return *this; }
unsigned char * moab::VarLenTag::resize | ( | unsigned | size | ) | [inline] |
Definition at line 172 of file VarLenTag.hpp.
{ #ifdef VAR_LEN_TAG_ELIDE_DATA if (s <= VarLenTagData::INLINE_COUNT) { if (size() > VarLenTagData::INLINE_COUNT) { unsigned char* tmp_ptr = mData.mData.mPointer.array; memcpy( mData.mData.mInline.array, tmp_ptr, s ); free( tmp_ptr ); } mData.mData.mInline.size = s; return mData.mData.mInline.array; } else if (size() <= VarLenTagData::INLINE_COUNT) { void* tmp_ptr = malloc(s); memcpy( tmp_ptr, mData.mData.mInline.array, size() ); mData.mData.mPointer.array = reinterpret_cast<unsigned char*>(tmp_ptr); } else #endif if (size() < s) { void* tmp_ptr = size() ? realloc( mData.mData.mPointer.array, s ) : malloc( s ); mData.mData.mPointer.array = reinterpret_cast<unsigned char*>(tmp_ptr); } mData.mData.mPointer.size = s; return mData.mData.mPointer.array; }
void moab::VarLenTag::set | ( | const void * | dat, |
unsigned | sz | ||
) | [inline] |
Definition at line 164 of file VarLenTag.hpp.
{ memcpy( resize(sz), dat, sz ); }
unsigned moab::VarLenTag::size | ( | ) | const [inline] |
Definition at line 139 of file VarLenTag.hpp.
VarLenTagData moab::VarLenTag::mData [protected] |
Definition at line 131 of file VarLenTag.hpp.