/home/mupuf/Programmation/CVariant/cvariant.h File Reference

#include <sys/types.h>

Include dependency graph for cvariant.h:

Go to the source code of this file.

Data Structures

struct  cvariant
 CVariant (It is not meant to be read directly! Respect the abstract type and use the function we made!). More...

Defines

#define CVARIANT_EMPTY_STRING   NULL
#define CVARIANT_EMPTY_INT   0
#define CVARIANT_EMPTY_FLOAT   0.0

Enumerations

enum  cvariant_type { cvariant_none = 0, cvariant_string, cvariant_int, cvariant_float }
 CVariant Types. More...

Functions

cvariant cvariant_null ()
 Create an empty CVariant.
cvariant cvariant_from_string (const char *string)
 Create a CVariant from a given string. WARNING: Do not free the pointer and still use the cvariant. If you want to do so, use cvariant_from_string_copy.
cvariant cvariant_from_string_copy (const char *string, size_t n)
 Create a CVariant from a given string (copy, dynamically allocated).
cvariant cvariant_from_int (int value)
 Create a CVariant from a given integer.
cvariant cvariant_from_float (double value)
 Create a CVariant from a given.
int cvariant_not_null (cvariant cv)
 Test if a cvariant is null.
cvariant_type cvariant_get_type (cvariant cv)
 Get the current type of a cvariant.
const char * cvariant_get_string (cvariant cv)
 Get a string from a cvariant.
int cvariant_get_int (cvariant cv)
 Get an integer from a cvariant.
double cvariant_get_float (cvariant cv)
 Get an float from a cvariant.
int cvariant_compare (cvariant a, cvariant b)
 Compare two cvariants.
void cvariant_free (cvariant cv)
 Frees the memory allocated by the variant (if any).


Detailed Description

Author:
MùPùF - Martin Peres (martin<dot>peres<At>ensi-bourges<dot>fr)
Date:
04-08-2009

Enumeration Type Documentation

CVariant Types.

Enumerator:
cvariant_none  None.
cvariant_string  String.
cvariant_int  Int.
cvariant_float  Float.


Function Documentation

int cvariant_compare ( cvariant  a,
cvariant  b 
)

Compare two cvariants.

Parameters:
a The first cvariant.
b The second cvariant.
Returns:
Returns a non-zero value if a!=b, 0 otherwise.
Compare two cvariants. if a!=b, returns zero, otherwise, return a non-zero value.

void cvariant_free ( cvariant  cv  ) 

Frees the memory allocated by the variant (if any).

Parameters:
cv The cvariant to be freed.

cvariant cvariant_from_float ( double  value  ) 

Create a CVariant from a given.

Parameters:
value,: The float to be stored into the cvariant.
Returns:
Returns the corresponding cvariant.

cvariant cvariant_from_int ( int  value  ) 

Create a CVariant from a given integer.

Parameters:
value The integer to be stored into the cvariant.
Returns:
Returns the corresponding cvariant.

cvariant cvariant_from_string ( const char *  string  ) 

Create a CVariant from a given string. WARNING: Do not free the pointer and still use the cvariant. If you want to do so, use cvariant_from_string_copy.

Parameters:
string The string to be stored into the cvariant
Returns:
Returns the corresponding cvariant.

cvariant cvariant_from_string_copy ( const char *  string,
size_t  n 
)

Create a CVariant from a given string (copy, dynamically allocated).

Parameters:
string The string to be copied and stored into the cvariant.
Returns:
Returns the corresponding cvariant.

double cvariant_get_float ( cvariant  cv  ) 

Get an float from a cvariant.

Parameters:
cv The cvariant you want to get the float from.
Returns:
Returns the float or CVARIANT_EMPTY_FLOAT if it is not an integer.
Get a float from a cvariant. If the cvariant is not a float, -1.0 is returned.

int cvariant_get_int ( cvariant  cv  ) 

Get an integer from a cvariant.

Parameters:
cv The cvariant you want to get the integer from.
Returns:
Returns the integer or CVARIANT_EMPTY_INTEGER if it is not an integer.
Get an integer from a cvariant. If the cvariant is not an integer, -1 is returned.

const char* cvariant_get_string ( cvariant  cv  ) 

Get a string from a cvariant.

Parameters:
cv The cvariant you want to get the string from.
Returns:
Returns a null-terminated string or CVARIANT_EMPTY_STRING if it is not a string.
Get a string from a cvariant. If the cvariant is not a string, NULL is returned.

cvariant_type cvariant_get_type ( cvariant  cv  ) 

Get the current type of a cvariant.

Parameters:
cv The cvariant you want to get the type from.
Returns:
Returns a the type

int cvariant_not_null ( cvariant  cv  ) 

Test if a cvariant is null.

Parameters:
cv The cvariant to be tested.
Returns:
Returns a non-zero value if the cvariant is not null, 0 otherwise

cvariant cvariant_null (  ) 

Create an empty CVariant.

Returns:
Returns a null cvariant


Generated on Tue Aug 4 23:09:11 2009 for CVariant by  doxygen 1.5.9