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