Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
dur_value.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 //
35 // END_DOUGLAS_MARK_ROYER_COPYRIGHT
36 //
37 
45 #ifndef __DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_DUR_VALUE_HPP__
46 #define __DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_DUR_VALUE_HPP__
47 
48 #ifndef EXPORT_ICALENDAR
49 #ifdef BUILDING_LIBRARY_ICALENDAR
50 #define EXPORT_ICALENDAR EXPORT_OUT
51 #else
52 #define EXPORT_ICALENDAR EXPORT_IN
53 #endif
54 #endif
55 
56 #include <SaS/iCalendar/iCalendar.hpp>
57 #include <SaS/iCalendar/BaseValueType.hpp>
58 #include <SaS/iCalendar/date_time.hpp>
59 #include <SaS/Common/DateTime.hpp>
60 #include <SaS/iCalendar/iCalError.hpp>
61 #include <SaS/iCalendar/integer.hpp>
62 
63 using namespace std;
67 
68 namespace SoftwareAndServices
69 {
70  namespace Library
71  {
72  namespace iCalendar
73  {
74 
82  class EXPORT_ICALENDAR dur_value
83  : public BaseValueType
84  {
85 
86  public:
87 
91  dur_value();
92 
100  dur_value(bool plus, time * TimeDuration);
101 
113  dur_value(bool plus, integer * weeks, time * TimeDuration);
114 
122  dur_value(bool plus, integer * weeks);
123 
132  dur_value(const date_time * EndOfDuration);
133 
142  dur_value(const DateTime * EndOfDuration);
143 
147  virtual ~dur_value();
148 
152  time_t getInSeconds() const;
153 
154  // Return the durations end date/time in Z
155  // NOTE: CALLER MUST DELETE RESULTS!
156  //
165  date * getEnd(const date * startDateTime) const;
166 
177  date_time * getEnd(const date_time * StartDateTime) const;
178 
189  date_time * getEnd(const DateTime * StartDateTime) const;
190 
198  virtual bool sprint(String * Results) const;
199 
210  bool parse(Parse & in, component * errors);
211 
222  bool parse(const char * in, component * errors);
223 
232  bool add(time_t Seconds);
233 
242  bool add(const dur_value * DurVal);
243 
250  void setPlus(bool isPlus);
251 
255  static const time_t secondsPerHour;
256 
260  static const time_t secondsPerDay;
261 
265  static const time_t secondsPerWeek;
266 
267  private:
268  time_t _seconds;
269  bool _plus;
270  };
271  typedef vector<dur_value*> dur_valueVec;
272 
273  }
274  }
275 }
276 
277 #endif /*__DOUGLAS_MARK_ROYER_LIBRARY_ICALENDAR_DUR_VALUE_HPP__*/
static const time_t secondsPerHour
The number of seconds per hour.
Definition: dur_value.hpp:255
static const time_t secondsPerDay
The number of seconds per day.
Definition: dur_value.hpp:260
This object represents an RFC-iCalendar TIME object.
Definition: time.hpp:74
STL namespace.
Generic text parsing routines.
Definition: Parse.hpp:102
static const time_t secondsPerWeek
The number of seconds per week.
Definition: dur_value.hpp:265
An RFC-iCalendar implementation of a DATE-TIME parameter.
Definition: date_time.hpp:90
An RFC-iCalendar integer value.
Definition: integer.hpp:79
This is a class that allows:
Definition: String.hpp:114
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
The base class for calendar objects.
Definition: iCalendar.hpp:434
A DateTime class used by many other objects.
Definition: DateTime.hpp:105
All (almost all) values are derived from this base class.
An RFC-iCalendar implementation of a DUR parameter.
Definition: dur_value.hpp:82
This object represents an RFC-iCalendar DATE object.
Definition: date.hpp:80
Base class for all RFC-iCalendar components.
Definition: component.hpp:98