Main Page   Modules   Namespace List   Data Structures   File List   Data Fields   Examples  

Variant type manipulation


Data Structures

struct  _variant_value
 Variant value structure. More...


Typedefs

typedef _variant_value VARIANT_VALUE
 Variant value structure.


Enumerations

enum  VariantType {
  VARIANT_TYPE_UNKNOWN = 0, VARIANT_TYPE_STRING, VARIANT_TYPE_MULTI_STRING, VARIANT_TYPE_SIGNED_INTEGER,
  VARIANT_TYPE_UNSIGNED_INTEGER, VARIANT_TYPE_SIGNED_SHORT, VARIANT_TYPE_UNSIGNED_SHORT, VARIANT_TYPE_FLOAT,
  VARIANT_TYPE_DOUBLE, VARIANT_TYPE_CHAR, VARIANT_TYPE_BINARY_B64
}

Functions

void variantSet (enum VariantType type, void *value, unsigned long valueSize, void *userParam, void(*setter)(void *userParam, const char *string))
void * variantGet (enum VariantType type, const char *string)
void variantFree (VARIANT_VALUE *value)

Detailed Description

Variant type manipulation and coersion.

Typedef Documentation

typedef struct _variant_value VARIANT_VALUE
 

Variant value structure.

This structure is used for returning values from variantGet that do not fit within 4 bytes.


Enumeration Type Documentation

enum VariantType
 

The variable type enumeration.

Enumeration values:
VARIANT_TYPE_UNKNOWN  Unknown type
VARIANT_TYPE_STRING  Null terminated string (const char *)
VARIANT_TYPE_MULTI_STRING  Multiple strings (array)

Remarks:
This is currently unsupported.
VARIANT_TYPE_SIGNED_INTEGER  Signed integer (signed long)
VARIANT_TYPE_UNSIGNED_INTEGER  Unsigned integer (unsigned long)
VARIANT_TYPE_SIGNED_SHORT  Signed short (signed short)
VARIANT_TYPE_UNSIGNED_SHORT  Unsigned short (unsigned short)
VARIANT_TYPE_FLOAT  Float (float)

Remarks:
This type, when used with variantGet returns a VARIANT_VALUE structure that must be deallocated via variantFree.
VARIANT_TYPE_DOUBLE  Double (double)

Remarks:
This type, when used with variantGet returns a VARIANT_VALUE structure that must be deallocated via variantFree.
VARIANT_TYPE_CHAR  Character (char)
VARIANT_TYPE_BINARY_B64  Binary_B64 (unsigned char *)

Remarks:
This type, when used with variantGet returns a VARIANT_VALUE structure that must be deallocated via variantFree. The binary type assumes that the value was originally set as a VARIANT_TYPE_BINARY_B64. Binary types are non-convertable. Trying to convert a value that was stored as a binary to any other type is not suggested and may cause unpredictable results. The reason they are not convertable is because they are stored as a base64 encoded string.


Function Documentation

void variantFree VARIANT_VALUE   value
 

Deallocates the variant value passed in.

This is used to clean up memory returned from variantGet for some types.

Parameters:
value [in] The variant value to destroy.
Examples:
variant.c.

void* variantGet enum VariantType    type,
const char *    string
 

Returns the variant value associated with the string.

The return values expected for each type are:

  • VARIANT_TYPE_STRING
    A pointer to a null terminated string. This buffer should be considered constant and remain unmodified.
  • VARIANT_TYPE_SIGNED_INTEGER
    A signed integer is returned.
  • VARIANT_TYPE_UNSIGNED_INTEGER
    An unsigned integer is returned.
  • VARIANT_TYPE_SIGNED_SHORT
    A signed short is returned.
  • VARIANT_TYPE_UNSIGNED_SHORT
    An unsigned short is returned.
  • VARIANT_TYPE_FLOAT
    A pointer to a VARIANT_VALUE structure is returned with the 'flt' member populated. This structure is dynamically allocated and should be free'd with VariantFree.
  • VARIANT_TYPE_DOUBLE
    A pointer to a VARIANT_VALUE structure is returned with the 'dbl' member populated. This structure is dynamically allocated and should be free'd with VariantFree.
  • VARIANT_TYPE_CHAR
    A signed character is returned.
  • VARIANT_TYPE_BINARY_B64
    A pointer to a VARIANT_VALUE structure is returned with the 'binary' member populated. This structure is dynamically allocated and should be free'd with VariantFree.
If the operation fails to render the value into a given type, NULL wll be returned.

Parameters:
type [in] The type to interpret the string as.
string [in] The null terminated string.
Returns:
The return value is arbitrary and dependent on the type.

void variantSet enum VariantType    type,
void *    value,
unsigned long    valueSize,
void *    userParam,
void(*    setter)(void *userParam, const char *string)
 

Converts the raw data passed in to a string and passes it to the 'setter' callback.

Parameters:
type [in] The variant type that is used to interpret the value argument.
value [in] A pointer to the raw data.
valueSize [in] The size of the value buffer in bytes.
userParam [in] The user parameter passed in as the first argument to 'setter'.
setter [in] The callback used to do the actual 'setting' of the converted type.


Generated on Tue Mar 25 19:49:04 2003 for libsgml by doxygen1.3-rc3