Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
icalspanlist_cxx.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2001, Critical Path
3 * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
4*/
5
11
12#include "icalspanlist_cxx.hpp"
13#include "icalerror.h"
14#include "vcomponent_cxx.hpp"
15
16#include <cstdlib> // for free()
17#include <vector>
18
19using namespace LibICal;
20
21ICalSpanList::ICalSpanList()
22 : data(0)
23{
24 throw icalerrno;
25}
26
27ICalSpanList::ICalSpanList(const ICalSpanList &v)
28 : data(v.data)
29{
30 if (data == NULL) {
31 throw icalerrno;
32 }
33}
34
40ICalSpanList::ICalSpanList(icalset *set, const icaltimetype &start, const icaltimetype &end)
41 : data(icalspanlist_new(set, start, end))
42{
43 if (data == NULL) {
44 throw icalerrno;
45 }
46}
47
51
52ICalSpanList::ICalSpanList(icalcomponent *comp)
53 : data(icalspanlist_from_vfreebusy(comp))
54{
55 if (data == NULL) {
56 throw icalerrno;
57 }
58}
59
63ICalSpanList::ICalSpanList(VComponent &comp)
64 : data(icalspanlist_from_vfreebusy(static_cast<icalcomponent *>(comp)))
65{
66 if (data == NULL) {
67 throw icalerrno;
68 }
69}
70
72{
74}
75
78{
79 if (data == NULL) {
81 }
82}
83
89
90VComponent *ICalSpanList::get_vfreebusy(const char *organizer, const char *attendee)
91{
92 icalcomponent *comp;
93 VComponent *vcomp;
94
95 comp = icalspanlist_as_vfreebusy(data, organizer, attendee);
96 if (comp == NULL) {
97 throw icalerrno;
98 }
99
100 vcomp = new VComponent(comp);
101 if (vcomp == NULL) {
102 throw icalerrno;
103 }
104
105 return vcomp;
106}
107
119
120std::vector<int> ICalSpanList::as_vector(int delta_t)
121{
122 int *matrix;
123 const int i = 0;
124 std::vector<int> event_vec;
125
126 matrix = icalspanlist_as_freebusy_matrix(data, delta_t);
127
128 if (matrix == NULL) {
129 throw icalerrno;
130 }
131
132 while (matrix[i] != -1) {
133 event_vec.push_back(matrix[i]); // Add item at end of vector
134 }
135
136 free(matrix);
137 return event_vec;
138}
VComponent * get_vfreebusy(const char *organizer, const char *attendee)
Returns a VFREEBUSY component for the object.
std::vector< int > as_vector(int delta_t)
Returns a summary of events over delta_t.
A class wrapping the libical icalcomponent functions.
Error handling for libical.
#define icalerrno
Access the current icalerrno value.
Definition icalerror.h:130
void icalspanlist_dump(icalspanlist *sl)
icalspanlist * icalspanlist_from_vfreebusy(icalcomponent *comp)
int * icalspanlist_as_freebusy_matrix(icalspanlist *spanlist, int delta_t)
void icalspanlist_free(icalspanlist *sl)
icalspanlist * icalspanlist_new(icalset *set, struct icaltimetype start, struct icaltimetype end)
icalcomponent * icalspanlist_as_vfreebusy(icalspanlist *sl, const char *organizer, const char *attendee)
C++ class wrapping the icalspanlist data structure.
C++ classes for the icalcomponent wrapper (VToDo VEvent, etc..).