chromium/third_party/libc++/src/include/ios

// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_IOS
#define _LIBCPP_IOS

/*
    ios synopsis

#include <iosfwd>

namespace std
{

typedef OFF_T streamoff;
typedef SZ_T streamsize;
template <class stateT> class fpos;

class ios_base
{
public:
    class failure;

    typedef T1 fmtflags;
    static constexpr fmtflags boolalpha;
    static constexpr fmtflags dec;
    static constexpr fmtflags fixed;
    static constexpr fmtflags hex;
    static constexpr fmtflags internal;
    static constexpr fmtflags left;
    static constexpr fmtflags oct;
    static constexpr fmtflags right;
    static constexpr fmtflags scientific;
    static constexpr fmtflags showbase;
    static constexpr fmtflags showpoint;
    static constexpr fmtflags showpos;
    static constexpr fmtflags skipws;
    static constexpr fmtflags unitbuf;
    static constexpr fmtflags uppercase;
    static constexpr fmtflags adjustfield;
    static constexpr fmtflags basefield;
    static constexpr fmtflags floatfield;

    typedef T2 iostate;
    static constexpr iostate badbit;
    static constexpr iostate eofbit;
    static constexpr iostate failbit;
    static constexpr iostate goodbit;

    typedef T3 openmode;
    static constexpr openmode app;
    static constexpr openmode ate;
    static constexpr openmode binary;
    static constexpr openmode in;
    static constexpr openmode noreplace; // since C++23
    static constexpr openmode out;
    static constexpr openmode trunc;

    typedef T4 seekdir;
    static constexpr seekdir beg;
    static constexpr seekdir cur;
    static constexpr seekdir end;

    class Init;

    // 27.5.2.2 fmtflags state:
    fmtflags flags() const;
    fmtflags flags(fmtflags fmtfl);
    fmtflags setf(fmtflags fmtfl);
    fmtflags setf(fmtflags fmtfl, fmtflags mask);
    void unsetf(fmtflags mask);

    streamsize precision() const;
    streamsize precision(streamsize prec);
    streamsize width() const;
    streamsize width(streamsize wide);

    // 27.5.2.3 locales:
    locale imbue(const locale& loc);
    locale getloc() const;

    // 27.5.2.5 storage:
    static int xalloc();
    long& iword(int index);
    void*& pword(int index);

    // destructor
    virtual ~ios_base();

    // 27.5.2.6 callbacks;
    enum event { erase_event, imbue_event, copyfmt_event };
    typedef void (*event_callback)(event, ios_base&, int index);
    void register_callback(event_callback fn, int index);

    ios_base(const ios_base&) = delete;
    ios_base& operator=(const ios_base&) = delete;

    static bool sync_with_stdio(bool sync = true);

protected:
    ios_base();
};

template <class charT, class traits = char_traits<charT> >
class basic_ios
    : public ios_base
{
public:
    // types:
    typedef charT char_type;
    typedef typename traits::int_type int_type;  // removed in C++17
    typedef typename traits::pos_type pos_type;  // removed in C++17
    typedef typename traits::off_type off_type;  // removed in C++17
    typedef traits traits_type;

    operator unspecified-bool-type() const;
    bool operator!() const;
    iostate rdstate() const;
    void clear(iostate state = goodbit);
    void setstate(iostate state);
    bool good() const;
    bool eof() const;
    bool fail() const;
    bool bad() const;

    iostate exceptions() const;
    void exceptions(iostate except);

    // 27.5.4.1 Constructor/destructor:
    explicit basic_ios(basic_streambuf<charT,traits>* sb);
    virtual ~basic_ios();

    // 27.5.4.2 Members:
    basic_ostream<charT,traits>* tie() const;
    basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);

    basic_streambuf<charT,traits>* rdbuf() const;
    basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);

    basic_ios& copyfmt(const basic_ios& rhs);

    char_type fill() const;
    char_type fill(char_type ch);

    locale imbue(const locale& loc);

    char narrow(char_type c, char dfault) const;
    char_type widen(char c) const;

    basic_ios(const basic_ios& ) = delete;
    basic_ios& operator=(const basic_ios&) = delete;

protected:
    basic_ios();
    void init(basic_streambuf<charT,traits>* sb);
    void move(basic_ios& rhs);
    void swap(basic_ios& rhs) noexcept;
    void set_rdbuf(basic_streambuf<charT, traits>* sb);
};

// 27.5.5, manipulators:
ios_base& boolalpha (ios_base& str);
ios_base& noboolalpha(ios_base& str);
ios_base& showbase (ios_base& str);
ios_base& noshowbase (ios_base& str);
ios_base& showpoint (ios_base& str);
ios_base& noshowpoint(ios_base& str);
ios_base& showpos (ios_base& str);
ios_base& noshowpos (ios_base& str);
ios_base& skipws (ios_base& str);
ios_base& noskipws (ios_base& str);
ios_base& uppercase (ios_base& str);
ios_base& nouppercase(ios_base& str);
ios_base& unitbuf (ios_base& str);
ios_base& nounitbuf (ios_base& str);

// 27.5.5.2 adjustfield:
ios_base& internal (ios_base& str);
ios_base& left (ios_base& str);
ios_base& right (ios_base& str);

// 27.5.5.3 basefield:
ios_base& dec (ios_base& str);
ios_base& hex (ios_base& str);
ios_base& oct (ios_base& str);

// 27.5.5.4 floatfield:
ios_base& fixed (ios_base& str);
ios_base& scientific (ios_base& str);
ios_base& hexfloat (ios_base& str);
ios_base& defaultfloat(ios_base& str);

// 27.5.5.5 error reporting:
enum class io_errc
{
    stream = 1
};

concept_map ErrorCodeEnum<io_errc> { };
error_code make_error_code(io_errc e) noexcept;
error_condition make_error_condition(io_errc e) noexcept;
storage-class-specifier const error_category& iostream_category() noexcept;

}  // std

*/

#include <__config>

#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)

#  include <__fwd/ios.h>
#  include <__ios/fpos.h>
#  include <__locale>
#  include <__memory/addressof.h>
#  include <__system_error/error_category.h>
#  include <__system_error/error_code.h>
#  include <__system_error/error_condition.h>
#  include <__system_error/system_error.h>
#  include <__utility/swap.h>
#  include <__verbose_abort>
#  include <version>

// standard-mandated includes

// [ios.syn]
#  include <iosfwd>

#  if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
#    include <__atomic/atomic.h> // for __xindex_
#  endif

#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#    pragma GCC system_header
#  endif

_LIBCPP_PUSH_MACROS
#  include <__undef_macros>

_LIBCPP_BEGIN_NAMESPACE_STD

streamsize;

class _LIBCPP_EXPORTED_FROM_ABI ios_base {};

// enum class io_errc
_LIBCPP_DECLARE_STRONG_ENUM(io_errc){};
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG()

template <>
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};

#  ifdef _LIBCPP_CXX03_LANG
template <>
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};
#  endif

_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;

inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(io_errc __e) _NOEXCEPT {}

inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(io_errc __e) _NOEXCEPT {}

class _LIBCPP_EXPORTED_FROM_ABI ios_base::failure : public system_error {};

_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) {}

class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init {};

// fmtflags

inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::flags() const {}

inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::flags(fmtflags __fmtfl) {}

inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::setf(fmtflags __fmtfl) {}

inline _LIBCPP_HIDE_FROM_ABI void ios_base::unsetf(fmtflags __mask) {}

inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::setf(fmtflags __fmtfl, fmtflags __mask) {}

// precision

inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::precision() const {}

inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::precision(streamsize __prec) {}

// width

inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::width() const {}

inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::width(streamsize __wide) {}

// iostate

inline _LIBCPP_HIDE_FROM_ABI ios_base::iostate ios_base::rdstate() const {}

inline _LIBCPP_HIDE_FROM_ABI void ios_base::setstate(iostate __state) {}

inline _LIBCPP_HIDE_FROM_ABI bool ios_base::good() const {}

inline _LIBCPP_HIDE_FROM_ABI bool ios_base::eof() const {}

inline _LIBCPP_HIDE_FROM_ABI bool ios_base::fail() const {}

inline _LIBCPP_HIDE_FROM_ABI bool ios_base::bad() const {}

inline _LIBCPP_HIDE_FROM_ABI ios_base::iostate ios_base::exceptions() const {}

inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) {}

template <class _Traits>
// Attribute 'packed' is used to keep the layout compatible with the previous
// definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS.
struct _LIBCPP_PACKED _FillHelper {};

template <class _Traits>
struct _LIBCPP_PACKED _SentinelValueFill {};

template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base {};

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type, traits_type>* __sb) {}

template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>::~basic_ios() {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie() const {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf() const {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI char basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c) const {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) {}

template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) {}

extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;

#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
#  endif

_LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& noboolalpha(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& showbase(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& noshowbase(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& showpoint(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& noshowpoint(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& showpos(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& noshowpos(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& skipws(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& noskipws(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& uppercase(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& nouppercase(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& unitbuf(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& nounitbuf(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& internal(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& left(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& right(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& dec(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& hex(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& oct(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& fixed(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& scientific(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& hexfloat(ios_base& __str) {}

_LIBCPP_HIDE_FROM_ABI inline ios_base& defaultfloat(ios_base& __str) {}

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
#  include <atomic>
#  include <concepts>
#  include <cstddef>
#  include <cstdlib>
#  include <cstring>
#  include <initializer_list>
#  include <limits>
#  include <mutex>
#  include <new>
#  include <stdexcept>
#  include <system_error>
#  include <type_traits>
#  include <typeinfo>
#endif

#endif // _LIBCPP_IOS