2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
12 #ifndef _LIBCPP___CHRONO_TZDB_LIST_H
13 #define _LIBCPP___CHRONO_TZDB_LIST_H
16 // Enable the contents of the header only when libc++ was built with experimental features enabled.
17 #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
19 # include <__chrono/time_zone.h>
20 # include <__chrono/tzdb.h>
22 # include <__fwd/string.h>
23 # include <forward_list>
24 # include <string_view>
26 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27 # pragma GCC system_header
30 _LIBCPP_BEGIN_NAMESPACE_STD
32 # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
37 // Libc++ recently switched to only export __ugly_names from the dylib.
38 // Since the library is still experimental the functions in this header
39 // should be adapted to this new style. The other tzdb headers should be
42 class _LIBCPP_AVAILABILITY_TZDB tzdb_list
{
44 class __impl
; // public to allow construction in dylib
45 _LIBCPP_HIDE_FROM_ABI
explicit tzdb_list(__impl
* __p
) : __impl_(__p
) {
46 _LIBCPP_ASSERT_NON_NULL(__impl_
!= nullptr, "initialized time_zone without a valid pimpl object");
48 _LIBCPP_EXPORTED_FROM_ABI
~tzdb_list();
50 tzdb_list(const tzdb_list
&) = delete;
51 tzdb_list
& operator=(const tzdb_list
&) = delete;
53 using const_iterator
= forward_list
<tzdb
>::const_iterator
;
55 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
const tzdb
& front() const noexcept
{ return __front(); }
57 _LIBCPP_HIDE_FROM_ABI const_iterator
erase_after(const_iterator __p
) { return __erase_after(__p
); }
59 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI const_iterator
begin() const noexcept
{ return __begin(); }
60 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI const_iterator
end() const noexcept
{ return __end(); }
62 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI const_iterator
cbegin() const noexcept
{ return __cbegin(); }
63 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI const_iterator
cend() const noexcept
{ return __cend(); }
65 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI __impl
& __implementation() { return *__impl_
; }
68 [[nodiscard
]] _LIBCPP_EXPORTED_FROM_ABI
const tzdb
& __front() const noexcept
;
70 _LIBCPP_EXPORTED_FROM_ABI const_iterator
__erase_after(const_iterator __p
);
72 [[nodiscard
]] _LIBCPP_EXPORTED_FROM_ABI const_iterator
__begin() const noexcept
;
73 [[nodiscard
]] _LIBCPP_EXPORTED_FROM_ABI const_iterator
__end() const noexcept
;
75 [[nodiscard
]] _LIBCPP_EXPORTED_FROM_ABI const_iterator
__cbegin() const noexcept
;
76 [[nodiscard
]] _LIBCPP_EXPORTED_FROM_ABI const_iterator
__cend() const noexcept
;
81 [[nodiscard
]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list
& get_tzdb_list();
83 [[nodiscard
]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI
inline const tzdb
& get_tzdb() {
84 return get_tzdb_list().front();
87 [[nodiscard
]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI
inline const time_zone
* locate_zone(string_view __name
) {
88 return get_tzdb().locate_zone(__name
);
91 [[nodiscard
]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI
inline const time_zone
* current_zone() {
92 return get_tzdb().current_zone();
95 _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI
const tzdb
& reload_tzdb();
97 [[nodiscard
]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string
remote_version();
101 # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
102 // _LIBCPP_HAS_LOCALIZATION
104 _LIBCPP_END_NAMESPACE_STD
106 #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
108 #endif // _LIBCPP___CHRONO_TZDB_LIST_H