summaryrefslogtreecommitdiff
path: root/src/libical/icalvalue_cxx.cpp
blob: 48029fa6f5621bc662b137294f6f1efb7785afe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/* -*- Mode: C -*- */
/*======================================================================
 FILE: icalvalue_cxx.cpp
 CREATOR: fnguyen 12/21/01
 (C) COPYRIGHT 2001, Critical Path

 This program is free software; you can redistribute it and/or modify
 it under the terms of either: 

    The LGPL as published by the Free Software Foundation, version
    2.1, available at: http://www.fsf.org/copyleft/lesser.html

  Or:

    The Mozilla Public License Version 1.0. You may obtain a copy of
    the License at http://www.mozilla.org/MPL/
======================================================================*/

#ifndef ICALVALUE_CXX_H
#include "icalvalue_cxx.h"
#endif

typedef	char* string; // Will use the string library from STL

ICalValue::ICalValue() throw(icalerrorenum) : imp(icalvalue_new(ICAL_ANY_VALUE)){}

ICalValue::ICalValue(const ICalValue& v) throw (icalerrorenum) {
	imp = icalvalue_new_clone(v.imp);
	if (!imp) throw icalerrno;
}
ICalValue& ICalValue::operator=(const ICalValue& v) throw(icalerrorenum) {
	if (this == &v) return *this;

	if (imp != NULL)
	{
		icalvalue_free(imp);
		imp = icalvalue_new_clone(v.imp);
		if (!imp) throw icalerrno;
	}

	return *this;
}

ICalValue::~ICalValue(){
	if (imp != NULL) icalvalue_free(imp);
}

ICalValue::ICalValue(icalvalue* v) throw(icalerrorenum) : imp(v){
}

ICalValue::ICalValue(icalvalue_kind kind) throw(icalerrorenum) {
	imp = icalvalue_new(kind);
	if (!imp) throw icalerrno;
}

ICalValue::ICalValue(icalvalue_kind kind, string  str) throw(icalerrorenum) {
	imp = icalvalue_new_from_string(kind, str);
	if (!imp) throw icalerrno;
}

string ICalValue::as_ical_string(){
	return (string)icalvalue_as_ical_string(imp);
}
bool ICalValue::is_valid(){
	if (imp == NULL) return false;
	return (icalvalue_is_valid(imp) ? true : false);
}
icalvalue_kind ICalValue::isa(){
	return icalvalue_isa(imp);
}
int ICalValue::isa_value(void* value){
	return icalvalue_isa_value(value);
}

/* Special, non autogenerated value accessors */
void ICalValue::set_recur(struct icalrecurrencetype v){
	icalvalue_set_recur(imp, v);
}
struct icalrecurrencetype ICalValue::get_recur(){
	return icalvalue_get_recur(imp);
}

void ICalValue::set_trigger(struct icaltriggertype v){}
struct icaltriggertype ICalValue::get_trigger(){
	return icalvalue_get_trigger(imp);
}

void ICalValue::set_datetimeperiod(struct icaldatetimeperiodtype v){
	icalvalue_set_datetimeperiod(imp, v);
}
struct icaldatetimeperiodtype ICalValue::get_datetimeperiod(){
	return icalvalue_get_datetimeperiod(imp);
}

icalparameter_xliccomparetype ICalValue::compare(ICalValue& a, ICalValue& b){
	return icalvalue_compare(a, b);
}

/* Convert enumerations */
icalvalue_kind ICalValue::string_to_kind(string  str){
	return icalvalue_string_to_kind(str);
}
string ICalValue::kind_to_string(icalvalue_kind kind){
	return (string)icalvalue_kind_to_string(kind);
}

/* BOOLEAN */ 
int ICalValue::get_boolean(){
	return icalvalue_get_boolean(imp);
} 
void ICalValue::set_boolean(int v){
	icalvalue_set_boolean(imp, v);
}

/* UTC-OFFSET */ 
int ICalValue::get_utcoffset(){
	return icalvalue_get_utcoffset(imp);
} 
void ICalValue::set_utcoffset(int v){
	icalvalue_set_utcoffset(imp, v);
}

/* METHOD */ 
enum icalproperty_method ICalValue::get_method(){
	return icalvalue_get_method(imp);
} 
void ICalValue::set_method(enum icalproperty_method v){
	icalvalue_set_method(imp, v);
}

/* CAL-ADDRESS */ 
string ICalValue::get_caladdress(){
	return (string)icalvalue_get_caladdress(imp);
} 
void ICalValue::set_caladdress(string  v){
	icalvalue_set_caladdress(imp, v);
}

/* PERIOD */ 
struct icalperiodtype ICalValue::get_period(){
	return icalvalue_get_period(imp);
} 
void ICalValue::set_period(struct icalperiodtype v){
	icalvalue_set_period(imp, v);
}

/* STATUS */ 
enum icalproperty_status ICalValue::get_status(){
	return icalvalue_get_status(imp);
} 
void ICalValue::set_status(enum icalproperty_status v){
	icalvalue_set_status(imp, v);
}

/* BINARY */ 
string ICalValue::get_binary(){
	return (string)icalvalue_get_binary(imp);
} 
void ICalValue::set_binary(string  v){
	icalvalue_set_binary(imp, v);
}

/* TEXT */ 
string ICalValue::get_text(){
	return (string)icalvalue_get_text(imp);
} 
void ICalValue::set_text(string  v){
	icalvalue_set_text(imp, v);
}

/* DURATION */ 
struct icaldurationtype ICalValue::get_duration(){
	return icalvalue_get_duration(imp);
} 
void ICalValue::set_duration(struct icaldurationtype v){
	icalvalue_set_duration(imp, v);
}

/* INTEGER */ 
int ICalValue::get_integer(){
	return icalvalue_get_integer(imp);
} 
void ICalValue::set_integer(int v){
	icalvalue_set_integer(imp, v);
}

/* URI */ 
string ICalValue::get_uri(){
	return (string)icalvalue_get_uri(imp);
} 
void ICalValue::set_uri(string  v){
	icalvalue_set_uri(imp, v);
}

/* ATTACH */ 
icalattach *ICalValue::get_attach(){
	return icalvalue_get_attach(imp);
} 
void ICalValue::set_attach(icalattach *v){
	icalvalue_set_attach(imp, v);
}

/* CLASS */ 
enum icalproperty_class ICalValue::get_class(){
	return icalvalue_get_class(imp);
} 
void ICalValue::set_class(enum icalproperty_class v){
	icalvalue_set_class(imp, v);
}

/* FLOAT */ 
float ICalValue::get_float(){
	return icalvalue_get_float(imp);
} 
void ICalValue::set_float(float v){
	icalvalue_set_float(imp, v);
}

/* QUERY */ 
string ICalValue::get_query(){
	return (string)icalvalue_get_query(imp);
} 
void ICalValue::set_query(string  v){
	icalvalue_set_query(imp, v);
}

/* STRING */ 
string ICalValue::get_string(){
	return (string)icalvalue_get_string(imp);
} 
void ICalValue::set_string(string v){
	icalvalue_set_string(imp, v);
}

/* TRANSP */ 
enum icalproperty_transp ICalValue::get_transp(){
	return icalvalue_get_transp(imp);
} 
void ICalValue::set_transp(enum icalproperty_transp v){
	icalvalue_set_transp(imp, v);
}

/* DATE-TIME */ 
struct icaltimetype ICalValue::get_datetime(){
	return icalvalue_get_datetime(imp);
} 
void ICalValue::set_datetime(struct icaltimetype v){
	icalvalue_set_datetime(imp, v);
}

/* GEO */ 
struct icalgeotype ICalValue::get_geo(){
	return icalvalue_get_geo(imp);
} 
void ICalValue::set_geo(struct icalgeotype v){
	icalvalue_set_geo(imp, v);
}

/* DATE */ 
struct icaltimetype ICalValue::get_date(){
	return icalvalue_get_date(imp);
} 
void ICalValue::set_date(struct icaltimetype v){
	icalvalue_set_date(imp, v);
}

/* ACTION */ 
enum icalproperty_action ICalValue::get_action(){
	return icalvalue_get_action(imp);
} 
void ICalValue::set_action(enum icalproperty_action v){
	icalvalue_set_action(imp, v);
}