[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / libcxx / include / __chrono / tzdb_list.h
blob9c507764c97a7a48c394e26372465e619fa2e247
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 //===----------------------------------------------------------------------===//
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
15 #include <version>
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>
21 # include <__config>
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
28 # endif
30 _LIBCPP_BEGIN_NAMESPACE_STD
32 # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
34 namespace chrono {
36 // TODO TZDB
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
40 // evaluated too.
42 class _LIBCPP_AVAILABILITY_TZDB tzdb_list {
43 public:
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_; }
67 private:
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;
78 __impl* __impl_;
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();
99 } // namespace chrono
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