xref: /freebsd/contrib/llvm-project/libcxx/include/format (revision fe6060f10f634930ff71b7c50291ddc610da2475)
1*fe6060f1SDimitry Andric// -*- C++ -*-
2*fe6060f1SDimitry Andric//===--------------------------- format -----------------------------------===//
3*fe6060f1SDimitry Andric//
4*fe6060f1SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*fe6060f1SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6*fe6060f1SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*fe6060f1SDimitry Andric//
8*fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
9*fe6060f1SDimitry Andric
10*fe6060f1SDimitry Andric#ifndef _LIBCPP_FORMAT
11*fe6060f1SDimitry Andric#define _LIBCPP_FORMAT
12*fe6060f1SDimitry Andric
13*fe6060f1SDimitry Andric/*
14*fe6060f1SDimitry Andric
15*fe6060f1SDimitry Andricnamespace std {
16*fe6060f1SDimitry Andric  // [format.error], class format_error
17*fe6060f1SDimitry Andric  class format_error : public runtime_error {
18*fe6060f1SDimitry Andric  public:
19*fe6060f1SDimitry Andric    explicit format_error(const string& what_arg);
20*fe6060f1SDimitry Andric    explicit format_error(const char* what_arg);
21*fe6060f1SDimitry Andric  };
22*fe6060f1SDimitry Andric
23*fe6060f1SDimitry Andric  // [format.parse.ctx], class template basic_format_parse_context
24*fe6060f1SDimitry Andric  template<class charT>
25*fe6060f1SDimitry Andric  class basic_format_parse_context {
26*fe6060f1SDimitry Andric  public:
27*fe6060f1SDimitry Andric    using char_type = charT;
28*fe6060f1SDimitry Andric    using const_iterator = typename basic_string_view<charT>::const_iterator;
29*fe6060f1SDimitry Andric    using iterator = const_iterator;
30*fe6060f1SDimitry Andric
31*fe6060f1SDimitry Andric  private:
32*fe6060f1SDimitry Andric    iterator begin_;                                    // exposition only
33*fe6060f1SDimitry Andric    iterator end_;                                      // exposition only
34*fe6060f1SDimitry Andric    enum indexing { unknown, manual, automatic };       // exposition only
35*fe6060f1SDimitry Andric    indexing indexing_;                                 // exposition only
36*fe6060f1SDimitry Andric    size_t next_arg_id_;                                // exposition only
37*fe6060f1SDimitry Andric    size_t num_args_;                                   // exposition only
38*fe6060f1SDimitry Andric
39*fe6060f1SDimitry Andric  public:
40*fe6060f1SDimitry Andric    constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
41*fe6060f1SDimitry Andric                                                  size_t num_args = 0) noexcept;
42*fe6060f1SDimitry Andric    basic_format_parse_context(const basic_format_parse_context&) = delete;
43*fe6060f1SDimitry Andric    basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
44*fe6060f1SDimitry Andric
45*fe6060f1SDimitry Andric    constexpr const_iterator begin() const noexcept;
46*fe6060f1SDimitry Andric    constexpr const_iterator end() const noexcept;
47*fe6060f1SDimitry Andric    constexpr void advance_to(const_iterator it);
48*fe6060f1SDimitry Andric
49*fe6060f1SDimitry Andric    constexpr size_t next_arg_id();
50*fe6060f1SDimitry Andric    constexpr void check_arg_id(size_t id);
51*fe6060f1SDimitry Andric  };
52*fe6060f1SDimitry Andric  using format_parse_context = basic_format_parse_context<char>;
53*fe6060f1SDimitry Andric  using wformat_parse_context = basic_format_parse_context<wchar_t>;
54*fe6060f1SDimitry Andric}
55*fe6060f1SDimitry Andric
56*fe6060f1SDimitry Andric*/
57*fe6060f1SDimitry Andric
58*fe6060f1SDimitry Andric#include <__config>
59*fe6060f1SDimitry Andric#include <__format/format_error.h>
60*fe6060f1SDimitry Andric#include <__format/format_parse_context.h>
61*fe6060f1SDimitry Andric#include <version>
62*fe6060f1SDimitry Andric
63*fe6060f1SDimitry Andric#if defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
64*fe6060f1SDimitry Andric# error "The Format library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
65*fe6060f1SDimitry Andric#endif
66*fe6060f1SDimitry Andric
67*fe6060f1SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68*fe6060f1SDimitry Andric#  pragma GCC system_header
69*fe6060f1SDimitry Andric#endif
70*fe6060f1SDimitry Andric
71*fe6060f1SDimitry Andric_LIBCPP_PUSH_MACROS
72*fe6060f1SDimitry Andric#include <__undef_macros>
73*fe6060f1SDimitry Andric
74*fe6060f1SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
75*fe6060f1SDimitry Andric
76*fe6060f1SDimitry Andric#if _LIBCPP_STD_VER > 17
77*fe6060f1SDimitry Andric
78*fe6060f1SDimitry Andric#endif //_LIBCPP_STD_VER > 17
79*fe6060f1SDimitry Andric
80*fe6060f1SDimitry Andric_LIBCPP_END_NAMESPACE_STD
81*fe6060f1SDimitry Andric
82*fe6060f1SDimitry Andric_LIBCPP_POP_MACROS
83*fe6060f1SDimitry Andric
84*fe6060f1SDimitry Andric#endif // _LIBCPP_FORMAT
85