Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:15

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
0011 
0012 #ifndef _LIBCPP___CHRONO_TIME_ZONE_LINK_H
0013 #define _LIBCPP___CHRONO_TIME_ZONE_LINK_H
0014 
0015 #include <version>
0016 // Enable the contents of the header only when libc++ was built with experimental features enabled.
0017 #if _LIBCPP_HAS_EXPERIMENTAL_TZDB
0018 
0019 #  include <__compare/strong_order.h>
0020 #  include <__config>
0021 #  include <__utility/private_constructor_tag.h>
0022 #  include <string>
0023 #  include <string_view>
0024 
0025 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0026 #    pragma GCC system_header
0027 #  endif
0028 
0029 _LIBCPP_PUSH_MACROS
0030 #  include <__undef_macros>
0031 
0032 _LIBCPP_BEGIN_NAMESPACE_STD
0033 
0034 #  if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
0035 
0036 namespace chrono {
0037 
0038 class time_zone_link {
0039 public:
0040   [[nodiscard]]
0041   _LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__private_constructor_tag, string_view __name, string_view __target)
0042       : __name_{__name}, __target_{__target} {}
0043 
0044   _LIBCPP_HIDE_FROM_ABI time_zone_link(time_zone_link&&)            = default;
0045   _LIBCPP_HIDE_FROM_ABI time_zone_link& operator=(time_zone_link&&) = default;
0046 
0047   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name_; }
0048   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view target() const noexcept { return __target_; }
0049 
0050 private:
0051   string __name_;
0052   // TODO TZDB instead of the name we can store the pointer to a zone. These
0053   // pointers are immutable. This makes it possible to directly return a
0054   // pointer in the time_zone in the 'locate_zone' function.
0055   string __target_;
0056 };
0057 
0058 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool
0059 operator==(const time_zone_link& __x, const time_zone_link& __y) noexcept {
0060   return __x.name() == __y.name();
0061 }
0062 
0063 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering
0064 operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {
0065   return __x.name() <=> __y.name();
0066 }
0067 
0068 } // namespace chrono
0069 
0070 #  endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
0071          // _LIBCPP_HAS_LOCALIZATION
0072 
0073 _LIBCPP_END_NAMESPACE_STD
0074 
0075 _LIBCPP_POP_MACROS
0076 
0077 #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
0078 
0079 #endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H