Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
vcardcomponent.h
Go to the documentation of this file.
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
13
14#ifndef VCARDCOMPONENT_H
15#define VCARDCOMPONENT_H
16
17#include "libical_sentinel.h"
18#include "libical_vcard_export.h"
19#include "vcardproperty.h"
20
21#include <stdbool.h>
22
23typedef enum vcardcomponent_kind
24{
25 VCARD_NO_COMPONENT,
26 VCARD_ANY_COMPONENT, /* Used to select all components */
27 VCARD_XROOT_COMPONENT, /* Used as container for multiple vCards */
28 VCARD_VCARD_COMPONENT,
29 VCARD_X_COMPONENT,
30 VCARD_NUM_COMPONENT_TYPES /* MUST be last (unless we can put NO_COMP last) */
31} vcardcomponent_kind;
32
33typedef struct vcardcomponent_impl vcardcomponent;
34
37LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_new(vcardcomponent_kind kind);
38
44LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_clone(const vcardcomponent *old);
45
48LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_new_from_string(const char *str);
49
52LIBICAL_VCARD_EXPORT LIBICAL_SENTINEL vcardcomponent *vcardcomponent_vanew(vcardcomponent_kind kind, ...);
53
54/*** @brief Destructor
55 */
56LIBICAL_VCARD_EXPORT void vcardcomponent_free(vcardcomponent *comp);
57
58LIBICAL_VCARD_EXPORT char *vcardcomponent_as_vcard_string(vcardcomponent *comp);
59
60LIBICAL_VCARD_EXPORT char *vcardcomponent_as_vcard_string_r(vcardcomponent *comp);
61
62LIBICAL_VCARD_EXPORT bool vcardcomponent_is_valid(const vcardcomponent *comp);
63
64LIBICAL_VCARD_EXPORT vcardcomponent_kind vcardcomponent_isa(const vcardcomponent *comp);
65
66LIBICAL_VCARD_EXPORT bool vcardcomponent_isa_component(const void *comp);
67
68/***** Working with Properties *****/
69
70LIBICAL_VCARD_EXPORT void vcardcomponent_add_property(vcardcomponent *comp,
71 vcardproperty *property);
72
73LIBICAL_VCARD_EXPORT void vcardcomponent_remove_property(vcardcomponent *comp,
74 vcardproperty *property);
75
76LIBICAL_VCARD_EXPORT int vcardcomponent_count_properties(vcardcomponent *comp,
77 vcardproperty_kind kind,
78 int ignore_alts);
79
80/***** Working with Components *****/
81
82LIBICAL_VCARD_EXPORT void vcardcomponent_add_component(vcardcomponent *parent, vcardcomponent *child);
83
84LIBICAL_VCARD_EXPORT void vcardcomponent_remove_component(vcardcomponent *parent,
85 vcardcomponent *child);
86
87LIBICAL_VCARD_EXPORT int vcardcomponent_count_components(vcardcomponent *comp,
88 vcardcomponent_kind kind);
89
90/* Kind conversion routines */
91
92LIBICAL_VCARD_EXPORT bool vcardcomponent_kind_is_valid(const vcardcomponent_kind kind);
93
94LIBICAL_VCARD_EXPORT vcardcomponent_kind vcardcomponent_string_to_kind(const char *string);
95
96LIBICAL_VCARD_EXPORT const char *vcardcomponent_kind_to_string(vcardcomponent_kind kind);
97
98/* Iteration Routines. There are two forms of iterators, internal and
99external. The internal ones came first, and are almost completely
100sufficient, but they fail badly when you want to construct a loop that
101removes components from the container.*/
102
103/* Iterate through components */
104LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_get_current_component(vcardcomponent *comp);
105
106LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_get_first_component(vcardcomponent *comp,
107 vcardcomponent_kind kind);
108LIBICAL_VCARD_EXPORT vcardcomponent *vcardcomponent_get_next_component(vcardcomponent *comp,
109 vcardcomponent_kind kind);
110
115LIBICAL_VCARD_EXPORT void vcardproperty_set_parent(vcardproperty *property,
116 vcardcomponent *comp);
117
121LIBICAL_VCARD_EXPORT vcardcomponent *vcardproperty_get_parent(const vcardproperty *property);
122
123/* Iterate through the properties */
124LIBICAL_VCARD_EXPORT vcardproperty *vcardcomponent_get_current_property(vcardcomponent *comp);
125
126LIBICAL_VCARD_EXPORT vcardproperty *vcardcomponent_get_first_property(vcardcomponent *comp,
127 vcardproperty_kind kind);
128LIBICAL_VCARD_EXPORT vcardproperty *vcardcomponent_get_next_property(vcardcomponent *comp,
129 vcardproperty_kind kind);
130
131/***** Working with embedded error properties *****/
132
133/* Check the component against itip rules and insert error properties*/
134/* Working with embedded error properties */
135LIBICAL_VCARD_EXPORT int vcardcomponent_check_restrictions(vcardcomponent *comp);
136
142LIBICAL_VCARD_EXPORT int vcardcomponent_count_errors(vcardcomponent *comp);
143
145LIBICAL_VCARD_EXPORT void vcardcomponent_strip_errors(vcardcomponent *comp);
146
151LIBICAL_VCARD_EXPORT void vcardcomponent_normalize(vcardcomponent *comp);
152
153LIBICAL_VCARD_EXPORT void vcardcomponent_transform(vcardcomponent *impl,
154 vcardproperty_version version);
155
156/******************** Convenience routines **********************/
157
158LIBICAL_VCARD_EXPORT enum vcardproperty_version vcardcomponent_get_version(vcardcomponent *comp);
159LIBICAL_VCARD_EXPORT const char *vcardcomponent_get_uid(vcardcomponent *comp);
160LIBICAL_VCARD_EXPORT const char *vcardcomponent_get_fn(vcardcomponent *comp);
161
162#endif /* !VCARDCOMPONENT_H */
void vcardcomponent_strip_errors(vcardcomponent *comp)
Removes all X-LIC-ERROR properties.
vcardcomponent * vcardcomponent_clone(const vcardcomponent *old)
Deeply clones an vcard. Returns a pointer to the memory for the newly cloned vcard.
int vcardcomponent_count_errors(vcardcomponent *comp)
Returns the number of errors encountered parsing the data.
LIBICAL_SENTINEL vcardcomponent * vcardcomponent_vanew(vcardcomponent_kind kind,...)
Constructor.
vcardcomponent * vcardproperty_get_parent(const vcardproperty *property)
Returns the parent vcard for the specified property.
void vcardproperty_set_parent(vcardproperty *property, vcardcomponent *comp)
Sets the parent vcard for the specified vcardproperty property.
vcardcomponent * vcardcomponent_new(vcardcomponent_kind kind)
Constructor.
vcardcomponent * vcardcomponent_new_from_string(const char *str)
Constructor.
void vcardcomponent_normalize(vcardcomponent *comp)
Normalizes (reorders and sorts the properties) the specified vcard comp.
Defines the data structure representing vCard properties.