| 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 | |
| 16 | namespace std |
| 17 | { |
| 18 | |
| 19 | template<class charT> struct char_traits; |
| 20 | template<> struct char_traits<char>; |
| 21 | template<> struct char_traits<char8_t>; // C++20 |
| 22 | template<> struct char_traits<char16_t>; |
| 23 | template<> struct char_traits<char32_t>; |
| 24 | template<> struct char_traits<wchar_t>; |
| 25 | |
| 26 | template<class T> class allocator; |
| 27 | |
| 28 | class ios_base; |
| 29 | template <class charT, class traits = char_traits<charT> > class basic_ios; |
| 30 | |
| 31 | template <class charT, class traits = char_traits<charT> > class basic_streambuf; |
| 32 | template <class charT, class traits = char_traits<charT> > class basic_istream; |
| 33 | template <class charT, class traits = char_traits<charT> > class basic_ostream; |
| 34 | template <class charT, class traits = char_traits<charT> > class basic_iostream; |
| 35 | |
| 36 | template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > |
| 37 | class basic_stringbuf; |
| 38 | template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > |
| 39 | class basic_istringstream; |
| 40 | template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > |
| 41 | class basic_ostringstream; |
| 42 | template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > |
| 43 | class basic_stringstream; |
| 44 | |
| 45 | template <class charT, class traits = char_traits<charT> > class basic_filebuf; |
| 46 | template <class charT, class traits = char_traits<charT> > class basic_ifstream; |
| 47 | template <class charT, class traits = char_traits<charT> > class basic_ofstream; |
| 48 | template <class charT, class traits = char_traits<charT> > class basic_fstream; |
| 49 | |
| 50 | template <class charT, class traits = char_traits<charT> > class istreambuf_iterator; |
| 51 | template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator; |
| 52 | |
| 53 | typedef basic_ios<char> ios; |
| 54 | typedef basic_ios<wchar_t> wios; |
| 55 | |
| 56 | typedef basic_streambuf<char> streambuf; |
| 57 | typedef basic_istream<char> istream; |
| 58 | typedef basic_ostream<char> ostream; |
| 59 | typedef basic_iostream<char> iostream; |
| 60 | |
| 61 | typedef basic_stringbuf<char> stringbuf; |
| 62 | typedef basic_istringstream<char> istringstream; |
| 63 | typedef basic_ostringstream<char> ostringstream; |
| 64 | typedef basic_stringstream<char> stringstream; |
| 65 | |
| 66 | typedef basic_filebuf<char> filebuf; |
| 67 | typedef basic_ifstream<char> ifstream; |
| 68 | typedef basic_ofstream<char> ofstream; |
| 69 | typedef basic_fstream<char> fstream; |
| 70 | |
| 71 | typedef basic_streambuf<wchar_t> wstreambuf; |
| 72 | typedef basic_istream<wchar_t> wistream; |
| 73 | typedef basic_ostream<wchar_t> wostream; |
| 74 | typedef basic_iostream<wchar_t> wiostream; |
| 75 | |
| 76 | typedef basic_stringbuf<wchar_t> wstringbuf; |
| 77 | typedef basic_istringstream<wchar_t> wistringstream; |
| 78 | typedef basic_ostringstream<wchar_t> wostringstream; |
| 79 | typedef basic_stringstream<wchar_t> wstringstream; |
| 80 | |
| 81 | typedef basic_filebuf<wchar_t> wfilebuf; |
| 82 | typedef basic_ifstream<wchar_t> wifstream; |
| 83 | typedef basic_ofstream<wchar_t> wofstream; |
| 84 | typedef basic_fstream<wchar_t> wfstream; |
| 85 | |
| 86 | template <class state> class fpos; |
| 87 | using streampos = fpos<char_traits<char>::state_type>; |
| 88 | using wstreampos = fpos<char_traits<wchar_t>::state_type>; |
| 89 | using u8streampos = fpos<char_traits<char8_t>::state_type>; // C++20 |
| 90 | using u16streampos = fpos<char_traits<char16_t>::state_type>; |
| 91 | using 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 | |
| 108 | class _LIBCPP_TYPE_VIS ios_base; |
| 109 | |
| 110 | template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits; |
| 111 | template<> struct char_traits<char>; |
| 112 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 113 | template<> struct char_traits<char8_t>; |
| 114 | #endif |
| 115 | template<> struct char_traits<char16_t>; |
| 116 | template<> struct char_traits<char32_t>; |
| 117 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 118 | template<> struct char_traits<wchar_t>; |
| 119 | #endif |
| 120 | |
| 121 | template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator; |
| 122 | |
| 123 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 124 | class _LIBCPP_TEMPLATE_VIS basic_ios; |
| 125 | |
| 126 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 127 | class _LIBCPP_TEMPLATE_VIS basic_streambuf; |
| 128 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 129 | class _LIBCPP_TEMPLATE_VIS basic_istream; |
| 130 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 131 | class _LIBCPP_TEMPLATE_VIS basic_ostream; |
| 132 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 133 | class _LIBCPP_TEMPLATE_VIS basic_iostream; |
| 134 | |
| 135 | template <class _CharT, class _Traits = char_traits<_CharT>, |
| 136 | class _Allocator = allocator<_CharT> > |
| 137 | class _LIBCPP_TEMPLATE_VIS basic_stringbuf; |
| 138 | template <class _CharT, class _Traits = char_traits<_CharT>, |
| 139 | class _Allocator = allocator<_CharT> > |
| 140 | class _LIBCPP_TEMPLATE_VIS basic_istringstream; |
| 141 | template <class _CharT, class _Traits = char_traits<_CharT>, |
| 142 | class _Allocator = allocator<_CharT> > |
| 143 | class _LIBCPP_TEMPLATE_VIS basic_ostringstream; |
| 144 | template <class _CharT, class _Traits = char_traits<_CharT>, |
| 145 | class _Allocator = allocator<_CharT> > |
| 146 | class _LIBCPP_TEMPLATE_VIS basic_stringstream; |
| 147 | |
| 148 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 149 | class _LIBCPP_TEMPLATE_VIS basic_filebuf; |
| 150 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 151 | class _LIBCPP_TEMPLATE_VIS basic_ifstream; |
| 152 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 153 | class _LIBCPP_TEMPLATE_VIS basic_ofstream; |
| 154 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 155 | class _LIBCPP_TEMPLATE_VIS basic_fstream; |
| 156 | |
| 157 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 158 | class _LIBCPP_TEMPLATE_VIS istreambuf_iterator; |
| 159 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 160 | class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator; |
| 161 | |
| 162 | typedef basic_ios<char> ios; |
| 163 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 164 | typedef basic_ios<wchar_t> wios; |
| 165 | #endif |
| 166 | |
| 167 | typedef basic_streambuf<char> streambuf; |
| 168 | typedef basic_istream<char> istream; |
| 169 | typedef basic_ostream<char> ostream; |
| 170 | typedef basic_iostream<char> iostream; |
| 171 | |
| 172 | typedef basic_stringbuf<char> stringbuf; |
| 173 | typedef basic_istringstream<char> istringstream; |
| 174 | typedef basic_ostringstream<char> ostringstream; |
| 175 | typedef basic_stringstream<char> stringstream; |
| 176 | |
| 177 | typedef basic_filebuf<char> filebuf; |
| 178 | typedef basic_ifstream<char> ifstream; |
| 179 | typedef basic_ofstream<char> ofstream; |
| 180 | typedef basic_fstream<char> fstream; |
| 181 | |
| 182 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 183 | typedef basic_streambuf<wchar_t> wstreambuf; |
| 184 | typedef basic_istream<wchar_t> wistream; |
| 185 | typedef basic_ostream<wchar_t> wostream; |
| 186 | typedef basic_iostream<wchar_t> wiostream; |
| 187 | |
| 188 | typedef basic_stringbuf<wchar_t> wstringbuf; |
| 189 | typedef basic_istringstream<wchar_t> wistringstream; |
| 190 | typedef basic_ostringstream<wchar_t> wostringstream; |
| 191 | typedef basic_stringstream<wchar_t> wstringstream; |
| 192 | |
| 193 | typedef basic_filebuf<wchar_t> wfilebuf; |
| 194 | typedef basic_ifstream<wchar_t> wifstream; |
| 195 | typedef basic_ofstream<wchar_t> wofstream; |
| 196 | typedef basic_fstream<wchar_t> wfstream; |
| 197 | #endif |
| 198 | |
| 199 | template <class _CharT, class _Traits> |
| 200 | class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios; |
| 201 | |
| 202 | template <class _CharT, class _Traits> |
| 203 | class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf; |
| 204 | template <class _CharT, class _Traits> |
| 205 | class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream; |
| 206 | template <class _CharT, class _Traits> |
| 207 | class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream; |
| 208 | template <class _CharT, class _Traits> |
| 209 | class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream; |
| 210 | |
| 211 | template <class _CharT, class _Traits, class _Allocator> |
| 212 | class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf; |
| 213 | template <class _CharT, class _Traits, class _Allocator> |
| 214 | class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream; |
| 215 | template <class _CharT, class _Traits, class _Allocator> |
| 216 | class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream; |
| 217 | template <class _CharT, class _Traits, class _Allocator> |
| 218 | class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream; |
| 219 | |
| 220 | template <class _CharT, class _Traits> |
| 221 | class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf; |
| 222 | template <class _CharT, class _Traits> |
| 223 | class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream; |
| 224 | template <class _CharT, class _Traits> |
| 225 | class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream; |
| 226 | template <class _CharT, class _Traits> |
| 227 | class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream; |
| 228 | |
| 229 | template <class _State> class _LIBCPP_TEMPLATE_VIS fpos; |
| 230 | typedef fpos<mbstate_t> streampos; |
| 231 | typedef fpos<mbstate_t> wstreampos; |
| 232 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 233 | typedef fpos<mbstate_t> u8streampos; |
| 234 | #endif |
| 235 | typedef fpos<mbstate_t> u16streampos; |
| 236 | typedef fpos<mbstate_t> u32streampos; |
| 237 | |
| 238 | #if defined(_NEWLIB_VERSION) |
| 239 | // On newlib, off_t is 'long int' |
| 240 | typedef long int streamoff; // for char_traits in <string> |
| 241 | #else |
| 242 | typedef long long streamoff; // for char_traits in <string> |
| 243 | #endif |
| 244 | |
| 245 | template <class _CharT, // for <stdexcept> |
| 246 | class _Traits = char_traits<_CharT>, |
| 247 | class _Allocator = allocator<_CharT> > |
| 248 | class _LIBCPP_TEMPLATE_VIS basic_string; |
| 249 | typedef basic_string<char, char_traits<char>, allocator<char> > string; |
| 250 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 251 | typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring; |
| 252 | #endif |
| 253 | |
| 254 | template <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 |
| 258 | template <class _Tp, class _Alloc = allocator<_Tp> > |
| 259 | class _LIBCPP_TEMPLATE_VIS vector; |
| 260 | |
| 261 | template <class _CharT, class _Traits> |
| 262 | class __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&); |
| 273 | public: |
| 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 | |