/src/quantlib/ql/time/calendars/bespokecalendar.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2008 StatPro Italia srl |
5 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <https://www.quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | #include <ql/time/calendars/bespokecalendar.hpp> |
21 | | #include <sstream> |
22 | | #include <utility> |
23 | | |
24 | | namespace QuantLib { |
25 | | |
26 | 0 | BespokeCalendar::Impl::Impl(std::string name) : name_(std::move(name)) {} |
27 | | |
28 | 0 | std::string BespokeCalendar::Impl::name() const { |
29 | 0 | return name_; |
30 | 0 | } |
31 | | |
32 | 0 | bool BespokeCalendar::Impl::isWeekend(Weekday w) const { |
33 | 0 | return (weekend_mask_ & (1 << w)) != 0; |
34 | 0 | } |
35 | | |
36 | 0 | bool BespokeCalendar::Impl::isBusinessDay(const Date& date) const { |
37 | 0 | return !isWeekend(date.weekday()); |
38 | 0 | } |
39 | | |
40 | 0 | void BespokeCalendar::Impl::addWeekend(Weekday w) { |
41 | 0 | weekend_mask_ |= (1 << w); |
42 | 0 | } |
43 | | |
44 | | |
45 | 0 | BespokeCalendar::BespokeCalendar(const std::string& name) { |
46 | 0 | bespokeImpl_ = ext::make_shared<BespokeCalendar::Impl>( |
47 | 0 | name); |
48 | 0 | impl_ = bespokeImpl_; |
49 | 0 | } |
50 | | |
51 | 0 | void BespokeCalendar::addWeekend(Weekday w) { |
52 | 0 | bespokeImpl_->addWeekend(w); |
53 | 0 | } |
54 | | |
55 | | } |
56 | | |