11 #ifndef _UtlSerialized_h_ 12 #define _UtlSerialized_h_ 25 #define UTL_SERIALIZED_SIZE 1024 62 #define SERIALIZE_POD_DEFINE(type) \ 63 inline OsStatus serialize(type val) \ 65 if (sizeof(type) > getFreeSize()) \ 67 return OS_LIMIT_REACHED; \ 69 *(type*)mpEnd = val; \ 70 mpEnd += sizeof(type); \ 71 mSize += sizeof(type); \ 74 inline OsStatus deserialize(type &val) \ 76 if (sizeof(type) > getSize() - (mpEnd-mData)) \ 78 return OS_NO_MORE_DATA; \ 80 val = *(type*)mpEnd; \ 81 mpEnd += sizeof(type); \ 94 #if defined(_WIN64) || defined(__ppc64__) 99 #undef SERIALIZE_POD_DEFINE 104 size_t length = val.
length() + 1;
133 memcpy((
void*)val.
data(),
mpEnd, length);
196 #endif // _UtlSerialized_h_ OsStatus serialize(const UtlString &val)
Definition: UtlSerialized.h:101
UtlSerialized()
Constructor.
Definition: UtlSerialized.h:37
void resize(size_t N, UtlBoolean clearTail=TRUE)
Set a new size for the string.
Definition: UtlString.cpp:671
const char * data() const
Return a read-only pointer to the stored string value..
Definition: UtlString.cpp:832
OsStatus deserialize(UtlString &val)
Definition: UtlSerialized.h:116
Definition: OsStatus.h:30
uint8_t mData[UTL_SERIALIZED_SIZE]
Array to serialize data to.
Definition: UtlSerialized.h:186
unsigned char uint8_t
Definition: stdint.h:78
void finishSerialize()
Prepare for de-serialization.
Definition: UtlSerialized.h:139
#define UTL_SERIALIZED_SIZE
Definition: UtlSerialized.h:25
OsStatus
Definition: OsStatus.h:27
size_t mSize
Size of the serialized data.
Definition: UtlSerialized.h:187
virtual ~UtlSerialized()
Destructor.
Definition: UtlSerialized.h:52
Definition: OsStatus.h:41
size_t length() const
The current length of the string value.
Definition: UtlString.cpp:825
Definition: OsStatus.h:31
Definition: UtlString.h:48
size_t getFreeSize() const
Get free size in storage (in bytes).
Definition: UtlSerialized.h:172
size_t getMaxSize() const
Get size of available space (in bytes).
Definition: UtlSerialized.h:166
uint8_t * mpEnd
Pointer to the byte right after the end of data.
Definition: UtlSerialized.h:185
Definition: UtlSerialized.h:27
SERIALIZE_POD_DEFINE(char)
UtlSerialized(const UtlSerialized &rhs)
Copy constructor.
Definition: UtlSerialized.h:44
size_t getSize() const
Get size of stored data (in bytes).
Definition: UtlSerialized.h:169
#define FALSE
Definition: UtlDefs.h:21
UtlSerialized & operator=(const UtlSerialized &rhs)
Assignment operator.
Definition: UtlSerialized.h:145