Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
component.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 // THE LOG DATES BELOW ARE THE SOURCE CONTROL TAGS.
35 // THEY DO NOT REFLECT COPYRIGHT DATES OR NOTICES.
36 //
37 // END_DOUGLAS_MARK_ROYER_COPYRIGHT
38 //
39 
47 #ifndef __DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_COMPONENT_HPP__
48 #define __DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_COMPONENT_HPP__
49 
50 #ifndef EXPORT_ICALENDAR
51 #ifdef BUILDING_LIBRARY_ICALENDAR
52 #define EXPORT_ICALENDAR EXPORT_OUT
53 #else
54 #define EXPORT_ICALENDAR EXPORT_IN
55 #endif
56 #endif
57 
58 #ifdef BUILDING_LIBRARY_ICALENDAR
59 #include "iCalendar.hpp"
60 #include "property.hpp"
61 #include "parameter.hpp"
62 #include "date_time.hpp"
63 #else
64 #include <SaS/iCalendar/iCalendar.hpp>
65 #include <SaS/iCalendar/property.hpp>
66 #include <SaS/iCalendar/parameter.hpp>
67 #include <SaS/iCalendar/date_time.hpp>
68 #endif
69 
70 using namespace std;
74 
75 namespace SoftwareAndServices
76 {
77  namespace Library
78  {
79  namespace iCalendar
80  {
81 
86  typedef vector<component*> componentVec;
87 
92  typedef vector<time_t> time_tVec;
93 
98  class EXPORT_ICALENDAR component
99  : virtual public instance<component>
100  {
101 
102  protected:
103 
107  component(const char * xname, size_t len); // For x_component
108 
123  bool _parse(Tokens_t newToken,
124  property ** newProp,
125  Parse & in,
126  component * errors);
127 
142  bool validComponent(requiredList * propList,
143  bool xpropAllowed = true,
144  requiredList * compList = NULL,
145  bool xcompAllowed = true);
146 
147  public:
148 
154  component(Tokens_t type);
155 
163  component(component & CopyFrom);
164 
168  virtual ~component();
169 
176  void setUserData(void * userData);
177 
184  void * getUserData() const;
185 
191  virtual bool valid() const;
192 
205  virtual bool parse(Parse & in, component * errors);
206 
218  virtual bool parse(const char * in, component * errors);
219 
227  virtual bool add(const property * newProperty);
228 
239  virtual bool addIfNew(const property * newProperty);
240 
248  virtual bool add(const component * NewComp);
249 
258  virtual bool addIfNew(const component * NewComp);
259 
267  virtual bool add(iCalError * ErrorToAdd);
268 
273 
277  componentVec * componentList;
278 
282  unsigned int getPropertyCount() const;
283 
293  unsigned int getPropertyCount(Tokens_t PropTypeToCount) const;
294 
304  bool removeProperty(Tokens_t PropTypeToRemove,
305  unsigned int nTh);
306 
316  bool removeComponent(Tokens_t CompTypeToRemove,
317  unsigned int nTh);
318 
320  // * Remove the xx
321  // */
322  //bool removeComp(Tokens_t type, const component * ptr);
323 
331  property * getProperty(unsigned int nTh = 0) const;
332 
342  property * getProperty(Tokens_t PropTypeToFind,
343  unsigned int nTh) const;
344 
354  property * getProperty(const char * xName,
355  unsigned int nTh) const;
356 
365  component * getComponent(const uid * uidValue) const;
366 
375  component * getComponent(const char * uidValue) const;
376 
385  valarm * getValarm(int SequenceToFind) const;
386 
395  valarm * getValarm(const sequence * SequenceToFind) const;
396 
400  unsigned int getComponentCount() const;
401 
405  unsigned int getComponentCount(Tokens_t OfType) const;
406 
412  component * getComponent(unsigned int offset) const;
413 
421  component * getComponent(Tokens_t CompTypeToFind,
422  unsigned int nTh) const;
423 
431  component * getComponent(const char * xName,
432  unsigned int nTh) const;
433 
437  void setComponentType(Tokens_t type);
438 
446  void setComponentType(const char * xType,
447  unsigned int len = 0);
448 
452  Tokens_t getComponentType() const;
453 
457  const char * getXComponentType() const;
458 
465  virtual bool sprint(String * Results) const;
466 
473  bool removeProperty(const property * PropertyToRemove);
474 
481  bool removeComponent(const component * ComponentToRemove);
482 
489  bool addDtstamp(const dtstamp * TimeStamp = NULL);
490 
494  iCalErrorVec * getErrorList() const;
495 
514  propertyVec * getInstanceArray(iCalendar * ical,
515  const date_time * start,
516  unsigned int inst_count = 0) const;
517 
536  propertyVec * getInstanceArray(iCalendar * ical,
537  const date_time * start,
538  const date_time * until = NULL) const;
539 
550  time_tVec * getAlarmArray(const date_time * start, const date_time * until);
551 
560  virtual bool operator==(const component & Other) const;
561 
569  virtual bool operator!=(const component & Other) const;
570 
580  virtual component & operator=(const component & CopyFrom);
581 
588  virtual InstanceCount_t incInstance() const;
589 
596  virtual InstanceCount_t decInstance() const;
597 
603  virtual InstanceCount_t getInstance() const;
604 
610  void operator delete(void * ToFree);
611 
612  private:
613 
617  void _RemoveAllProperties();
618 
622  void _RemoveAllComponents();
623 
627  void _RemoveListOfErrors();
628 
629 
630  iCalErrorVec * _listOfErrors;
631  Tokens_t _type;
632  const char * _xType; // StringCache
633  void * _userData;
634 
635  // Computed/cached from the Start to End (inclusive).
636  //
637  mutable propertyVec * _instances;
638  mutable date_timeVec * _alarmTimes; // Tied to _instances.
639 
643  void _clearInstances();
644  };
645 
646  }
647  }
648 }
649 
650 #endif /*__DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_COMPONENT_HPP__*/
An implementation of a RFC-CAP VALARM component.
Definition: valarm.hpp:82
This class contains, processes, and formats iCalendar errors.
Definition: iCalError.hpp:90
An RFC-iCalendar implementation of DTSTAMP property.
Definition: dtstamp.hpp:80
vector< component * > componentVec
An array of component.
Definition: component.hpp:86
STL namespace.
An RFC-iCalendar implementation of SEQUENCE property.
Definition: sequence.hpp:80
Generic text parsing routines.
Definition: Parse.hpp:102
An RFC-iCalendar implementation of UID property.
Definition: uid.hpp:78
componentVec * componentList
The list of components in this component.
Definition: component.hpp:277
An RFC-iCalendar implementation of a DATE-TIME parameter.
Definition: date_time.hpp:90
Base class for all RFC-iCalendar properties.
Definition: property.hpp:79
vector< time_t > time_tVec
An array of time_t.
Definition: component.hpp:92
Instance counting and tracking.
Definition: instance.hpp:90
propertyVec * propertyList
The list of properties in this component.
Definition: component.hpp:272
EXPORT_ICALENDAR typedef vector< property * > propertyVec
An array of property.
Definition: iCalendar.hpp:425
This is a class that allows:
Definition: String.hpp:114
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
uint64_t InstanceCount_t
Many, many instances supported by the software.
Definition: instance.hpp:83
The base class for calendar objects.
Definition: iCalendar.hpp:434
Many of the methods in the iCalendar namespace will define their own valid() function.
Definition: iCalendar.hpp:700
Base class for all RFC-iCalendar components.
Definition: component.hpp:98