bump to 1.0.0 and clean up spec file
[platform/upstream/libical.git] / src / libical / icalvalue_cxx.cpp
1 /* -*- Mode: C -*- */
2 /*======================================================================
3  FILE: icalvalue_cxx.cpp
4  CREATOR: fnguyen 12/21/01
5  (C) COPYRIGHT 2001, Critical Path
6
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of either: 
9
10     The LGPL as published by the Free Software Foundation, version
11     2.1, available at: http://www.fsf.org/copyleft/lesser.html
12
13   Or:
14
15     The Mozilla Public License Version 1.0. You may obtain a copy of
16     the License at http://www.mozilla.org/MPL/
17 ======================================================================*/
18
19 #ifndef ICALVALUE_CXX_H
20 #include "icalvalue_cxx.h"
21 #endif
22
23 typedef char* string; // Will use the string library from STL
24
25 ICalValue::ICalValue() throw(icalerrorenum) : imp(icalvalue_new(ICAL_ANY_VALUE)){}
26
27 ICalValue::ICalValue(const ICalValue& v) throw (icalerrorenum) {
28         imp = icalvalue_new_clone(v.imp);
29         if (!imp) throw icalerrno;
30 }
31 ICalValue& ICalValue::operator=(const ICalValue& v) throw(icalerrorenum) {
32         if (this == &v) return *this;
33
34         if (imp != NULL)
35         {
36                 icalvalue_free(imp);
37                 imp = icalvalue_new_clone(v.imp);
38                 if (!imp) throw icalerrno;
39         }
40
41         return *this;
42 }
43
44 ICalValue::~ICalValue(){
45         if (imp != NULL) icalvalue_free(imp);
46 }
47
48 ICalValue::ICalValue(icalvalue* v) throw(icalerrorenum) : imp(v){
49 }
50
51 ICalValue::ICalValue(icalvalue_kind kind) throw(icalerrorenum) {
52         imp = icalvalue_new(kind);
53         if (!imp) throw icalerrno;
54 }
55
56 ICalValue::ICalValue(icalvalue_kind kind, string  str) throw(icalerrorenum) {
57         imp = icalvalue_new_from_string(kind, str);
58         if (!imp) throw icalerrno;
59 }
60
61 string ICalValue::as_ical_string(){
62         return (string)icalvalue_as_ical_string(imp);
63 }
64 bool ICalValue::is_valid(){
65         if (imp == NULL) return false;
66         return (icalvalue_is_valid(imp) ? true : false);
67 }
68 icalvalue_kind ICalValue::isa(){
69         return icalvalue_isa(imp);
70 }
71 int ICalValue::isa_value(void* value){
72         return icalvalue_isa_value(value);
73 }
74
75 /* Special, non autogenerated value accessors */
76 void ICalValue::set_recur(struct icalrecurrencetype v){
77         icalvalue_set_recur(imp, v);
78 }
79 struct icalrecurrencetype ICalValue::get_recur(){
80         return icalvalue_get_recur(imp);
81 }
82
83 void ICalValue::set_trigger(struct icaltriggertype v){}
84 struct icaltriggertype ICalValue::get_trigger(){
85         return icalvalue_get_trigger(imp);
86 }
87
88 void ICalValue::set_datetimeperiod(struct icaldatetimeperiodtype v){
89         icalvalue_set_datetimeperiod(imp, v);
90 }
91 struct icaldatetimeperiodtype ICalValue::get_datetimeperiod(){
92         return icalvalue_get_datetimeperiod(imp);
93 }
94
95 icalparameter_xliccomparetype ICalValue::compare(ICalValue& a, ICalValue& b){
96         return icalvalue_compare(a, b);
97 }
98
99 /* Convert enumerations */
100 icalvalue_kind ICalValue::string_to_kind(string  str){
101         return icalvalue_string_to_kind(str);
102 }
103 string ICalValue::kind_to_string(icalvalue_kind kind){
104         return (string)icalvalue_kind_to_string(kind);
105 }
106
107 /* BOOLEAN */ 
108 int ICalValue::get_boolean(){
109         return icalvalue_get_boolean(imp);
110
111 void ICalValue::set_boolean(int v){
112         icalvalue_set_boolean(imp, v);
113 }
114
115 /* UTC-OFFSET */ 
116 int ICalValue::get_utcoffset(){
117         return icalvalue_get_utcoffset(imp);
118
119 void ICalValue::set_utcoffset(int v){
120         icalvalue_set_utcoffset(imp, v);
121 }
122
123 /* METHOD */ 
124 enum icalproperty_method ICalValue::get_method(){
125         return icalvalue_get_method(imp);
126
127 void ICalValue::set_method(enum icalproperty_method v){
128         icalvalue_set_method(imp, v);
129 }
130
131 /* CAL-ADDRESS */ 
132 string ICalValue::get_caladdress(){
133         return (string)icalvalue_get_caladdress(imp);
134
135 void ICalValue::set_caladdress(string  v){
136         icalvalue_set_caladdress(imp, v);
137 }
138
139 /* PERIOD */ 
140 struct icalperiodtype ICalValue::get_period(){
141         return icalvalue_get_period(imp);
142
143 void ICalValue::set_period(struct icalperiodtype v){
144         icalvalue_set_period(imp, v);
145 }
146
147 /* STATUS */ 
148 enum icalproperty_status ICalValue::get_status(){
149         return icalvalue_get_status(imp);
150
151 void ICalValue::set_status(enum icalproperty_status v){
152         icalvalue_set_status(imp, v);
153 }
154
155 /* BINARY */ 
156 string ICalValue::get_binary(){
157         return (string)icalvalue_get_binary(imp);
158
159 void ICalValue::set_binary(string  v){
160         icalvalue_set_binary(imp, v);
161 }
162
163 /* TEXT */ 
164 string ICalValue::get_text(){
165         return (string)icalvalue_get_text(imp);
166
167 void ICalValue::set_text(string  v){
168         icalvalue_set_text(imp, v);
169 }
170
171 /* DURATION */ 
172 struct icaldurationtype ICalValue::get_duration(){
173         return icalvalue_get_duration(imp);
174
175 void ICalValue::set_duration(struct icaldurationtype v){
176         icalvalue_set_duration(imp, v);
177 }
178
179 /* INTEGER */ 
180 int ICalValue::get_integer(){
181         return icalvalue_get_integer(imp);
182
183 void ICalValue::set_integer(int v){
184         icalvalue_set_integer(imp, v);
185 }
186
187 /* URI */ 
188 string ICalValue::get_uri(){
189         return (string)icalvalue_get_uri(imp);
190
191 void ICalValue::set_uri(string  v){
192         icalvalue_set_uri(imp, v);
193 }
194
195 /* ATTACH */ 
196 icalattach *ICalValue::get_attach(){
197         return icalvalue_get_attach(imp);
198
199 void ICalValue::set_attach(icalattach *v){
200         icalvalue_set_attach(imp, v);
201 }
202
203 /* CLASS */ 
204 enum icalproperty_class ICalValue::get_class(){
205         return icalvalue_get_class(imp);
206
207 void ICalValue::set_class(enum icalproperty_class v){
208         icalvalue_set_class(imp, v);
209 }
210
211 /* FLOAT */ 
212 float ICalValue::get_float(){
213         return icalvalue_get_float(imp);
214
215 void ICalValue::set_float(float v){
216         icalvalue_set_float(imp, v);
217 }
218
219 /* QUERY */ 
220 string ICalValue::get_query(){
221         return (string)icalvalue_get_query(imp);
222
223 void ICalValue::set_query(string  v){
224         icalvalue_set_query(imp, v);
225 }
226
227 /* STRING */ 
228 string ICalValue::get_string(){
229         return (string)icalvalue_get_string(imp);
230
231 void ICalValue::set_string(string v){
232         icalvalue_set_string(imp, v);
233 }
234
235 /* TRANSP */ 
236 enum icalproperty_transp ICalValue::get_transp(){
237         return icalvalue_get_transp(imp);
238
239 void ICalValue::set_transp(enum icalproperty_transp v){
240         icalvalue_set_transp(imp, v);
241 }
242
243 /* DATE-TIME */ 
244 struct icaltimetype ICalValue::get_datetime(){
245         return icalvalue_get_datetime(imp);
246
247 void ICalValue::set_datetime(struct icaltimetype v){
248         icalvalue_set_datetime(imp, v);
249 }
250
251 /* GEO */ 
252 struct icalgeotype ICalValue::get_geo(){
253         return icalvalue_get_geo(imp);
254
255 void ICalValue::set_geo(struct icalgeotype v){
256         icalvalue_set_geo(imp, v);
257 }
258
259 /* DATE */ 
260 struct icaltimetype ICalValue::get_date(){
261         return icalvalue_get_date(imp);
262
263 void ICalValue::set_date(struct icaltimetype v){
264         icalvalue_set_date(imp, v);
265 }
266
267 /* ACTION */ 
268 enum icalproperty_action ICalValue::get_action(){
269         return icalvalue_get_action(imp);
270
271 void ICalValue::set_action(enum icalproperty_action v){
272         icalvalue_set_action(imp, v);
273 }