1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H
13#define _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H
14
15#include <chrono>
16#include <string>
17#include <vector>
18
19#include "types_private.h"
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23namespace chrono {
24
25class time_zone::__impl {
26public:
27 explicit _LIBCPP_HIDE_FROM_ABI __impl(string&& __name, const __tz::__rules_storage_type& __rules_db)
28 : __name_(std::move(__name)), __rules_db_(__rules_db) {}
29
30 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view __name() const noexcept { return __name_; }
31
32 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI vector<__tz::__continuation>& __continuations() { return __continuations_; }
33 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const vector<__tz::__continuation>& __continuations() const {
34 return __continuations_;
35 }
36
37 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __tz::__rules_storage_type& __rules_db() const { return __rules_db_; }
38
39private:
40 string __name_;
41 // Note the first line has a name + __continuation, the other lines
42 // are just __continuations. So there is always at least one item in
43 // the vector.
44 vector<__tz::__continuation> __continuations_;
45
46 // Continuations often depend on a set of rules. The rules are stored in
47 // parallel data structurs in tzdb_list. From the time_zone it's not possible
48 // to find its associated tzdb entry and thus not possible to find its
49 // associated rules. Therefore a link to the rules in stored in this class.
50 const __tz::__rules_storage_type& __rules_db_;
51};
52
53} // namespace chrono
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H
58