1// -*- C++ -*-
2//===--------------------------- iosfwd -----------------------------------===//
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 <wchar.h>  // for mbstate_t
99
100#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
101#pragma GCC system_header
102#endif
103
104_LIBCPP_BEGIN_NAMESPACE_STD
105
106class _LIBCPP_TYPE_VIS ios_base;
107
108template<class _CharT>  struct _LIBCPP_TEMPLATE_VIS char_traits;
109template<> struct char_traits<char>;
110#ifndef _LIBCPP_HAS_NO_CHAR8_T
111template<> struct char_traits<char8_t>;
112#endif
113template<> struct char_traits<char16_t>;
114template<> struct char_traits<char32_t>;
115template<> struct char_traits<wchar_t>;
116
117template<class _Tp>     class _LIBCPP_TEMPLATE_VIS allocator;
118
119template <class _CharT, class _Traits = char_traits<_CharT> >
120    class _LIBCPP_TEMPLATE_VIS basic_ios;
121
122template <class _CharT, class _Traits = char_traits<_CharT> >
123    class _LIBCPP_TEMPLATE_VIS basic_streambuf;
124template <class _CharT, class _Traits = char_traits<_CharT> >
125    class _LIBCPP_TEMPLATE_VIS basic_istream;
126template <class _CharT, class _Traits = char_traits<_CharT> >
127    class _LIBCPP_TEMPLATE_VIS basic_ostream;
128template <class _CharT, class _Traits = char_traits<_CharT> >
129    class _LIBCPP_TEMPLATE_VIS basic_iostream;
130
131template <class _CharT, class _Traits = char_traits<_CharT>,
132          class _Allocator = allocator<_CharT> >
133    class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
134template <class _CharT, class _Traits = char_traits<_CharT>,
135          class _Allocator = allocator<_CharT> >
136    class _LIBCPP_TEMPLATE_VIS basic_istringstream;
137template <class _CharT, class _Traits = char_traits<_CharT>,
138          class _Allocator = allocator<_CharT> >
139    class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
140template <class _CharT, class _Traits = char_traits<_CharT>,
141          class _Allocator = allocator<_CharT> >
142    class _LIBCPP_TEMPLATE_VIS basic_stringstream;
143
144template <class _CharT, class _Traits = char_traits<_CharT> >
145    class _LIBCPP_TEMPLATE_VIS basic_filebuf;
146template <class _CharT, class _Traits = char_traits<_CharT> >
147    class _LIBCPP_TEMPLATE_VIS basic_ifstream;
148template <class _CharT, class _Traits = char_traits<_CharT> >
149    class _LIBCPP_TEMPLATE_VIS basic_ofstream;
150template <class _CharT, class _Traits = char_traits<_CharT> >
151    class _LIBCPP_TEMPLATE_VIS basic_fstream;
152
153template <class _CharT, class _Traits = char_traits<_CharT> >
154    class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;
155template <class _CharT, class _Traits = char_traits<_CharT> >
156    class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
157
158typedef basic_ios<char>              ios;
159typedef basic_ios<wchar_t>           wios;
160
161typedef basic_streambuf<char>        streambuf;
162typedef basic_istream<char>          istream;
163typedef basic_ostream<char>          ostream;
164typedef basic_iostream<char>         iostream;
165
166typedef basic_stringbuf<char>        stringbuf;
167typedef basic_istringstream<char>    istringstream;
168typedef basic_ostringstream<char>    ostringstream;
169typedef basic_stringstream<char>     stringstream;
170
171typedef basic_filebuf<char>          filebuf;
172typedef basic_ifstream<char>         ifstream;
173typedef basic_ofstream<char>         ofstream;
174typedef basic_fstream<char>          fstream;
175
176typedef basic_streambuf<wchar_t>     wstreambuf;
177typedef basic_istream<wchar_t>       wistream;
178typedef basic_ostream<wchar_t>       wostream;
179typedef basic_iostream<wchar_t>      wiostream;
180
181typedef basic_stringbuf<wchar_t>     wstringbuf;
182typedef basic_istringstream<wchar_t> wistringstream;
183typedef basic_ostringstream<wchar_t> wostringstream;
184typedef basic_stringstream<wchar_t>  wstringstream;
185
186typedef basic_filebuf<wchar_t>       wfilebuf;
187typedef basic_ifstream<wchar_t>      wifstream;
188typedef basic_ofstream<wchar_t>      wofstream;
189typedef basic_fstream<wchar_t>       wfstream;
190
191template <class _CharT, class _Traits>
192    class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios;
193
194template <class _CharT, class _Traits>
195    class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_PREFERRED_NAME(wstreambuf) basic_streambuf;
196template <class _CharT, class _Traits>
197    class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_PREFERRED_NAME(wistream) basic_istream;
198template <class _CharT, class _Traits>
199    class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_PREFERRED_NAME(wostream) basic_ostream;
200template <class _CharT, class _Traits>
201    class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_PREFERRED_NAME(wiostream) basic_iostream;
202
203template <class _CharT, class _Traits, class _Allocator>
204    class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_PREFERRED_NAME(wstringbuf) basic_stringbuf;
205template <class _CharT, class _Traits, class _Allocator>
206    class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_PREFERRED_NAME(wistringstream) basic_istringstream;
207template <class _CharT, class _Traits, class _Allocator>
208    class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_PREFERRED_NAME(wostringstream) basic_ostringstream;
209template <class _CharT, class _Traits, class _Allocator>
210    class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_PREFERRED_NAME(wstringstream) basic_stringstream;
211
212template <class _CharT, class _Traits>
213    class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_PREFERRED_NAME(wfilebuf) basic_filebuf;
214template <class _CharT, class _Traits>
215    class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_PREFERRED_NAME(wifstream) basic_ifstream;
216template <class _CharT, class _Traits>
217    class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_PREFERRED_NAME(wofstream) basic_ofstream;
218template <class _CharT, class _Traits>
219    class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_PREFERRED_NAME(wfstream) basic_fstream;
220
221template <class _State>             class _LIBCPP_TEMPLATE_VIS fpos;
222typedef fpos<mbstate_t>    streampos;
223typedef fpos<mbstate_t>    wstreampos;
224#ifndef _LIBCPP_HAS_NO_CHAR8_T
225typedef fpos<mbstate_t>    u8streampos;
226#endif
227#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
228typedef fpos<mbstate_t>    u16streampos;
229typedef fpos<mbstate_t>    u32streampos;
230#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
231
232#if defined(_NEWLIB_VERSION)
233// On newlib, off_t is 'long int'
234typedef long int streamoff;         // for char_traits in <string>
235#else
236typedef long long streamoff;        // for char_traits in <string>
237#endif
238
239template <class _CharT,             // for <stdexcept>
240          class _Traits = char_traits<_CharT>,
241          class _Allocator = allocator<_CharT> >
242    class _LIBCPP_TEMPLATE_VIS basic_string;
243typedef basic_string<char, char_traits<char>, allocator<char> > string;
244typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
245
246template <class _CharT, class _Traits, class _Allocator>
247    class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_PREFERRED_NAME(wstring) basic_string;
248
249// Include other forward declarations here
250template <class _Tp, class _Alloc = allocator<_Tp> >
251class _LIBCPP_TEMPLATE_VIS vector;
252
253template <class _CharT, class _Traits>
254class __save_flags
255{
256    typedef basic_ios<_CharT, _Traits> __stream_type;
257    typedef typename __stream_type::fmtflags fmtflags;
258
259    __stream_type& __stream_;
260    fmtflags       __fmtflags_;
261    _CharT         __fill_;
262
263    __save_flags(const __save_flags&);
264    __save_flags& operator=(const __save_flags&);
265public:
266    _LIBCPP_INLINE_VISIBILITY
267    explicit __save_flags(__stream_type& __stream)
268        : __stream_(__stream),
269          __fmtflags_(__stream.flags()),
270          __fill_(__stream.fill())
271        {}
272    _LIBCPP_INLINE_VISIBILITY
273    ~__save_flags()
274    {
275        __stream_.flags(__fmtflags_);
276        __stream_.fill(__fill_);
277    }
278};
279
280_LIBCPP_END_NAMESPACE_STD
281
282#endif // _LIBCPP_IOSFWD
283