2 /*======================================================================
4 CREATOR: eric 02 May 1999
9 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
22 The original code is icalvalue.c
25 Graham Davison (g.m.davison@computer.org)
28 ======================================================================*/
34 #include "icalerror.h"
35 #include "icalmemory.h"
36 #include "icalparser.h"
37 #include "icalenums.h"
39 #include "icalvalueimpl.h"
41 #include <stdlib.h> /* for malloc */
42 #include <stdio.h> /* for sprintf */
43 #include <string.h> /* For memset, others */
44 #include <stddef.h> /* For offsetof() macro */
46 #include <time.h> /* for mktime */
47 #include <stdlib.h> /* for atoi and atof */
48 #include <limits.h> /* for SHRT_MAX */
52 #define TMP_BUF_SIZE 1024
54 struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind);
56 /* This map associates each of the value types with its string
58 struct icalvalue_kind_map {
63 static struct icalvalue_kind_map value_map[];
65 const char* icalvalue_kind_to_string(icalvalue_kind kind)
69 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
70 if (value_map[i].kind == kind) {
71 return value_map[i].name;
78 icalvalue_kind icalvalue_string_to_kind(const char* str)
82 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
83 if (strcmp(value_map[i].name,str) == 0) {
84 return value_map[i].kind;
88 return value_map[i].kind;
92 icalvalue* icalvalue_new_x (const char* v){
93 struct icalvalue_impl* impl;
94 icalerror_check_arg_rz( (v!=0),"v");
95 impl = icalvalue_new_impl(ICAL_X_VALUE);
96 icalvalue_set_x((icalvalue*)impl,v);
97 return (icalvalue*)impl;
99 void icalvalue_set_x(icalvalue* value, const char* v) {
100 struct icalvalue_impl* impl;
101 icalerror_check_arg_rv( (value!=0),"value");
102 icalerror_check_arg_rv( (v!=0),"v");
104 impl = (struct icalvalue_impl*)value;
105 if(impl->x_value!=0) {free((void*)impl->x_value);}
107 impl->x_value = icalmemory_strdup(v);
109 if (impl->x_value == 0){
114 const char* icalvalue_get_x(icalvalue* value) {
116 icalerror_check_arg_rz( (value!=0),"value");
117 icalerror_check_value_type(value, ICAL_X_VALUE);
118 return ((struct icalvalue_impl*)value)->x_value;
121 /* Recur is a special case, so it is not auto generated. */
123 icalvalue_new_recur (struct icalrecurrencetype v)
125 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE);
127 icalvalue_set_recur((icalvalue*)impl,v);
129 return (icalvalue*)impl;
133 icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v)
135 struct icalvalue_impl* impl;
137 icalerror_check_arg_rv( (value!=0),"value");
138 icalerror_check_value_type(value, ICAL_RECUR_VALUE);
140 impl = (struct icalvalue_impl*)value;
142 if (impl->data.v_recur != 0){
143 free(impl->data.v_recur);
144 impl->data.v_recur = 0;
147 impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
149 if (impl->data.v_recur == 0){
150 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
153 memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
158 struct icalrecurrencetype
159 icalvalue_get_recur(icalvalue* value)
161 icalerror_check_arg( (value!=0),"value");
162 icalerror_check_value_type(value, ICAL_RECUR_VALUE);
164 return *(((struct icalvalue_impl*)value)->data.v_recur);
171 icalvalue_new_trigger (struct icaltriggertype v)
173 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE);
175 icalvalue_set_trigger((icalvalue*)impl,v);
177 return (icalvalue*)impl;
181 icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v)
183 struct icalvalue_impl* impl;
185 icalerror_check_arg_rv( (value!=0),"value");
187 impl = (struct icalvalue_impl*)value;
189 if(!icaltime_is_null_time(v.time)){
190 icalvalue_set_datetime((icalvalue*)impl,v.time);
191 impl->kind = ICAL_DATETIME_VALUE;
193 icalvalue_set_duration((icalvalue*)impl,v.duration);
194 impl->kind = ICAL_DURATION_VALUE;
199 struct icaltriggertype
200 icalvalue_get_trigger(icalvalue* value)
202 struct icalvalue_impl *impl = (struct icalvalue_impl*)value;
203 struct icaltriggertype tr;
205 icalerror_check_arg( (value!=0),"value");
207 if(impl->kind == ICAL_DATETIME_VALUE){
208 tr.duration = icaldurationtype_from_int(0);
209 tr.time = impl->data.v_time;
210 } else if(impl->kind == ICAL_DURATION_VALUE){
211 tr.time = icaltime_null_time();
212 tr.duration = impl->data.v_duration;
214 tr.duration = icaldurationtype_from_int(0);
215 tr.time = icaltime_null_time();
216 icalerror_set_errno(ICAL_BADARG_ERROR);
222 /* DATE-TIME-PERIOD is a special case, and is not auto generated */
225 icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v)
227 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE);
229 icalvalue_set_datetimeperiod((icalvalue*)impl,v);
231 return (icalvalue*)impl;
235 icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v)
237 struct icalvalue_impl* impl = (struct icalvalue_impl*)value;
239 icalerror_check_arg_rv( (value!=0),"value");
241 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
243 if(!icaltime_is_null_time(v.time)){
244 if(!icaltime_is_valid_time(v.time)){
245 icalerror_set_errno(ICAL_BADARG_ERROR);
248 impl->kind = ICAL_DATETIME_VALUE;
249 icalvalue_set_datetime(impl,v.time);
250 } else if (!icalperiodtype_is_null_period(v.period)) {
251 if(!icalperiodtype_is_valid_period(v.period)){
252 icalerror_set_errno(ICAL_BADARG_ERROR);
255 impl->kind = ICAL_PERIOD_VALUE;
256 icalvalue_set_period(impl,v.period);
258 icalerror_set_errno(ICAL_BADARG_ERROR);
262 struct icaldatetimeperiodtype
263 icalvalue_get_datetimeperiod(icalvalue* value)
265 struct icaldatetimeperiodtype dtp;
267 struct icalvalue_impl* impl = (struct icalvalue_impl*)value;
268 icalerror_check_arg( (value!=0),"value");
269 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
271 if(impl->kind == ICAL_DATETIME_VALUE){
272 dtp.period = icalperiodtype_null_period();
273 dtp.time = impl->data.v_time;
274 } else if(impl->kind == ICAL_PERIOD_VALUE) {
275 dtp.period = impl->data.v_period;
276 dtp.time = icaltime_null_time();
278 dtp.period = icalperiodtype_null_period();
279 dtp.time = icaltime_null_time();
280 icalerror_set_errno(ICAL_BADARG_ERROR);
294 /* The remaining interfaces are 'new', 'set' and 'get' for each of the value
298 /* Everything below this line is machine generated. Do not edit. */
299 static struct icalvalue_kind_map value_map[]={
300 {ICAL_RECUR_VALUE,"RECUR"},
301 {ICAL_DATETIMEDATE_VALUE,"DATE-TIME-DATE"},
302 {ICAL_DATETIMEPERIOD_VALUE,"DATE-TIME-PERIOD"},
303 {ICAL_CALADDRESS_VALUE,"CAL-ADDRESS"},
304 {ICAL_BOOLEAN_VALUE,"BOOLEAN"},
305 {ICAL_DATETIME_VALUE,"DATE-TIME"},
306 {ICAL_DURATION_VALUE,"DURATION"},
307 {ICAL_TRIGGER_VALUE,"TRIGGER"},
308 {ICAL_UTCOFFSET_VALUE,"UTC-OFFSET"},
309 {ICAL_TRANSP_VALUE,"TRANSP"},
310 {ICAL_DATE_VALUE,"DATE"},
311 {ICAL_GEO_VALUE,"GEO"},
312 {ICAL_PERIOD_VALUE,"PERIOD"},
313 {ICAL_INTEGER_VALUE,"INTEGER"},
315 {ICAL_TIME_VALUE,"TIME"},
316 {ICAL_QUERY_VALUE,"QUERY"},
317 {ICAL_ATTACH_VALUE,"ATTACH"},
318 {ICAL_FLOAT_VALUE,"FLOAT"},
319 {ICAL_BINARY_VALUE,"BINARY"},
320 {ICAL_STRING_VALUE,"STRING"},
321 {ICAL_URI_VALUE,"URI"},
322 {ICAL_ACTION_VALUE,"ACTION"},
323 {ICAL_CLASS_VALUE,"CLASS"},
324 {ICAL_METHOD_VALUE,"METHOD"},
325 {ICAL_TEXT_VALUE,"TEXT"},
326 {ICAL_STATUS_VALUE,"STATUS"},
331 icalvalue* icalvalue_new_datetimedate (struct icaltimetype v){
332 struct icalvalue_impl* impl;
334 impl = icalvalue_new_impl(ICAL_DATETIMEDATE_VALUE);
335 icalvalue_set_datetimedate((icalvalue*)impl,v);
336 return (icalvalue*)impl;
338 void icalvalue_set_datetimedate(icalvalue* value, struct icaltimetype v) {
339 struct icalvalue_impl* impl;
340 icalerror_check_arg_rv( (value!=0),"value");
342 icalerror_check_value_type(value, ICAL_DATETIMEDATE_VALUE);
343 impl = (struct icalvalue_impl*)value;
345 impl->data.v_time = v;
347 struct icaltimetype icalvalue_get_datetimedate(icalvalue* value) {
349 icalerror_check_arg( (value!=0),"value");
350 icalerror_check_value_type(value, ICAL_DATETIMEDATE_VALUE);
351 return ((struct icalvalue_impl*)value)->data.v_time;
356 icalvalue* icalvalue_new_caladdress (const char* v){
357 struct icalvalue_impl* impl;
358 icalerror_check_arg_rz( (v!=0),"v");
360 impl = icalvalue_new_impl(ICAL_CALADDRESS_VALUE);
361 icalvalue_set_caladdress((icalvalue*)impl,v);
362 return (icalvalue*)impl;
364 void icalvalue_set_caladdress(icalvalue* value, const char* v) {
365 struct icalvalue_impl* impl;
366 icalerror_check_arg_rv( (value!=0),"value");
367 icalerror_check_arg_rv( (v!=0),"v");
369 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE);
370 impl = (struct icalvalue_impl*)value;
371 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
373 impl->data.v_string = icalmemory_strdup(v);
375 if (impl->data.v_string == 0){
380 const char* icalvalue_get_caladdress(icalvalue* value) {
382 icalerror_check_arg_rz( (value!=0),"value");
383 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE);
384 return ((struct icalvalue_impl*)value)->data.v_string;
389 icalvalue* icalvalue_new_boolean (int v){
390 struct icalvalue_impl* impl;
392 impl = icalvalue_new_impl(ICAL_BOOLEAN_VALUE);
393 icalvalue_set_boolean((icalvalue*)impl,v);
394 return (icalvalue*)impl;
396 void icalvalue_set_boolean(icalvalue* value, int v) {
397 struct icalvalue_impl* impl;
398 icalerror_check_arg_rv( (value!=0),"value");
400 icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE);
401 impl = (struct icalvalue_impl*)value;
403 impl->data.v_int = v;
405 int icalvalue_get_boolean(icalvalue* value) {
407 icalerror_check_arg( (value!=0),"value");
408 icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE);
409 return ((struct icalvalue_impl*)value)->data.v_int;
414 icalvalue* icalvalue_new_datetime (struct icaltimetype v){
415 struct icalvalue_impl* impl;
417 impl = icalvalue_new_impl(ICAL_DATETIME_VALUE);
418 icalvalue_set_datetime((icalvalue*)impl,v);
419 return (icalvalue*)impl;
421 void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) {
422 struct icalvalue_impl* impl;
423 icalerror_check_arg_rv( (value!=0),"value");
425 icalerror_check_value_type(value, ICAL_DATETIME_VALUE);
426 impl = (struct icalvalue_impl*)value;
428 impl->data.v_time = v;
430 struct icaltimetype icalvalue_get_datetime(icalvalue* value) {
432 icalerror_check_arg( (value!=0),"value");
433 icalerror_check_value_type(value, ICAL_DATETIME_VALUE);
434 return ((struct icalvalue_impl*)value)->data.v_time;
439 icalvalue* icalvalue_new_duration (struct icaldurationtype v){
440 struct icalvalue_impl* impl;
442 impl = icalvalue_new_impl(ICAL_DURATION_VALUE);
443 icalvalue_set_duration((icalvalue*)impl,v);
444 return (icalvalue*)impl;
446 void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) {
447 struct icalvalue_impl* impl;
448 icalerror_check_arg_rv( (value!=0),"value");
450 icalerror_check_value_type(value, ICAL_DURATION_VALUE);
451 impl = (struct icalvalue_impl*)value;
453 impl->data.v_duration = v;
455 struct icaldurationtype icalvalue_get_duration(icalvalue* value) {
457 icalerror_check_arg( (value!=0),"value");
458 icalerror_check_value_type(value, ICAL_DURATION_VALUE);
459 return ((struct icalvalue_impl*)value)->data.v_duration;
464 icalvalue* icalvalue_new_utcoffset (int v){
465 struct icalvalue_impl* impl;
467 impl = icalvalue_new_impl(ICAL_UTCOFFSET_VALUE);
468 icalvalue_set_utcoffset((icalvalue*)impl,v);
469 return (icalvalue*)impl;
471 void icalvalue_set_utcoffset(icalvalue* value, int v) {
472 struct icalvalue_impl* impl;
473 icalerror_check_arg_rv( (value!=0),"value");
475 icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE);
476 impl = (struct icalvalue_impl*)value;
478 impl->data.v_int = v;
480 int icalvalue_get_utcoffset(icalvalue* value) {
482 icalerror_check_arg( (value!=0),"value");
483 icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE);
484 return ((struct icalvalue_impl*)value)->data.v_int;
489 icalvalue* icalvalue_new_transp (enum icalproperty_transp v){
490 struct icalvalue_impl* impl;
492 impl = icalvalue_new_impl(ICAL_TRANSP_VALUE);
493 icalvalue_set_transp((icalvalue*)impl,v);
494 return (icalvalue*)impl;
496 void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
497 struct icalvalue_impl* impl;
498 icalerror_check_arg_rv( (value!=0),"value");
500 icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
501 impl = (struct icalvalue_impl*)value;
503 impl->data.v_enum = v;
505 enum icalproperty_transp icalvalue_get_transp(icalvalue* value) {
507 icalerror_check_arg( (value!=0),"value");
508 icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
509 return ((struct icalvalue_impl*)value)->data.v_enum;
514 icalvalue* icalvalue_new_date (struct icaltimetype v){
515 struct icalvalue_impl* impl;
517 impl = icalvalue_new_impl(ICAL_DATE_VALUE);
518 icalvalue_set_date((icalvalue*)impl,v);
519 return (icalvalue*)impl;
521 void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
522 struct icalvalue_impl* impl;
523 icalerror_check_arg_rv( (value!=0),"value");
525 icalerror_check_value_type(value, ICAL_DATE_VALUE);
526 impl = (struct icalvalue_impl*)value;
528 impl->data.v_time = v;
530 struct icaltimetype icalvalue_get_date(icalvalue* value) {
532 icalerror_check_arg( (value!=0),"value");
533 icalerror_check_value_type(value, ICAL_DATE_VALUE);
534 return ((struct icalvalue_impl*)value)->data.v_time;
539 icalvalue* icalvalue_new_geo (struct icalgeotype v){
540 struct icalvalue_impl* impl;
542 impl = icalvalue_new_impl(ICAL_GEO_VALUE);
543 icalvalue_set_geo((icalvalue*)impl,v);
544 return (icalvalue*)impl;
546 void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
547 struct icalvalue_impl* impl;
548 icalerror_check_arg_rv( (value!=0),"value");
550 icalerror_check_value_type(value, ICAL_GEO_VALUE);
551 impl = (struct icalvalue_impl*)value;
553 impl->data.v_geo = v;
555 struct icalgeotype icalvalue_get_geo(icalvalue* value) {
557 icalerror_check_arg( (value!=0),"value");
558 icalerror_check_value_type(value, ICAL_GEO_VALUE);
559 return ((struct icalvalue_impl*)value)->data.v_geo;
564 icalvalue* icalvalue_new_period (struct icalperiodtype v){
565 struct icalvalue_impl* impl;
567 impl = icalvalue_new_impl(ICAL_PERIOD_VALUE);
568 icalvalue_set_period((icalvalue*)impl,v);
569 return (icalvalue*)impl;
571 void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
572 struct icalvalue_impl* impl;
573 icalerror_check_arg_rv( (value!=0),"value");
575 icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
576 impl = (struct icalvalue_impl*)value;
578 impl->data.v_period = v;
580 struct icalperiodtype icalvalue_get_period(icalvalue* value) {
582 icalerror_check_arg( (value!=0),"value");
583 icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
584 return ((struct icalvalue_impl*)value)->data.v_period;
589 icalvalue* icalvalue_new_integer (int v){
590 struct icalvalue_impl* impl;
592 impl = icalvalue_new_impl(ICAL_INTEGER_VALUE);
593 icalvalue_set_integer((icalvalue*)impl,v);
594 return (icalvalue*)impl;
596 void icalvalue_set_integer(icalvalue* value, int v) {
597 struct icalvalue_impl* impl;
598 icalerror_check_arg_rv( (value!=0),"value");
600 icalerror_check_value_type(value, ICAL_INTEGER_VALUE);
601 impl = (struct icalvalue_impl*)value;
603 impl->data.v_int = v;
605 int icalvalue_get_integer(icalvalue* value) {
607 icalerror_check_arg( (value!=0),"value");
608 icalerror_check_value_type(value, ICAL_INTEGER_VALUE);
609 return ((struct icalvalue_impl*)value)->data.v_int;
614 icalvalue* icalvalue_new_time (struct icaltimetype v){
615 struct icalvalue_impl* impl;
617 impl = icalvalue_new_impl(ICAL_TIME_VALUE);
618 icalvalue_set_time((icalvalue*)impl,v);
619 return (icalvalue*)impl;
621 void icalvalue_set_time(icalvalue* value, struct icaltimetype v) {
622 struct icalvalue_impl* impl;
623 icalerror_check_arg_rv( (value!=0),"value");
625 icalerror_check_value_type(value, ICAL_TIME_VALUE);
626 impl = (struct icalvalue_impl*)value;
628 impl->data.v_time = v;
630 struct icaltimetype icalvalue_get_time(icalvalue* value) {
632 icalerror_check_arg( (value!=0),"value");
633 icalerror_check_value_type(value, ICAL_TIME_VALUE);
634 return ((struct icalvalue_impl*)value)->data.v_time;
639 icalvalue* icalvalue_new_query (const char* v){
640 struct icalvalue_impl* impl;
641 icalerror_check_arg_rz( (v!=0),"v");
643 impl = icalvalue_new_impl(ICAL_QUERY_VALUE);
644 icalvalue_set_query((icalvalue*)impl,v);
645 return (icalvalue*)impl;
647 void icalvalue_set_query(icalvalue* value, const char* v) {
648 struct icalvalue_impl* impl;
649 icalerror_check_arg_rv( (value!=0),"value");
650 icalerror_check_arg_rv( (v!=0),"v");
652 icalerror_check_value_type(value, ICAL_QUERY_VALUE);
653 impl = (struct icalvalue_impl*)value;
654 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
656 impl->data.v_string = icalmemory_strdup(v);
658 if (impl->data.v_string == 0){
663 const char* icalvalue_get_query(icalvalue* value) {
665 icalerror_check_arg_rz( (value!=0),"value");
666 icalerror_check_value_type(value, ICAL_QUERY_VALUE);
667 return ((struct icalvalue_impl*)value)->data.v_string;
672 icalvalue* icalvalue_new_attach (struct icalattachtype v){
673 struct icalvalue_impl* impl;
675 impl = icalvalue_new_impl(ICAL_ATTACH_VALUE);
676 icalvalue_set_attach((icalvalue*)impl,v);
677 return (icalvalue*)impl;
679 void icalvalue_set_attach(icalvalue* value, struct icalattachtype v) {
680 struct icalvalue_impl* impl;
681 icalerror_check_arg_rv( (value!=0),"value");
683 icalerror_check_value_type(value, ICAL_ATTACH_VALUE);
684 impl = (struct icalvalue_impl*)value;
686 impl->data.v_attach = v;
688 struct icalattachtype icalvalue_get_attach(icalvalue* value) {
690 icalerror_check_arg( (value!=0),"value");
691 icalerror_check_value_type(value, ICAL_ATTACH_VALUE);
692 return ((struct icalvalue_impl*)value)->data.v_attach;
697 icalvalue* icalvalue_new_float (float v){
698 struct icalvalue_impl* impl;
700 impl = icalvalue_new_impl(ICAL_FLOAT_VALUE);
701 icalvalue_set_float((icalvalue*)impl,v);
702 return (icalvalue*)impl;
704 void icalvalue_set_float(icalvalue* value, float v) {
705 struct icalvalue_impl* impl;
706 icalerror_check_arg_rv( (value!=0),"value");
708 icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
709 impl = (struct icalvalue_impl*)value;
711 impl->data.v_float = v;
713 float icalvalue_get_float(icalvalue* value) {
715 icalerror_check_arg( (value!=0),"value");
716 icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
717 return ((struct icalvalue_impl*)value)->data.v_float;
722 icalvalue* icalvalue_new_binary (const char* v){
723 struct icalvalue_impl* impl;
724 icalerror_check_arg_rz( (v!=0),"v");
726 impl = icalvalue_new_impl(ICAL_BINARY_VALUE);
727 icalvalue_set_binary((icalvalue*)impl,v);
728 return (icalvalue*)impl;
730 void icalvalue_set_binary(icalvalue* value, const char* v) {
731 struct icalvalue_impl* impl;
732 icalerror_check_arg_rv( (value!=0),"value");
733 icalerror_check_arg_rv( (v!=0),"v");
735 icalerror_check_value_type(value, ICAL_BINARY_VALUE);
736 impl = (struct icalvalue_impl*)value;
737 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
739 impl->data.v_string = icalmemory_strdup(v);
741 if (impl->data.v_string == 0){
746 const char* icalvalue_get_binary(icalvalue* value) {
748 icalerror_check_arg_rz( (value!=0),"value");
749 icalerror_check_value_type(value, ICAL_BINARY_VALUE);
750 return ((struct icalvalue_impl*)value)->data.v_string;
755 icalvalue* icalvalue_new_string (const char* v){
756 struct icalvalue_impl* impl;
757 icalerror_check_arg_rz( (v!=0),"v");
759 impl = icalvalue_new_impl(ICAL_STRING_VALUE);
760 icalvalue_set_string((icalvalue*)impl,v);
761 return (icalvalue*)impl;
763 void icalvalue_set_string(icalvalue* value, const char* v) {
764 struct icalvalue_impl* impl;
765 icalerror_check_arg_rv( (value!=0),"value");
766 icalerror_check_arg_rv( (v!=0),"v");
768 icalerror_check_value_type(value, ICAL_STRING_VALUE);
769 impl = (struct icalvalue_impl*)value;
770 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
772 impl->data.v_string = icalmemory_strdup(v);
774 if (impl->data.v_string == 0){
779 const char* icalvalue_get_string(icalvalue* value) {
781 icalerror_check_arg_rz( (value!=0),"value");
782 icalerror_check_value_type(value, ICAL_STRING_VALUE);
783 return ((struct icalvalue_impl*)value)->data.v_string;
788 icalvalue* icalvalue_new_uri (const char* v){
789 struct icalvalue_impl* impl;
790 icalerror_check_arg_rz( (v!=0),"v");
792 impl = icalvalue_new_impl(ICAL_URI_VALUE);
793 icalvalue_set_uri((icalvalue*)impl,v);
794 return (icalvalue*)impl;
796 void icalvalue_set_uri(icalvalue* value, const char* v) {
797 struct icalvalue_impl* impl;
798 icalerror_check_arg_rv( (value!=0),"value");
799 icalerror_check_arg_rv( (v!=0),"v");
801 icalerror_check_value_type(value, ICAL_URI_VALUE);
802 impl = (struct icalvalue_impl*)value;
803 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
805 impl->data.v_string = icalmemory_strdup(v);
807 if (impl->data.v_string == 0){
812 const char* icalvalue_get_uri(icalvalue* value) {
814 icalerror_check_arg_rz( (value!=0),"value");
815 icalerror_check_value_type(value, ICAL_URI_VALUE);
816 return ((struct icalvalue_impl*)value)->data.v_string;
821 icalvalue* icalvalue_new_action (enum icalproperty_action v){
822 struct icalvalue_impl* impl;
824 impl = icalvalue_new_impl(ICAL_ACTION_VALUE);
825 icalvalue_set_action((icalvalue*)impl,v);
826 return (icalvalue*)impl;
828 void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
829 struct icalvalue_impl* impl;
830 icalerror_check_arg_rv( (value!=0),"value");
832 icalerror_check_value_type(value, ICAL_ACTION_VALUE);
833 impl = (struct icalvalue_impl*)value;
835 impl->data.v_enum = v;
837 enum icalproperty_action icalvalue_get_action(icalvalue* value) {
839 icalerror_check_arg( (value!=0),"value");
840 icalerror_check_value_type(value, ICAL_ACTION_VALUE);
841 return ((struct icalvalue_impl*)value)->data.v_enum;
846 icalvalue* icalvalue_new_class (enum icalproperty_class v){
847 struct icalvalue_impl* impl;
849 impl = icalvalue_new_impl(ICAL_CLASS_VALUE);
850 icalvalue_set_class((icalvalue*)impl,v);
851 return (icalvalue*)impl;
853 void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) {
854 struct icalvalue_impl* impl;
855 icalerror_check_arg_rv( (value!=0),"value");
857 icalerror_check_value_type(value, ICAL_CLASS_VALUE);
858 impl = (struct icalvalue_impl*)value;
860 impl->data.v_enum = v;
862 enum icalproperty_class icalvalue_get_class(icalvalue* value) {
864 icalerror_check_arg( (value!=0),"value");
865 icalerror_check_value_type(value, ICAL_CLASS_VALUE);
866 return ((struct icalvalue_impl*)value)->data.v_enum;
871 icalvalue* icalvalue_new_method (enum icalproperty_method v){
872 struct icalvalue_impl* impl;
874 impl = icalvalue_new_impl(ICAL_METHOD_VALUE);
875 icalvalue_set_method((icalvalue*)impl,v);
876 return (icalvalue*)impl;
878 void icalvalue_set_method(icalvalue* value, enum icalproperty_method v) {
879 struct icalvalue_impl* impl;
880 icalerror_check_arg_rv( (value!=0),"value");
882 icalerror_check_value_type(value, ICAL_METHOD_VALUE);
883 impl = (struct icalvalue_impl*)value;
885 impl->data.v_enum = v;
887 enum icalproperty_method icalvalue_get_method(icalvalue* value) {
889 icalerror_check_arg( (value!=0),"value");
890 icalerror_check_value_type(value, ICAL_METHOD_VALUE);
891 return ((struct icalvalue_impl*)value)->data.v_enum;
896 icalvalue* icalvalue_new_text (const char* v){
897 struct icalvalue_impl* impl;
898 icalerror_check_arg_rz( (v!=0),"v");
900 impl = icalvalue_new_impl(ICAL_TEXT_VALUE);
901 icalvalue_set_text((icalvalue*)impl,v);
902 return (icalvalue*)impl;
904 void icalvalue_set_text(icalvalue* value, const char* v) {
905 struct icalvalue_impl* impl;
906 icalerror_check_arg_rv( (value!=0),"value");
907 icalerror_check_arg_rv( (v!=0),"v");
909 icalerror_check_value_type(value, ICAL_TEXT_VALUE);
910 impl = (struct icalvalue_impl*)value;
911 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
913 impl->data.v_string = icalmemory_strdup(v);
915 if (impl->data.v_string == 0){
920 const char* icalvalue_get_text(icalvalue* value) {
922 icalerror_check_arg_rz( (value!=0),"value");
923 icalerror_check_value_type(value, ICAL_TEXT_VALUE);
924 return ((struct icalvalue_impl*)value)->data.v_string;
929 icalvalue* icalvalue_new_status (enum icalproperty_status v){
930 struct icalvalue_impl* impl;
932 impl = icalvalue_new_impl(ICAL_STATUS_VALUE);
933 icalvalue_set_status((icalvalue*)impl,v);
934 return (icalvalue*)impl;
936 void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) {
937 struct icalvalue_impl* impl;
938 icalerror_check_arg_rv( (value!=0),"value");
940 icalerror_check_value_type(value, ICAL_STATUS_VALUE);
941 impl = (struct icalvalue_impl*)value;
943 impl->data.v_enum = v;
945 enum icalproperty_status icalvalue_get_status(icalvalue* value) {
947 icalerror_check_arg( (value!=0),"value");
948 icalerror_check_value_type(value, ICAL_STATUS_VALUE);
949 return ((struct icalvalue_impl*)value)->data.v_enum;