Portability Libraries  2015.2.0.0
Common Methods and Objects for Platform Independance.
iCalendar.hpp
Go to the documentation of this file.
1 //
2 // BEGIN_DOUGLAS_MARK_ROYER_COPYRIGHT
3 //
4 // Copyright (C) 1993-2012 Douglas Mark Royer, All Rights Reserved.
5 //
6 // NOTICE:
7 //
8 // THIS SOURCE CODE BELONGS TO DOUGLAS MARK ROYER
9 // THIS CODE IS CONSIDERED A
10 // TRADE SECRET AND IS NOT TO BE DIVULGED OR USED BY PARTIES WHO HAVE
11 // NOT RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER.
12 //
13 //
14 // THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
15 // COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
16 // AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
17 // OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
18 // BE SUBJECT TO CIVIL LIABILITY.
19 //
20 // THIS NOTICE AND THE ABOVE COPYRIGHT NOTICE MUST REMAIN IN ALL
21 // COPIES AND ANY DERIVED WORK.
22 //
23 // ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
24 //
25 // THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN IS
26 // PROVIDED ON AN "AS IS" BASIS AND INET-CONSULTING.COM, INC.
27 // DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
28 // NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
29 // HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
30 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
31 // PURPOSE. ANY SERVICE CONTRACT WILL BE UNDER A SEPARATE
32 // LICENSE.
33 //
34 // END_DOUGLAS_MARK_ROYER_COPYRIGHT
35 //
36 #ifndef __DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_HPP__
37 #define __DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_HPP__
38 
39 #ifndef EXPORT_ICALENDAR
40 #ifdef BUILDING_LIBRARY_ICALENDAR
41 #define EXPORT_ICALENDAR EXPORT_OUT
42 #else
43 #define EXPORT_ICALENDAR EXPORT_IN
44 #endif
45 #endif
46 
47 #include <SaS/Common/osver.h>
48 #include <SaS/Common/String.hpp>
49 #include <SaS/Common/StringCache.hpp>
50 #include <SaS/Common/Parse.hpp>
51 #include <SaS/Common/DateTime.hpp>
52 #include <SaS/RfcBasic/Uri.hpp>
53 #include <SaS/Common/Error.hpp>
54 #include <SaS/Common/File.hpp>
55 
56 /**
57  * dbiCalTokens is included here as this file is automatically
58  * generated during the top level build process. The
59  * values are in a database. A program opens up the database
60  * and generates the dbiCalTokens.hpp file. Then the
61  * directory containing the source to this file are built.
62  */
63 #ifdef BUILDING_LIBRARY_ICALENDAR
64 #include "dbiCalTokens.hpp"
65 #else
66 #include <SaS/iCalendar/dbiCalTokens.hpp>
67 #endif
68 
69 #include <memory.h>
70 #include <stdlib.h>
71 #include <sys/types.h>
72 #include <string>
73 #include <vector>
74 #include <map>
75 #include <SaS/Common/winWrappers.hpp>
76 
77 #include <assert.h>
78 
79 #include <SaS/iCalendar/BaseValueType.hpp>
80 
81 using namespace std;
84 //using namespace SoftwareAndServices::Library::iCalendar;
85 
86 #ifdef ComponentId_t
87 #undef ComponentId_t
88 #endif
89 
90 #ifdef PropertyId_t
91 #undef PropertyId_t
92 #endif
93 
94 #ifdef ParameterId_t
95 #undef ParameterId_t
96 #endif
97 
98 #ifdef WIN32
99 ///**
100 // * This warning message tells us that data members that
101 // * use the vector<> std template, can not be accessible
102 // * from outside the class (from a derived class) unless the
103 // * data type is EXPORTED, yet MS-.NET rejects the EXPORT tag
104 // * for ALL vector typedefs. If this is an issue make the member
105 // * variable private and create a method to return the value
106 //* and not the <vector> array.
107 // */
108 #pragma warning(disable: 4251)
109 
110 /**
111  * These are defined and unrelated in WIN32
112  * So they are UNDEFINED here to avoid conflicts.
113  */
114 #ifdef OPAQUE
115 #undef OPAQUE
116 #endif
117 #ifdef TRANSPARENT
118 #undef TRANSPARENT
119 #endif
120 #ifdef DEFAULT_CHARSET
121 #undef DEFAULT_CHARSET
122 #endif
123 
124 #endif
125 
126 extern "C" {
128  void _iCalendar_once_proc();
129 }
130 
131 /**
132  * @author Doug Royer / SoftwareAndServices
133  * @file
134  * This is a class and interfaces in C and C++ that represents iCalendar
135  * object. It is designed to be compatible with RFC-iCalendar, RFC-iTIP, RFC-iMIP,
136  * CAP, and current WebDAV and CalDAV calendars.
137  */
138 
139 namespace SoftwareAndServices
140 {
141  namespace Library
142  {
143  namespace iCalendar
144  {
145  /**
146  * These are some shortcut variables that are defined
147  * so that multiple instances of const strings are not
148  * in the built library.
149  */
150  EXPORT_ICALENDAR extern const char * CRLF_s;
151  EXPORT_ICALENDAR extern const String * CRLF_S;
152 
153  EXPORT_ICALENDAR extern const char * L_COLON_s;
154 
155  EXPORT_ICALENDAR extern const char * L_H_s;
156  EXPORT_ICALENDAR extern const char * L_M_s;
157  EXPORT_ICALENDAR extern const char * L_MINUS_s;
158  EXPORT_ICALENDAR extern const char * L_P_s;
159  EXPORT_ICALENDAR extern const char * L_PLUS_s;
160  EXPORT_ICALENDAR extern const char * L_S_s;
161  EXPORT_ICALENDAR extern const char * L_SEMICOLON_s;
162  EXPORT_ICALENDAR extern const char * L_SLASH_s;
163  EXPORT_ICALENDAR extern const char * L_T_s;
164  EXPORT_ICALENDAR extern const char * L_W_s;
165  EXPORT_ICALENDAR extern const char * L_Z_s;
166 
167 
168  class EXPORT_ICALENDAR action;
169  class EXPORT_ICALENDAR action_param;
170  class EXPORT_ICALENDAR allow_conflict;
171  class EXPORT_ICALENDAR altrep;
172  class EXPORT_ICALENDAR att_counter;
173  class EXPORT_ICALENDAR attach;
174  class EXPORT_ICALENDAR attendee;
175  class EXPORT_ICALENDAR binary;
176  class EXPORT_ICALENDAR binary_parameter;
177  class EXPORT_ICALENDAR binary_property;
178  class EXPORT_ICALENDAR boolean;
179  class EXPORT_ICALENDAR boolean_parameter;
180  class EXPORT_ICALENDAR boolean_property;
181  class EXPORT_ICALENDAR cal_address;
182  class EXPORT_ICALENDAR cal_address_parameter;
183  class EXPORT_ICALENDAR cal_address_property;
184  class EXPORT_ICALENDAR cal_query;
185  class EXPORT_ICALENDAR cal_query_parameter;
186  class EXPORT_ICALENDAR cal_query_property;
187  class EXPORT_ICALENDAR calid;
188  class EXPORT_ICALENDAR calmaster;
189  class EXPORT_ICALENDAR calscale;
190  class EXPORT_ICALENDAR cap_version;
191  class EXPORT_ICALENDAR car_level;
192  class EXPORT_ICALENDAR carid;
193  class EXPORT_ICALENDAR categories;
194  class EXPORT_ICALENDAR class_prop;
195  class EXPORT_ICALENDAR cmd;
196  class EXPORT_ICALENDAR comment;
197  class EXPORT_ICALENDAR component;
198  class EXPORT_ICALENDAR components;
199  class EXPORT_ICALENDAR contact;
200  class EXPORT_ICALENDAR create;
201  class EXPORT_ICALENDAR created;
202  class EXPORT_ICALENDAR csid;
203  class EXPORT_ICALENDAR cutype;
204  class EXPORT_ICALENDAR date;
205  class EXPORT_ICALENDAR date_parameter;
206  class EXPORT_ICALENDAR date_property;
207  class EXPORT_ICALENDAR date_time;
208  class EXPORT_ICALENDAR date_time_parameter;
209  class EXPORT_ICALENDAR date_time_property;
210  class EXPORT_ICALENDAR daylightValue;
211  class EXPORT_ICALENDAR decreed;
212  class EXPORT_ICALENDAR default_charset;
213  class EXPORT_ICALENDAR default_locale;
214  class EXPORT_ICALENDAR default_tzid;
215  class EXPORT_ICALENDAR default_vcars;
216  class EXPORT_ICALENDAR delegated_from;
217  class EXPORT_ICALENDAR delegated_to;
218  class EXPORT_ICALENDAR deny;
219  class EXPORT_ICALENDAR description;
220  class EXPORT_ICALENDAR dir;
221  class EXPORT_ICALENDAR dtend;
222  class EXPORT_ICALENDAR dtstamp;
223  class EXPORT_ICALENDAR dtstart;
224  class EXPORT_ICALENDAR due;
225  class EXPORT_ICALENDAR dur_parameter;
226  class EXPORT_ICALENDAR dur_property;
227  class EXPORT_ICALENDAR dur_value;
228  class EXPORT_ICALENDAR duration;
229  class EXPORT_ICALENDAR enable;
230  class EXPORT_ICALENDAR encoding;
231  class EXPORT_ICALENDAR exdate;
232  class EXPORT_ICALENDAR expand;
233  class EXPORT_ICALENDAR exrule;
234  class EXPORT_ICALENDAR fbtype;
235  class EXPORT_ICALENDAR float_parameter;
236  class EXPORT_ICALENDAR float_property;
237  class EXPORT_ICALENDAR float_value;
238  class EXPORT_ICALENDAR fmttype;
239  class EXPORT_ICALENDAR fn;
240  class EXPORT_ICALENDAR freebush;
241  class EXPORT_ICALENDAR geo;
242  class EXPORT_ICALENDAR grant;
243  class EXPORT_ICALENDAR iCalError;
244  class EXPORT_ICALENDAR iCalendar;
245  class EXPORT_ICALENDAR icalbody;
246  class EXPORT_ICALENDAR icaldata;
247  class EXPORT_ICALENDAR id;
248  class EXPORT_ICALENDAR integer;
249  class EXPORT_ICALENDAR integer_parameter;
250  class EXPORT_ICALENDAR integer_property;
251  class EXPORT_ICALENDAR itip_version;
252  class EXPORT_ICALENDAR label;
253  class EXPORT_ICALENDAR language;
254  class EXPORT_ICALENDAR last_modified;
255  class EXPORT_ICALENDAR latency;
256  class EXPORT_ICALENDAR local;
257  class EXPORT_ICALENDAR localize;
258  class EXPORT_ICALENDAR location;
259  class EXPORT_ICALENDAR max_comp_size;
260  class EXPORT_ICALENDAR maxdate;
261  class EXPORT_ICALENDAR member;
262  class EXPORT_ICALENDAR method;
263  class EXPORT_ICALENDAR mindate;
264  class EXPORT_ICALENDAR multipart;
265  class EXPORT_ICALENDAR name;
266  class EXPORT_ICALENDAR options;
267  class EXPORT_ICALENDAR organizer;
268  class EXPORT_ICALENDAR owner;
269  class EXPORT_ICALENDAR parameter;
270  class EXPORT_ICALENDAR parser;
271  class EXPORT_ICALENDAR partstat;
272  class EXPORT_ICALENDAR percent_complete;
273  class EXPORT_ICALENDAR period;
274  class EXPORT_ICALENDAR period_parameter;
275  class EXPORT_ICALENDAR period_property;
276  class EXPORT_ICALENDAR permission;
277  class EXPORT_ICALENDAR photo;
278  class EXPORT_ICALENDAR priority;
279  class EXPORT_ICALENDAR property;
280  class EXPORT_ICALENDAR query;
281  class EXPORT_ICALENDAR query_level;
282  class EXPORT_ICALENDAR queryid;
283  class EXPORT_ICALENDAR range;
284  class EXPORT_ICALENDAR rdate;
285  class EXPORT_ICALENDAR recur;
286  class EXPORT_ICALENDAR recur_accepted;
287  class EXPORT_ICALENDAR recur_expanded;
288  class EXPORT_ICALENDAR recur_limit;
289  class EXPORT_ICALENDAR recur_parameter;
290  class EXPORT_ICALENDAR recur_property;
291  class EXPORT_ICALENDAR recurrence_id;
292  class EXPORT_ICALENDAR related;
293  class EXPORT_ICALENDAR related_to;
294  class EXPORT_ICALENDAR reltype;
295  class EXPORT_ICALENDAR repeat;
296  class EXPORT_ICALENDAR request_status;
297  class EXPORT_ICALENDAR resources;
298  class EXPORT_ICALENDAR restriction;
299  class EXPORT_ICALENDAR role;
300  class EXPORT_ICALENDAR rrule;
301  class EXPORT_ICALENDAR rsvp;
302  class EXPORT_ICALENDAR scope;
303  class EXPORT_ICALENDAR sent_by;
304  class EXPORT_ICALENDAR sequence;
305  class EXPORT_ICALENDAR sort_string;
306  class EXPORT_ICALENDAR sound;
307  class EXPORT_ICALENDAR standardValue;
308  class EXPORT_ICALENDAR status;
309  class EXPORT_ICALENDAR stores_expanded;
310  class EXPORT_ICALENDAR summary;
311  class EXPORT_ICALENDAR target;
312  class EXPORT_ICALENDAR text;
313  class EXPORT_ICALENDAR text_parameter;
314  class EXPORT_ICALENDAR text_property;
315  class EXPORT_ICALENDAR time;
316  class EXPORT_ICALENDAR time_parameter;
317  class EXPORT_ICALENDAR time_property;
318  class EXPORT_ICALENDAR title;
319  class EXPORT_ICALENDAR transp;
320  class EXPORT_ICALENDAR trigger;
321  class EXPORT_ICALENDAR tzid;
322  class EXPORT_ICALENDAR tzid_param;
323  class EXPORT_ICALENDAR tznameValue;
324  class EXPORT_ICALENDAR tzoffsetfrom;
325  class EXPORT_ICALENDAR tzoffsetto;
326  class EXPORT_ICALENDAR tzurl;
327  class EXPORT_ICALENDAR uid;
328  class EXPORT_ICALENDAR upn_filter;
329  class EXPORT_ICALENDAR upn_filter_parameter;
330  class EXPORT_ICALENDAR upn_filter_property;
331  class EXPORT_ICALENDAR upn_parameter;
332  class EXPORT_ICALENDAR upn_value;
333  class EXPORT_ICALENDAR uri;
334  class EXPORT_ICALENDAR uri_parameter;
335  class EXPORT_ICALENDAR uri_property;
336  class EXPORT_ICALENDAR url;
337  class EXPORT_ICALENDAR utc_offset;
338  class EXPORT_ICALENDAR utc_offset_parameter;
339  class EXPORT_ICALENDAR utc_offset_property;
340  class EXPORT_ICALENDAR vagenda;
341  class EXPORT_ICALENDAR valarm;
342  class EXPORT_ICALENDAR value;
343  class EXPORT_ICALENDAR BaseValueType;
344  class EXPORT_ICALENDAR value_datum;
345  class EXPORT_ICALENDAR valuetype;
346  class EXPORT_ICALENDAR vc_version;
347  class EXPORT_ICALENDAR vcalendar;
348  class EXPORT_ICALENDAR vcalstore;
349  class EXPORT_ICALENDAR vcar;
350  class EXPORT_ICALENDAR version;
351  class EXPORT_ICALENDAR vevent;
352  class EXPORT_ICALENDAR vfreebusy;
353  class EXPORT_ICALENDAR vjournal;
354  class EXPORT_ICALENDAR vquery;
355  class EXPORT_ICALENDAR vreply;
356  class EXPORT_ICALENDAR vrights;
357  class EXPORT_ICALENDAR vtimezone;
358  class EXPORT_ICALENDAR vtodo;
359  class EXPORT_ICALENDAR x_component;
360  class EXPORT_ICALENDAR x_inet_color;
361  class EXPORT_ICALENDAR x_inet_fixed_recur;
362  class EXPORT_ICALENDAR x_inet_id;
363  class EXPORT_ICALENDAR x_inet_invited;
364  class EXPORT_ICALENDAR x_inet_local;
365  class EXPORT_ICALENDAR x_inet_parent;
366  class EXPORT_ICALENDAR x_intellical_group;
367  class EXPORT_ICALENDAR x_intellical_image;
368  class EXPORT_ICALENDAR x_intellical_photo;
369  class EXPORT_ICALENDAR x_intellical_sound;
370  class EXPORT_ICALENDAR x_param;
371  class EXPORT_ICALENDAR x_prop;
372 
373  /**
374  * @typedef CalendarId_t An identifier for all calendars.
375  */
376  EXPORT_ICALENDAR typedef uint64_t CalendarId_t;
377 
378  /**
379  * @typedef ComponentId_t An identifier for all components
380  * including VCALENDAR, VCALSTORE, VEVENT, VALARM, ...
381  */
382  EXPORT_ICALENDAR typedef uint64_t ComponentId_t;
383 
384  /**
385  * @typedef PropertyId_t An identifier for any property.
386  */
387  EXPORT_ICALENDAR typedef uint64_t PropertyId_t;
388 
389  /**
390  * @typedef ParameterId_t An identifier for any parameter.
391  */
392  EXPORT_ICALENDAR typedef uint64_t ParameterId_t;
393 
394  /**
395  * @typedef GroupId_t An identifier for a group.
396  */
397  EXPORT_ICALENDAR typedef uint64_t GroupId_t;
398 
399  /**
400  * @typedef time_tVec Used to represent an array of instances.
401  */
402  EXPORT_ICALENDAR typedef vector<time_t> time_tVec;
403 
404  /**
405  * @typedef time_tVec Used to represent an array of instances.
406  */
407  EXPORT_ICALENDAR typedef vector<icalbody*> icalbodyVec;
408 
409  /**
410  * @typedef iCalendarVec
411  * An array of iCalendar.
412  */
413  EXPORT_ICALENDAR typedef vector<iCalendar*> iCalendarVec;
414 
415  /**
416  * @typedef componentVec
417  * An array of component.
418  */
419  EXPORT_ICALENDAR typedef vector<component*> componentVec;
420 
421  /**
422  * @typedef propertyVec
423  * An array of property.
424  */
425  EXPORT_ICALENDAR typedef vector<property*> propertyVec;
426 
427  /**
428  * @class iCalendar
429  *
430  * The base class for calendar objects.
431  * Generally this would not be used by applications. Instead
432  * they would use libINET-iCalFile, libINET-iCalXML, and so on.
433  */
434  class EXPORT_ICALENDAR iCalendar
435  : virtual public instance<iCalendar>
436  {
437 
438  public:
439 
440  /**
441  * iCalendar Constructor.
442  */
443  iCalendar();
444 
445  /**
446  * iCalendar Constructor.
447  *
448  * @param ExistingiCalendarObject An existing VCALENDER/VCALSTORE object to be added to 'this' object.
449  */
450  iCalendar(iCalendar * ExistingiCalendarObject);
451 
452  /**
453  * iCalendar Constructor.
454  *
455  * @param ExistingVCalendarObject An existing VCALENDER object to be added to 'this' object.
456  */
457  iCalendar(icalbody * ExistingVCalendarObject);
458 
459  /**
460  * iCalendar Destructor
461  */
462  virtual ~iCalendar();
463 
464  /**
465  * User data associated with this object. This is not iCal specific,
466  * it is to be used in any way needed by calling application.
467  *
468  * @param userData A pointer to any kind of data.
469  *
470  * @see getUserdata();
471  */
472  void setUserData(const void * userData);
473 
474  /**
475  * Return the data set by a call to setUserData().
476  *
477  * @return The pointer set by a call to setUserData().
478  */
479  void * getUserData() const;
480 
481  /**
482  * Parse a string of calendar data.
483  *
484  * @param in The already initialized Parse() object.
485  *
486  * @param errors An iCalendar formatted list of errors.
487  *
488  * @return Returns the number of octets parsed.
489  *
490  * @see Parse()
491  */
492  bool parse(const char * in, component * errors);
493 
494 
495  /**
496  * Parse an open File.
497  *
498  * @param in The already opened File that contains calendar data.
499  *
500  * @param errors An iCalendar formatted list of errors.
501  *
502  * @return Returns the number of octets parsed.
503  *
504  * @see File()
505  */
506  bool parse(File * in, component * errors);
507 
508  /**
509  * Parse the contents of a already initialized Parse() object that
510  * contains calendar data.
511  *
512  * @param in The already initialized Parse() object.
513  *
514  * @param errors An iCalendar formatted list of errors.
515  *
516  * @return Returns the number of octets parsed.
517  *
518  * @see Parse()
519  */
520  bool parse(Parse & in, component * errors);
521 
522  /**
523  * Do basic checking to determine if the data parsed looks like
524  * some kind of known iCalendar object.
525  *
526  * @return TRUE if it looks valid after parsing.
527  */
528  bool valid() const;
529 
530  /**
531  * Add another iCalendar to this object.
532  *
533  * @param anotheriCal the other iCalendar pointer.
534  *
535  * @return TRUE if added.
536  */
537  bool add(const iCalendar * anotheriCal);
538 
539  /**
540  * Add an icalbody to this iCalendar object.
541  *
542  * @param body The icalbody to add.
543  *
544  * @return TRUE if added.
545  */
546  bool add(const icalbody * body);
547 
548  /**
549  * Add a component to this iCalendar object.
550  *
551  * @param comp The component to add.
552  *
553  * @return TRUE if added.
554  */
555  bool add(const component * comp);
556 
557  /**
558  * Add a property to the iCalendar object.
559  *
560  * @param prop The property to add.
561  *
562  * @return TRUE if added.
563  */
564  bool add(const property * prop);
565 
566  /**
567  * Convert this object to an RFC-iCalendar formatted string.
568  *
569  * @param Results A pointer to a String where the results will
570  * be appended to.
571  *
572  * @return TRUE when something was added to Results.
573  */
574  bool sprint(String * Results) const;
575 
576 
577  /**
578  * Get the number of iCalender objects in this object.
579  *
580  * @return The number of iCalendar objects in this object.
581  */
582  unsigned int getiCalCount() const;
583 
584  /**
585  * Get the nTh ical object.
586  *
587  * @param nTh nTh starts at zero for the first object.
588  *
589  * @return NULL if the Nth iCalendar object does not exist.
590  */
591  iCalendar * getiCal(unsigned int nTh) const;
592 
593  /**
594  * Get the number of icalbody objects in this object.
595  *
596  * @return The number of icalbody objects in this object.
597  */
598  unsigned int getBodyCount() const;
599 
600  /**
601  * Get the nTh icalbody object.
602  *
603  * @param nTh nTh starts at zero for the first object.
604  *
605  * @return NULL if the Nth icalbody object does not exist.
606  */
607  icalbody * getiCalBody(unsigned int nTh) const;
608 
609  /**
610  * Return the number of components in this object.
611  *
612  * @return The number of components in this object.
613  */
614  unsigned int getComponentCount() const;
615 
616  /**
617  * Return the number of components in this object of type typeToCount.
618  *
619  * @param typeToCount Only count this kind of components in the results.
620  *
621  * @return The number of components in this object.
622  */
623  unsigned int getComponentCount(Tokens_t typeToCount) const;
624 
625  /**
626  * Return the nTh component.
627  *
628  * @param nTh nTh starts from zero.
629  *
630  * @return NULL if not found, else the nTh component.
631  */
632  component * getComponent(unsigned int nTh) const;
633 
634  /**
635  * Return the nTh component that is typeToGet
636  *
637  * @param typeToGet Get the nTh component of this type.
638  *
639  * @param nTh nTh starts from zero.
640  *
641  * @return NULL if not found, else the nTh component.
642  */
643  component * getComponent(Tokens_t typeToGet, unsigned int nTh) const;
644 
645  /**
646  * Return the number of properties in this object.
647  *
648  * @return The number of properties in this object.
649  */
650  unsigned int getPropertyCount() const;
651 
652  /**
653  * Return the nTh property.
654  *
655  * @param nTh nTh starts from zero.
656  *
657  * @return NULL if not found, else the nTh property.
658  */
659  property * getProperty(unsigned int nTh) const;
660 
661  protected:
662  iCalendarVec * _icalList;
663  icalbodyVec * _bodyList;
664  componentVec * _componentList;
665  propertyVec * _propertyList;
666  void * _userData;
667  };
668 
669  /**
670  * @typedef iCalendarVec
671  * An array of iCalendar.
672  */
673  //typedef vector<iCalendar*> iCalendarVec;
674 
675  /**
676  * Convert the object token ID into a string.
677  *
678  * @param token The token ID to convert to a string.
679  *
680  * @return NULL if not a valid ID, or the text string that
681  * token represents.
682  */
683  EXPORT_ICALENDAR const char * token2text(Tokens_t token);
684 
685  /**
686  * Convert a string into an object token ID.
687  *
688  * @param TokenString The string to convert.
689  *
690  * @param Length If Length is greater than zero, only convert up to Length characters.
691  *
692  * @return The token ID matching TokenString (up to Length), or UnknownToken_t if not known.
693  */
694  EXPORT_ICALENDAR Tokens_t text2token(const char * TokenString, size_t Length = 0);
695 
696  /**
697  * Many of the methods in the iCalendar namespace will define their own valid() function.
698  * requiredList is an object that describes some basic validation information.
699  */
700  struct EXPORT_ICALENDAR requiredList {
701 
702  /**
703  * A token (type of object) that it can have.
704  */
706 
707  /**
708  * When TRUE, a component, property, parameter, or value of type 'token'
709  * must be supplied in the object.
710  */
711  bool required;
712 
713  /**
714  * The maximum number of times the token type can be included.
715  * Unlimited = UCHAR_MAX
716  */
717  unsigned char maxInstances;
718 
719  /**
720  * The minimum number of times the token type can be included.
721  */
722  unsigned char minInstances;
723 
724  };
725 
726  /**
727  * This is the start of a parsing idea.
728  * Each type of property or parameter will have a PAdispatch_f
729  * or a POdispatch_f. The parse function will be called
730  * from a top level parser, which will call the correct
731  * property or parameter parser.
732  *
733  * C++ virtual functions were having a problem because
734  * some of the object types are not known until after
735  * they are parsed, so the runtime code does not know
736  * which to call. A base + derived virtual parse
737  * function will be implemented.
738  */
739  EXPORT_ICALENDAR typedef parameter * (*PAdispatch_f)(const char * text);
740  EXPORT_ICALENDAR typedef property * (*POdispatch_f)(const char * text);
741 
742  /**
743  * The dispatch table will contain the string name (of
744  * a property pr parameter), then depending on the context
745  * the pa_func or po_func will be called (if they exist).
746  *
747  * - If no pa_function (for parameters) and we are parsing
748  * parameters, then xparam will be called.
749  *
750  * - If no po_function (for properties) and we are parsing
751  * properties, then xprop will be called.
752  */
753  struct EXPORT_ICALENDAR dispatchTable {
754  const char * string;
757  };
758 
759  }
760  }
761 }
762 
763 #endif /*__DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_HPP__ */
764 
class EXPORT_ICALENDAR x_inet_parent
Definition: iCalendar.hpp:365
void _iCalendar_once_proc()
class EXPORT_ICALENDAR x_inet_invited
Definition: iCalendar.hpp:363
class EXPORT_ICALENDAR x_intellical_photo
Definition: iCalendar.hpp:368
EXPORT_ICALENDAR typedef vector< iCalendar * > iCalendarVec
Definition: iCalendar.hpp:413
void _BaseValueType_once_proc()
EXPORT_ICALENDAR typedef uint64_t PropertyId_t
Definition: iCalendar.hpp:387
class EXPORT_ICALENDAR value_datum
Definition: iCalendar.hpp:344
EXPORT_ICALENDAR const char * token2text(Tokens_t token)
EXPORT_ICALENDAR const char * L_H_s
STL namespace.
class EXPORT_ICALENDAR sort_string
Definition: iCalendar.hpp:305
unsigned int errors[MAX_TESTS]
class EXPORT_ICALENDAR x_inet_local
Definition: iCalendar.hpp:364
EXPORT_ICALENDAR const char * L_SLASH_s
EXPORT_ICALENDAR typedef property *(* POdispatch_f)(const char *text)
Definition: iCalendar.hpp:740
vector< component * > componentVec
Definition: component.hpp:86
EXPORT_ICALENDAR const char * L_Z_s
EXPORT_ICALENDAR const char * CRLF_s
EXPORT_ICALENDAR typedef uint64_t GroupId_t
Definition: iCalendar.hpp:397
EXPORT_ICALENDAR const char * L_COLON_s
EXPORT_ICALENDAR const char * L_SEMICOLON_s
class EXPORT_ICALENDAR recur_expanded
Definition: iCalendar.hpp:287
EXPORT_ICALENDAR typedef uint64_t CalendarId_t
Definition: iCalendar.hpp:376
EXPORT_ICALENDAR typedef uint64_t ParameterId_t
Definition: iCalendar.hpp:392
EXPORT_ICALENDAR const char * L_T_s
class EXPORT_ICALENDAR x_inet_color
Definition: iCalendar.hpp:360
EXPORT_ICALENDAR typedef uint64_t ComponentId_t
Definition: iCalendar.hpp:382
EXPORT_ICALENDAR const char * L_PLUS_s
EXPORT_ICALENDAR const char * L_MINUS_s
EXPORT_ICALENDAR typedef parameter *(* PAdispatch_f)(const char *text)
Definition: iCalendar.hpp:739
EXPORT_ICALENDAR const char * L_S_s
class EXPORT_ICALENDAR x_intellical_group
Definition: iCalendar.hpp:366
EXPORT_ICALENDAR Tokens_t text2token(const char *TokenString, size_t Length=0)
EXPORT_ICALENDAR const String * CRLF_S
EXPORT_ICALENDAR const char * L_W_s
EXPORT_ICALENDAR const char * L_P_s
class EXPORT_ICALENDAR x_inet_fixed_recur
Definition: iCalendar.hpp:361
class EXPORT_ICALENDAR x_intellical_sound
Definition: iCalendar.hpp:369
EXPORT_ICALENDAR const char * L_M_s
std::vector< icalbody * > icalbodyVec
Definition: icalbody.hpp:109
EXPORT_ICALENDAR typedef vector< property * > propertyVec
Definition: iCalendar.hpp:425
class EXPORT_ICALENDAR x_intellical_image
Definition: iCalendar.hpp:367