Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SoftwareAndServices::Library::iCalendar::dur_value Class Reference

An RFC-iCalendar implementation of a DUR parameter. More...

#include </home/doug/src/SoftwareAndServices/libSaSiCalendar/dur_parameter.hpp>

+ Inheritance diagram for SoftwareAndServices::Library::iCalendar::dur_value:
+ Collaboration diagram for SoftwareAndServices::Library::iCalendar::dur_value:

Public Types

enum  quote_errors { NO_END_QUOTE_e = 1, NO_DATA_PROVIDED_e, UNKNOWN_BACKSLASH_ESCAPE_e, NO_TERM_FOUND_e }
 These are C++ objects that can be thrown as errors. More...
 

Public Member Functions

 dur_value ()
 dur_value Constructor. More...
 
 dur_value (bool plus, time *TimeDuration)
 dur_value Constructor. More...
 
 dur_value (bool plus, integer *weeks, time *TimeDuration)
 dur_value Constructor. More...
 
 dur_value (bool plus, integer *weeks)
 dur_value Constructor. More...
 
 dur_value (const date_time *EndOfDuration)
 dur_value Constructor. More...
 
 dur_value (const DateTime *EndOfDuration)
 dur_value Constructor. More...
 
virtual ~dur_value ()
 dur_value Destructor. More...
 
bool add (time_t Seconds)
 Add time to a duration. More...
 
bool add (const dur_value *DurVal)
 Add time to a duration. More...
 
virtual InstanceCount_t decInstance () const
 Decrement the instance. More...
 
const valuegetData () const
 Get the pointer to the data being stored. More...
 
dategetEnd (const date *startDateTime) const
 Apply this duration amount to a date in GMT (Z) and return it. More...
 
date_timegetEnd (const date_time *StartDateTime) const
 Get the end of the duration. More...
 
date_timegetEnd (const DateTime *StartDateTime) const
 Get the end of the duration. More...
 
time_t getInSeconds () const
 
virtual InstanceCount_t getInstance () const
 
Tokens_t getType () const
 Get the type of data being stored. More...
 
const char * getXValueType () const
 Get the type of data being stored. More...
 
virtual InstanceCount_t incInstance () const
 Increment the instance. More...
 
void operator delete (void *data)
 This class uses instance counting, this entry point overloads the default delete() operator in order to correctly track the instance. More...
 
bool parse (Parse &in, component *errors)
 #Parse a duration value (dur_value) object. More...
 
bool parse (const char *in, component *errors)
 #Parse a duration value (dur_value) object. More...
 
void setData (void *DataPtr)
 Set the data to the data being stored. More...
 
void setPlus (bool isPlus)
 Set (or unset) a flag indicating if this is a positive or negative duration of time. More...
 
void setType (Tokens_t Token)
 Set the type of data being stored. More...
 
void setXValueType (const char *xValType)
 Set the type of data being stored - non-standard types only. More...
 
virtual bool sprint (String *Results) const
 Print the object in RFC-iCalendar format. More...
 

Static Public Member Functions

static char * addQuotes (const char *text)
 Add quotes to the value. More...
 
static char * escape (const char *text)
 Escape a value and return an RFC-iCalendar value encoded. More...
 
static char * removeQuotes (const char *text)
 Remove quotes from a user supplied value so that the raw data can be stored. More...
 
static bool sprintTokensAsText (String *Results, Tokens_t token)
 Called by text2token() to get the token name as a String. More...
 
static char * unescape (const char *text, const char *term)
 Un-escape a value and return what a user originally entered. More...
 

Static Public Attributes

static const time_t secondsPerDay
 The number of seconds per day. More...
 
static const time_t secondsPerHour
 The number of seconds per hour. More...
 
static const time_t secondsPerWeek
 The number of seconds per week. More...
 
static const char ** tokenStrings
 A list of strings for the names of tokens. More...
 

Detailed Description

An RFC-iCalendar implementation of a DUR parameter.

DURATION VALUE NOTE:

  • Not derived from 'class value' as this data type has TWO data types, so 'class value' will not work.

Definition at line 82 of file dur_value.hpp.

Member Enumeration Documentation

◆ quote_errors

These are C++ objects that can be thrown as errors.

Definition at line 204 of file BaseValueType.hpp.

Constructor & Destructor Documentation

◆ dur_value() [1/6]

SoftwareAndServices::Library::iCalendar::dur_value::dur_value ( )

dur_value Constructor.

◆ dur_value() [2/6]

SoftwareAndServices::Library::iCalendar::dur_value::dur_value ( bool  plus,
time TimeDuration 
)

dur_value Constructor.

Parameters
plusWhen TRUE, the duration is a positive duration, else a negative duration.
TimeDurationThe length of the duration.

◆ dur_value() [3/6]

SoftwareAndServices::Library::iCalendar::dur_value::dur_value ( bool  plus,
integer weeks,
time TimeDuration 
)

dur_value Constructor.

Parameters
plusWhen TRUE, the duration is a positive duration, else a negative duration.
weeksHow many weeks in the duration. NOTE: TimeDuration ignored if weeks is supplied.
TimeDurationThe length of the duration. NOTE: TimeDuration ignored if weeks is supplied.

◆ dur_value() [4/6]

SoftwareAndServices::Library::iCalendar::dur_value::dur_value ( bool  plus,
integer weeks 
)

dur_value Constructor.

Parameters
plusWhen TRUE, the duration is a positive duration, else a negative duration.
weeksHow many weeks in the duration.

◆ dur_value() [5/6]

SoftwareAndServices::Library::iCalendar::dur_value::dur_value ( const date_time EndOfDuration)

dur_value Constructor.

NOTE: date_time is a RFC-iCalendar object.

Duration ends at EndOfDuration.

Parameters
EndOfDurationDuration ends at EndOfDuration.

◆ dur_value() [6/6]

SoftwareAndServices::Library::iCalendar::dur_value::dur_value ( const DateTime EndOfDuration)

dur_value Constructor.

NOTE: DateTime is a generic DATE-TIME object.

Duration ends at EndOfDuration.

Parameters
EndOfDurationDuration ends at EndOfDuration.

◆ ~dur_value()

virtual SoftwareAndServices::Library::iCalendar::dur_value::~dur_value ( )
virtual

dur_value Destructor.

Member Function Documentation

◆ add() [1/2]

bool SoftwareAndServices::Library::iCalendar::dur_value::add ( time_t  Seconds)

Add time to a duration.

Parameters
SecondsNumber of seconds to add to the current duration.
Returns
TRUE when successful. FALSE when the results would exceed the maximum (or minimum) time supported by this implementation.

◆ add() [2/2]

bool SoftwareAndServices::Library::iCalendar::dur_value::add ( const dur_value DurVal)

Add time to a duration.

Parameters
DurValHow much time to add to this duration.
Returns
TRUE when successful. FALSE when the results would exceed the maximum (or minimum) time supported by this implementation.

◆ addQuotes()

static char* SoftwareAndServices::Library::iCalendar::BaseValueType::addQuotes ( const char *  text)
staticinherited

Add quotes to the value.

Caller MUST free results.

Parameters
textThe text to be de-quoted.
Returns
The de-quoted data.

◆ decInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< BaseValueType >::decInstance ( ) const
inlinevirtualinherited

Decrement the instance.

Returns
The instance count, after decrementing it.

Reimplemented in SoftwareAndServices::Library::iCalendar::date_time.

Definition at line 129 of file instance.hpp.

◆ escape()

static char* SoftwareAndServices::Library::iCalendar::BaseValueType::escape ( const char *  text)
staticinherited

Escape a value and return an RFC-iCalendar value encoded.

Caller MUST free results.

Parameters
textthe text to escape.
Returns
The escaped string.

◆ getData()

const value* SoftwareAndServices::Library::iCalendar::BaseValueType::getData ( ) const
inherited

Get the pointer to the data being stored.

Returns
Pointer to the data being stored.

◆ getEnd() [1/3]

date* SoftwareAndServices::Library::iCalendar::dur_value::getEnd ( const date startDateTime) const

Apply this duration amount to a date in GMT (Z) and return it.

NOTE: CALLER MUST DELETE THE RESULTS when no longer needed.

Returns
The date of the duration end. NOTE: CALLER MUST DELETE THE RESULTS when no longer needed.

◆ getEnd() [2/3]

date_time* SoftwareAndServices::Library::iCalendar::dur_value::getEnd ( const date_time StartDateTime) const

Get the end of the duration.

Take the StartOfDuration add or subtract this duration amount and return the end of the duration.

Parameters
StartOfDurationA start date_time to use in the duration math.
Returns
A date_time object that is the end of the duration. NOTE: CALLER MUST DELETE THE RESULTS when no longer needed.

◆ getEnd() [3/3]

date_time* SoftwareAndServices::Library::iCalendar::dur_value::getEnd ( const DateTime StartDateTime) const

Get the end of the duration.

Take the StartOfDuration add or subtract this duration amount and return the end of the duration.

Parameters
StartOfDurationA start DateTime to use in the duration math.
Returns
A date_time object that is the end of the duration. NOTE: CALLER MUST DELETE THE RESULTS when no longer needed.

◆ getInSeconds()

time_t SoftwareAndServices::Library::iCalendar::dur_value::getInSeconds ( ) const
Returns
The duration length in seconds.

◆ getInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< BaseValueType >::getInstance ( ) const
inlinevirtualinherited
Returns
The current instance count.

Definition at line 118 of file instance.hpp.

◆ getType()

Tokens_t SoftwareAndServices::Library::iCalendar::BaseValueType::getType ( ) const
inherited

Get the type of data being stored.

If it returns Unknown_t, call getXType()

Returns
The type of data being stored.
See also
getXValueType()

◆ getXValueType()

const char* SoftwareAndServices::Library::iCalendar::BaseValueType::getXValueType ( ) const
inherited

Get the type of data being stored.

If it returns NULL, call getType()

Returns
The type of data being stored as a string.
See also
geXValueType()

◆ incInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< BaseValueType >::incInstance ( ) const
inlinevirtualinherited

Increment the instance.

Returns
The instance value, after incrementing it.

Reimplemented in SoftwareAndServices::Library::iCalendar::date_time.

Definition at line 109 of file instance.hpp.

◆ operator delete()

void SoftwareAndServices::Library::iCalendar::BaseValueType::operator delete ( void *  data)
inherited

This class uses instance counting, this entry point overloads the default delete() operator in order to correctly track the instance.

◆ parse() [1/2]

bool SoftwareAndServices::Library::iCalendar::dur_value::parse ( Parse in,
component errors 
)

#Parse a duration value (dur_value) object.

Parameters
inAn open Parse object.
errorsWhere to store any errors.
Returns
TRUE when successful.FALSE when the results would exceed the maximum (or minimum) time supported by this implementation.

◆ parse() [2/2]

bool SoftwareAndServices::Library::iCalendar::dur_value::parse ( const char *  in,
component errors 
)

#Parse a duration value (dur_value) object.

Parameters
inA string pointing to a duration value.
errorsWhere to store any errors.
Returns
TRUE when successful.FALSE when the results would exceed the maximum (or minimum) time supported by this implementation.

◆ removeQuotes()

static char* SoftwareAndServices::Library::iCalendar::BaseValueType::removeQuotes ( const char *  text)
staticinherited

Remove quotes from a user supplied value so that the raw data can be stored.

Caller MUST free results.

Parameters
textThe text to be de-quoted. No harm if it does not already contain quotes.
Returns
The de-quoted data.

◆ setData()

void SoftwareAndServices::Library::iCalendar::BaseValueType::setData ( void *  DataPtr)
inherited

Set the data to the data being stored.

Parameters
DataPtrPointer to the data.

◆ setPlus()

void SoftwareAndServices::Library::iCalendar::dur_value::setPlus ( bool  isPlus)

Set (or unset) a flag indicating if this is a positive or negative duration of time.

Parameters
isPlusWhen TRUE, it is a positive duration.

◆ setType()

void SoftwareAndServices::Library::iCalendar::BaseValueType::setType ( Tokens_t  Token)
inherited

Set the type of data being stored.

If the type is not a predefined one, call setXValueType()

Parameters
TokenThe type of data being stored.
See also
setXValueType()

◆ setXValueType()

void SoftwareAndServices::Library::iCalendar::BaseValueType::setXValueType ( const char *  xValType)
inherited

Set the type of data being stored - non-standard types only.

If the type is a predefined one, call setValueType()

Parameters
xValTypeThe type of data being stored as a string.
See also
setValueType()

◆ sprint()

virtual bool SoftwareAndServices::Library::iCalendar::dur_value::sprint ( String Results) const
virtual

Print the object in RFC-iCalendar format.

Parameters
ResultsAppend the results to Results.
Returns
TRUE when data was appended.

Implements SoftwareAndServices::Library::iCalendar::BaseValueType.

◆ sprintTokensAsText()

static bool SoftwareAndServices::Library::iCalendar::BaseValueType::sprintTokensAsText ( String Results,
Tokens_t  token 
)
staticinherited

Called by text2token() to get the token name as a String.

Parameters
ResultsThe token name as a String.
tokenThe token to convert to a string.
Returns
TRUE when something appended to Results.

◆ unescape()

static char* SoftwareAndServices::Library::iCalendar::BaseValueType::unescape ( const char *  text,
const char *  term 
)
staticinherited

Un-escape a value and return what a user originally entered.

Caller MUST delete results when done. The string would have been encoded as an RFC-iCalendar value encoding.

Parameters
textthe text to un-escape.
termA string to be used as the data separator. This value is passed to strpbrk().
Returns
The un-escaped string.

Member Data Documentation

◆ secondsPerDay

const time_t SoftwareAndServices::Library::iCalendar::dur_value::secondsPerDay
static

The number of seconds per day.

Definition at line 260 of file dur_value.hpp.

◆ secondsPerHour

const time_t SoftwareAndServices::Library::iCalendar::dur_value::secondsPerHour
static

The number of seconds per hour.

Definition at line 255 of file dur_value.hpp.

◆ secondsPerWeek

const time_t SoftwareAndServices::Library::iCalendar::dur_value::secondsPerWeek
static

The number of seconds per week.

Definition at line 265 of file dur_value.hpp.

◆ tokenStrings

const char** SoftwareAndServices::Library::iCalendar::BaseValueType::tokenStrings
staticinherited

A list of strings for the names of tokens.

The token value used as an offset into this array is the name of the token as a string.

The strings "X_COMP", "X_PROP", and "XPARAM" ARE included. Strings matching X_COMP, X_PROP, and XPARAM values are not included.

Definition at line 144 of file BaseValueType.hpp.


The documentation for this class was generated from the following file: