Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
vcardcomponent.h
1/*======================================================================
2 FILE: vcardcomponent.h
3 CREATOR: Ken Murchison 24 Aug 2022 <murch@fastmailteam.com>
4
5 SPDX-FileCopyrightText: 2022, Fastmail Pty. Ltd. (https://fastmail.com)
6 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7 ======================================================================*/
8
9#ifndef VCARDCOMPONENT_H
10#define VCARDCOMPONENT_H
11
12#include "libical_sentinel.h"
13#include "libical_vcard_export.h"
14#include "vcardproperty.h"
15
16#include <stdbool.h>
17
18typedef enum vcardcomponent_kind
19{
20 VCARD_NO_COMPONENT,
21 VCARD_ANY_COMPONENT, /* Used to select all components */
22 VCARD_XROOT_COMPONENT, /* Used as container for multiple vCards */
23 VCARD_VCARD_COMPONENT,
24 VCARD_X_COMPONENT,
25 VCARD_NUM_COMPONENT_TYPES /* MUST be last (unless we can put NO_COMP last) */
26} vcardcomponent_kind;
27
28typedef struct vcardcomponent_impl vcardcomponent;
29
32LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_new(vcardcomponent_kind kind);
33
39LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_clone(const vcardcomponent *old);
40
43LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_new_from_string(const char *str);
44
47LIBICAL_VCARD_EXPORT LIBICAL_SENTINEL vcardcomponent *vcardcomponent_vanew(vcardcomponent_kind kind, ...);
48
49/*** @brief Destructor
50 */
51LIBICAL_VCARD_EXPORT void vcardcomponent_free(vcardcomponent *comp);
52
53LIBICAL_VCARD_EXPORT char *vcardcomponent_as_vcard_string(vcardcomponent *comp);
54
55LIBICAL_VCARD_EXPORT char *vcardcomponent_as_vcard_string_r(vcardcomponent *comp);
56
57LIBICAL_VCARD_EXPORT bool vcardcomponent_is_valid(const vcardcomponent *comp);
58
59LIBICAL_VCARD_EXPORT vcardcomponent_kind vcardcomponent_isa(const vcardcomponent *comp);
60
61LIBICAL_VCARD_EXPORT bool vcardcomponent_isa_component(const void *comp);
62
63/***** Working with Properties *****/
64
65LIBICAL_VCARD_EXPORT void vcardcomponent_add_property(vcardcomponent *comp,
66 vcardproperty *property);
67
68LIBICAL_VCARD_EXPORT void vcardcomponent_remove_property(vcardcomponent *comp,
69 vcardproperty *property);
70
71LIBICAL_VCARD_EXPORT int vcardcomponent_count_properties(vcardcomponent *comp,
72 vcardproperty_kind kind,
73 int ignore_alts);
74
75/***** Working with Components *****/
76
77LIBICAL_VCARD_EXPORT void vcardcomponent_add_component(vcardcomponent *parent, vcardcomponent *child);
78
79LIBICAL_VCARD_EXPORT void vcardcomponent_remove_component(vcardcomponent *parent,
80 vcardcomponent *child);
81
82LIBICAL_VCARD_EXPORT int vcardcomponent_count_components(vcardcomponent *comp,
83 vcardcomponent_kind kind);
84
85/* Kind conversion routines */
86
87LIBICAL_VCARD_EXPORT bool vcardcomponent_kind_is_valid(const vcardcomponent_kind kind);
88
89LIBICAL_VCARD_EXPORT vcardcomponent_kind vcardcomponent_string_to_kind(const char *string);
90
91LIBICAL_VCARD_EXPORT const char *vcardcomponent_kind_to_string(vcardcomponent_kind kind);
92
93/* Iteration Routines. There are two forms of iterators, internal and
94external. The internal ones came first, and are almost completely
95sufficient, but they fail badly when you want to construct a loop that
96removes components from the container.*/
97
98/* Iterate through components */
99LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_get_current_component(vcardcomponent *comp);
100
101LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_get_first_component(vcardcomponent *comp,
102 vcardcomponent_kind kind);
103LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_get_next_component(vcardcomponent *comp,
104 vcardcomponent_kind kind);
105
110LIBICAL_VCARD_EXPORT void vcardproperty_set_parent(vcardproperty *property,
111 vcardcomponent *comp);
112
116LIBICAL_VCARD_EXPORT vcardcomponent *vcardproperty_get_parent(const vcardproperty *property);
117
118/* Iterate through the properties */
119LIBICAL_VCARD_EXPORT vcardproperty *vcardcomponent_get_current_property(vcardcomponent *comp);
120
121LIBICAL_VCARD_EXPORT vcardproperty *vcardcomponent_get_first_property(vcardcomponent *comp,
122 vcardproperty_kind kind);
123LIBICAL_VCARD_EXPORT vcardproperty *vcardcomponent_get_next_property(vcardcomponent *comp,
124 vcardproperty_kind kind);
125
126/***** Working with embedded error properties *****/
127
128/* Check the component against itip rules and insert error properties*/
129/* Working with embedded error properties */
130LIBICAL_VCARD_EXPORT int vcardcomponent_check_restrictions(vcardcomponent *comp);
131
137LIBICAL_VCARD_EXPORT int vcardcomponent_count_errors(vcardcomponent *comp);
138
140LIBICAL_VCARD_EXPORT void vcardcomponent_strip_errors(vcardcomponent *comp);
141
146LIBICAL_VCARD_EXPORT void vcardcomponent_normalize(vcardcomponent *comp);
147
148LIBICAL_VCARD_EXPORT void vcardcomponent_transform(vcardcomponent *impl,
149 vcardproperty_version version);
150
151/******************** Convenience routines **********************/
152
153LIBICAL_VCARD_EXPORT enum vcardproperty_version vcardcomponent_get_version(vcardcomponent *comp);
154LIBICAL_VCARD_EXPORT const char *vcardcomponent_get_uid(vcardcomponent *comp);
155LIBICAL_VCARD_EXPORT const char *vcardcomponent_get_fn(vcardcomponent *comp);
156
157#endif /* !VCARDCOMPONENT_H */