Mark de Wever | df5fd83 | 2020-11-26 19:12:18 +0100 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- format -----------------------------------===// |
| 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-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_FORMAT |
| 11 | #define _LIBCPP_FORMAT |
| 12 | |
| 13 | /* |
| 14 | |
| 15 | namespace std { |
| 16 | // [format.error], class format_error |
| 17 | class format_error : public runtime_error { |
| 18 | public: |
| 19 | explicit format_error(const string& what_arg); |
| 20 | explicit format_error(const char* what_arg); |
| 21 | }; |
Mark de Wever | 6a67a5f | 2021-02-02 18:10:33 +0100 | [diff] [blame] | 22 | |
| 23 | // [format.parse.ctx], class template basic_format_parse_context |
| 24 | template<class charT> |
| 25 | class basic_format_parse_context { |
| 26 | public: |
| 27 | using char_type = charT; |
| 28 | using const_iterator = typename basic_string_view<charT>::const_iterator; |
| 29 | using iterator = const_iterator; |
| 30 | |
| 31 | private: |
| 32 | iterator begin_; // exposition only |
| 33 | iterator end_; // exposition only |
| 34 | enum indexing { unknown, manual, automatic }; // exposition only |
| 35 | indexing indexing_; // exposition only |
| 36 | size_t next_arg_id_; // exposition only |
| 37 | size_t num_args_; // exposition only |
| 38 | |
| 39 | public: |
| 40 | constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt, |
| 41 | size_t num_args = 0) noexcept; |
| 42 | basic_format_parse_context(const basic_format_parse_context&) = delete; |
| 43 | basic_format_parse_context& operator=(const basic_format_parse_context&) = delete; |
| 44 | |
| 45 | constexpr const_iterator begin() const noexcept; |
| 46 | constexpr const_iterator end() const noexcept; |
| 47 | constexpr void advance_to(const_iterator it); |
| 48 | |
| 49 | constexpr size_t next_arg_id(); |
| 50 | constexpr void check_arg_id(size_t id); |
| 51 | }; |
| 52 | using format_parse_context = basic_format_parse_context<char>; |
| 53 | using wformat_parse_context = basic_format_parse_context<wchar_t>; |
Mark de Wever | df5fd83 | 2020-11-26 19:12:18 +0100 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | */ |
| 57 | |
Mark de Wever | be38c38 | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 58 | // Make sure all feature-test macros are available. |
Mark de Wever | 14151d2 | 2021-07-30 14:35:37 -0400 | [diff] [blame] | 59 | #include <version> |
Mark de Wever | be38c38 | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 60 | // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. |
Mark de Wever | 14151d2 | 2021-07-30 14:35:37 -0400 | [diff] [blame] | 61 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) |
| 62 | |
Mark de Wever | df5fd83 | 2020-11-26 19:12:18 +0100 | [diff] [blame] | 63 | #include <__config> |
Mark de Wever | 1aef5d0 | 2021-04-25 17:58:03 +0200 | [diff] [blame] | 64 | #include <__format/format_error.h> |
Mark de Wever | e26bdbb | 2021-04-25 18:23:42 +0200 | [diff] [blame] | 65 | #include <__format/format_parse_context.h> |
Mark de Wever | 8a0a188 | 2021-07-25 09:18:53 +0200 | [diff] [blame] | 66 | |
Mark de Wever | df5fd83 | 2020-11-26 19:12:18 +0100 | [diff] [blame] | 67 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 68 | # pragma GCC system_header |
| 69 | #endif |
| 70 | |
Mark de Wever | 14151d2 | 2021-07-30 14:35:37 -0400 | [diff] [blame] | 71 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) |
| 72 | |
Mark de Wever | df5fd83 | 2020-11-26 19:12:18 +0100 | [diff] [blame] | 73 | #endif // _LIBCPP_FORMAT |