GPL_Message
GPL_Message
gpl
1998 12-05
CLASS
GPL_Message - an object within which to serialize/marshall data
SYNOPSIS
GPL_Message is basically a buffer of memory with methods to pack
and extract data. For reading, a current position is maintained which
is moved forward through the message as data is read.
PARENTS
CONSTRUCTORS
GPL_Message(void)
Construct a GPL_Message object.
GPL_Message(const GPL_Message & msg)
Construct a GPL_Message object identical to msg.
OPERATORS
GPL_Message & operator=(const GPL_Message & msg)
Copy msg.
GPL_Boolean operator==(const GPL_Message &m) const
If Compare() returns zero return TRUE, otherwise return FALSE.
GPL_Boolean operator!=(const GPL_Message &m) const
If Compare() returns non-zero return TRUE, otherwise return FALSE.
MEMBER FUNCTIONS
long Compare(const GPL_Message &m) const
Return zero if m and this are identical in content. Otherwise,
return non-zero.
void DeleteRange(long index_1, long index_2)
Delete all data from index index_1 to index index_2.
void AppendChar(char c)
Append character c to the end of the message.
void InsertChar(char c, long at_index)
Insert character c at index at_index.
char ReadChar(void)
Read a character from the current position and return it.
void AppendUnsignedChar(unsigned char c)
Append unsigned character c to the end of the message.
void InsertUnsignedChar(unsigned char c, long at_index)
Insert unsigned character c at index at_index.
unsigned char ReadUnsignedChar(void)
Read an unsigned character from the current position and return it.
void AppendShort(short hs)
Append short hs to the end of the message.
void InsertShort(short hs, long at_index)
Insert short hs at index at_index.
short ReadShort(void)
Read a short from the current position and return it.
void AppendUnsignedShort(unsigned short hs)
Append unsigned short hs to the end of the message.
void InsertUnsignedShort(unsigned short hs, long at_index)
Insert unsigned short hs at index at_index.
unsigned short ReadUnsignedShort(void)
Read a unsigned short from the current position and return it.
void AppendLong(long hl)
Append long hl to the end of the message.
void InsertLong(long hl, long at_index)
Insert long hl at index at_index.
long ReadLong(void)
Read a long from the current position and return it.
void AppendUnsignedLong(unsigned long hl)
Append unsigned long hl to the end of the message.
void InsertUnsignedLong(unsigned long hl, long at_index)
Insert unsigned long hl at index at_index.
unsigned long ReadUnsignedLong(void)
Read a unsigned long from the current position and return it.
void AppendFloat(float hf)
Append float hf to the end of the message.
void InsertFloat(float hf, long at_index)
Insert float hf at index at_index.
float ReadFloat(void)
Read a float from the current position and return it.
void AppendDouble(double hd)
Append double hd to the end of the message.
void InsertDouble(double hd, long at_index)
Insert double hd at index at_index.
double ReadDouble(void)
Read a double from the current position and return it.
void AppendInetAddress(unsigned long hl)
Append unsigned long hl to the end of the message. This does not
convert the unsigned long to network byte order.
void InsertInetAddress(unsigned long hl, long at_index)
Insert unsigned long hl at index at_index. This does not
convert the unsigned long to network byte order.
unsigned long ReadInetAddress(void)
Read a unsigned long from the current position and return it. This does
not convert the unsigned long from network byte order.
void AppendString(const GPL_String & string)
Append string to the end of the message.
void InsertString(const GPL_String & string, long at_index)
Insert string at index at_index.
GPL_String ReadString(void)
Read a string from the current position and return it.
void AppendCharPtr(const GPL_CharPtr & string)
Append string to the end of the message.
GPL_CharPtr ReadCharPtr(void)
Read a string from the current position and return it. The returned
string is NULL terminated.
void InsertCharPtr(const GPL_CharPtr & string, long at_index)
Insert string at index at_index.
void AppendCharStar(char *string)
Append string to the end of the message.
char *ReadCharStar(void)
Read a string from the current position and return it. The returned
string is NULL terminated. NULL is returned for a zero
length string. Memory for the string is allocated by
ReadCharStar() and it is the caller's responsibility to free the
memory when done.
void InsertCharStar(char *string, long at_index)
Insert string at index at_index.
void AppendBlock(char *block, long block_length)
void AppendBlock(char *block, unsigned long block_length)
Append a block_length long block of memory pointed to by
block to the end of the message.
void InsertBlock(char *block,long block_length,long at_index)
void InsertBlock(char *block,unsigned long block_length,long at_index)
Insert a block_length long block of memory pointed to by
block at index at_index.
char *SkipBlock(long *block_length)
char *SkipBlock(unsigned long *block_length)
Skip the memory block at the current position. The length of the
skipped block is return in block_length while a pointer to the
actual memory in the message buffer is returned. The caller should not
free this memory since it is managed by GPL_Message internally.
long CopyBlock(char *block, long block_length)
unsigned long CopyBlock(char *block, unsigned long block_length)
Copy the memory block at the current position ito a buffer specified by
block. The length of block is specified by block_length and
only that many bytes will be copied. The number of bytes copied is
returned.
char *ReadBlock(long *block_length)
char *ReadBlock(unsigned long *block_length)
Read the memory block at the current position and return it. The memory
block is allocated internally and it is the caller's responsibility to
free the memory when done. The length of the return block is returned
in block_length.
unsigned long QueryBlockLength(void)
Return the length of the memory block at the current position.
void AppendMessage(GPL_Message *other)
Appends the message other to the end of the message. The appended
message is not wrapped, which means there is no ReadMessage call.
void InsertMessage(GPL_Message *other,long at_index)
Inserts the message other into the message. The inserted message
is not wrapped, which means there is no ReadMessage call.
void Rewind(void)
Move the current read position to the start of the message.
void Clear(void)
Restore the message to an uninitialized state, which includes resetting
the length, moving the current read position to the start of the
message, and clearing all flags.
void Print(void)
Print the current message to stderr. This call is for simple message
debugging. Non-printable bytes (don't correspond to an printable ascii
character) are printed as a period.
long Length(void)
Return the length of the message.
long Position(long jump)
Jump position by the amount specified by jump. Return the final
position. Note that Position(0) may be used to get the current position.
char *GetBuffer(unsigned long *buffer_size)
Return the address of the internal buffer of bytes. The number of bytes
which are valid is placed in buffer_size. Use of this method is
discouraged since the internal storage mechanism may change, resulting
in subtle semantic differences in usage.
void CopyBuffer(GPL_Array<GPL_Byte> & bytes) const
char *CopyBuffer(unsigned long *buffer_size)
Return an address of a copy of the internal buffer of bytes.
The number of bytes
which are valid is placed in buffer_size. It is the caller's
responsibility to free the memory when done.
char *CopyRemainder(unsigned long *buffer_size)
void CopyRemainder(GPL_Array<GPL_Byte> & bytes) const
Return an address of a copy of the remainder of the internal buffer of bytes.
The number of bytes
which are valid is placed in buffer_size. It is the caller's
responsibility to free the memory when done.
void SetBuffer(char *buffer_ptr, unsigned long buffer_size, const long duplicate = 1)
void SetBuffer(const GPL_Array<GPL_Byte> & bytes)
Cause the internal representation of the message to use
buffer_size bytes from the block buffer_ptr. If
duplicate is TRUE, the bytes are copied to a new, internal
block. If duplicate is FALSE, the address buffer_ptr
is used directly; changing the contents of the buffer will lead to
erroneous behavior. Use of duplicate==FALSE mode is discouraged
since the internal storage mechanism may change, resulting
in subtle semantic differences in usage.