Back to home page

EIC code displayed by LXR

 
 

    


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

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___CXX03___CHRONO_TIME_ZONE_LINK_H
0013 #define _LIBCPP___CXX03___CHRONO_TIME_ZONE_LINK_H
0014 
0015 #include <__cxx03/version>
0016 // Enable the contents of the header only when libc++ was built with experimental features enabled.
0017 #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
0018 
0019 #  include <__cxx03/__compare/strong_order.h>
0020 #  include <__cxx03/__config>
0021 #  include <__cxx03/__utility/private_constructor_tag.h>
0022 #  include <__cxx03/string>
0023 #  include <__cxx03/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 <__cxx03/__undef_macros>
0031 
0032 _LIBCPP_BEGIN_NAMESPACE_STD
0033 
0034 #  if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&   \
0035       !defined(_LIBCPP_HAS_NO_LOCALIZATION)
0036 
0037 namespace chrono {
0038 
0039 class time_zone_link {
0040 public:
0041   [[nodiscard]]
0042   _LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__private_constructor_tag, string_view __name, string_view __target)
0043       : __name_{__name}, __target_{__target} {}
0044 
0045   _LIBCPP_HIDE_FROM_ABI time_zone_link(time_zone_link&&)            = default;
0046   _LIBCPP_HIDE_FROM_ABI time_zone_link& operator=(time_zone_link&&) = default;
0047 
0048   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name_; }
0049   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view target() const noexcept { return __target_; }
0050 
0051 private:
0052   string __name_;
0053   // TODO TZDB instead of the name we can store the pointer to a zone. These
0054   // pointers are immutable. This makes it possible to directly return a
0055   // pointer in the time_zone in the 'locate_zone' function.
0056   string __target_;
0057 };
0058 
0059 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool
0060 operator==(const time_zone_link& __x, const time_zone_link& __y) noexcept {
0061   return __x.name() == __y.name();
0062 }
0063 
0064 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering
0065 operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {
0066   return __x.name() <=> __y.name();
0067 }
0068 
0069 } // namespace chrono
0070 
0071 #  endif //_LIBCPP_STD_VER >= 20
0072 
0073 _LIBCPP_END_NAMESPACE_STD
0074 
0075 _LIBCPP_POP_MACROS
0076 
0077 #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
0078 
0079 #endif // _LIBCPP___CXX03___CHRONO_TIME_ZONE_LINK_H