Author: Marc Munro Copyright (c) 2009 - 2011 Marc Munro License: BSD
Definition in file veil_serialise.c.
#include "postgres.h"
#include "veil_version.h"
#include "veil_funcs.h"
#include "veil_datatypes.h"
Go to the source code of this file.
Functions | |
static int | streamlen (int bytes) |
Return the length of a base64 encoded stream for a binary stream of bytes length. | |
static int | hdrlen (char *name) |
Return the length of the header part of a serialised data stream for the given named variable. | |
static void | serialise_int4 (char **p_stream, int4 value) |
Serialise an int4 value as a base64 stream (truncated to save a byte) into *p_stream. | |
static int4 | deserialise_int4 (char **p_stream) |
De-serialise an int4 value from a base64 character stream. | |
static void | serialise_stream (char **p_stream, int4 bytes, char *instream) |
Serialise a binary stream as a base64 stream into *p_stream. | |
static void | deserialise_stream (char **p_stream, int4 bytes, char *outstream) |
De-serialise a binary stream. | |
static void | serialise_bool (char **p_stream, bool value) |
Serialise a boolean value into *p_stream. | |
static bool | deserialise_bool (char **p_stream) |
De-serialise a boolean value. | |
static void | serialise_char (char **p_stream, char value) |
Serialise a character value into *p_stream. | |
static char | deserialise_char (char **p_stream) |
De-serialise a character value. | |
static void | serialise_name (char **p_stream, char *name) |
Serialise a string (containing a name) into *p_stream. | |
static char * | deserialise_name (char **p_stream) |
De-serialise a string returning a dynamically allocated string. | |
static char * | serialise_int4var (Int4Var *var, char *name) |
Serialise a veil integer variable into a dynamically allocated string. | |
static VarEntry * | deserialise_int4var (char **p_stream) |
De-serialise a veil integer variable. | |
static char * | serialise_int4array (Int4Array *array, char *name) |
Serialise a veil integer array variable into a dynamically allocated string. | |
static VarEntry * | deserialise_int4array (char **p_stream) |
De-serialise a veil integer array variable. | |
static char * | serialise_range (Range *range, char *name) |
Serialise a veil range variable into a dynamically allocated string. | |
static VarEntry * | deserialise_range (char **p_stream) |
De-serialise a veil range variable. | |
static void | serialise_one_bitmap (char **p_stream, Bitmap *bitmap) |
Serialise a single bitmap from a veil bitmap array or bitmap hash. | |
static char * | serialise_bitmap (Bitmap *bitmap, char *name) |
Serialise a veil bitmap variable into a dynamically allocated string. | |
static void | deserialise_one_bitmap (Bitmap **p_bitmap, char *name, bool shared, char **p_stream) |
De-serialise a single bitmap into a veil bitmap array or bitmap hash. | |
static VarEntry * | deserialise_bitmap (char **p_stream) |
De-serialise a veil bitmap variable. | |
static char * | serialise_bitmap_array (BitmapArray *bmarray, char *name) |
Serialise a veil bitmap array variable into a dynamically allocated string. | |
static VarEntry * | deserialise_bitmap_array (char **p_stream) |
De-serialise a veil bitmap array variable. | |
static int | sizeof_bitmaps_in_hash (BitmapHash *bmhash, int bitset_size) |
Calculate the size needed for a base64 stream to contain all of the bitmaps in a bitmap hash including their keys. | |
static char * | serialise_bitmap_hash (BitmapHash *bmhash, char *name) |
Serialise a veil bitmap hash variable into a dynamically allocated string. | |
static VarEntry * | deserialise_bitmap_hash (char **p_stream) |
De-serialise a veil bitmap hash variable. | |
char * | vl_serialise_var (char *name) |
Serialise a veil variable. | |
VarEntry * | vl_deserialise_next (char **p_stream) |
De-serialise the next veil variable from *p_stream. | |
int4 | vl_deserialise (char **p_stream) |
De-serialise a base64 string containing, possibly many, derialised veil variables. |
static int streamlen | ( | int | bytes | ) | [static] |
Return the length of a base64 encoded stream for a binary stream of bytes length.
bytes | The length of the input binary stream in bytes |
Definition at line 190 of file veil_serialise.c.
Referenced by deserialise_stream(), serialise_bitmap(), serialise_bitmap_array(), serialise_bitmap_hash(), and serialise_int4array().
static int hdrlen | ( | char * | name | ) | [static] |
Return the length of the header part of a serialised data stream for the given named variable.
Note that the header contains the name and a base64 encode length indicator for the name.
name | The variable name to be recorded in the header |
Definition at line 205 of file veil_serialise.c.
Referenced by serialise_bitmap(), serialise_bitmap_array(), serialise_bitmap_hash(), serialise_int4array(), serialise_int4var(), serialise_range(), and sizeof_bitmaps_in_hash().
static void serialise_int4 | ( | char ** | p_stream, | |
int4 | value | |||
) | [static] |
Serialise an int4 value as a base64 stream (truncated to save a byte) into *p_stream.
p_stream | Pointer into stream currently being written. This must be large enought to take the contents to be written. This pointer is updated to point to the next free slot in the stream after writing the int4 value, and is null terminated at that position. | |
value | The value to be written to the stream. |
Definition at line 222 of file veil_serialise.c.
Referenced by serialise_bitmap_array(), serialise_bitmap_hash(), serialise_int4array(), serialise_int4var(), serialise_name(), serialise_one_bitmap(), and serialise_range().
static int4 deserialise_int4 | ( | char ** | p_stream | ) | [static] |
De-serialise an int4 value from a base64 character stream.
p_stream | Pointer into the stream currently being read. must be large enought to take the contents to be written. This pointer is updated to point to the next free slot in the stream after reading the int4 value. |
Definition at line 240 of file veil_serialise.c.
Referenced by deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_int4array(), deserialise_int4var(), deserialise_name(), deserialise_one_bitmap(), and deserialise_range().
static void serialise_stream | ( | char ** | p_stream, | |
int4 | bytes, | |||
char * | instream | |||
) | [static] |
Serialise a binary stream as a base64 stream into *p_stream.
p_stream | Pointer into stream currently being written. This pointer is updated to point to the next free slot in the stream after writing the contents of instream and is null terminated at that position. | |
bytes | The number of bytes to be written. | |
instream | The binary stream to be written. |
Definition at line 263 of file veil_serialise.c.
Referenced by serialise_int4array(), and serialise_one_bitmap().
static void deserialise_stream | ( | char ** | p_stream, | |
int4 | bytes, | |||
char * | outstream | |||
) | [static] |
De-serialise a binary stream.
p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream. | |
bytes | The number of bytes to be read | |
outstream | Pointer into the pre-allocated memory are into which the binary from p_stream is to be written. |
Definition at line 281 of file veil_serialise.c.
References streamlen().
Referenced by deserialise_int4array(), and deserialise_one_bitmap().
static void serialise_bool | ( | char ** | p_stream, | |
bool | value | |||
) | [static] |
Serialise a boolean value into *p_stream.
p_stream | Pointer into stream currently being written. This pointer is updated to point to the next free slot in the stream after writing the contents of value and is null terminated at that position. A true value is written as 'T', and false as 'F'. | |
value | The boolean value to be written. |
Definition at line 299 of file veil_serialise.c.
Referenced by serialise_int4var().
static bool deserialise_bool | ( | char ** | p_stream | ) | [static] |
De-serialise a boolean value.
p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream. |
Definition at line 315 of file veil_serialise.c.
Referenced by deserialise_int4var().
static void serialise_char | ( | char ** | p_stream, | |
char | value | |||
) | [static] |
Serialise a character value into *p_stream.
p_stream | Pointer into stream currently being written. This pointer is updated to point to the next free slot in the stream after writing the contents of value and is null terminated at that position. The character is written as a single byte character. | |
value | The character value to be written. |
Definition at line 333 of file veil_serialise.c.
Referenced by serialise_bitmap(), serialise_bitmap_array(), serialise_bitmap_hash(), serialise_int4array(), serialise_int4var(), and serialise_range().
static char deserialise_char | ( | char ** | p_stream | ) | [static] |
De-serialise a character value.
p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream. |
Definition at line 349 of file veil_serialise.c.
Referenced by deserialise_bitmap_hash(), and vl_deserialise_next().
static void serialise_name | ( | char ** | p_stream, | |
char * | name | |||
) | [static] |
Serialise a string (containing a name) into *p_stream.
p_stream | Pointer into stream currently being written. This pointer is updated to point to the next free slot in the stream after writing the contents of value and is null terminated at that position. The character is written as a single byte character. | |
name | The string to be written. |
Definition at line 367 of file veil_serialise.c.
References serialise_int4().
Referenced by serialise_bitmap(), serialise_bitmap_array(), serialise_bitmap_hash(), serialise_int4array(), serialise_int4var(), and serialise_range().
static char* deserialise_name | ( | char ** | p_stream | ) | [static] |
De-serialise a string returning a dynamically allocated string.
p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream. |
Definition at line 393 of file veil_serialise.c.
References deserialise_int4().
Referenced by deserialise_bitmap(), deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_int4array(), deserialise_int4var(), and deserialise_range().
static char* serialise_int4var | ( | Int4Var * | var, | |
char * | name | |||
) | [static] |
Serialise a veil integer variable into a dynamically allocated string.
var | Pointer to the variable to be serialised | |
name | The name of the variable |
Definition at line 412 of file veil_serialise.c.
References hdrlen(), Int4Var::isnull, serialise_bool(), serialise_char(), serialise_int4(), serialise_name(), and Int4Var::value.
Referenced by vl_serialise_var().
static VarEntry* deserialise_int4var | ( | char ** | p_stream | ) | [static] |
De-serialise a veil integer variable.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 434 of file veil_serialise.c.
References deserialise_bool(), deserialise_int4(), deserialise_name(), Int4Var::isnull, VarEntry::obj, VarEntry::shared, Int4Var::type, Int4Var::value, vl_lookup_variable(), vl_NewInt4(), and vl_type_mismatch().
Referenced by vl_deserialise_next().
static char* serialise_int4array | ( | Int4Array * | array, | |
char * | name | |||
) | [static] |
Serialise a veil integer array variable into a dynamically allocated string.
array | Pointer to the variable to be serialised | |
name | The name of the variable |
Definition at line 464 of file veil_serialise.c.
References Int4Array::array, Int4Array::arraymax, Int4Array::arrayzero, hdrlen(), serialise_char(), serialise_int4(), serialise_name(), serialise_stream(), and streamlen().
Referenced by vl_serialise_var().
static VarEntry* deserialise_int4array | ( | char ** | p_stream | ) | [static] |
De-serialise a veil integer array variable.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 491 of file veil_serialise.c.
References Int4Array::array, deserialise_int4(), deserialise_name(), deserialise_stream(), VarEntry::obj, VarEntry::shared, Int4Array::type, vl_lookup_variable(), vl_NewInt4Array(), and vl_type_mismatch().
Referenced by vl_deserialise_next().
static char* serialise_range | ( | Range * | range, | |
char * | name | |||
) | [static] |
Serialise a veil range variable into a dynamically allocated string.
range | Pointer to the variable to be serialised | |
name | The name of the variable |
Definition at line 527 of file veil_serialise.c.
References hdrlen(), Range::max, Range::min, serialise_char(), serialise_int4(), and serialise_name().
Referenced by vl_serialise_var().
static VarEntry* deserialise_range | ( | char ** | p_stream | ) | [static] |
De-serialise a veil range variable.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 549 of file veil_serialise.c.
References deserialise_int4(), deserialise_name(), Range::max, Range::min, VarEntry::obj, VarEntry::shared, Range::type, vl_lookup_variable(), vl_NewRange(), and vl_type_mismatch().
Referenced by vl_deserialise_next().
static void serialise_one_bitmap | ( | char ** | p_stream, | |
Bitmap * | bitmap | |||
) | [static] |
Serialise a single bitmap from a veil bitmap array or bitmap hash.
p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after writing the stream. | |
bitmap | The bitmap to be serialised. |
Definition at line 579 of file veil_serialise.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, Bitmap::bitzero, serialise_int4(), and serialise_stream().
Referenced by serialise_bitmap(), serialise_bitmap_array(), and serialise_bitmap_hash().
static char* serialise_bitmap | ( | Bitmap * | bitmap, | |
char * | name | |||
) | [static] |
Serialise a veil bitmap variable into a dynamically allocated string.
bitmap | Pointer to the variable to be serialised | |
name | The name of the variable |
Definition at line 598 of file veil_serialise.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitzero, hdrlen(), serialise_char(), serialise_name(), serialise_one_bitmap(), and streamlen().
Referenced by vl_serialise_var().
static void deserialise_one_bitmap | ( | Bitmap ** | p_bitmap, | |
char * | name, | |||
bool | shared, | |||
char ** | p_stream | |||
) | [static] |
De-serialise a single bitmap into a veil bitmap array or bitmap hash.
p_bitmap | Pointer to bitmap pointer. This may be updated to contain a dynamically allocated bitmap if none is already present. | |
name | The name of the variable, for error reporting purposes. | |
shared | Whether the bitmap is part of a shared rather than session variable. | |
p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream. |
Definition at line 625 of file veil_serialise.c.
References ARRAYELEMS, Bitmap::bitset, deserialise_int4(), deserialise_stream(), Bitmap::type, vl_NewBitmap(), and vl_type_mismatch().
Referenced by deserialise_bitmap(), deserialise_bitmap_array(), and deserialise_bitmap_hash().
static VarEntry* deserialise_bitmap | ( | char ** | p_stream | ) | [static] |
De-serialise a veil bitmap variable.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 660 of file veil_serialise.c.
References deserialise_name(), deserialise_one_bitmap(), VarEntry::obj, VarEntry::shared, and vl_lookup_variable().
Referenced by vl_deserialise_next().
static char* serialise_bitmap_array | ( | BitmapArray * | bmarray, | |
char * | name | |||
) | [static] |
Serialise a veil bitmap array variable into a dynamically allocated string.
bmarray | Pointer to the variable to be serialised | |
name | The name of the variable |
Definition at line 681 of file veil_serialise.c.
References ARRAYELEMS, BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, BitmapArray::bitmax, BitmapArray::bitzero, hdrlen(), serialise_char(), serialise_int4(), serialise_name(), serialise_one_bitmap(), and streamlen().
Referenced by vl_serialise_var().
static VarEntry* deserialise_bitmap_array | ( | char ** | p_stream | ) | [static] |
De-serialise a veil bitmap array variable.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 714 of file veil_serialise.c.
References BitmapArray::bitmap, deserialise_int4(), deserialise_name(), deserialise_one_bitmap(), VarEntry::obj, VarEntry::shared, BitmapArray::type, vl_lookup_variable(), vl_NewBitmapArray(), and vl_type_mismatch().
Referenced by vl_deserialise_next().
static int sizeof_bitmaps_in_hash | ( | BitmapHash * | bmhash, | |
int | bitset_size | |||
) | [static] |
Calculate the size needed for a base64 stream to contain all of the bitmaps in a bitmap hash including their keys.
bmhash | Pointer to the variable to be serialised | |
bitset_size | The size, in bytes, of each bitset in the bitmap hash. |
Definition at line 762 of file veil_serialise.c.
References BitmapHash::hash, hdrlen(), VarEntry::key, and vl_NextHashEntry().
Referenced by serialise_bitmap_hash().
static char* serialise_bitmap_hash | ( | BitmapHash * | bmhash, | |
char * | name | |||
) | [static] |
Serialise a veil bitmap hash variable into a dynamically allocated string.
bmhash | Pointer to the variable to be serialised | |
name | The name of the variable |
Definition at line 785 of file veil_serialise.c.
References ARRAYELEMS, BitmapHash::bitmax, BitmapHash::bitzero, BitmapHash::hash, hdrlen(), VarEntry::key, VarEntry::obj, serialise_char(), serialise_int4(), serialise_name(), serialise_one_bitmap(), sizeof_bitmaps_in_hash(), streamlen(), and vl_NextHashEntry().
Referenced by vl_serialise_var().
static VarEntry* deserialise_bitmap_hash | ( | char ** | p_stream | ) | [static] |
De-serialise a veil bitmap hash variable.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 820 of file veil_serialise.c.
References deserialise_char(), deserialise_int4(), deserialise_name(), deserialise_one_bitmap(), VarEntry::obj, VarEntry::shared, BitmapHash::type, vl_AddBitmapToHash(), vl_BitmapUnion(), vl_lookup_variable(), vl_NewBitmapHash(), and vl_type_mismatch().
Referenced by vl_deserialise_next().
char* vl_serialise_var | ( | char * | name | ) |
Serialise a veil variable.
name | The name of the variable to be serialised. |
Definition at line 865 of file veil_serialise.c.
References VarEntry::obj, serialise_bitmap(), serialise_bitmap_array(), serialise_bitmap_hash(), serialise_int4array(), serialise_int4var(), serialise_range(), Object::type, and vl_lookup_variable().
VarEntry* vl_deserialise_next | ( | char ** | p_stream | ) |
De-serialise the next veil variable from *p_stream.
**p_stream | Pointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream |
Definition at line 913 of file veil_serialise.c.
References deserialise_bitmap(), deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_char(), deserialise_int4array(), deserialise_int4var(), and deserialise_range().
Referenced by vl_deserialise().
int4 vl_deserialise | ( | char ** | p_stream | ) |
De-serialise a base64 string containing, possibly many, derialised veil variables.
**p_stream | Pointer into the stream currently being read. |
Definition at line 952 of file veil_serialise.c.
References vl_deserialise_next().
Referenced by veil_serialise().