brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 2b83a6d Raw
109 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html11 12#ifndef _LIBCPP___CHRONO_TZDB_LIST_H13#define _LIBCPP___CHRONO_TZDB_LIST_H14 15#include <version>16// Enable the contents of the header only when libc++ was built with experimental features enabled.17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB18 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>25 26#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#    pragma GCC system_header28#  endif29 30_LIBCPP_BEGIN_NAMESPACE_STD31 32#  if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION33 34namespace chrono {35 36// TODO TZDB37// Libc++ recently switched to only export __ugly_names from the dylib.38// Since the library is still experimental the functions in this header39// should be adapted to this new style. The other tzdb headers should be40// evaluated too.41 42class _LIBCPP_AVAILABILITY_TZDB tzdb_list {43public:44  class __impl; // public to allow construction in dylib45  _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");47  }48  _LIBCPP_EXPORTED_FROM_ABI ~tzdb_list();49 50  tzdb_list(const tzdb_list&)            = delete;51  tzdb_list& operator=(const tzdb_list&) = delete;52 53  using const_iterator = forward_list<tzdb>::const_iterator;54 55  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const tzdb& front() const noexcept { return __front(); }56 57  _LIBCPP_HIDE_FROM_ABI const_iterator erase_after(const_iterator __p) { return __erase_after(__p); }58 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(); }61 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(); }64 65  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __impl& __implementation() { return *__impl_; }66 67private:68  [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const tzdb& __front() const noexcept;69 70  _LIBCPP_EXPORTED_FROM_ABI const_iterator __erase_after(const_iterator __p);71 72  [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __begin() const noexcept;73  [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __end() const noexcept;74 75  [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __cbegin() const noexcept;76  [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __cend() const noexcept;77 78  __impl* __impl_;79};80 81[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list();82 83[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const tzdb& get_tzdb() {84  return get_tzdb_list().front();85}86 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);89}90 91[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const time_zone* current_zone() {92  return get_tzdb().current_zone();93}94 95_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();96 97[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version();98 99} // namespace chrono100 101#  endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&102         // _LIBCPP_HAS_LOCALIZATION103 104_LIBCPP_END_NAMESPACE_STD105 106#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB107 108#endif // _LIBCPP___CHRONO_TZDB_LIST_H109