$darkmode
Libical API Documentation 4.0 STABLE VERSION Visit the v3.0 documentation
icalvalue_cxx.cpp
Go to the documentation of this file.
1 /*======================================================================
2  FILE: icalvalue_cxx.cpp
3  CREATOR: fnguyen 12/21/01
4 
5  SPDX-FileCopyrightText: 2001, Critical Path
6  SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7 ======================================================================*/
8 
14 #ifdef HAVE_CONFIG_H
15 #include <config.h>
16 #endif
17 
18 #include "icalvalue_cxx.hpp"
19 
20 extern "C" {
21 #include "icalerror_p.h"
22 }
23 
24 #include <string>
25 
26 using namespace LibICal;
27 
28 ICalValue::ICalValue()
29  : imp(icalvalue_new(ICAL_ANY_VALUE))
30 {
31 }
32 
33 ICalValue::ICalValue(const ICalValue &v)
34  : imp(icalvalue_clone(v.imp))
35 {
36  if (imp == NULL) {
37  throw icalerrno;
38  }
39 }
40 
41 ICalValue &ICalValue::operator=(const ICalValue &v)
42 {
43  if (this == &v) {
44  return *this;
45  }
46 
47  icalvalue_free(imp);
48  imp = icalvalue_clone(v.imp);
49  if (imp == NULL) {
50  throw icalerrno;
51  }
52 
53  return *this;
54 }
55 
56 void ICalValue::detach()
57 {
58  imp = NULL;
59 }
60 
61 ICalValue::~ICalValue()
62 {
63  icalvalue_free(imp);
64 }
65 
66 ICalValue::ICalValue(icalvalue *v)
67  : imp(v)
68 {
69 }
70 
71 ICalValue::ICalValue(const icalvalue_kind &kind)
72  : imp(icalvalue_new(kind))
73 {
74  if (imp == NULL) {
75  throw icalerrno;
76  }
77 }
78 
79 ICalValue::ICalValue(const icalvalue_kind &kind, const std::string &str)
80  : imp(icalvalue_new_from_string(kind, str.c_str()))
81 {
82  if (imp == NULL) {
83  throw icalerrno;
84  }
85 }
86 
87 std::string ICalValue::as_ical_string()
88 {
89  return static_cast<std::string>(icalvalue_as_ical_string(imp));
90 }
91 
92 bool ICalValue::is_valid()
93 {
94  if (imp == NULL) {
95  return false;
96  }
97  return icalvalue_is_valid(imp);
98 }
99 
100 icalvalue_kind ICalValue::isa()
101 {
102  return icalvalue_isa(imp);
103 }
104 
105 /* cppcheck-suppress functionStatic */
106 bool ICalValue::isa_value(void *value) //NOLINT(readability-convert-member-functions-to-static)
107 {
108  return icalvalue_isa_value(value);
109 }
110 
111 /* Special, non autogenerated value accessors */
112 void ICalValue::set_recur(struct icalrecurrencetype *v)
113 {
114  icalvalue_set_recur(imp, v);
115 }
116 
117 struct icalrecurrencetype *ICalValue::get_recur()
118 {
119  return icalvalue_get_recur(imp);
120 }
121 
122 /* cppcheck-suppress functionStatic */
123 void ICalValue::set_trigger(const struct icaltriggertype &v) //NOLINT(readability-convert-member-functions-to-static)
124 {
125  _unused(v);
126 }
127 
128 struct icaltriggertype ICalValue::get_trigger()
129 {
130  return icalvalue_get_trigger(imp);
131 }
132 
133 void ICalValue::set_datetimeperiod(const struct icaldatetimeperiodtype &v)
134 {
135  icalvalue_set_datetimeperiod(imp, v);
136 }
137 
138 struct icaldatetimeperiodtype ICalValue::get_datetimeperiod()
139 {
140  return icalvalue_get_datetimeperiod(imp);
141 }
142 
143 /* cppcheck-suppress constParameterReference */
144 icalparameter_xliccomparetype ICalValue::compare(ICalValue &a, ICalValue &b)
145 {
146  return icalvalue_compare(a, b);
147 }
148 
149 /* Convert enumerations */
150 icalvalue_kind ICalValue::string_to_kind(const std::string &str)
151 {
152  return icalvalue_string_to_kind(str.c_str());
153 }
154 
155 /* cppcheck-suppress functionStatic */
156 std::string ICalValue::kind_to_string(const icalvalue_kind &kind) //NOLINT(readability-convert-member-functions-to-static)
157 {
158  return static_cast<std::string>(icalvalue_kind_to_string(kind));
159 }
160 
161 /* BOOLEAN */
162 int ICalValue::get_boolean() const
163 {
164  return icalvalue_get_boolean(imp);
165 }
166 
167 void ICalValue::set_boolean(const int &v)
168 {
169  icalvalue_set_boolean(imp, v);
170 }
171 
172 /* UTC-OFFSET */
173 int ICalValue::get_utcoffset() const
174 {
175  return icalvalue_get_utcoffset(imp);
176 }
177 
178 void ICalValue::set_utcoffset(const int &v)
179 {
180  icalvalue_set_utcoffset(imp, v);
181 }
182 
183 /* METHOD */
184 enum icalproperty_method ICalValue::get_method() const
185 {
186  return icalvalue_get_method(imp);
187 }
188 
189 void ICalValue::set_method(const enum icalproperty_method &v)
190 {
191  icalvalue_set_method(imp, v);
192 }
193 
194 /* CAL-ADDRESS */
195 std::string ICalValue::get_caladdress() const
196 {
197  return static_cast<std::string>(icalvalue_get_caladdress(imp));
198 }
199 
200 void ICalValue::set_caladdress(const std::string &v)
201 {
202  icalvalue_set_caladdress(imp, v.c_str());
203 }
204 
205 /* PERIOD */
206 struct icalperiodtype ICalValue::get_period() const
207 {
208  return icalvalue_get_period(imp);
209 }
210 
211 void ICalValue::set_period(const struct icalperiodtype &v)
212 {
213  icalvalue_set_period(imp, v);
214 }
215 
216 /* STATUS */
217 enum icalproperty_status ICalValue::get_status() const
218 {
219  return icalvalue_get_status(imp);
220 }
221 
222 void ICalValue::set_status(const enum icalproperty_status &v)
223 {
224  icalvalue_set_status(imp, v);
225 }
226 
227 /* BINARY */
228 std::string ICalValue::get_binary() const
229 {
230  return static_cast<std::string>(icalvalue_get_binary(imp));
231 }
232 
233 void ICalValue::set_binary(const std::string &v)
234 {
235  icalvalue_set_binary(imp, v.c_str());
236 }
237 
238 /* TEXT */
239 std::string ICalValue::get_text() const
240 {
241  return static_cast<std::string>(icalvalue_get_text(imp));
242 }
243 
244 void ICalValue::set_text(const std::string &v)
245 {
246  icalvalue_set_text(imp, v.c_str());
247 }
248 
249 /* DURATION */
250 struct icaldurationtype ICalValue::get_duration() const
251 {
252  return icalvalue_get_duration(imp);
253 }
254 
255 void ICalValue::set_duration(const struct icaldurationtype &v)
256 {
257  icalvalue_set_duration(imp, v);
258 }
259 
260 /* INTEGER */
261 int ICalValue::get_integer() const
262 {
263  return icalvalue_get_integer(imp);
264 }
265 
266 void ICalValue::set_integer(const int &v)
267 {
268  icalvalue_set_integer(imp, v);
269 }
270 
271 /* URI */
272 std::string ICalValue::get_uri() const
273 {
274  return static_cast<std::string>(icalvalue_get_uri(imp));
275 }
276 
277 void ICalValue::set_uri(const std::string &v)
278 {
279  icalvalue_set_uri(imp, v.c_str());
280 }
281 
282 /* ATTACH */
283 icalattach *ICalValue::get_attach()
284 {
285  return icalvalue_get_attach(imp);
286 }
287 
288 void ICalValue::set_attach(icalattach *v)
289 {
290  icalvalue_set_attach(imp, v);
291 }
292 
293 /* CLASS */
294 enum icalproperty_class ICalValue::get_class() const
295 {
296  return icalvalue_get_class(imp);
297 }
298 
299 void ICalValue::set_class(const enum icalproperty_class &v)
300 {
301  icalvalue_set_class(imp, v);
302 }
303 
304 /* FLOAT */
305 float ICalValue::get_float() const
306 {
307  return icalvalue_get_float(imp);
308 }
309 
310 void ICalValue::set_float(const float &v)
311 {
312  icalvalue_set_float(imp, v);
313 }
314 
315 /* QUERY */
316 std::string ICalValue::get_query() const
317 {
318  return static_cast<std::string>(icalvalue_get_query(imp));
319 }
320 
321 void ICalValue::set_query(const std::string &v)
322 {
323  icalvalue_set_query(imp, v.c_str());
324 }
325 
326 /* STRING */
327 std::string ICalValue::get_string() const
328 {
329  return static_cast<std::string>(icalvalue_get_string(imp));
330 }
331 
332 void ICalValue::set_string(const std::string &v)
333 {
334  icalvalue_set_string(imp, v.c_str());
335 }
336 
337 /* TRANSP */
338 enum icalproperty_transp ICalValue::get_transp() const
339 {
340  return icalvalue_get_transp(imp);
341 }
342 
343 void ICalValue::set_transp(const enum icalproperty_transp &v)
344 {
345  icalvalue_set_transp(imp, v);
346 }
347 
348 /* DATE-TIME */
349 struct icaltimetype ICalValue::get_datetime() const
350 {
351  return icalvalue_get_datetime(imp);
352 }
353 
354 void ICalValue::set_datetime(const struct icaltimetype &v)
355 {
356  icalvalue_set_datetime(imp, v);
357 }
358 
359 /* GEO */
360 struct icalgeotype ICalValue::get_geo() const
361 {
362  return icalvalue_get_geo(imp);
363 }
364 
365 void ICalValue::set_geo(const struct icalgeotype &v)
366 {
367  icalvalue_set_geo(imp, v);
368 }
369 
370 /* DATE */
371 struct icaltimetype ICalValue::get_date() const
372 {
373  return icalvalue_get_date(imp);
374 }
375 
376 void ICalValue::set_date(const struct icaltimetype &v)
377 {
378  icalvalue_set_date(imp, v);
379 }
380 
381 /* ACTION */
382 enum icalproperty_action ICalValue::get_action() const
383 {
384  return icalvalue_get_action(imp);
385 }
386 
387 void ICalValue::set_action(const enum icalproperty_action &v)
388 {
389  icalvalue_set_action(imp, v);
390 }
icalparameter_xliccomparetype icalvalue_compare(const icalvalue *a, const icalvalue *b)
Definition: icalvalue.c:1356
bool icalvalue_is_valid(const icalvalue *value)
Definition: icalvalue.c:873
void icalvalue_free(icalvalue *v)
Definition: icalvalue.c:796
icalvalue_kind icalvalue_string_to_kind(const char *str)
Definition of C++ Wrapper for icalvalue.c.
bool icalvalue_isa_value(void *value)
Definition: icalvalue.c:1336
icalvalue * icalvalue_clone(const icalvalue *old)
Definition: icalvalue.c:65
icalvalue_kind icalvalue_isa(const icalvalue *value)
Definition: icalvalue.c:1327
const char * icalvalue_kind_to_string(const icalvalue_kind kind)
struct icalattach_impl icalattach
An iCal attach object representing a link to a document object.
Definition: icalattach.h:36
icalvalue * icalvalue_new(icalvalue_kind kind)
Definition: icalvalue.c:60
#define icalerrno
Access the current icalerrno value.
Definition: icalerror.h:133
const char * icalvalue_as_ical_string(const icalvalue *value)
Definition: icalvalue.c:1217
icalvalue * icalvalue_new_from_string(icalvalue_kind kind, const char *str)
Definition: icalvalue.c:791