8#ifndef INCLUDED_BDLT_CALENDAR
9#define INCLUDED_BDLT_CALENDAR
516#include <bdlscm_version.h>
539#include <bsl_iosfwd.h>
540#include <bsl_iterator.h>
545class Calendar_BusinessDayConstIter;
584 template <
class HASHALG>
595 void synchronizeCache();
602 bool isCacheSynchronized()
const;
874 template <
class STREAM>
1249 template <
class STREAM>
1262 bsl::ostream&
print(bsl::ostream& stream,
1264 int spacesPerLevel = 4)
const;
1266#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1278#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1327template <
class HASHALG>
1353 int d_currentOffset;
1379 const Date& firstDateOfCalendar,
1380 const Date& startDate,
1620template <
class STREAM>
1630 d_packedCalendar.
swap(inCal);
1680 return d_packedCalendar.beginHolidayCodes(date);
1687 return d_packedCalendar.beginHolidayCodes(iter);
1742 return d_packedCalendar.endHolidayCodes(date);
1749 return d_packedCalendar.endHolidayCodes(iter);
1786 enum { e_SUCCESS = 0, e_FAILURE = 1 };
1788 int offset =
static_cast<int>(
1791 *nextBusinessDay =
firstDate() + offset;
1802 return d_packedCalendar.
holiday(index);
1820 return d_packedCalendar.
isHoliday(date);
1826 return d_packedCalendar.
isInRange(date);
1836 return d_nonBusinessDays[date -
firstDate()];
1854 return d_packedCalendar.
lastDate();
1860 return static_cast<int>(d_nonBusinessDays.
length());
1866 return static_cast<int>(d_nonBusinessDays.
num0());
1878 return static_cast<int>(d_nonBusinessDays.
num0(beginDate -
firstDate(),
1903 return static_cast<int>(d_nonBusinessDays.
num1());
1921 return d_packedCalendar;
2037template <
class STREAM>
2049 int spacesPerLevel)
const
2051 return d_packedCalendar.
print(stream, level, spacesPerLevel);
2054#ifndef BDE_OMIT_INTERNAL_DEPRECATED
2071 return lhs.d_packedCalendar == rhs.d_packedCalendar;
2077 return lhs.d_packedCalendar != rhs.d_packedCalendar;
2081bsl::ostream&
bdlt::operator<<(bsl::ostream& stream,
const Calendar& calendar)
2083 calendar.print(stream, 0, -1);
2088template <
class HASHALG>
2092 using ::BloombergLP::bslh::hashAppend;
2093 hashAppend(hashAlg,
object.d_packedCalendar);
2104Calendar_BusinessDayConstIter::Calendar_BusinessDayConstIter(
2106: d_nonBusinessDays_p(original.d_nonBusinessDays_p)
2107, d_firstDate(original.d_firstDate)
2108, d_currentOffset(original.d_currentOffset)
2122 d_nonBusinessDays_p = rhs.d_nonBusinessDays_p;
2123 d_firstDate = rhs.d_firstDate;
2124 d_currentOffset = rhs.d_currentOffset;
2133 d_currentOffset =
static_cast<int>(
2141 if (-1 == d_currentOffset) {
2142 d_currentOffset =
static_cast<int>(d_nonBusinessDays_p->
2143 find0AtMaxIndex(0, d_nonBusinessDays_p->
length()));
2146 d_currentOffset =
static_cast<int>(d_nonBusinessDays_p->
2147 find0AtMaxIndex(0, d_currentOffset));
2191 const Calendar_BusinessDayConstIter& rhs)
2195 return lhs.d_firstDate == rhs.d_firstDate
2196 && lhs.d_currentOffset == rhs.d_currentOffset;
2201 const Calendar_BusinessDayConstIter& rhs)
2205 return lhs.d_firstDate != rhs.d_firstDate
2206 || lhs.d_currentOffset != rhs.d_currentOffset;
Definition bdlc_bitarray.h:521
bsl::size_t num0(bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
Definition bdlc_bitarray.h:1821
bsl::size_t length() const
Return the number of bits in this array.
Definition bdlc_bitarray.h:1815
bsl::size_t num1(bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
Definition bdlc_bitarray.h:1833
void removeAll()
Definition bdlc_bitarray.h:1578
bsl::size_t find0AtMinIndex(bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
Definition bdlc_bitarray.h:1761
void assign0(bsl::size_t index)
Definition bdlc_bitarray.h:1413
void reserveCapacity(bsl::size_t numBits)
Definition bdlc_bitarray.h:1586
Definition bdlt_calendarreverseiteratoradapter.h:298
Definition bdlt_calendar.h:1343
friend bool operator==(const Calendar_BusinessDayConstIter &, const Calendar_BusinessDayConstIter &)
Date value_type
Definition bdlt_calendar.h:1385
int difference_type
Definition bdlt_calendar.h:1386
friend bool operator!=(const Calendar_BusinessDayConstIter &, const Calendar_BusinessDayConstIter &)
PackedCalendar_DateRef operator*() const
Definition bdlt_calendar.h:2175
PackedCalendar_DateProxy pointer
Definition bdlt_calendar.h:1387
PackedCalendar_DateRef reference
The star operator returns a PackedCalendar_DateRef by value.
Definition bdlt_calendar.h:1390
Calendar_BusinessDayConstIter & operator++()
Definition bdlt_calendar.h:2129
Calendar_BusinessDayConstIter & operator=(const Calendar_BusinessDayConstIter &rhs)
Definition bdlt_calendar.h:2119
PackedCalendar_DateProxy operator->() const
Definition bdlt_calendar.h:2181
bsl::bidirectional_iterator_tag iterator_category
Definition bdlt_calendar.h:1392
~Calendar_BusinessDayConstIter()
Destroy this object.
Definition bdlt_calendar.h:2113
Calendar_BusinessDayConstIter & operator--()
Definition bdlt_calendar.h:2139
Definition bdlt_calendar.h:569
int getNextBusinessDay(Date *nextBusinessDay, const Date &date, int nth) const
BusinessDayConstIterator endBusinessDays() const
Definition bdlt_calendar.h:1710
WeekendDaysTransitionConstIterator endWeekendDaysTransitions() const
Definition bdlt_calendar.h:1766
int numHolidayCodesTotal() const
Definition bdlt_calendar.h:1889
HolidayConstIterator beginHolidays() const
Definition bdlt_calendar.h:1691
PackedCalendar::WeekendDaysTransitionConstReverseIterator WeekendDaysTransitionConstReverseIterator
Definition bdlt_calendar.h:627
void removeHoliday(const Date &date)
Definition bdlt_calendar.h:1560
void unionBusinessDays(const Calendar &other)
Definition bdlt_calendar.h:1607
Calendar_BusinessDayConstIter BusinessDayConstIterator
Definition bdlt_calendar.h:606
int numNonBusinessDays() const
Definition bdlt_calendar.h:1901
static int maxSupportedBdexVersion()
Definition bdlt_calendar.h:2058
void unionNonBusinessDays(const Calendar &other)
Definition bdlt_calendar.h:1613
HolidayConstReverseIterator rendHolidays() const
Definition bdlt_calendar.h:2003
void addWeekendDay(DayOfWeek::Enum weekendDay)
Date getNextBusinessDay(const Date &initialDate) const
BusinessDayConstReverseIterator rendBusinessDays() const
Definition bdlt_calendar.h:1974
HolidayCodeConstReverseIterator rendHolidayCodes(const Date &date) const
Definition bdlt_calendar.h:1990
Date getNextBusinessDay(const Date &initialDate, int nth) const
PackedCalendar::WeekendDaysTransition WeekendDaysTransition
Definition bdlt_calendar.h:621
void setValidRange(const Date &firstDate, const Date &lastDate)
Definition bdlt_calendar.h:1588
PackedCalendar::HolidayCodeConstIterator HolidayCodeConstIterator
Definition bdlt_calendar.h:610
void removeHolidayCode(const Date &date, int holidayCode)
Definition bdlt_calendar.h:1570
bool isInRange(const Date &date) const
Definition bdlt_calendar.h:1824
HolidayCodeConstIterator beginHolidayCodes(const Date &date) const
Definition bdlt_calendar.h:1678
WeekendDaysTransitionConstReverseIterator rendWeekendDaysTransitions() const
Definition bdlt_calendar.h:2017
void addDay(const Date &date)
void addHoliday(const Date &date)
int holidayCode(const Date &date, int index) const
Definition bdlt_calendar.h:1806
HolidayCodeConstIterator endHolidayCodes(const Date &date) const
Definition bdlt_calendar.h:1740
void addWeekendDaysTransition(const Date &startDate, const DayOfWeekSet &weekendDays)
Definition bdlt_calendar.h:1519
PackedCalendar::HolidayConstIterator HolidayConstIterator
Definition bdlt_calendar.h:608
Calendar(bslma::Allocator *basicAllocator=0)
WeekendDaysTransition weekendDaysTransition(int index) const
Definition bdlt_calendar.h:2024
int getNextBusinessDay(Date *nextBusinessDay, const Date &date) const
Definition bdlt_calendar.h:1778
void unionNonBusinessDays(const PackedCalendar &other)
int numHolidayCodes(const Date &date) const
Definition bdlt_calendar.h:1883
bool isNonBusinessDay(const Date &date) const
Definition bdlt_calendar.h:1830
friend void hashAppend(HASHALG &hashAlg, const Calendar &)
HolidayConstReverseIterator rbeginHolidays() const
Definition bdlt_calendar.h:1954
WeekendDaysTransitionConstIterator beginWeekendDaysTransitions() const
Definition bdlt_calendar.h:1704
void addHolidayCode(const Date &date, int holidayCode)
BusinessDayConstReverseIterator rbeginBusinessDays() const
Definition bdlt_calendar.h:1925
void reserveHolidayCodeCapacity(int numHolidayCodes)
Definition bdlt_calendar.h:1582
const Date & firstDate() const
Definition bdlt_calendar.h:1772
bool isHoliday(const Date &date) const
Definition bdlt_calendar.h:1818
const Date & lastDate() const
Definition bdlt_calendar.h:1852
Calendar(const Calendar &original, bslma::Allocator *basicAllocator=0)
BusinessDayConstIterator beginBusinessDays() const
Definition bdlt_calendar.h:1650
bslma::Allocator * allocator() const
Return the allocator used by this object to supply memory.
Definition bdlt_calendar.h:2032
int numBusinessDays() const
Definition bdlt_calendar.h:1864
WeekendDaysTransitionConstReverseIterator rbeginWeekendDaysTransitions() const
Definition bdlt_calendar.h:1968
~Calendar()
Destroy this object.
int addHolidayCodeIfInRange(const Date &date, int holidayCode)
Definition bdlt_calendar.h:1499
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlt_calendar.h:1621
void intersectBusinessDays(const Calendar &other)
Definition bdlt_calendar.h:1534
void addWeekendDays(const DayOfWeekSet &weekendDays)
HolidayConstIterator endHolidays() const
Definition bdlt_calendar.h:1753
const PackedCalendar & packedCalendar() const
Definition bdlt_calendar.h:1919
Date holiday(int index) const
Definition bdlt_calendar.h:1800
void intersectNonBusinessDays(const Calendar &other)
Definition bdlt_calendar.h:1547
PackedCalendar::HolidayCodeConstReverseIterator HolidayCodeConstReverseIterator
Definition bdlt_calendar.h:619
void swap(Calendar &other)
Definition bdlt_calendar.h:1637
int length() const
Definition bdlt_calendar.h:1858
bool isWeekendDay(const Date &date) const
Definition bdlt_calendar.h:1840
void reserveHolidayCapacity(int numHolidays)
Definition bdlt_calendar.h:1576
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlt_calendar.h:2047
int numWeekendDaysTransitions() const
Definition bdlt_calendar.h:1913
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlt_calendar.h:2039
PackedCalendar::WeekendDaysTransitionConstIterator WeekendDaysTransitionConstIterator
Definition bdlt_calendar.h:624
HolidayCodeConstReverseIterator rbeginHolidayCodes(const Date &date) const
Definition bdlt_calendar.h:1941
bool isBusinessDay(const Date &date) const
Definition bdlt_calendar.h:1812
Calendar(const bdlt::PackedCalendar &packedCalendar, bslma::Allocator *basicAllocator=0)
PackedCalendar::HolidayConstReverseIterator HolidayConstReverseIterator
Definition bdlt_calendar.h:616
friend bool operator==(const Calendar &, const Calendar &)
Calendar & operator=(const Calendar &rhs)
Definition bdlt_calendar.h:1485
int numWeekendDaysInRange() const
Definition bdlt_calendar.h:1907
int numHolidays() const
Definition bdlt_calendar.h:1895
void unionBusinessDays(const PackedCalendar &other)
int addHolidayIfInRange(const Date &date)
Definition bdlt_calendar.h:1509
CalendarReverseIteratorAdapter< BusinessDayConstIterator > BusinessDayConstReverseIterator
Definition bdlt_calendar.h:613
friend bool operator!=(const Calendar &, const Calendar &)
Calendar(const Date &firstDate, const Date &lastDate, bslma::Allocator *basicAllocator=0)
void removeAll()
Definition bdlt_calendar.h:1553
Definition bdlt_date.h:294
Definition bdlt_dayofweekset.h:398
Definition bdlt_packedcalendar.h:1436
Definition bdlt_packedcalendar.h:1474
Definition bdlt_packedcalendar.h:1628
Definition bdlt_packedcalendar.h:1510
Definition bdlt_packedcalendar.h:592
void reserveHolidayCodeCapacity(int numHolidayCodes)
Definition bdlt_packedcalendar.h:2343
HolidayConstReverseIterator rbeginHolidays() const
Definition bdlt_packedcalendar.h:3106
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
int numWeekendDaysInRange() const
void setValidRange(const Date &firstDate, const Date &lastDate)
const Date & firstDate() const
Definition bdlt_packedcalendar.h:2927
int numHolidays() const
Definition bdlt_packedcalendar.h:3059
int numHolidayCodesTotal() const
Definition bdlt_packedcalendar.h:3053
void removeHoliday(const Date &date)
WeekendDaysTransitionConstReverseIterator rendWeekendDaysTransitions() const
Definition bdlt_packedcalendar.h:3180
HolidayCodeConstReverseIterator rendHolidayCodes(const Date &date) const
Definition bdlt_packedcalendar.h:3146
int holidayCode(const Date &date, int index) const
Definition bdlt_packedcalendar.h:2962
WeekendDaysTransitionConstIterator endWeekendDaysTransitions() const
Definition bdlt_packedcalendar.h:2921
WeekendDaysTransitionSequence::const_iterator WeekendDaysTransitionConstIterator
Definition bdlt_packedcalendar.h:645
void removeHolidayCode(const Date &date, int holidayCode)
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlt_packedcalendar.h:2353
void addWeekendDaysTransition(const Date &startDate, const DayOfWeekSet &weekendDays)
void reserveHolidayCapacity(int numHolidays)
Definition bdlt_packedcalendar.h:2334
HolidayConstIterator beginHolidays() const
Definition bdlt_packedcalendar.h:2850
const Date & lastDate() const
Definition bdlt_packedcalendar.h:3033
bool isHoliday(const Date &date) const
Definition bdlt_packedcalendar.h:2988
HolidayCodeConstReverseIterator rbeginHolidayCodes(const Date &date) const
Definition bdlt_packedcalendar.h:3088
void swap(PackedCalendar &other)
void intersectNonBusinessDays(const PackedCalendar &other)
WeekendDaysTransition weekendDaysTransition(int index) const
Definition bdlt_packedcalendar.h:3188
HolidayConstIterator endHolidays() const
Definition bdlt_packedcalendar.h:2901
bool isInRange(const Date &date) const
Definition bdlt_packedcalendar.h:3003
void intersectBusinessDays(const PackedCalendar &other)
bsl::reverse_iterator< WeekendDaysTransitionSequence::const_iterator > WeekendDaysTransitionConstReverseIterator
Definition bdlt_packedcalendar.h:649
bslma::Allocator * allocator() const
Return the allocator used by this object to supply memory.
Definition bdlt_packedcalendar.h:3199
int length() const
Definition bdlt_packedcalendar.h:3041
bdlt::Date holiday(int index) const
Definition bdlt_packedcalendar.h:2953
static int maxSupportedBdexVersion()
Definition bdlt_packedcalendar.h:3287
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlt_packedcalendar.h:3205
int numWeekendDaysTransitions() const
Definition bdlt_packedcalendar.h:3065
WeekendDaysTransitionConstIterator beginWeekendDaysTransitions() const
Definition bdlt_packedcalendar.h:2870
HolidayConstReverseIterator rendHolidays() const
Definition bdlt_packedcalendar.h:3164
WeekendDaysTransitionConstReverseIterator rbeginWeekendDaysTransitions() const
Definition bdlt_packedcalendar.h:3122
bool isWeekendDay(const Date &date) const
int numHolidayCodes(const Date &date) const
Definition bslstl_pair.h:1210
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:194
Definition bslma_allocator.h:457
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_PRECONDITIONS_END()
Definition bsls_preconditions.h:131
#define BSLS_PRECONDITIONS_BEGIN()
Definition bsls_preconditions.h:130
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
Definition bbldc_basicisma30360.h:112
Calendar_BusinessDayConstIter operator++(Calendar_BusinessDayConstIter &iterator, int)
Definition bdlt_calendar.h:2156
bool operator==(const Calendar &lhs, const Calendar &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const Calendar &calendar)
void hashAppend(HASHALG &hashAlg, const Calendar &object)
bool operator!=(const Calendar &lhs, const Calendar &rhs)
Calendar_BusinessDayConstIter operator--(Calendar_BusinessDayConstIter &iterator, int)
Definition bdlt_calendar.h:2165
Definition balxml_encoderoptions.h:68
Enum
Enumerated day-of-week values.
Definition bdlt_dayofweek.h:123
Definition bslma_usesbslmaallocator.h:343