1 /* -*- Mode: C++ -*- */
4 * @file icalparameter_cxx.cpp
5 * @author fnguyen (12/10/01)
6 * @brief Implementation of C++ Wrapper for icalparameter.c
8 * (C) COPYRIGHT 2001, Critical Path
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of either:
13 The LGPL as published by the Free Software Foundation, version
14 2.1, available at: http://www.fsf.org/copyleft/lesser.html
18 The Mozilla Public License Version 1.0. You may obtain a copy of
19 the License at http://www.mozilla.org/MPL/
22 #ifndef ICALPARAMETER_CXX_H
23 #include "icalparameter_cxx.h"
26 #ifndef ICALVALUE_CXX_H
27 #include "icalvalue_cxx.h"
30 typedef char* string; // Will use the string library from STL
32 ICalParameter::ICalParameter() throw(icalerrorenum) : imp(icalparameter_new(ICAL_ANY_PARAMETER)){
35 ICalParameter::ICalParameter(const ICalParameter& v) throw(icalerrorenum) {
36 imp = icalparameter_new_clone(v.imp);
37 if (!imp) throw icalerrno;
40 ICalParameter& ICalParameter::operator=(const ICalParameter& v) throw(icalerrorenum) {
41 if (this == &v) return *this;
45 icalparameter_free(imp);
46 imp = icalparameter_new_clone(v.imp);
47 if (!imp) throw icalerrno;
53 ICalParameter::~ICalParameter(){
54 if (imp != NULL) icalparameter_free(imp);
57 ICalParameter::ICalParameter(icalparameter* v) throw(icalerrorenum) : imp(v){
60 /// Create from string of form "PARAMNAME=VALUE"
61 ICalParameter::ICalParameter(string str) throw(icalerrorenum) {
62 imp = icalparameter_new_from_string(str);
63 if (!imp) throw icalerrno;
66 /// Create from just the value, the part after the "="
67 ICalParameter::ICalParameter(icalparameter_kind kind, string str) throw(icalerrorenum) {
68 imp = icalparameter_new_from_value_string(kind, str);
69 if (!imp) throw icalerrno;
72 ICalParameter::ICalParameter(icalparameter_kind kind) throw(icalerrorenum) {
73 imp = icalparameter_new(kind);
74 if (!imp) throw icalerrno;
77 string ICalParameter::as_ical_string() throw(icalerrorenum) {
78 char *str = icalparameter_as_ical_string(imp);
80 if (!str) throw icalerrno;
85 bool ICalParameter::is_valid(){
86 if (imp == NULL) return false;
87 return (icalparameter_isa_parameter((void*)imp) ? true : false);
89 icalparameter_kind ICalParameter::isa(){
90 return icalparameter_isa(imp);
92 int ICalParameter::isa_parameter(void* param){
93 return icalparameter_isa_parameter(param);
96 /* Acess the name of an X parameer */
97 void ICalParameter::set_xname(ICalParameter ¶m, string v){
98 icalparameter_set_xname(param, v);
100 string ICalParameter::get_xname(ICalParameter ¶m){
101 return (string)icalparameter_get_xname(param);
103 void ICalParameter::set_xvalue (ICalParameter ¶m, string v){
104 icalparameter_set_xvalue(param, v);
106 string ICalParameter::get_xvalue(ICalParameter ¶m){
107 return (string)icalparameter_get_xvalue(param);
110 /* Convert enumerations */
111 string ICalParameter::kind_to_string(icalparameter_kind kind){
112 return (string)icalparameter_kind_to_string(kind);
114 icalparameter_kind ICalParameter::string_to_kind(string str){
115 return icalparameter_string_to_kind(str);
119 string ICalParameter::get_delegatedfrom(){
120 return (string)icalparameter_get_delegatedfrom(imp);
122 void ICalParameter::set_delegatedfrom(string v){
123 icalparameter_set_delegatedfrom(imp, v);
127 icalparameter_related ICalParameter::get_related(){
128 return icalparameter_get_related(imp);
130 void ICalParameter::set_related(icalparameter_related v){
131 icalparameter_set_related(imp, v);
135 string ICalParameter::get_sentby(){
136 return (string)icalparameter_get_sentby(imp);
138 void ICalParameter::set_sentby(string v){
139 icalparameter_set_sentby(imp, v);
143 string ICalParameter::get_language(){
144 return (string)icalparameter_get_language(imp);
146 void ICalParameter::set_language(string v){
147 icalparameter_set_language(imp, v);
151 icalparameter_reltype ICalParameter::get_reltype(){
152 return icalparameter_get_reltype(imp);
154 void ICalParameter::set_reltype(icalparameter_reltype v){
155 icalparameter_set_reltype(imp, v);
159 icalparameter_encoding ICalParameter::get_encoding(){
160 return icalparameter_get_encoding(imp);
162 void ICalParameter::set_encoding(icalparameter_encoding v){
163 icalparameter_set_encoding(imp, v);
167 string ICalParameter::get_altrep(){
168 return (string)icalparameter_get_language(imp);
170 void ICalParameter::set_altrep(string v){
171 icalparameter_set_altrep(imp, v);
175 string ICalParameter::get_fmttype(){
176 return (string)icalparameter_get_fmttype(imp);
178 void ICalParameter::set_fmttype(string v){
179 icalparameter_set_fmttype(imp, v);
183 icalparameter_fbtype ICalParameter::get_fbtype(){
184 return icalparameter_get_fbtype(imp);
186 void ICalParameter::set_fbtype(icalparameter_fbtype v){
187 icalparameter_set_fbtype(imp, v);
191 icalparameter_rsvp ICalParameter::get_rsvp(){
192 return icalparameter_get_rsvp(imp);
194 void ICalParameter::set_rsvp(icalparameter_rsvp v){
195 icalparameter_set_rsvp(imp, v);
199 icalparameter_range ICalParameter::get_range(){
200 return icalparameter_get_range(imp);
202 void ICalParameter::set_range(icalparameter_range v){
203 icalparameter_set_range(imp, v);
207 string ICalParameter::get_delegatedto(){
208 return (string)icalparameter_get_delegatedto(imp);
210 void ICalParameter::set_delegatedto(string v){
211 icalparameter_set_delegatedto(imp, v);
215 string ICalParameter::get_cn(){
216 return (string)icalparameter_get_cn(imp);
218 void ICalParameter::set_cn(string v){
219 icalparameter_set_cn(imp, v);
223 icalparameter_role ICalParameter::get_role(){
224 return icalparameter_get_role(imp);
226 void ICalParameter::set_role(icalparameter_role v){
227 icalparameter_set_role(imp, v);
230 /* X-LIC-COMPARETYPE */
231 icalparameter_xliccomparetype ICalParameter::get_xliccomparetype(){
232 return icalparameter_get_xliccomparetype(imp);
234 void ICalParameter::set_xliccomparetype(icalparameter_xliccomparetype v){
235 icalparameter_set_xliccomparetype(imp, v);
239 icalparameter_partstat ICalParameter::get_partstat(){
240 return icalparameter_get_partstat(imp);
242 void ICalParameter::set_partstat(icalparameter_partstat v){
243 icalparameter_set_partstat(imp, v);
246 /* X-LIC-ERRORTYPE */
247 icalparameter_xlicerrortype ICalParameter::get_xlicerrortype(){
248 return icalparameter_get_xlicerrortype(imp);
250 void ICalParameter::set_xlicerrortype(icalparameter_xlicerrortype v){
251 icalparameter_set_xlicerrortype(imp, v);
255 string ICalParameter::get_member(){
256 return (string)icalparameter_get_member(imp);
258 void ICalParameter::set_member(string v){
259 icalparameter_set_member(imp, v);
263 string ICalParameter::get_x(){
264 return (string)icalparameter_get_x(imp);
266 void ICalParameter::set_x(string v){
267 icalparameter_set_x(imp, v);
271 icalparameter_cutype ICalParameter::get_cutype(){
272 return icalparameter_get_cutype(imp);
274 void ICalParameter::set_cutype(icalparameter_cutype v){
275 icalparameter_set_cutype(imp, v);
279 string ICalParameter::get_tzid(){
280 return (string)icalparameter_get_tzid(imp);
282 void ICalParameter::set_tzid(string v){
283 icalparameter_set_tzid(imp, v);
287 icalparameter_value ICalParameter::get_value(){
288 return icalparameter_get_value(imp);
290 void ICalParameter::set_value(icalparameter_value v){
291 icalparameter_set_value(imp, v);
295 string ICalParameter::get_dir(){
296 return (string)icalparameter_get_dir(imp);
298 void ICalParameter::set_dir(string v){
299 icalparameter_set_dir(imp, v);