BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlt::PackedCalendar Class Reference

#include <bdlt_packedcalendar.h>

Public Types

typedef WeekendDaysTransitionPrivate WeekendDaysTransition
 
typedef PackedCalendar_BusinessDayConstIterator BusinessDayConstIterator
 
typedef PackedCalendar_HolidayConstIterator HolidayConstIterator
 
typedef PackedCalendar_HolidayCodeConstIterator HolidayCodeConstIterator
 
typedef bdlt::CalendarReverseIteratorAdapter< BusinessDayConstIteratorBusinessDayConstReverseIterator
 
typedef bdlt::CalendarReverseIteratorAdapter< HolidayConstIteratorHolidayConstReverseIterator
 
typedef bdlt::CalendarReverseIteratorAdapter< HolidayCodeConstIteratorHolidayCodeConstReverseIterator
 
typedef WeekendDaysTransitionSequence::const_iterator WeekendDaysTransitionConstIterator
 
typedef bsl::reverse_iterator< WeekendDaysTransitionSequence::const_iteratorWeekendDaysTransitionConstReverseIterator
 

Public Member Functions

 PackedCalendar (bslma::Allocator *basicAllocator=0)
 
 PackedCalendar (const Date &firstDate, const Date &lastDate, bslma::Allocator *basicAllocator=0)
 
 PackedCalendar (const PackedCalendar &original, bslma::Allocator *basicAllocator=0)
 
 ~PackedCalendar ()
 Destroy this object.
 
PackedCalendaroperator= (const PackedCalendar &rhs)
 
void addDay (const Date &date)
 
void addHoliday (const Date &date)
 
void addHolidayCode (const Date &date, int holidayCode)
 
int addHolidayCodeIfInRange (const Date &date, int holidayCode)
 
int addHolidayIfInRange (const Date &date)
 
void addWeekendDay (DayOfWeek::Enum weekendDay)
 
void addWeekendDays (const DayOfWeekSet &weekendDays)
 
void addWeekendDaysTransition (const Date &startDate, const DayOfWeekSet &weekendDays)
 
void intersectBusinessDays (const PackedCalendar &other)
 
void intersectNonBusinessDays (const PackedCalendar &other)
 
void removeAll ()
 
void removeHoliday (const Date &date)
 
void removeHolidayCode (const Date &date, int holidayCode)
 
void reserveHolidayCapacity (int numHolidays)
 
void reserveHolidayCodeCapacity (int numHolidayCodes)
 
void setValidRange (const Date &firstDate, const Date &lastDate)
 
void unionBusinessDays (const PackedCalendar &other)
 
void unionNonBusinessDays (const PackedCalendar &other)
 
template<class STREAM >
STREAM & bdexStreamIn (STREAM &stream, int version)
 
void swap (PackedCalendar &other)
 
BusinessDayConstIterator beginBusinessDays () const
 
BusinessDayConstIterator beginBusinessDays (const Date &date) const
 
HolidayCodeConstIterator beginHolidayCodes (const Date &date) const
 
HolidayCodeConstIterator beginHolidayCodes (const HolidayConstIterator &iter) const
 
HolidayConstIterator beginHolidays () const
 
HolidayConstIterator beginHolidays (const Date &date) const
 
WeekendDaysTransitionConstIterator beginWeekendDaysTransitions () const
 
BusinessDayConstIterator endBusinessDays () const
 
BusinessDayConstIterator endBusinessDays (const Date &date) const
 
HolidayCodeConstIterator endHolidayCodes (const Date &date) const
 
HolidayCodeConstIterator endHolidayCodes (const HolidayConstIterator &iter) const
 
HolidayConstIterator endHolidays () const
 
HolidayConstIterator endHolidays (const Date &date) const
 
WeekendDaysTransitionConstIterator endWeekendDaysTransitions () const
 
const DatefirstDate () const
 
int getNextBusinessDay (Date *nextBusinessDay, const Date &date) const
 
int getNextBusinessDay (Date *nextBusinessDay, const Date &date, int nth) const
 
bdlt::Date holiday (int index) const
 
int holidayCode (const Date &date, int index) const
 
bool isBusinessDay (const Date &date) const
 
bool isHoliday (const Date &date) const
 
bool isInRange (const Date &date) const
 
bool isNonBusinessDay (const Date &date) const
 
bool isWeekendDay (const Date &date) const
 
bool isWeekendDay (DayOfWeek::Enum dayOfWeek) const
 
const DatelastDate () const
 
int length () const
 
int numBusinessDays () const
 
int numBusinessDays (const Date &beginDate, const Date &endDate) const
 
int numHolidayCodes (const Date &date) const
 
int numHolidayCodesTotal () const
 
int numHolidays () const
 
int numNonBusinessDays () const
 
int numWeekendDaysInRange () const
 
int numWeekendDaysTransitions () const
 
BusinessDayConstReverseIterator rbeginBusinessDays () const
 
BusinessDayConstReverseIterator rbeginBusinessDays (const Date &date) const
 
HolidayCodeConstReverseIterator rbeginHolidayCodes (const Date &date) const
 
HolidayCodeConstReverseIterator rbeginHolidayCodes (const HolidayConstIterator &iter) const
 
HolidayConstReverseIterator rbeginHolidays () const
 
HolidayConstReverseIterator rbeginHolidays (const Date &date) const
 
WeekendDaysTransitionConstReverseIterator rbeginWeekendDaysTransitions () const
 
BusinessDayConstReverseIterator rendBusinessDays () const
 
BusinessDayConstReverseIterator rendBusinessDays (const Date &date) const
 
HolidayCodeConstReverseIterator rendHolidayCodes (const Date &date) const
 
HolidayCodeConstReverseIterator rendHolidayCodes (const HolidayConstIterator &iter) const
 
HolidayConstReverseIterator rendHolidays () const
 
HolidayConstReverseIterator rendHolidays (const Date &date) const
 
WeekendDaysTransitionConstReverseIterator rendWeekendDaysTransitions () const
 
WeekendDaysTransition weekendDaysTransition (int index) const
 
bslma::Allocatorallocator () const
 Return the allocator used by this object to supply memory.
 
template<class STREAM >
STREAM & bdexStreamOut (STREAM &stream, int version) const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Static Public Member Functions

static int maxSupportedBdexVersion (int versionSelector)
 
static int maxSupportedBdexVersion ()
 

Friends

class PackedCalendar_BusinessDayConstIterator
 
bool operator== (const PackedCalendar &, const PackedCalendar &)
 
bool operator!= (const PackedCalendar &, const PackedCalendar &)
 
template<class HASHALG >
void hashAppend (HASHALG &hashAlg, const PackedCalendar &)
 

Detailed Description

This class implements a space-efficient, value-semantic repository of weekend and holiday information over a valid range of dates. This valid range, [firstDate() .. lastDate()], spans the first and last dates of a calendar's accessible contents. A calendar can be "populated" with weekend and holiday information via a suite of "add" methods. Any subset of days of the week may be specified as weekend (i.e., recurring non-business) days starting from a specified date by adding a weekend-days transition; holidays within the valid range are specified individually. When adding a holiday, an arbitrary integer "holiday code" may be associated with that date. Additional holiday codes for that date may subsequently be added. Both the holidays and the set of unique holiday codes associated with each holiday date are maintained (internally) in order of increasing value. Note that the behavior of requesting any calendar information for a supplied date whose value is outside the current valid range for that calendar (unless otherwise noted, e.g., isWeekendDay) is undefined.

See bdlt_packedcalendar

Member Typedef Documentation

◆ BusinessDayConstIterator

◆ BusinessDayConstReverseIterator

◆ HolidayCodeConstIterator

◆ HolidayCodeConstReverseIterator

◆ HolidayConstIterator

◆ HolidayConstReverseIterator

◆ WeekendDaysTransition

◆ WeekendDaysTransitionConstIterator

◆ WeekendDaysTransitionConstReverseIterator

Constructor & Destructor Documentation

◆ PackedCalendar() [1/3]

bdlt::PackedCalendar::PackedCalendar ( bslma::Allocator basicAllocator = 0)
explicit

Create an empty calendar, i.e., a calendar having an empty valid range. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ PackedCalendar() [2/3]

bdlt::PackedCalendar::PackedCalendar ( const Date firstDate,
const Date lastDate,
bslma::Allocator basicAllocator = 0 
)

Create a calendar having a valid range from the specified firstDate through the specified lastDate. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless firstDate <= lastDate.

◆ PackedCalendar() [3/3]

bdlt::PackedCalendar::PackedCalendar ( const PackedCalendar original,
bslma::Allocator basicAllocator = 0 
)

Create a calendar having the value of the specified original calendar. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~PackedCalendar()

bdlt::PackedCalendar::~PackedCalendar ( )

Member Function Documentation

◆ addDay()

void bdlt::PackedCalendar::addDay ( const Date date)

Extend the valid range (if necessary) of this calendar to include the specified date value.

◆ addHoliday()

void bdlt::PackedCalendar::addHoliday ( const Date date)

Mark the specified date as a holiday (i.e., a non-business day) in this calendar. Extend the valid range of this calendar if necessary. If date is already marked as a holiday, this method has no effect. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ addHolidayCode()

void bdlt::PackedCalendar::addHolidayCode ( const Date date,
int  holidayCode 
)

Mark the specified date as a holiday (i.e., a non-business day) in this calendar and add the specified holidayCode (if not already present) to the ordered set of codes associated with date. Extend the valid range of this calendar if necessary. If holidayCode is already a code for date, this method has no effect. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ addHolidayCodeIfInRange()

int bdlt::PackedCalendar::addHolidayCodeIfInRange ( const Date date,
int  holidayCode 
)
inline

Mark the specified date as a holiday (i.e., a non-business day) in this calendar and add the specified holidayCode (if not already present) to the set of codes associated with date, if date is within the valid range of this calendar. Return 0 if date is in range, and a non-zero value otherwise. If holidayCode is already a code for date, or if date is not in the valid range, this method has no effect. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. Note that this method may be called repeatedly with the same value for date to build up a set of holiday codes for that date.

◆ addHolidayIfInRange()

int bdlt::PackedCalendar::addHolidayIfInRange ( const Date date)
inline

Mark the specified date as a holiday (i.e., a non-business day) in this calendar if date is within the valid range. Return 0 if date is in range, and a non-zero value otherwise. This method has no effect if date is already marked as a holiday or is not in the valid range. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ addWeekendDay()

void bdlt::PackedCalendar::addWeekendDay ( DayOfWeek::Enum  weekendDay)

Add the specified weekendDay to the set of weekend days associated with the weekend-days transition at January 1, 0001 maintained by this calendar. Create a transition at January 1, 0001 if one does not exist. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. The behavior is undefined unless no weekend-days transitions were added to this calendar via the addWeekendDaysTransition method.

◆ addWeekendDays()

void bdlt::PackedCalendar::addWeekendDays ( const DayOfWeekSet weekendDays)

Add the specified weekendDays to the set of weekend days associated with the weekend-days transition at January 1, 0001 maintained by this calendar. Create a transition at January 1, 0001 if one does not exist. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. The behavior is undefined unless no weekend-days transitions were added to this calendar via the addWeekendDaysTransition method.

◆ addWeekendDaysTransition()

void bdlt::PackedCalendar::addWeekendDaysTransition ( const Date startDate,
const DayOfWeekSet weekendDays 
)

Add to this calendar a weekend-days transition on the specified startDate having the specified weekendDays set. If a weekend-days transition already exists on startDate, replace the set of weekend days of that transition with weekendDays. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. Note that this method does not extend the valid range of the calendar.

◆ allocator()

bslma::Allocator * bdlt::PackedCalendar::allocator ( ) const
inline

◆ bdexStreamIn()

template<class STREAM >
STREAM & bdlt::PackedCalendar::bdexStreamIn ( STREAM &  stream,
int  version 
)

Assign to this object the value read from the specified input stream using the specified version format and return a reference to the modifiable stream. If stream is initially invalid, this operation has no effect. If stream becomes invalid during this operation or if version is not supported, this object is unaltered. Note that no version is read from stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ bdexStreamOut()

template<class STREAM >
STREAM & bdlt::PackedCalendar::bdexStreamOut ( STREAM &  stream,
int  version 
) const

Write this value to the specified output stream using the specified version format and return a reference to the modifiable stream. If version is not supported, stream is unmodified. Note that version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ beginBusinessDays() [1/2]

PackedCalendar::BusinessDayConstIterator bdlt::PackedCalendar::beginBusinessDays ( ) const
inline

Return an iterator providing non-modifiable access to the first business day in this calendar. If this calendar has no valid business days, the returned iterator has the same value as that returned by endBusinessDays().

◆ beginBusinessDays() [2/2]

PackedCalendar::BusinessDayConstIterator bdlt::PackedCalendar::beginBusinessDays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first business day that occurs on or after the specified date in this calendar. If this calendar has no such business day, the returned iterator has the same value as that returned by endBusinessDays(date). The behavior is undefined unless date is within the valid range of this calendar.

◆ beginHolidayCodes() [1/2]

HolidayCodeConstIterator bdlt::PackedCalendar::beginHolidayCodes ( const Date date) const

Return an iterator providing non-modifiable access to the first holiday code for the specified date in this calendar. If there is no holiday code associated with date, the returned iterator has the same value as that returned by endHolidayCodes(date). The behavior is undefined unless date is marked as a holiday in this calendar.

◆ beginHolidayCodes() [2/2]

PackedCalendar::HolidayCodeConstIterator bdlt::PackedCalendar::beginHolidayCodes ( const HolidayConstIterator iter) const
inline

Return an iterator providing non-modifiable access to the first holiday code for the holiday referenced by the specified iter. If there is no holiday code associated with the date referenced by iter, the returned iterator has the same value as that returned by endHolidayCodes(iter). The behavior is undefined unless iter refers to a valid holiday of this calendar.

◆ beginHolidays() [1/2]

PackedCalendar::HolidayConstIterator bdlt::PackedCalendar::beginHolidays ( ) const
inline

Return an iterator providing non-modifiable access to the first holiday in this calendar. If this calendar has no holidays, the returned iterator has the same value as that returned by endHolidays().

◆ beginHolidays() [2/2]

PackedCalendar::HolidayConstIterator bdlt::PackedCalendar::beginHolidays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first holiday that occurs on or after the specified date in this calendar. If this calendar has no such holiday, the returned iterator has the same value as that returned by endHolidays(date). The behavior is undefined unless date is within the valid range of this calendar.

◆ beginWeekendDaysTransitions()

PackedCalendar::WeekendDaysTransitionConstIterator bdlt::PackedCalendar::beginWeekendDaysTransitions ( ) const
inline

Return an iterator providing non-modifiable access to the first weekend-days transition in the chronological sequence of weekend-days transitions maintained by this calendar. If this calendar has no weekend-days transitions, the returned iterator has the same value as that returned by endWeekendDaysTransitions().

◆ endBusinessDays() [1/2]

PackedCalendar::BusinessDayConstIterator bdlt::PackedCalendar::endBusinessDays ( ) const
inline

Return an iterator providing non-modifiable access to the past-the-end business day in this calendar.

◆ endBusinessDays() [2/2]

PackedCalendar::BusinessDayConstIterator bdlt::PackedCalendar::endBusinessDays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first business day that occurs after the specified date in this calendar. If this calendar has no such business day, the returned iterator has the same value as that returned by endBusinessDays(). The behavior is undefined unless date is within the valid range of this calendar.

◆ endHolidayCodes() [1/2]

HolidayCodeConstIterator bdlt::PackedCalendar::endHolidayCodes ( const Date date) const

Return an iterator providing non-modifiable access to the past-the-end holiday code associated with the specified date. The behavior is undefined unless date is marked as a holiday in this calendar.

◆ endHolidayCodes() [2/2]

PackedCalendar::HolidayCodeConstIterator bdlt::PackedCalendar::endHolidayCodes ( const HolidayConstIterator iter) const
inline

Return an iterator providing non-modifiable access to the past-the-end holiday code associated with the date referenced by the specified iter. The behavior is undefined unless iter references a valid holiday in this calendar.

◆ endHolidays() [1/2]

PackedCalendar::HolidayConstIterator bdlt::PackedCalendar::endHolidays ( ) const
inline

Return an iterator providing non-modifiable access to the past-the-end holiday in the chronological sequence of holidays maintained by this calendar.

◆ endHolidays() [2/2]

PackedCalendar::HolidayConstIterator bdlt::PackedCalendar::endHolidays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first holiday that occurs after the specified date in this calendar. If this calendar has no such holiday, the returned iterator has the same value as that returned by endHolidays(). The behavior is undefined unless date is within the valid range of this calendar.

◆ endWeekendDaysTransitions()

PackedCalendar::WeekendDaysTransitionConstIterator bdlt::PackedCalendar::endWeekendDaysTransitions ( ) const
inline

Return an iterator providing non-modifiable access to the past-the-end weekend-days transition in the chronological sequence of weekend-days transitions maintained by this calendar.

◆ firstDate()

const Date & bdlt::PackedCalendar::firstDate ( ) const
inline

Return a reference providing non-modifiable access to the earliest date in the valid range of this calendar. The behavior is undefined unless this calendar is non-empty – i.e., unless 1 <= length().

◆ getNextBusinessDay() [1/2]

int bdlt::PackedCalendar::getNextBusinessDay ( Date nextBusinessDay,
const Date date 
) const
inline

Load, into the specified nextBusinessDay, the date of the first business day in this calendar following the specified date. Return 0 on success – i.e., if such a business day exists, and a non-zero value (with no effect on nextBusinessDay) otherwise. The behavior is undefined unless date + 1 is both a valid bdlt::Date and within the valid range of this calendar.

◆ getNextBusinessDay() [2/2]

int bdlt::PackedCalendar::getNextBusinessDay ( Date nextBusinessDay,
const Date date,
int  nth 
) const

Load, into the specified nextBusinessDay, the date of the specified nth business day in this calendar following the specified date. Return 0 on success – i.e., if such a business day exists, and a non-zero value (with no effect on nextBusinessDay) otherwise. The behavior is undefined unless date + 1 is both a valid bdlt::Date and within the valid range of this calendar, and 0 < nth.

◆ holiday()

bdlt::Date bdlt::PackedCalendar::holiday ( int  index) const
inline

Return the holiday at the specified index in this calendar. For all index values from 0 to numHolidays() - 1 (inclusive), a unique holiday is returned. The mapping of index to holiday is invalidated when the set of holidays is modified by an invocation of addHoliday, addHolidayIfInRange, intersectBusinessDays, intersectNonBusinessDays, removeAll, removeHoliday, setValidRange, unionBusinessDays, or unionNonBusinessDays. The behavior is undefined unless 0 <= index < numHolidays().

◆ holidayCode()

int bdlt::PackedCalendar::holidayCode ( const Date date,
int  index 
) const
inline

Return, for the holiday at the specified date in this calendar, the holiday code at the specified index. For all index values from 0 to numHolidayCodes(date) - 1 (inclusive), a unique holiday code is returned. The mapping of index to holiday code is invalidated when the set of holidays or holiday codes is modified by an invocation of addHoliday, addHolidayCode, addHolidayCodeIfInRange, addHolidayIfInRange, intersectBusinessDays, intersectNonBusinessDays, removeAll, removeHoliday, removeHolidayCode, setValidRange, unionBusinessDays, or unionNonBusinessDays. The behavior is undefined unless date is a holiday in this calendar and 0 <= index < numHolidayCodes(date). Note that this method facilitates testing and generally should not be used by clients; in particular, using this method to iterate over the holiday codes for date is less efficient than using a HolidayCodeConstIterator.

◆ intersectBusinessDays()

void bdlt::PackedCalendar::intersectBusinessDays ( const PackedCalendar other)

Merge the specified other calendar into this calendar such that the valid range of this calendar becomes the intersection of the two calendars' ranges, and the weekend days and holidays for this calendar become the union of those (non-business) days from the two calendars – i.e., the valid business days of this calendar become the intersection of those of the two original calendar values over the intersection of their ranges. For each holiday that remains, the resulting holiday codes in this calendar will be the union of the corresponding original holiday codes. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ intersectNonBusinessDays()

void bdlt::PackedCalendar::intersectNonBusinessDays ( const PackedCalendar other)

Merge the specified other calendar into this calendar such that the valid range of this calendar becomes the intersection of the two calendars' ranges, the weekend days for this calendar become the intersection of those days from the two calendars, and the holidays for this calendar become the set of days that are a holiday in one of the calendars and a non-business day in the other calendar – i.e., the valid business days of this calendar become the union of those of the two original calendars over the intersection of their ranges. For each holiday that remains, the resulting holiday codes in this calendar will be the union of the corresponding original holiday codes. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ isBusinessDay()

bool bdlt::PackedCalendar::isBusinessDay ( const Date date) const
inline

Return true if the specified date is a business day (i.e., not a holiday or weekend day) in this calendar, and false otherwise. The behavior is undefined unless date is within the valid range of this calendar.

◆ isHoliday()

bool bdlt::PackedCalendar::isHoliday ( const Date date) const
inline

Return true if the specified date is a holiday in this calendar, and false otherwise. The behavior is undefined unless date is within the valid range of this calendar.

◆ isInRange()

bool bdlt::PackedCalendar::isInRange ( const Date date) const
inline

Return true if the specified date is within the valid range of this calendar (i.e., firstDate() <= date <= lastDate()), and false otherwise. Note that the valid range for a PackedCalendar is empty if its length is 0.

◆ isNonBusinessDay()

bool bdlt::PackedCalendar::isNonBusinessDay ( const Date date) const
inline

Return true if the specified date is not a business day (i.e., is either a holiday or weekend day) in this calendar, and false otherwise. The behavior is undefined unless date is within the valid range of this calendar. Note that:

bool isBusinessDay(const Date &date) const
Definition bdlt_packedcalendar.h:2980

returns the same result.

◆ isWeekendDay() [1/2]

bool bdlt::PackedCalendar::isWeekendDay ( const Date date) const

Return true if the specified date falls on a day of the week that is considered a weekend day in this calendar, and false otherwise. Note that this method is defined for all date values, not just those that fall within the valid range, and may be invoked even on an empty calendar (i.e., having 0 == length()).

◆ isWeekendDay() [2/2]

bool bdlt::PackedCalendar::isWeekendDay ( DayOfWeek::Enum  dayOfWeek) const
inline

Return true if the specified dayOfWeek is a weekend day in this calendar, and false otherwise. The behavior is undefined unless no weekend-days transitions were added to this calendar via the addWeekendDaysTransition method.

◆ lastDate()

const Date & bdlt::PackedCalendar::lastDate ( ) const
inline

Return a reference providing non-modifiable access to the latest date in the valid range of this calendar. The behavior is undefined unless this calendar is non-empty – i.e., unless 1 <= length().

◆ length()

int bdlt::PackedCalendar::length ( ) const
inline

Return the number of days in the valid range of this calendar, which is defined to be 0 if this calendar is empty, and lastDate() - firstDate() + 1 otherwise.

◆ maxSupportedBdexVersion() [1/2]

int bdlt::PackedCalendar::maxSupportedBdexVersion ( )
inlinestatic
Deprecated:
Use maxSupportedBdexVersion(int) instead.

Return the most current BDEX streaming version number supported by this class.

◆ maxSupportedBdexVersion() [2/2]

int bdlt::PackedCalendar::maxSupportedBdexVersion ( int  versionSelector)
inlinestatic

Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method. Note that it is highly recommended that versionSelector be formatted as "YYYYMMDD", a date representation. Also note that versionSelector should be a compile-time-chosen value that selects a format version supported by both externalizer and unexternalizer. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ numBusinessDays() [1/2]

int bdlt::PackedCalendar::numBusinessDays ( ) const
inline

Return the number of days in the valid range of this calendar that are considered business days – i.e., are neither holidays nor weekend days. Note that numBusinessDays() == length() - numNonBusinessDays().

◆ numBusinessDays() [2/2]

int bdlt::PackedCalendar::numBusinessDays ( const Date beginDate,
const Date endDate 
) const

Return the number of days in the specified range [beginDate .. endDate] of this calendar that are considered business days – i.e., are neither holidays nor weekend days. The behavior is undefined unless beginDate and endDate are within the valid range of this calendar, and beginDate <= endDate.

◆ numHolidayCodes()

int bdlt::PackedCalendar::numHolidayCodes ( const Date date) const

Return the number of (unique) holiday codes associated with the specified date in this calendar if date is a holiday in this calendar, and 0 otherwise. The behavior is undefined unless date is within the valid range of this calendar.

◆ numHolidayCodesTotal()

int bdlt::PackedCalendar::numHolidayCodesTotal ( ) const
inline

Return the total number of holiday codes for all holidays in this calendar. Note that this function is used primarily in conjunction with reserveHolidayCodeCapacity.

◆ numHolidays()

int bdlt::PackedCalendar::numHolidays ( ) const
inline

Return the number of days in the valid range of this calendar that are individually marked as holidays, irrespective of whether or not the date is also considered a weekend day.

◆ numNonBusinessDays()

int bdlt::PackedCalendar::numNonBusinessDays ( ) const

Return the number of days in the valid range of this calendar that are not considered business days – i.e., are either holidays, weekend days, or both. Note that numNonBusinessDays() == length() - numBusinessDays().

◆ numWeekendDaysInRange()

int bdlt::PackedCalendar::numWeekendDaysInRange ( ) const

Return the number of days in the valid range of this calendar that are considered weekend days, irrespective of any designated holidays.

◆ numWeekendDaysTransitions()

int bdlt::PackedCalendar::numWeekendDaysTransitions ( ) const
inline

Return the number of weekend-days transitions maintained by this calendar.

◆ operator=()

PackedCalendar & bdlt::PackedCalendar::operator= ( const PackedCalendar rhs)

Assign to this calendar the value of the specified rhs calendar, and return a reference providing modifiable access to this calendar. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ print()

bsl::ostream & bdlt::PackedCalendar::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ rbeginBusinessDays() [1/2]

PackedCalendar::BusinessDayConstReverseIterator bdlt::PackedCalendar::rbeginBusinessDays ( ) const
inline

Return an iterator providing non-modifiable access to the last business day in this calendar. If this calendar has no valid business days, the returned iterator has the same value as that returned by rendBusinessDays().

◆ rbeginBusinessDays() [2/2]

PackedCalendar::BusinessDayConstReverseIterator bdlt::PackedCalendar::rbeginBusinessDays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first business day that occurs on or before the specified date in this calendar. If this calendar has no such business day, the returned iterator has the same value as that returned by rendBusinessDays(date). The behavior is undefined unless date is within the valid range of this calendar.

◆ rbeginHolidayCodes() [1/2]

PackedCalendar::HolidayCodeConstReverseIterator bdlt::PackedCalendar::rbeginHolidayCodes ( const Date date) const
inline

Return an iterator providing non-modifiable access to the last holiday code associated with the specified date in this calendar. If there are no holiday codes associated with date, the returned iterator has the same value as that returned by rendHolidayCodes(date). The behavior is undefined unless date is marked as a holiday in this calendar.

◆ rbeginHolidayCodes() [2/2]

PackedCalendar::HolidayCodeConstReverseIterator bdlt::PackedCalendar::rbeginHolidayCodes ( const HolidayConstIterator iter) const
inline

Return an iterator providing non-modifiable access to the last holiday code associated with the holiday referenced by the specified iter. If there are no holiday codes associated with the date referenced by iter, the returned iterator has the same value as that returned by rendHolidayCodes(iter). The behavior is undefined unless iter refers to a valid holiday of this calendar.

◆ rbeginHolidays() [1/2]

PackedCalendar::HolidayConstReverseIterator bdlt::PackedCalendar::rbeginHolidays ( ) const
inline

Return an iterator providing non-modifiable access to the last holiday in this calendar. If this calendar has no holidays, the returned iterator has the same value as that returned by rendHolidays().

◆ rbeginHolidays() [2/2]

PackedCalendar::HolidayConstReverseIterator bdlt::PackedCalendar::rbeginHolidays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first holiday that occurs on or before the specified date in this calendar. If this calendar has no such holiday, the returned iterator has the same value as that returned by rendHolidays(date). The behavior is undefined unless date is within the valid range of this calendar.

◆ rbeginWeekendDaysTransitions()

PackedCalendar::WeekendDaysTransitionConstReverseIterator bdlt::PackedCalendar::rbeginWeekendDaysTransitions ( ) const
inline

Return an iterator providing non-modifiable access to the last weekend-days transition in the chronological sequence of weekend-days transitions maintained by this calendar. If this calendar has no weekend-days transitions, the returned iterator has the same value as that returned by rendWeekendDaysTransitions().

◆ removeAll()

void bdlt::PackedCalendar::removeAll ( )

Remove all information from this calendar, leaving it with its default constructed "empty" value. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ removeHoliday()

void bdlt::PackedCalendar::removeHoliday ( const Date date)

Remove from this calendar the holiday having the specified date if such a holiday exists. This operation has no effect if date is not a holiday in this calendar. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. Note that this method is defined for all date values, not just those that fall within the valid range, and may be invoked even on an empty calendar (i.e., having 0 == length()).

◆ removeHolidayCode()

void bdlt::PackedCalendar::removeHolidayCode ( const Date date,
int  holidayCode 
)

Remove from this calendar the specified holidayCode for the holiday having the specified date if such a holiday having holidayCode exists. This operation has no effect if date is not a holiday in this calendar, or if the holiday at date does not have holidayCode associated with it. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. Note that this method is defined for all date values, not just those that fall within the valid range, and may be invoked even on an empty calendar (i.e., having 0 == length()).

◆ rendBusinessDays() [1/2]

PackedCalendar::BusinessDayConstReverseIterator bdlt::PackedCalendar::rendBusinessDays ( ) const
inline

Return an iterator providing non-modifiable access to the element one before the first business day in this calendar.

◆ rendBusinessDays() [2/2]

PackedCalendar::BusinessDayConstReverseIterator bdlt::PackedCalendar::rendBusinessDays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first business day that occurs before the specified date in this calendar. If this calendar has no such business day, the returned iterator has the same value as that returned by rendBusinessDays(). The behavior is undefined unless date is within the valid range of this calendar.

◆ rendHolidayCodes() [1/2]

PackedCalendar::HolidayCodeConstReverseIterator bdlt::PackedCalendar::rendHolidayCodes ( const Date date) const
inline

Return an iterator providing non-modifiable access to the element one before the first holiday code associated with the specified date. The behavior is undefined unless date is marked as a holiday in this calendar.

◆ rendHolidayCodes() [2/2]

PackedCalendar::HolidayCodeConstReverseIterator bdlt::PackedCalendar::rendHolidayCodes ( const HolidayConstIterator iter) const
inline

Return an iterator providing non-modifiable access to the element one before the first holiday code associated with the holiday referenced by the specified iter. The behavior is undefined unless iter references a valid holiday in this calendar.

◆ rendHolidays() [1/2]

PackedCalendar::HolidayConstReverseIterator bdlt::PackedCalendar::rendHolidays ( ) const
inline

Return an iterator providing non-modifiable access to the element one before the first holiday in this calendar.

◆ rendHolidays() [2/2]

PackedCalendar::HolidayConstReverseIterator bdlt::PackedCalendar::rendHolidays ( const Date date) const
inline

Return an iterator providing non-modifiable access to the first holiday that occurs before the specified date in this calendar. If this calendar has no such holiday, the returned iterator has the same value as that returned by rendHolidays(). The behavior is undefined unless date is within the valid range of this calendar.

◆ rendWeekendDaysTransitions()

PackedCalendar::WeekendDaysTransitionConstReverseIterator bdlt::PackedCalendar::rendWeekendDaysTransitions ( ) const
inline

Return an iterator providing non-modifiable access to the element one before the first weekend-days transition in the chronological sequence of weekend-days transitions maintained by this calendar.

◆ reserveHolidayCapacity()

void bdlt::PackedCalendar::reserveHolidayCapacity ( int  numHolidays)
inline

Reserve enough space to store at least the specified numHolidays within this calendar. This method has no effect if numHolidays <= numHolidays().

◆ reserveHolidayCodeCapacity()

void bdlt::PackedCalendar::reserveHolidayCodeCapacity ( int  numHolidayCodes)
inline

Reserve enough space to store at least the specified numHolidayCodes within this calendar assuming no additional holidays are added to this calendar. This method has no effect if numHolidayCodes <= numHolidayCodesTotal().

◆ setValidRange()

void bdlt::PackedCalendar::setValidRange ( const Date firstDate,
const Date lastDate 
)

Set the range of this calendar using the specified firstDate and lastDate as, respectively, the first date and the last date of the calendar. Any holiday that is outside the new range and its holiday codes are removed. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method. The behavior is undefined unless firstDate <= lastDate.

◆ swap()

void bdlt::PackedCalendar::swap ( PackedCalendar other)

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless this object was created with the same allocator as other.

◆ unionBusinessDays()

void bdlt::PackedCalendar::unionBusinessDays ( const PackedCalendar other)

Merge the specified other calendar into this calendar such that the valid range of this calendar becomes the union of the two calendars' ranges (or the minimal continuous range spanning the two ranges, if the ranges are non-overlapping), the weekend days for this calendar become the intersection of those days from the two calendars, and the holidays for this calendar become the set of days that are a holiday in one of the calendars and a non-business day in the other calendar – i.e., the valid business days of this calendar become the union of those of the two original calendar values. For each holiday that remains, the resulting holiday codes in this calendar will be the union of the corresponding original holiday codes. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ unionNonBusinessDays()

void bdlt::PackedCalendar::unionNonBusinessDays ( const PackedCalendar other)

Merge the specified other calendar into this calendar such that the valid range of this calendar becomes the union of the two calendars' ranges (or the minimal continuous range spanning the two ranges, if the ranges are non-overlapping), and the weekend days and holidays for this calendar become the union of those (non-business) days from the two calendars – i.e., the valid business days of this calendar become the intersection of those of the two calendars after each range is extended to cover the resulting one. For each holiday in either calendar, the resulting holiday codes in this calendar will be the union of the corresponding original holiday codes. See {Iterator Invalidation} for information regarding which iterators are affected by the use of this method.

◆ weekendDaysTransition()

PackedCalendar::WeekendDaysTransition bdlt::PackedCalendar::weekendDaysTransition ( int  index) const
inline

Return the weekend-days transition at the specified index in this calendar. For all index values from 0 to numWeekendDaysTransitions() - 1 (inclusive), a unique weekend-days transition is returned. The mapping of index to weekend-days transition is invalidated when the set of weekend-days transitions is modified by an invocation of addWeekendDay, addWeekendDays, addWeekendDaysTransition, intersectBusinessDays, intersectNonBusinessDays, removeAll, unionBusinessDays, or unionNonBusinessDays. The behavior is undefined unless 0 <= index < numWeekendDaysTransitions().

Friends And Related Symbol Documentation

◆ hashAppend

template<class HASHALG >
void hashAppend ( HASHALG &  hashAlg,
const PackedCalendar  
)
friend

Pass the specified object to the specified hashAlg. This function integrates with the bslh modular hashing system and effectively provides a bsl::hash specialization for PackedCalendar.

◆ operator!=

bool operator!= ( const PackedCalendar ,
const PackedCalendar  
)
friend

Return true if the specified lhs and rhs calendars do not have the same value, and false otherwise. Two calendars do not have the same value if they do not have the same valid range (and are not both empty), do not have the same weekend days, do not have the same holidays, or, for at least one corresponding pair of holidays, do not have the same (ordered) set of associated holiday codes.

◆ operator==

bool operator== ( const PackedCalendar ,
const PackedCalendar  
)
friend

Return true if the specified lhs and rhs calendars have the same value, and false otherwise. Two calendars have the same value if they have the same valid range (or are both empty), the same weekend days, the same holidays, and each corresponding pair of holidays has the same (ordered) set of associated holiday codes.

◆ PackedCalendar_BusinessDayConstIterator


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