blob: 974cb427deadc1e5b28cb7a9b34a1c34806070c1 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- iosfwd -----------------------------------===//
3//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// 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
Howard Hinnantc51e1022010-05-11 19:42:16 +00007//
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;
Marshall Clow8732fed2018-12-11 04:35:44 +000020template<> 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
Howard Hinnantc51e1022010-05-11 19:42:16 +000026template<class T> class allocator;
27
Howard Hinnantc8827ba2011-05-13 21:52:40 +000028class ios_base;
Howard Hinnantc51e1022010-05-11 19:42:16 +000029template <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;
Marek Kurdeje3ac4e22021-03-23 17:15:07 +010087using 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>;
Howard Hinnantc51e1022010-05-11 19:42:16 +000092
93} // std
94
95*/
96
97#include <__config>
Howard Hinnant155c2af2010-05-24 17:49:41 +000098#include <wchar.h> // for mbstate_t
Howard Hinnantc51e1022010-05-11 19:42:16 +000099
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000100#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000101#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000102#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000103
104_LIBCPP_BEGIN_NAMESPACE_STD
105
Howard Hinnant8331b762013-03-06 23:30:19 +0000106class _LIBCPP_TYPE_VIS ios_base;
Howard Hinnantd4335272011-01-08 20:00:48 +0000107
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000108template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
Marshall Clow8732fed2018-12-11 04:35:44 +0000109template<> struct char_traits<char>;
Arthur O'Dwyerafa5d5f2021-04-18 21:47:08 -0400110#ifndef _LIBCPP_HAS_NO_CHAR8_T
Marshall Clow8732fed2018-12-11 04:35:44 +0000111template<> 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
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000117template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000118
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000119template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000120 class _LIBCPP_TEMPLATE_VIS basic_ios;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000121
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000122template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000123 class _LIBCPP_TEMPLATE_VIS basic_streambuf;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000124template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000125 class _LIBCPP_TEMPLATE_VIS basic_istream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000126template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000127 class _LIBCPP_TEMPLATE_VIS basic_ostream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000128template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000129 class _LIBCPP_TEMPLATE_VIS basic_iostream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000130
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000131template <class _CharT, class _Traits = char_traits<_CharT>,
132 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000133 class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000134template <class _CharT, class _Traits = char_traits<_CharT>,
135 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000136 class _LIBCPP_TEMPLATE_VIS basic_istringstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000137template <class _CharT, class _Traits = char_traits<_CharT>,
138 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000139 class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000140template <class _CharT, class _Traits = char_traits<_CharT>,
141 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000142 class _LIBCPP_TEMPLATE_VIS basic_stringstream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000143
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000144template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000145 class _LIBCPP_TEMPLATE_VIS basic_filebuf;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000146template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000147 class _LIBCPP_TEMPLATE_VIS basic_ifstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000148template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000149 class _LIBCPP_TEMPLATE_VIS basic_ofstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000150template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000151 class _LIBCPP_TEMPLATE_VIS basic_fstream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000152
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000153template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000154 class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000155template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000156 class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000157
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
Richard Smith256954d2020-11-11 17:12:18 -0800191template <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
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000221template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
Howard Hinnant155c2af2010-05-24 17:49:41 +0000222typedef fpos<mbstate_t> streampos;
223typedef fpos<mbstate_t> wstreampos;
Arthur O'Dwyerafa5d5f2021-04-18 21:47:08 -0400224#ifndef _LIBCPP_HAS_NO_CHAR8_T
Marshall Clow8732fed2018-12-11 04:35:44 +0000225typedef fpos<mbstate_t> u8streampos;
226#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000227#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnant155c2af2010-05-24 17:49:41 +0000228typedef fpos<mbstate_t> u16streampos;
229typedef fpos<mbstate_t> u32streampos;
Louis Dionne96fc5f52021-09-09 11:25:10 -0400230#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000231
Jonathan Roelofsd3c81f42015-02-03 15:34:17 +0000232#if defined(_NEWLIB_VERSION)
233// On newlib, off_t is 'long int'
234typedef long int streamoff; // for char_traits in <string>
235#else
Howard Hinnantc51e1022010-05-11 19:42:16 +0000236typedef long long streamoff; // for char_traits in <string>
Jonathan Roelofsd3c81f42015-02-03 15:34:17 +0000237#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000238
239template <class _CharT, // for <stdexcept>
240 class _Traits = char_traits<_CharT>,
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000241 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000242 class _LIBCPP_TEMPLATE_VIS basic_string;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000243typedef basic_string<char, char_traits<char>, allocator<char> > string;
244typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
245
Richard Smith256954d2020-11-11 17:12:18 -0800246template <class _CharT, class _Traits, class _Allocator>
247 class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_PREFERRED_NAME(wstring) basic_string;
Eric Fiselier876c6862016-02-20 00:19:45 +0000248
249// Include other forward declarations here
250template <class _Tp, class _Alloc = allocator<_Tp> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000251class _LIBCPP_TEMPLATE_VIS vector;
Eric Fiselier876c6862016-02-20 00:19:45 +0000252
Louis Dionne3df65ce2020-10-15 13:27:27 -0400253template <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
Howard Hinnantc51e1022010-05-11 19:42:16 +0000280_LIBCPP_END_NAMESPACE_STD
281
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400282#endif // _LIBCPP_IOSFWD