Path: blob/main/contrib/llvm-project/libcxx/include/__chrono/time_zone_link.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html1011#ifndef _LIBCPP___CHRONO_TIME_ZONE_LINK_H12#define _LIBCPP___CHRONO_TIME_ZONE_LINK_H1314#include <version>15// Enable the contents of the header only when libc++ was built with experimental features enabled.16#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)1718# include <__compare/strong_order.h>19# include <__config>20# include <__utility/private_constructor_tag.h>21# include <string>22# include <string_view>2324# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25# pragma GCC system_header26# endif2728_LIBCPP_PUSH_MACROS29# include <__undef_macros>3031_LIBCPP_BEGIN_NAMESPACE_STD3233# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \34!defined(_LIBCPP_HAS_NO_LOCALIZATION)3536namespace chrono {3738class time_zone_link {39public:40[[nodiscard]]41_LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__private_constructor_tag, string_view __name, string_view __target)42: __name_{__name}, __target_{__target} {}4344_LIBCPP_HIDE_FROM_ABI time_zone_link(time_zone_link&&) = default;45_LIBCPP_HIDE_FROM_ABI time_zone_link& operator=(time_zone_link&&) = default;4647[[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name_; }48[[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view target() const noexcept { return __target_; }4950private:51string __name_;52// TODO TZDB instead of the name we can store the pointer to a zone. These53// pointers are immutable. This makes it possible to directly return a54// pointer in the time_zone in the 'locate_zone' function.55string __target_;56};5758[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool59operator==(const time_zone_link& __x, const time_zone_link& __y) noexcept {60return __x.name() == __y.name();61}6263[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering64operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {65return __x.name() <=> __y.name();66}6768} // namespace chrono6970# endif //_LIBCPP_STD_VER >= 207172_LIBCPP_END_NAMESPACE_STD7374_LIBCPP_POP_MACROS7576#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)7778#endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H798081