Back to index

lightning-sunbird  0.9+nobinonly
Functions
icalcluster.c File Reference
#include <stdlib.h>
#include <string.h>
#include "icalcluster.h"
#include "icalclusterimpl.h"
#include "icalgauge.h"

Go to the source code of this file.

Functions

icalcluster * icalcluster_new_impl (void)
 icalcluster is an utility class design to manage clusters of icalcomponents on behalf of an implementation of icalset.
icalcluster * icalcluster_new (const char *key, icalcomponent *data)
 Create a cluster with a key/value pair.
icalcluster * icalcluster_new_clone (const icalcluster *data)
 Deep clone an icalcluster to a new one.
void icalcluster_free (icalcluster *impl)
const char * icalcluster_key (icalcluster *impl)
int icalcluster_is_changed (icalcluster *impl)
void icalcluster_mark (icalcluster *impl)
void icalcluster_commit (icalcluster *impl)
icalcomponent * icalcluster_get_component (icalcluster *impl)
icalerrorenum icalcluster_add_component (icalcluster *impl, icalcomponent *child)
icalerrorenum icalcluster_remove_component (icalcluster *impl, icalcomponent *child)
int icalcluster_count_components (icalcluster *impl, icalcomponent_kind kind)
icalcomponent * icalcluster_get_current_component (icalcluster *impl)
 Iterate through components.
icalcomponent * icalcluster_get_first_component (icalcluster *impl)
icalcomponent * icalcluster_get_next_component (icalcluster *impl)

Function Documentation

icalerrorenum icalcluster_add_component ( icalcluster *  impl,
icalcomponent *  child 
)

Definition at line 189 of file icalcluster.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void icalcluster_commit ( icalcluster *  impl)

Definition at line 168 of file icalcluster.c.

                                           {
       icalerror_check_arg_rv((impl!=0),"cluster");

       impl->changed = 0;
}
int icalcluster_count_components ( icalcluster *  impl,
icalcomponent_kind  kind 
)

Definition at line 213 of file icalcluster.c.

                                                                             {

       icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);

       return icalcomponent_count_components(impl->data, kind);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void icalcluster_free ( icalcluster *  impl)

Definition at line 130 of file icalcluster.c.

                                         {
       icalerror_check_arg_rv((impl!=0),"cluster");

       if (impl->key != 0){
              free(impl->key);
              impl->key = 0;
       }

       if (impl->data != 0){
              icalcomponent_free(impl->data);
              impl->data = 0;
       }

       free(impl);
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* icalcluster_get_component ( icalcluster *  impl)

Definition at line 175 of file icalcluster.c.

                                                            {

       icalerror_check_arg_rz((impl!=0),"cluster");

       if (icalcomponent_isa(impl->data) != ICAL_XROOT_COMPONENT) {
              icalerror_warn("The top component is not an XROOT");
              fprintf(stderr, "%s\n", icalcomponent_as_ical_string(impl->data));
              abort();
       }

       return impl->data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* icalcluster_get_current_component ( icalcluster *  impl)

Iterate through components.

Definition at line 222 of file icalcluster.c.

                                                                    {

       icalerror_check_arg_rz((impl!=0),"cluster");

       return icalcomponent_get_current_component(impl->data);
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* icalcluster_get_first_component ( icalcluster *  impl)

Definition at line 230 of file icalcluster.c.

                                                                  {

       icalerror_check_arg_rz((impl!=0),"cluster");

       return icalcomponent_get_first_component(impl->data,
                                            ICAL_ANY_COMPONENT);
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* icalcluster_get_next_component ( icalcluster *  impl)

Definition at line 239 of file icalcluster.c.

                                                                 {

       icalerror_check_arg_rz((impl!=0),"cluster");
    
       return icalcomponent_get_next_component(impl->data,
                                        ICAL_ANY_COMPONENT);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int icalcluster_is_changed ( icalcluster *  impl)

Definition at line 154 of file icalcluster.c.

                                              {
       icalerror_check_arg_rz((impl!=0),"cluster");

       return impl->changed;
}
const char* icalcluster_key ( icalcluster *  impl)

Definition at line 147 of file icalcluster.c.

                                               {
       icalerror_check_arg_rz((impl!=0),"cluster");

       return impl->key;
}

Here is the caller graph for this function:

void icalcluster_mark ( icalcluster *  impl)

Definition at line 161 of file icalcluster.c.

                                         {
       icalerror_check_arg_rv((impl!=0),"cluster");

       impl->changed = 1;
}

Here is the caller graph for this function:

icalcluster* icalcluster_new ( const char *  key,
icalcomponent *  data 
)

Create a cluster with a key/value pair.

Todo:
Always do a deep copy.

Definition at line 92 of file icalcluster.c.

                                                                    {
       struct icalcluster_impl *impl = icalcluster_new_impl();
       assert(impl->data == 0);

       impl->key     = strdup(key);
       impl->changed = 0;
       impl->data    = 0;

       if (data != NULL) {
              if (icalcomponent_isa(data) != ICAL_XROOT_COMPONENT) {
                     impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
                     icalcomponent_add_component(impl->data, data);
              } else {
                     impl->data = icalcomponent_new_clone(data);
              }
       } else {
              impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
       }

       return impl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcluster* icalcluster_new_clone ( const icalcluster *  data)

Deep clone an icalcluster to a new one.

Definition at line 118 of file icalcluster.c.

                                                            {
       struct icalcluster_impl *old = (struct icalcluster_impl *)data;
       struct icalcluster_impl *impl = icalcluster_new_impl();

       impl->key     = strdup(old->key);
       impl->data    = icalcomponent_new_clone(old->data);
       impl->changed = 0;

       return impl;
}

Here is the call graph for this function:

icalcluster* icalcluster_new_impl ( void  )

icalcluster is an utility class design to manage clusters of icalcomponents on behalf of an implementation of icalset.

This is done in order to split out common behavior different classes might need. The definition of what exactly a cluster will contain depends on the icalset subclass. At the basic level, an icluster is just a tuple, with anything as key and an icalcomponent as value.

Definition at line 70 of file icalcluster.c.

                                         {

       struct icalcluster_impl* impl;
  
       if ((impl = (struct icalcluster_impl*)malloc(
                            sizeof(struct icalcluster_impl))) == 0) {
              icalerror_set_errno(ICAL_NEWFAILED_ERROR);
              return 0;
       }
  
       memset(impl, 0, sizeof(struct icalcluster_impl));
       strcpy(impl->id,ICALCLUSTER_ID);

       return impl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalerrorenum icalcluster_remove_component ( icalcluster *  impl,
icalcomponent *  child 
)

Definition at line 201 of file icalcluster.c.

Here is the call graph for this function:

Here is the caller graph for this function: