Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sobj_bin.c File Reference


Detailed Description

Implementation file for binary serialization and de-serialization.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <math.h>
#include <limits.h>
#include "sobject_p.h"

Include dependency graph for sobj_bin.c:

Include dependency graph

Functions

sobj_float64_t sobj_bin_decode_ieee_32 (const unsigned char *)
 Decode an IEEE encoded 32 bit floating point number.
sobj_float64_t sobj_bin_decode_ieee_64 (const unsigned char *)
 Decode an IEEE encoded 64 bit floating point number.
void sobj_bin_encode_ieee_32 (sobj_float64_t, unsigned char *)
 Encode an 32 bit IEEE floating point number.
void sobj_bin_encode_ieee_64 (sobj_float64_t, unsigned char *)
 Encode an 64 bit IEEE floating point number.
unsigned long sobj_bin_decode_counter (struct sobj_env *env, int, bool *, const char **, ptrdiff_t, size_t)
 Decode a counter value.
sobjsobj_bin_unpack_int (struct sobj_env *, const char *, int, const char **, ptrdiff_t, size_t)
 Unpack an encoded integer value.
sobjsobj_bin_unpack_float (struct sobj_env *, const char *, int, const char **, ptrdiff_t, size_t)
 Unpack an encoded floating point value.
sobjsobj_bin_unpack_string (struct sobj_env *, const char *, int, const char **, ptrdiff_t, size_t)
 Unpack an encoded string object.
sobjsobj_bin_unpack_binary (struct sobj_env *, const char *, int, const char **, ptrdiff_t, size_t)
 Unpack an encoded binary object.
sobjsobj_bin_unpack_array (struct sobj_env *, const char *, int, const char **, ptrdiff_t, size_t)
 Unpack an encoded array object.
sobjsobj_bin_unpack_expr (struct sobj_env *, const char *, const char **, ptrdiff_t, size_t)
 Unpack an encoded expression object.
sobjsobj_bin_unpack_vref (struct sobj_env *, const char *, int, const char **, ptrdiff_t, size_t)
 Unpack an encoded variable reference.
bool sobj_bin_float64_equal (sobj_float64_t, sobj_float64_t)
 Check if two floating point values are equal.
void sobj_bin_pack_cn (struct sobj *, struct sobj_buffer *)
 Pack the class name of a simple object.
void sobj_bin_pack_int_value (sobj_int64_t, int, struct sobj_buffer *)
 Pack an integer value.
void sobj_bin_pack_int (struct sobj *, char, struct sobj_buffer *)
 Pack an integer object.
void sobj_bin_pack_float (struct sobj *, char, struct sobj_buffer *)
 Pack a float object.
void sobj_bin_pack_string (struct sobj *, char, struct sobj_buffer *)
 Pack a string object.
void sobj_bin_pack_binary (struct sobj *, char, struct sobj_buffer *)
 Pack a binary object.
void sobj_bin_pack_array (struct sobj *, char, struct sobj_buffer *)
 Pack an array object.
void sobj_bin_pack_expr (struct sobj *, char, struct sobj_buffer *)
 Pack an expr object.
void sobj_bin_pack_vref (struct sobj *, char, struct sobj_buffer *)
 Pack an vref object.
sobjsobj_bin_unpack (struct sobj_env *env, const char **ptr, ptrdiff_t length, size_t offset)
 Internal function for binary deserialization.
int sobj_bin_unpack_scan (struct sobj_scan_input *input)
 Scan for the end of a binary serialization.
void sobj_bin_pack (struct sobj *sobj, struct sobj_buffer *buffer, struct sobj_env *env)
 Internal function for creating a binary serialization.

Function Documentation

unsigned long sobj_bin_decode_counter struct sobj_env env,
int  storage_size_num,
bool *  error,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Decode a counter value.

Parameters:
env The environment. This may be a null-pointer.
storage_size_num The storage size number from the type byte.
error In case of a decoding error and if error is not a null-pointer, *error is set to true.
ptr Pointer to a caller variable pointing to the first byte of the encoded counter. On success, *ptr is set to the first byte following the counter.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the binary serialization (used for error reporting).
Returns:
The value of the decoded counter.

sobj_float64_t sobj_bin_decode_ieee_32 const unsigned char *  buffer  )  [static]
 

Decode an IEEE encoded 32 bit floating point number.

Parameters:
buffer Buffer holding the big-endian encoded 32 bit IEEE floating point number.
Returns:
The decoded floating point number.

sobj_float64_t sobj_bin_decode_ieee_64 const unsigned char *  buffer  )  [static]
 

Decode an IEEE encoded 64 bit floating point number.

Parameters:
buffer Buffer holding the big-endian encoded 64 bit IEEE floating point number.
Returns:
The decoded floating point number.

void sobj_bin_encode_ieee_32 sobj_float64_t  value,
unsigned char *  buffer
[static]
 

Encode an 32 bit IEEE floating point number.

Parameters:
value Floating point value to be encoded.
buffer Buffer receiving the big-endian encoded 32 bit IEEE floating point number.

void sobj_bin_encode_ieee_64 sobj_float64_t  value,
unsigned char *  buffer
[static]
 

Encode an 64 bit IEEE floating point number.

Parameters:
value Floating point value to be encoded.
buffer Buffer receiving the big-endian encoded 64 bit IEEE floating point number.

bool sobj_bin_float64_equal sobj_float64_t  value1,
sobj_float64_t  value2
[static]
 

Check if two floating point values are equal.

Parameters:
value1 Floating point value.
value2 Floating point value.
Return values:
true If the parameter values for value1 and value2 are equal.
false If the parameter values for value1 and value2 differ by at least epsilon.

void sobj_bin_pack struct sobj sobj,
struct sobj_buffer buffer,
struct sobj_env env
 

Internal function for creating a binary serialization.

Parameters:
sobj The called object. The caller must own a reference to the object, since this function will RETAIN and RELEASE (!) this object.
buffer The byte buffer receiving the serialization. This may not be a null-pointer.
env The environment. This may be a null-pointer.

void sobj_bin_pack_array struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack an array object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_binary struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack a binary object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_cn struct sobj sobj,
struct sobj_buffer buffer
[static]
 

Pack the class name of a simple object.

Parameters:
sobj The called object.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_expr struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack an expr object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_float struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack a float object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_int struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack an integer object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_int_value sobj_int64_t  value,
int  storage_size_num,
struct sobj_buffer buffer
[static]
 

Pack an integer value.

Parameters:
value The integer value.
storage_size_num The storage size number written to the type byte.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_string struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack a string object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

void sobj_bin_pack_vref struct sobj sobj,
char  x,
struct sobj_buffer buffer
[static]
 

Pack an vref object.

Parameters:
sobj The called object.
x The type byte without the storage size number.
buffer The byte buffer receiving the serialization.

struct sobj* sobj_bin_unpack struct sobj_env env,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
 

Internal function for binary deserialization.

Parameters:
env The environment. This may be a null-pointer.
ptr The callers pointer to the serialization buffer.
length The length of the serialization buffer, relative to *ptr.
offset The offset of *ptr relative to the complete serialization (for error reporting).
Returns:
The function returns the deserialized object or a null-pointer on error.

struct sobj * sobj_bin_unpack_array struct sobj_env env,
const char *  cn,
int  storage_size_num,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded array object.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new array object.
storage_size_num The storage size number from the type byte.
ptr Pointer to a caller variable pointing to the first byte of the array object. (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded array object.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the array serialization (used for error reporting).
Returns:
A simple object instance representing the decoded array object. In case of a decoding error, a null-pointer is returned.

struct sobj * sobj_bin_unpack_binary struct sobj_env env,
const char *  cn,
int  storage_size_num,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded binary object.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new binary object.
storage_size_num The storage size number from the type byte.
ptr Pointer to a caller variable pointing to the first byte of the binary object. (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded binary object.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the binary serialization (used for error reporting).
Returns:
A simple object instance representing the decoded binary object. In case of a decoding error, a null-pointer is returned.

struct sobj * sobj_bin_unpack_expr struct sobj_env env,
const char *  cn,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded expression object.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new expression object.
ptr Pointer to a caller variable pointing to the first byte of the expression object. (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded expression object.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the expression serialization (used for error reporting).
Returns:
A simple object instance representing the decoded expression object. In case of a decoding error, a null-pointer is returned.

struct sobj * sobj_bin_unpack_float struct sobj_env env,
const char *  cn,
int  storage_size_num,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded floating point value.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new floating point object.
storage_size_num The storage size number from the type byte.
ptr Pointer to a caller variable pointing to the first byte of the encoded floating point value (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded floating point value.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the binary serialization (used for error reporting).
Returns:
A simple object instance representing the decoded floating point value. In case of a decoding error, a null-pointer is returned.

struct sobj * sobj_bin_unpack_int struct sobj_env env,
const char *  cn,
int  storage_size_num,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded integer value.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new integer object.
storage_size_num The storage size number from the type byte.
ptr Pointer to a caller variable pointing to the first byte of the encoded integer value (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded integer value.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the binary serialization (used for error reporting).
Returns:
A simple object instance representing the decoded integer value. In case of a decoding error, a null-pointer is returned.

int sobj_bin_unpack_scan struct sobj_scan_input input  ) 
 

Scan for the end of a binary serialization.

Parameters:
input The scan input.
Return values:
0 Success.
-1 The get function returned -1 (indicating EOF or error).

struct sobj * sobj_bin_unpack_string struct sobj_env env,
const char *  cn,
int  storage_size_num,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded string object.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new string object.
storage_size_num The storage size number from the type byte.
ptr Pointer to a caller variable pointing to the first byte of the encoded string value (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded string value.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the binary serialization (used for error reporting).
Returns:
A simple object instance representing the decoded string value. In case of a decoding error, a null-pointer is returned.

struct sobj * sobj_bin_unpack_vref struct sobj_env env,
const char *  cn,
int  storage_size_num,
const char **  ptr,
ptrdiff_t  length,
size_t  offset
[static]
 

Unpack an encoded variable reference.

Parameters:
env The environment. This may be a null-pointer.
cn The class name of the new variable reference.
storage_size_num The storage size number from the type byte.
ptr Pointer to a caller variable pointing to the first byte of the variable reference. (i.e. following the type byte and the class name). On success, *ptr is set to the first byte following the encoded variable reference.
length The length of the encoded buffer relative to *ptr.
offset The offset of *ptr relative to the beginning of the expression serialization (used for error reporting).
Returns:
A simple object instance representing the decoded variable reference. In case of a decoding error, a null-pointer is returned.


Generated on Sat Jul 23 16:04:47 2005 for sobject by  doxygen 1.3.9.1