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