xref: /freebsd/contrib/llvm-project/libcxx/include/iosfwd (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
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_IOSFWD
11#define _LIBCPP_IOSFWD
12
13/*
14    iosfwd synopsis
15
16namespace std
17{
18
19template<class charT> struct char_traits;
20template<>            struct char_traits<char>;
21template<>            struct char_traits<char8_t>;  // C++20
22template<>            struct char_traits<char16_t>;
23template<>            struct char_traits<char32_t>;
24template<>            struct char_traits<wchar_t>;
25
26template<class T>     class allocator;
27
28class ios_base;
29template <class charT, class traits = char_traits<charT> > class basic_ios;
30
31template <class charT, class traits = char_traits<charT> > class basic_streambuf;
32template <class charT, class traits = char_traits<charT> > class basic_istream;
33template <class charT, class traits = char_traits<charT> > class basic_ostream;
34template <class charT, class traits = char_traits<charT> > class basic_iostream;
35
36template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
37    class basic_stringbuf;
38template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
39    class basic_istringstream;
40template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
41    class basic_ostringstream;
42template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
43    class basic_stringstream;
44
45template <class charT, class traits = char_traits<charT> > class basic_filebuf;
46template <class charT, class traits = char_traits<charT> > class basic_ifstream;
47template <class charT, class traits = char_traits<charT> > class basic_ofstream;
48template <class charT, class traits = char_traits<charT> > class basic_fstream;
49
50template <class charT, class traits = char_traits<charT> > class istreambuf_iterator;
51template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
52
53typedef basic_ios<char>              ios;
54typedef basic_ios<wchar_t>           wios;
55
56typedef basic_streambuf<char>        streambuf;
57typedef basic_istream<char>          istream;
58typedef basic_ostream<char>          ostream;
59typedef basic_iostream<char>         iostream;
60
61typedef basic_stringbuf<char>        stringbuf;
62typedef basic_istringstream<char>    istringstream;
63typedef basic_ostringstream<char>    ostringstream;
64typedef basic_stringstream<char>     stringstream;
65
66typedef basic_filebuf<char>          filebuf;
67typedef basic_ifstream<char>         ifstream;
68typedef basic_ofstream<char>         ofstream;
69typedef basic_fstream<char>          fstream;
70
71typedef basic_streambuf<wchar_t>     wstreambuf;
72typedef basic_istream<wchar_t>       wistream;
73typedef basic_ostream<wchar_t>       wostream;
74typedef basic_iostream<wchar_t>      wiostream;
75
76typedef basic_stringbuf<wchar_t>     wstringbuf;
77typedef basic_istringstream<wchar_t> wistringstream;
78typedef basic_ostringstream<wchar_t> wostringstream;
79typedef basic_stringstream<wchar_t>  wstringstream;
80
81typedef basic_filebuf<wchar_t>       wfilebuf;
82typedef basic_ifstream<wchar_t>      wifstream;
83typedef basic_ofstream<wchar_t>      wofstream;
84typedef basic_fstream<wchar_t>       wfstream;
85
86template <class state> class fpos;
87using streampos  = fpos<char_traits<char>::state_type>;
88using wstreampos = fpos<char_traits<wchar_t>::state_type>;
89using u8streampos = fpos<char_traits<char8_t>::state_type>; // C++20
90using u16streampos = fpos<char_traits<char16_t>::state_type>;
91using u32streampos = fpos<char_traits<char32_t>::state_type>;
92
93}  // std
94
95*/
96
97#include <__config>
98#include <__mbstate_t.h>
99#include <version>
100
101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
102#pragma GCC system_header
103#endif
104
105_LIBCPP_BEGIN_NAMESPACE_STD
106
107class _LIBCPP_TYPE_VIS ios_base;
108
109template<class _CharT>  struct _LIBCPP_TEMPLATE_VIS char_traits;
110template<> struct char_traits<char>;
111#ifndef _LIBCPP_HAS_NO_CHAR8_T
112template<> struct char_traits<char8_t>;
113#endif
114template<> struct char_traits<char16_t>;
115template<> struct char_traits<char32_t>;
116#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
117template<> struct char_traits<wchar_t>;
118#endif
119
120template<class _Tp>     class _LIBCPP_TEMPLATE_VIS allocator;
121
122template <class _CharT, class _Traits = char_traits<_CharT> >
123    class _LIBCPP_TEMPLATE_VIS basic_ios;
124
125template <class _CharT, class _Traits = char_traits<_CharT> >
126    class _LIBCPP_TEMPLATE_VIS basic_streambuf;
127template <class _CharT, class _Traits = char_traits<_CharT> >
128    class _LIBCPP_TEMPLATE_VIS basic_istream;
129template <class _CharT, class _Traits = char_traits<_CharT> >
130    class _LIBCPP_TEMPLATE_VIS basic_ostream;
131template <class _CharT, class _Traits = char_traits<_CharT> >
132    class _LIBCPP_TEMPLATE_VIS basic_iostream;
133
134template <class _CharT, class _Traits = char_traits<_CharT>,
135          class _Allocator = allocator<_CharT> >
136    class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
137template <class _CharT, class _Traits = char_traits<_CharT>,
138          class _Allocator = allocator<_CharT> >
139    class _LIBCPP_TEMPLATE_VIS basic_istringstream;
140template <class _CharT, class _Traits = char_traits<_CharT>,
141          class _Allocator = allocator<_CharT> >
142    class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
143template <class _CharT, class _Traits = char_traits<_CharT>,
144          class _Allocator = allocator<_CharT> >
145    class _LIBCPP_TEMPLATE_VIS basic_stringstream;
146
147template <class _CharT, class _Traits = char_traits<_CharT> >
148    class _LIBCPP_TEMPLATE_VIS basic_filebuf;
149template <class _CharT, class _Traits = char_traits<_CharT> >
150    class _LIBCPP_TEMPLATE_VIS basic_ifstream;
151template <class _CharT, class _Traits = char_traits<_CharT> >
152    class _LIBCPP_TEMPLATE_VIS basic_ofstream;
153template <class _CharT, class _Traits = char_traits<_CharT> >
154    class _LIBCPP_TEMPLATE_VIS basic_fstream;
155
156template <class _CharT, class _Traits = char_traits<_CharT> >
157    class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;
158template <class _CharT, class _Traits = char_traits<_CharT> >
159    class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
160
161typedef basic_ios<char>              ios;
162#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
163typedef basic_ios<wchar_t>           wios;
164#endif
165
166typedef basic_streambuf<char>        streambuf;
167typedef basic_istream<char>          istream;
168typedef basic_ostream<char>          ostream;
169typedef basic_iostream<char>         iostream;
170
171typedef basic_stringbuf<char>        stringbuf;
172typedef basic_istringstream<char>    istringstream;
173typedef basic_ostringstream<char>    ostringstream;
174typedef basic_stringstream<char>     stringstream;
175
176typedef basic_filebuf<char>          filebuf;
177typedef basic_ifstream<char>         ifstream;
178typedef basic_ofstream<char>         ofstream;
179typedef basic_fstream<char>          fstream;
180
181#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
182typedef basic_streambuf<wchar_t>     wstreambuf;
183typedef basic_istream<wchar_t>       wistream;
184typedef basic_ostream<wchar_t>       wostream;
185typedef basic_iostream<wchar_t>      wiostream;
186
187typedef basic_stringbuf<wchar_t>     wstringbuf;
188typedef basic_istringstream<wchar_t> wistringstream;
189typedef basic_ostringstream<wchar_t> wostringstream;
190typedef basic_stringstream<wchar_t>  wstringstream;
191
192typedef basic_filebuf<wchar_t>       wfilebuf;
193typedef basic_ifstream<wchar_t>      wifstream;
194typedef basic_ofstream<wchar_t>      wofstream;
195typedef basic_fstream<wchar_t>       wfstream;
196#endif
197
198template <class _CharT, class _Traits>
199    class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios;
200
201template <class _CharT, class _Traits>
202    class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf;
203template <class _CharT, class _Traits>
204    class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream;
205template <class _CharT, class _Traits>
206    class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream;
207template <class _CharT, class _Traits>
208    class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream;
209
210template <class _CharT, class _Traits, class _Allocator>
211    class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf;
212template <class _CharT, class _Traits, class _Allocator>
213    class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream;
214template <class _CharT, class _Traits, class _Allocator>
215    class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream;
216template <class _CharT, class _Traits, class _Allocator>
217    class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream;
218
219template <class _CharT, class _Traits>
220    class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf;
221template <class _CharT, class _Traits>
222    class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream;
223template <class _CharT, class _Traits>
224    class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream;
225template <class _CharT, class _Traits>
226    class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream;
227
228template <class _State>             class _LIBCPP_TEMPLATE_VIS fpos;
229typedef fpos<mbstate_t>    streampos;
230typedef fpos<mbstate_t>    wstreampos;
231#ifndef _LIBCPP_HAS_NO_CHAR8_T
232typedef fpos<mbstate_t>    u8streampos;
233#endif
234#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
235typedef fpos<mbstate_t>    u16streampos;
236typedef fpos<mbstate_t>    u32streampos;
237#endif
238
239#if defined(_NEWLIB_VERSION)
240// On newlib, off_t is 'long int'
241typedef long int streamoff;         // for char_traits in <string>
242#else
243typedef long long streamoff;        // for char_traits in <string>
244#endif
245
246template <class _CharT,             // for <stdexcept>
247          class _Traits = char_traits<_CharT>,
248          class _Allocator = allocator<_CharT> >
249    class _LIBCPP_TEMPLATE_VIS basic_string;
250typedef basic_string<char, char_traits<char>, allocator<char> > string;
251#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
252typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
253#endif
254
255template <class _CharT, class _Traits, class _Allocator>
256    class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring)) basic_string;
257
258// Include other forward declarations here
259template <class _Tp, class _Alloc = allocator<_Tp> >
260class _LIBCPP_TEMPLATE_VIS vector;
261
262template <class _CharT, class _Traits>
263class __save_flags
264{
265    typedef basic_ios<_CharT, _Traits> __stream_type;
266    typedef typename __stream_type::fmtflags fmtflags;
267
268    __stream_type& __stream_;
269    fmtflags       __fmtflags_;
270    _CharT         __fill_;
271
272    __save_flags(const __save_flags&);
273    __save_flags& operator=(const __save_flags&);
274public:
275    _LIBCPP_INLINE_VISIBILITY
276    explicit __save_flags(__stream_type& __stream)
277        : __stream_(__stream),
278          __fmtflags_(__stream.flags()),
279          __fill_(__stream.fill())
280        {}
281    _LIBCPP_INLINE_VISIBILITY
282    ~__save_flags()
283    {
284        __stream_.flags(__fmtflags_);
285        __stream_.fill(__fill_);
286    }
287};
288
289_LIBCPP_END_NAMESPACE_STD
290
291#endif // _LIBCPP_IOSFWD
292