blob: 099b60e85d60721ac5183d3c7392bdfa208d0a33 [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>
Louis Dionne89258142021-08-23 15:32:36 -040098#include <__mbstate_t.h>
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>;
Louis Dionne89258142021-08-23 15:32:36 -0400115#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
Marshall Clow8732fed2018-12-11 04:35:44 +0000116template<> struct char_traits<wchar_t>;
Louis Dionne89258142021-08-23 15:32:36 -0400117#endif
Marshall Clow8732fed2018-12-11 04:35:44 +0000118
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000119template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000120
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_ios;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000123
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_streambuf;
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_istream;
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_ostream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000130template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000131 class _LIBCPP_TEMPLATE_VIS basic_iostream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000132
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000133template <class _CharT, class _Traits = char_traits<_CharT>,
134 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000135 class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000136template <class _CharT, class _Traits = char_traits<_CharT>,
137 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000138 class _LIBCPP_TEMPLATE_VIS basic_istringstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000139template <class _CharT, class _Traits = char_traits<_CharT>,
140 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000141 class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000142template <class _CharT, class _Traits = char_traits<_CharT>,
143 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000144 class _LIBCPP_TEMPLATE_VIS basic_stringstream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000145
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_filebuf;
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_ifstream;
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_ofstream;
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 basic_fstream;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000154
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 istreambuf_iterator;
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000157template <class _CharT, class _Traits = char_traits<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000158 class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000159
160typedef basic_ios<char> ios;
Louis Dionne89258142021-08-23 15:32:36 -0400161#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000162typedef basic_ios<wchar_t> wios;
Louis Dionne89258142021-08-23 15:32:36 -0400163#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000164
165typedef basic_streambuf<char> streambuf;
166typedef basic_istream<char> istream;
167typedef basic_ostream<char> ostream;
168typedef basic_iostream<char> iostream;
169
170typedef basic_stringbuf<char> stringbuf;
171typedef basic_istringstream<char> istringstream;
172typedef basic_ostringstream<char> ostringstream;
173typedef basic_stringstream<char> stringstream;
174
175typedef basic_filebuf<char> filebuf;
176typedef basic_ifstream<char> ifstream;
177typedef basic_ofstream<char> ofstream;
178typedef basic_fstream<char> fstream;
179
Louis Dionne89258142021-08-23 15:32:36 -0400180#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000181typedef basic_streambuf<wchar_t> wstreambuf;
182typedef basic_istream<wchar_t> wistream;
183typedef basic_ostream<wchar_t> wostream;
184typedef basic_iostream<wchar_t> wiostream;
185
186typedef basic_stringbuf<wchar_t> wstringbuf;
187typedef basic_istringstream<wchar_t> wistringstream;
188typedef basic_ostringstream<wchar_t> wostringstream;
189typedef basic_stringstream<wchar_t> wstringstream;
190
191typedef basic_filebuf<wchar_t> wfilebuf;
192typedef basic_ifstream<wchar_t> wifstream;
193typedef basic_ofstream<wchar_t> wofstream;
194typedef basic_fstream<wchar_t> wfstream;
Louis Dionne89258142021-08-23 15:32:36 -0400195#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000196
Richard Smith256954d2020-11-11 17:12:18 -0800197template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400198 class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios;
Richard Smith256954d2020-11-11 17:12:18 -0800199
200template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400201 class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf;
Richard Smith256954d2020-11-11 17:12:18 -0800202template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400203 class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream;
Richard Smith256954d2020-11-11 17:12:18 -0800204template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400205 class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream;
Richard Smith256954d2020-11-11 17:12:18 -0800206template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400207 class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream;
Richard Smith256954d2020-11-11 17:12:18 -0800208
209template <class _CharT, class _Traits, class _Allocator>
Louis Dionne89258142021-08-23 15:32:36 -0400210 class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf;
Richard Smith256954d2020-11-11 17:12:18 -0800211template <class _CharT, class _Traits, class _Allocator>
Louis Dionne89258142021-08-23 15:32:36 -0400212 class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream;
Richard Smith256954d2020-11-11 17:12:18 -0800213template <class _CharT, class _Traits, class _Allocator>
Louis Dionne89258142021-08-23 15:32:36 -0400214 class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream;
Richard Smith256954d2020-11-11 17:12:18 -0800215template <class _CharT, class _Traits, class _Allocator>
Louis Dionne89258142021-08-23 15:32:36 -0400216 class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream;
Richard Smith256954d2020-11-11 17:12:18 -0800217
218template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400219 class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf;
Richard Smith256954d2020-11-11 17:12:18 -0800220template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400221 class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream;
Richard Smith256954d2020-11-11 17:12:18 -0800222template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400223 class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream;
Richard Smith256954d2020-11-11 17:12:18 -0800224template <class _CharT, class _Traits>
Louis Dionne89258142021-08-23 15:32:36 -0400225 class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream;
Richard Smith256954d2020-11-11 17:12:18 -0800226
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000227template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
Howard Hinnant155c2af2010-05-24 17:49:41 +0000228typedef fpos<mbstate_t> streampos;
229typedef fpos<mbstate_t> wstreampos;
Arthur O'Dwyerafa5d5f2021-04-18 21:47:08 -0400230#ifndef _LIBCPP_HAS_NO_CHAR8_T
Marshall Clow8732fed2018-12-11 04:35:44 +0000231typedef fpos<mbstate_t> u8streampos;
232#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000233#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnant155c2af2010-05-24 17:49:41 +0000234typedef fpos<mbstate_t> u16streampos;
235typedef fpos<mbstate_t> u32streampos;
Louis Dionne96fc5f52021-09-09 11:25:10 -0400236#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000237
Jonathan Roelofsd3c81f42015-02-03 15:34:17 +0000238#if defined(_NEWLIB_VERSION)
239// On newlib, off_t is 'long int'
240typedef long int streamoff; // for char_traits in <string>
241#else
Howard Hinnantc51e1022010-05-11 19:42:16 +0000242typedef long long streamoff; // for char_traits in <string>
Jonathan Roelofsd3c81f42015-02-03 15:34:17 +0000243#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000244
245template <class _CharT, // for <stdexcept>
246 class _Traits = char_traits<_CharT>,
Howard Hinnant5e9669f2010-09-21 16:04:28 +0000247 class _Allocator = allocator<_CharT> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000248 class _LIBCPP_TEMPLATE_VIS basic_string;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000249typedef basic_string<char, char_traits<char>, allocator<char> > string;
Louis Dionne89258142021-08-23 15:32:36 -0400250#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000251typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
Louis Dionne89258142021-08-23 15:32:36 -0400252#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000253
Richard Smith256954d2020-11-11 17:12:18 -0800254template <class _CharT, class _Traits, class _Allocator>
Louis Dionne89258142021-08-23 15:32:36 -0400255 class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring)) basic_string;
Eric Fiselier876c6862016-02-20 00:19:45 +0000256
257// Include other forward declarations here
258template <class _Tp, class _Alloc = allocator<_Tp> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000259class _LIBCPP_TEMPLATE_VIS vector;
Eric Fiselier876c6862016-02-20 00:19:45 +0000260
Louis Dionne3df65ce2020-10-15 13:27:27 -0400261template <class _CharT, class _Traits>
262class __save_flags
263{
264 typedef basic_ios<_CharT, _Traits> __stream_type;
265 typedef typename __stream_type::fmtflags fmtflags;
266
267 __stream_type& __stream_;
268 fmtflags __fmtflags_;
269 _CharT __fill_;
270
271 __save_flags(const __save_flags&);
272 __save_flags& operator=(const __save_flags&);
273public:
274 _LIBCPP_INLINE_VISIBILITY
275 explicit __save_flags(__stream_type& __stream)
276 : __stream_(__stream),
277 __fmtflags_(__stream.flags()),
278 __fill_(__stream.fill())
279 {}
280 _LIBCPP_INLINE_VISIBILITY
281 ~__save_flags()
282 {
283 __stream_.flags(__fmtflags_);
284 __stream_.fill(__fill_);
285 }
286};
287
Howard Hinnantc51e1022010-05-11 19:42:16 +0000288_LIBCPP_END_NAMESPACE_STD
289
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400290#endif // _LIBCPP_IOSFWD