/builddir/build/BUILD/gru-0.2.0/src/common/gru_variant.c File Reference

#include <log/gru_logger.h>
#include "gru_variant.h"

Typedefs

typedef enum conversion_stat_t_ conversion_stat_t

Enumerations

enum  conversion_stat_t_ { VAR_ERROR = 0, VAR_SUCCESS = 1, VAR_OUT_OF_RANGE = 2, VAR_NOT_CONVERSIBLE = 4 }

Functions

bool gru_variant_set_string (gru_variant_t *variant, const char *str)
 Set the variant value to a string.
void gru_variant_set_integer (gru_variant_t *variant, uint64_t number)
 Set the variant value to an integer.
void gru_variant_clean (gru_variant_t *variant)
 Release the memory used by a variant (if any used at all).
gru_variant_t gru_variant_parse (const char *str)
 Parses a string and sets it to the most appropriate type.
bool gru_variant_equals_str (gru_variant_t *variant, const char *str)
 Simple equality check to test if the variant value matches a given string.

Typedef Documentation


Enumeration Type Documentation

Enumerator:
VAR_ERROR 
VAR_SUCCESS 
VAR_OUT_OF_RANGE 
VAR_NOT_CONVERSIBLE 

Function Documentation

void gru_variant_clean ( gru_variant_t variant  ) 

Release the memory used by a variant (if any used at all).

It's safe to pass any variant even if no memory is used at all

Parameters:
variant the variant to release
bool gru_variant_equals_str ( gru_variant_t variant,
const char *  str 
)

Simple equality check to test if the variant value matches a given string.

Parameters:
variant the variant to compare with
str the string to check
Returns:
true if it's equal or false otherwise
gru_variant_t gru_variant_parse ( const char *  str  ) 

Parses a string and sets it to the most appropriate type.

Parameters:
str the string to parse
Returns:
a variant (if all conversion fails, it defaults to string)
void gru_variant_set_integer ( gru_variant_t variant,
uint64_t  number 
)

Set the variant value to an integer.

Parameters:
variant the variant to hold the data
number the number to set
bool gru_variant_set_string ( gru_variant_t variant,
const char *  str 
)

Set the variant value to a string.

Parameters:
variant the variant hold the data
str the string to set
Returns:
false if unable to allocate memory for the string or true otherwise
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 7 Jan 2019 for GRU - Generic Reusable Utilities by  doxygen 1.6.1