eina_value_03.c
//Compile with:
//gcc eina_value_03.c -o eina_value_03 `pkg-config --cflags --libs eina`
#include <Eina.h>
#include <sys/time.h>
static Eina_Bool
{
memset(mem, 0, type->value_size);
return EINA_TRUE;
}
static Eina_Bool
{
return EINA_TRUE;
}
static Eina_Bool
{
struct timezone *tzsrc = src;
struct timezone *tzdst = dst;
*tzdst = *tzsrc;
return EINA_TRUE;
}
static Eina_Bool
{
struct timezone tza = *(struct timezone*)a;
struct timezone tzb = *(struct timezone*)b;
if (tza.tz_minuteswest < tzb.tz_minuteswest)
return -1;
else if (tza.tz_minuteswest > tzb.tz_minuteswest)
return 1;
return 0;
}
static Eina_Bool
{
*(struct timezone*)mem = *(struct timezone*)ptr;
return EINA_TRUE;
}
static Eina_Bool
{
const struct timezone tz = va_arg(args, struct timezone);
return _tz_pset(type, mem, &tz);
}
static Eina_Bool
{
memcpy(ptr, mem, type->value_size);
return EINA_TRUE;
}
static Eina_Bool
_tz_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
{
struct timezone v = *(struct timezone*)type_mem;
eina_error_set(0);
if (convert == EINA_VALUE_TYPE_UCHAR)
{
unsigned char other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
unsigned short other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
unsigned int other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
unsigned long other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
uint64_t other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
char other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
short other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
int other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
long other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
{
int64_t other_mem = v.tz_minuteswest;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
return eina_value_type_pset(convert, convert_mem, &v.tz_minuteswest);
return eina_value_type_pset(convert, convert_mem, &v.tz_minuteswest);
convert == EINA_VALUE_TYPE_STRING)
{
const char *other_mem;
char buf[64];
snprintf(buf, sizeof(buf), "%d", v.tz_minuteswest);
other_mem = buf; /* required due &buf == buf */
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
return EINA_FALSE;
}
static Eina_Value_Type TZ_TYPE = {
sizeof(struct timezone),
"struct timezone",
_tz_setup,
_tz_flush,
_tz_copy,
_tz_compare,
_tz_convert_to,
NULL, //No convert from
_tz_vset,
_tz_pset,
_tz_pget
};
int main(int argc, char **argv)
{
Eina_Value vtv, vtz;
struct timeval tv;
struct timezone tz;
char *s;
eina_init();
eina_value_setup(&vtz, &TZ_TYPE);
gettimeofday(&tv, &tz);
eina_value_set(&vtv, tv);
eina_value_set(&vtz, tz);
s = eina_value_to_string(&vtv);
printf("time: %s\n", s);
free(s);
s = eina_value_to_string(&vtz);
printf("timezone: %s\n", s);
free(s);
eina_value_flush(&vtz);
eina_value_flush(&vtv);
}
Eina Utility library.
const Eina_Value_Type * EINA_VALUE_TYPE_ULONG
manages unsigned long type.
Definition eina_value.c:5082
const Eina_Value_Type * EINA_VALUE_TYPE_CHAR
manages char type.
Definition eina_value.c:5085
const Eina_Value_Type * EINA_VALUE_TYPE_USHORT
manages unsigned short type.
Definition eina_value.c:5080
const Eina_Value_Type * EINA_VALUE_TYPE_TIMEVAL
manages 'struct timeval' type
Definition eina_value.c:5097
const Eina_Value_Type * EINA_VALUE_TYPE_UINT64
manages unsigned integer of 64 bits type.
Definition eina_value.c:5084
const Eina_Value_Type * EINA_VALUE_TYPE_UCHAR
manages unsigned char type.
Definition eina_value.c:5079
const Eina_Value_Type * EINA_VALUE_TYPE_LONG
manages long type.
Definition eina_value.c:5088
const Eina_Value_Type * EINA_VALUE_TYPE_INT64
manages integer of 64 bits type.
Definition eina_value.c:5089
const Eina_Value_Type * EINA_VALUE_TYPE_DOUBLE
manages double type.
Definition eina_value.c:5091
const Eina_Value_Type * EINA_VALUE_TYPE_INT
manages int type.
Definition eina_value.c:5087
const Eina_Value_Type * EINA_VALUE_TYPE_STRING
manages string type.
Definition eina_value.c:5093
const Eina_Value_Type * EINA_VALUE_TYPE_TIMESTAMP
manages unsigned long type used for timestamps.
Definition eina_value.c:5083
const Eina_Value_Type * EINA_VALUE_TYPE_FLOAT
manages float type.
Definition eina_value.c:5090
const Eina_Value_Type * EINA_VALUE_TYPE_UINT
manages unsigned int type.
Definition eina_value.c:5081
const Eina_Value_Type * EINA_VALUE_TYPE_STRINGSHARE
manages stringshared string type.
Definition eina_value.c:5092
int EINA_ERROR_VALUE_FAILED
Error identifier corresponding to value check failure.
Definition eina_value.c:5109
const Eina_Value_Type * EINA_VALUE_TYPE_SHORT
manages short type.
Definition eina_value.c:5086
#define EINA_VALUE_TYPE_VERSION
Current API version, used to validate type.
Definition eina_value.h:3363
static Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr)
Set memory using type descriptor and pointer.
char * eina_value_to_string(const Eina_Value *value)
Convert value to string.
Definition eina_value.c:5203
static Eina_Bool eina_value_setup(Eina_Value *value, const Eina_Value_Type *type)
Initialize generic value storage.