2 ODKDA: Data Access Library
5 Copyright (C) 2006 Carlos Daniel Ruvalcaba Valenzuela
6 Contact me: <clsdaniel@gmail.com>
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <odkutils_xml.h>
31 #include <odkda/common.h>
32 #include <odkda/date.h>
33 #include <odkda/time.h>
34 #include <odkda/datetime.h>
35 #include <odkda/value.h>
38 odk_value_delete (odkValue
* v
)
62 odk_value_init (odkValue
* v
)
108 odk_value_new (char type
)
110 odkValue
*v
= (odkValue
*) malloc (sizeof (odkValue
));
112 object_register (v
, "odkValue");
113 object_append_destructor (v
, (FREE_FUNC
)&odk_value_delete
);
123 odk_value_new_shared (char type
, odkMemPool
* m
)
125 odkValue
*v
= (odkValue
*) odk_mempool_alloc (m
, sizeof (odkValue
));
127 object_register (v
, "odkValue");
128 object_append_destructor (v
, (FREE_FUNC
)&odk_value_delete
);
138 odk_value_set (odkValue
* v
, char *val
)
144 v
->vString
= strcopy (val
);
145 v
->size
= strlen(val
);
149 odk_value_set_bool (odkValue
* v
, bool val
)
159 odk_value_set_char (odkValue
* v
, char val
)
169 odk_value_set_short (odkValue
* v
, short val
)
179 odk_value_set_int (odkValue
* v
, int val
)
189 odk_value_set_long (odkValue
* v
, long val
)
199 odk_value_set_float (odkValue
* v
, float val
)
209 odk_value_set_double (odkValue
* v
, double val
)
219 odk_value_set_blob (odkValue
* v
, int size
, void *val
)
230 odk_value_set_date (odkValue
* v
, odkDate
* val
)
240 odk_value_set_time (odkValue
* v
, odkTime
* val
)
250 odk_value_set_datetime (odkValue
* v
, odkDateTime
* val
)
260 odk_value_get (odkValue
* v
)
267 ret
= strcopy ("True");
269 ret
= strcopy ("False");
273 ret
= (char *) malloc (sizeof (char) * 4);
274 sprintf (ret
, "%i", v
->vChar
);
277 ret
= (char *) malloc (sizeof (char) * 6);
278 sprintf (ret
, "%i", v
->vShort
);
281 ret
= (char *) malloc (sizeof (char) * 10);
282 sprintf (ret
, "%i", v
->vInt
);
285 ret
= (char *) malloc (sizeof (char) * 16);
286 sprintf (ret
, "%i", v
->vLong
);
289 ret
= (char *) malloc (sizeof (char) * 20);
290 sprintf (ret
, "%f", v
->vFloat
);
293 ret
= (char *) malloc (sizeof (char) * 25);
294 sprintf (ret
, "%f", (float)v
->vDouble
);
297 ret
= strcopy (v
->vString
);
300 ret
= (char *) v
->vBlob
;
311 odk_value_get_bool (odkValue
* v
)
320 odk_value_get_char (odkValue
* v
)
327 return (char) v
->vBool
;
338 odk_value_get_short (odkValue
* v
)
345 return (short) v
->vBool
;
347 return (short) v
->vChar
;
358 odk_value_get_int (odkValue
* v
)
365 return (int) v
->vBool
;
367 return (int) v
->vChar
;
369 return (int) v
->vShort
;
380 odk_value_get_long (odkValue
* v
)
387 return (long) v
->vBool
;
389 return (long) v
->vChar
;
391 return (long) v
->vShort
;
393 return (long) v
->vInt
;
404 odk_value_get_float (odkValue
* v
)
411 return (float) v
->vBool
;
413 return (float) v
->vChar
;
415 return (float) v
->vShort
;
417 return (float) v
->vInt
;
419 return (float) v
->vLong
;
423 return (float) v
->vDouble
;
432 odk_value_get_double (odkValue
* v
)
439 return (double) v
->vBool
;
441 return (double) v
->vChar
;
443 return (double) v
->vShort
;
445 return (double) v
->vInt
;
447 return (double) v
->vLong
;
449 return (double) v
->vFloat
;
459 odk_value_get_blob (odkValue
* v
)
467 odk_value_get_date (odkValue
* v
)
476 odk_value_get_time (odkValue
* v
)
485 odk_value_get_datetime (odkValue
* v
)
494 int odk_value_get_type(odkValue
*v
){
501 int odk_value_get_size(odkValue
*v
){
508 bool odk_value_is_changed(odkValue
*v
){