libosmscout 1.1.1
Loading...
Searching...
No Matches
OpeningHours.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_OPENINGHOURS_H
2#define OSMSCOUT_OPENINGHOURS_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2023 Lukáš Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
24
25#include <cstdint>
26#include <vector>
27#include <string>
28#include <optional>
29
30namespace osmscout {
31
36 {
37 public:
41 enum class WeekDay
42 {
43 Monday = 0,
44 Tuesday,
45 Wednesday,
46 Thursday,
47 Friday,
48 Saturday,
49 Sunday,
50 PublicHoliday,
51 SchoolHoliday
52 };
53
54 struct DayTime
55 {
56 uint8_t hour=0;
57 uint8_t minute=0;
58 };
59
65
66 struct Rule
67 {
69 std::vector<TimeInterval> intervals;
70 };
71
72 private:
73 std::vector<Rule> rules;
74
75 public:
76 explicit OpeningHours(std::vector<Rule> rules);
77 OpeningHours(const OpeningHours&) = default;
79
80 ~OpeningHours() = default;
81
84
85 std::vector<Rule> GetRules() const
86 {
87 return rules;
88 }
89
96 static std::optional<OpeningHours> Parse(const std::string &str, bool explicitClosedDays=false);
97 };
98
99}
100
101#endif //OSMSCOUT_OPENINGHOURS_H
#define OSMSCOUT_API
Definition CoreImportExport.h:45
OpeningHours(std::vector< Rule > rules)
std::vector< Rule > GetRules() const
Definition OpeningHours.h:85
WeekDay
Definition OpeningHours.h:42
@ Monday
Definition OpeningHours.h:43
OpeningHours & operator=(const OpeningHours &)=default
OpeningHours & operator=(OpeningHours &&)=default
static std::optional< OpeningHours > Parse(const std::string &str, bool explicitClosedDays=false)
OpeningHours(const OpeningHours &)=default
OpeningHours(OpeningHours &&)=default
Definition Area.h:39
Definition OpeningHours.h:55
uint8_t minute
Definition OpeningHours.h:57
uint8_t hour
24 hour hour format. May be bigger than 24, when opened even after midnight (26 = 2 hours after midni...
Definition OpeningHours.h:56
Definition OpeningHours.h:67
std::vector< TimeInterval > intervals
Closed when empty.
Definition OpeningHours.h:69
WeekDay day
Definition OpeningHours.h:68
Definition OpeningHours.h:61
DayTime from
Definition OpeningHours.h:62
DayTime to
Definition OpeningHours.h:63