blob: 0a0de99ff3a7b667d591f089e3b0a44b2fe66be2 [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;
87typedef fpos<char_traits<char>::state_type> streampos;
88typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
89
90} // std
91
92*/
93
94#include <__config>
Howard Hinnant155c2af2010-05-24 17:49:41 +000095#include <wchar.h> // for mbstate_t
Howard Hinnantc51e1022010-05-11 19:42:16 +000096
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000097#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +000098#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000099#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000100
101_LIBCPP_BEGIN_NAMESPACE_STD
102
Howard Hinnant8331b762013-03-06 23:30:19 +0000103class _LIBCPP_TYPE_VIS ios_base;
Howard Hinnantd4335272011-01-08 20:00:48 +0000104
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000105template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
Marshall Clow8732fed2018-12-11 04:35:44 +0000106template<> struct char_traits<char>;
107#ifndef _LIBCPP_NO_HAS_CHAR8_T
108template<> struct char_traits<char8_t>;
109#endif
110template<> struct char_traits<char16_t>;
111template<> struct char_traits<char32_t>;
112template<> struct char_traits<wchar_t>;
113
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000114template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000115
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000116template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000117 class _LIBCPP_TEMPLATE_VIS basic_ios;
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_streambuf;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000121template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000122 class _LIBCPP_TEMPLATE_VIS basic_istream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000123template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000124 class _LIBCPP_TEMPLATE_VIS basic_ostream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000125template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000126 class _LIBCPP_TEMPLATE_VIS basic_iostream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000127
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000128template <class _CharT, class _Traits = char_traits<_CharT>,
129 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000130 class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
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_istringstream;
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_ostringstream;
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_stringstream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000140
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000141template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000142 class _LIBCPP_TEMPLATE_VIS basic_filebuf;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000143template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000144 class _LIBCPP_TEMPLATE_VIS basic_ifstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000145template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000146 class _LIBCPP_TEMPLATE_VIS basic_ofstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000147template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000148 class _LIBCPP_TEMPLATE_VIS basic_fstream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000149
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 istreambuf_iterator;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000152template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000153 class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000154
155typedef basic_ios<char> ios;
156typedef basic_ios<wchar_t> wios;
157
158typedef basic_streambuf<char> streambuf;
159typedef basic_istream<char> istream;
160typedef basic_ostream<char> ostream;
161typedef basic_iostream<char> iostream;
162
163typedef basic_stringbuf<char> stringbuf;
164typedef basic_istringstream<char> istringstream;
165typedef basic_ostringstream<char> ostringstream;
166typedef basic_stringstream<char> stringstream;
167
168typedef basic_filebuf<char> filebuf;
169typedef basic_ifstream<char> ifstream;
170typedef basic_ofstream<char> ofstream;
171typedef basic_fstream<char> fstream;
172
173typedef basic_streambuf<wchar_t> wstreambuf;
174typedef basic_istream<wchar_t> wistream;
175typedef basic_ostream<wchar_t> wostream;
176typedef basic_iostream<wchar_t> wiostream;
177
178typedef basic_stringbuf<wchar_t> wstringbuf;
179typedef basic_istringstream<wchar_t> wistringstream;
180typedef basic_ostringstream<wchar_t> wostringstream;
181typedef basic_stringstream<wchar_t> wstringstream;
182
183typedef basic_filebuf<wchar_t> wfilebuf;
184typedef basic_ifstream<wchar_t> wifstream;
185typedef basic_ofstream<wchar_t> wofstream;
186typedef basic_fstream<wchar_t> wfstream;
187
Richard Smith256954d2020-11-11 17:12:18 -0800188template <class _CharT, class _Traits>
189 class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios;
190
191template <class _CharT, class _Traits>
192 class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_PREFERRED_NAME(wstreambuf) basic_streambuf;
193template <class _CharT, class _Traits>
194 class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_PREFERRED_NAME(wistream) basic_istream;
195template <class _CharT, class _Traits>
196 class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_PREFERRED_NAME(wostream) basic_ostream;
197template <class _CharT, class _Traits>
198 class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_PREFERRED_NAME(wiostream) basic_iostream;
199
200template <class _CharT, class _Traits, class _Allocator>
201 class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_PREFERRED_NAME(wstringbuf) basic_stringbuf;
202template <class _CharT, class _Traits, class _Allocator>
203 class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_PREFERRED_NAME(wistringstream) basic_istringstream;
204template <class _CharT, class _Traits, class _Allocator>
205 class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_PREFERRED_NAME(wostringstream) basic_ostringstream;
206template <class _CharT, class _Traits, class _Allocator>
207 class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_PREFERRED_NAME(wstringstream) basic_stringstream;
208
209template <class _CharT, class _Traits>
210 class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_PREFERRED_NAME(wfilebuf) basic_filebuf;
211template <class _CharT, class _Traits>
212 class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_PREFERRED_NAME(wifstream) basic_ifstream;
213template <class _CharT, class _Traits>
214 class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_PREFERRED_NAME(wofstream) basic_ofstream;
215template <class _CharT, class _Traits>
216 class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_PREFERRED_NAME(wfstream) basic_fstream;
217
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000218template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
Howard Hinnant155c2af2010-05-24 17:49:41 +0000219typedef fpos<mbstate_t> streampos;
220typedef fpos<mbstate_t> wstreampos;
Marshall Clow8732fed2018-12-11 04:35:44 +0000221#ifndef _LIBCPP_NO_HAS_CHAR8_T
222typedef fpos<mbstate_t> u8streampos;
223#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000224#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnant155c2af2010-05-24 17:49:41 +0000225typedef fpos<mbstate_t> u16streampos;
226typedef fpos<mbstate_t> u32streampos;
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000227#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000228
Jonathan Roelofsd3c81f42015-02-03 15:34:17 +0000229#if defined(_NEWLIB_VERSION)
230// On newlib, off_t is 'long int'
231typedef long int streamoff; // for char_traits in <string>
232#else
Howard Hinnantc51e1022010-05-11 19:42:16 +0000233typedef long long streamoff; // for char_traits in <string>
Jonathan Roelofsd3c81f42015-02-03 15:34:17 +0000234#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000235
236template <class _CharT, // for <stdexcept>
237 class _Traits = char_traits<_CharT>,
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000238 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000239 class _LIBCPP_TEMPLATE_VIS basic_string;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000240typedef basic_string<char, char_traits<char>, allocator<char> > string;
241typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
242
Richard Smith256954d2020-11-11 17:12:18 -0800243template <class _CharT, class _Traits, class _Allocator>
244 class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_PREFERRED_NAME(wstring) basic_string;
Eric Fiselier876c6862016-02-20 00:19:45 +0000245
246// Include other forward declarations here
247template <class _Tp, class _Alloc = allocator<_Tp> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000248class _LIBCPP_TEMPLATE_VIS vector;
Eric Fiselier876c6862016-02-20 00:19:45 +0000249
Louis Dionne3df65ce2020-10-15 13:27:27 -0400250template <class _CharT, class _Traits>
251class __save_flags
252{
253 typedef basic_ios<_CharT, _Traits> __stream_type;
254 typedef typename __stream_type::fmtflags fmtflags;
255
256 __stream_type& __stream_;
257 fmtflags __fmtflags_;
258 _CharT __fill_;
259
260 __save_flags(const __save_flags&);
261 __save_flags& operator=(const __save_flags&);
262public:
263 _LIBCPP_INLINE_VISIBILITY
264 explicit __save_flags(__stream_type& __stream)
265 : __stream_(__stream),
266 __fmtflags_(__stream.flags()),
267 __fill_(__stream.fill())
268 {}
269 _LIBCPP_INLINE_VISIBILITY
270 ~__save_flags()
271 {
272 __stream_.flags(__fmtflags_);
273 __stream_.fill(__fill_);
274 }
275};
276
Howard Hinnantc51e1022010-05-11 19:42:16 +0000277_LIBCPP_END_NAMESPACE_STD
278
279#endif // _LIBCPP_IOSFWD