// -*- C++ -*- //===--------------------------- format -----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_FORMAT #define _LIBCPP_FORMAT /* namespace std { // [format.context], class template basic_format_context template class basic_format_context { basic_format_args args_; // exposition only Out out_; // exposition only public: using iterator = Out; using char_type = charT; template using formatter_type = formatter; basic_format_arg arg(size_t id) const; std::locale locale(); iterator out(); void advance_to(iterator it); }; using format_context = basic_format_context; using wformat_context = basic_format_context; // [format.args], class template basic_format_args template class basic_format_args { size_t size_; // exposition only const basic_format_arg* data_; // exposition only public: basic_format_args() noexcept; template basic_format_args(const format-arg-store& store) noexcept; basic_format_arg get(size_t i) const noexcept; }; using format_args = basic_format_args; using wformat_args = basic_format_args; template using format_args_t = basic_format_args>; // [format.parse.ctx], class template basic_format_parse_context template class basic_format_parse_context { public: using char_type = charT; using const_iterator = typename basic_string_view::const_iterator; using iterator = const_iterator; private: iterator begin_; // exposition only iterator end_; // exposition only enum indexing { unknown, manual, automatic }; // exposition only indexing indexing_; // exposition only size_t next_arg_id_; // exposition only size_t num_args_; // exposition only public: constexpr explicit basic_format_parse_context(basic_string_view fmt, size_t num_args = 0) noexcept; basic_format_parse_context(const basic_format_parse_context&) = delete; basic_format_parse_context& operator=(const basic_format_parse_context&) = delete; constexpr const_iterator begin() const noexcept; constexpr const_iterator end() const noexcept; constexpr void advance_to(const_iterator it); constexpr size_t next_arg_id(); constexpr void check_arg_id(size_t id); }; using format_parse_context = basic_format_parse_context; using wformat_parse_context = basic_format_parse_context; // [format.arguments], arguments // [format.arg], class template basic_format_arg template class basic_format_arg { public: class handle; private: using char_type = typename Context::char_type; // exposition only variant, const void*, handle> value; // exposition only template explicit basic_format_arg(const T& v) noexcept; // exposition only explicit basic_format_arg(float n) noexcept; // exposition only explicit basic_format_arg(double n) noexcept; // exposition only explicit basic_format_arg(long double n) noexcept; // exposition only explicit basic_format_arg(const char_type* s); // exposition only template explicit basic_format_arg( basic_string_view s) noexcept; // exposition only template explicit basic_format_arg( const basic_string& s) noexcept; // exposition only explicit basic_format_arg(nullptr_t) noexcept; // exposition only template explicit basic_format_arg(const T* p) noexcept; // exposition only public: basic_format_arg() noexcept; explicit operator bool() const noexcept; }; template see below visit_format_arg(Visitor&& vis, basic_format_arg arg); // [format.arg.store], class template format-arg-store template struct format-arg-store { // exposition only array, sizeof...(Args)> args; }; template format-arg-store make_format_args(const Args&... args); template format-arg-store make_wformat_args(const Args&... args); // [format.error], class format_error class format_error : public runtime_error { public: explicit format_error(const string& what_arg); explicit format_error(const char* what_arg); }; // [format.parse.ctx], class template basic_format_parse_context template class basic_format_parse_context { public: using char_type = charT; using const_iterator = typename basic_string_view::const_iterator; using iterator = const_iterator; private: iterator begin_; // exposition only iterator end_; // exposition only enum indexing { unknown, manual, automatic }; // exposition only indexing indexing_; // exposition only size_t next_arg_id_; // exposition only size_t num_args_; // exposition only public: constexpr explicit basic_format_parse_context(basic_string_view fmt, size_t num_args = 0) noexcept; basic_format_parse_context(const basic_format_parse_context&) = delete; basic_format_parse_context& operator=(const basic_format_parse_context&) = delete; constexpr const_iterator begin() const noexcept; constexpr const_iterator end() const noexcept; constexpr void advance_to(const_iterator it); constexpr size_t next_arg_id(); constexpr void check_arg_id(size_t id); }; using format_parse_context = basic_format_parse_context; using wformat_parse_context = basic_format_parse_context; } */ // Make sure all feature-test macros are available. #include // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) #include <__config> #include <__format/format_arg.h> #include <__format/format_args.h> #include <__format/format_context.h> #include <__format/format_error.h> #include <__format/format_parse_context.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 // TODO FMT Remove this once we require compilers with proper C++20 support. // If the compiler has no concepts support, the format header will be disabled. // Without concepts support enable_if needs to be used and that too much effort // to support compilers with partial C++20 support. #if !defined(_LIBCPP_HAS_NO_CONCEPTS) // TODO FMT Evaluate which templates should be external templates. This // improves the efficiency of the header. However since the header is still // under heavy development and not all classes are stable it makes no sense // to do this optimization now. using format_args = basic_format_args; using wformat_args = basic_format_args; template using format_args_t = basic_format_args>; template struct _LIBCPP_TEMPLATE_VIS __format_arg_store { // TODO FMT Use a built-in array. array, sizeof...(_Args)> __args; }; template _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(const _Args&... __args) { return {basic_format_arg<_Context>(__args)...}; } template _LIBCPP_HIDE_FROM_ABI __format_arg_store make_wformat_args(const _Args&... __args) { return _VSTD::make_format_args(__args...); } #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) #endif //_LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) #endif // _LIBCPP_FORMAT