2021-06-11 09:55:11 -04:00
|
|
|
// -*- 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___ITERATOR_OSTREAMBUF_ITERATOR_H
|
|
|
|
#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
|
|
|
|
|
|
|
|
#include <__config>
|
2024-10-31 02:20:10 +01:00
|
|
|
#include <__cstddef/ptrdiff_t.h>
|
2024-09-16 15:06:20 -04:00
|
|
|
#include <__fwd/ios.h>
|
|
|
|
#include <__fwd/ostream.h>
|
|
|
|
#include <__fwd/streambuf.h>
|
2021-06-11 09:55:11 -04:00
|
|
|
#include <__iterator/iterator.h>
|
2021-06-29 02:32:59 +00:00
|
|
|
#include <__iterator/iterator_traits.h>
|
2024-09-16 15:06:20 -04:00
|
|
|
#include <iosfwd> // for forward declaration of ostreambuf_iterator
|
2021-06-11 09:55:11 -04:00
|
|
|
|
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2022-02-01 20:16:40 -05:00
|
|
|
# pragma GCC system_header
|
2021-06-11 09:55:11 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
|
|
|
template <class _CharT, class _Traits>
|
2025-04-09 23:47:57 +02:00
|
|
|
class ostreambuf_iterator
|
2021-06-11 09:55:11 -04:00
|
|
|
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
|
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
2023-12-18 14:01:33 -05:00
|
|
|
|
2021-06-11 09:55:11 -04:00
|
|
|
public:
|
|
|
|
typedef output_iterator_tag iterator_category;
|
|
|
|
typedef void value_type;
|
2023-02-14 00:56:09 +01:00
|
|
|
#if _LIBCPP_STD_VER >= 20
|
2021-06-11 09:55:11 -04:00
|
|
|
typedef ptrdiff_t difference_type;
|
|
|
|
#else
|
|
|
|
typedef void difference_type;
|
|
|
|
#endif
|
|
|
|
typedef void pointer;
|
|
|
|
typedef void reference;
|
|
|
|
typedef _CharT char_type;
|
|
|
|
typedef _Traits traits_type;
|
|
|
|
typedef basic_streambuf<_CharT, _Traits> streambuf_type;
|
|
|
|
typedef basic_ostream<_CharT, _Traits> ostream_type;
|
|
|
|
|
|
|
|
private:
|
|
|
|
streambuf_type* __sbuf_;
|
2023-12-18 14:01:33 -05:00
|
|
|
|
2021-06-11 09:55:11 -04:00
|
|
|
public:
|
|
|
|
_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator(ostream_type& __s) _NOEXCEPT : __sbuf_(__s.rdbuf()) {}
|
|
|
|
_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT : __sbuf_(__s) {}
|
|
|
|
_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator=(_CharT __c) {
|
|
|
|
if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
|
|
|
|
__sbuf_ = nullptr;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator*() { return *this; }
|
|
|
|
_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++() { return *this; }
|
|
|
|
_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; }
|
|
|
|
_LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; }
|
|
|
|
|
2024-11-18 17:03:29 +08:00
|
|
|
#if _LIBCPP_HAS_LOCALIZATION
|
2021-06-11 09:55:11 -04:00
|
|
|
template <class _Ch, class _Tr>
|
|
|
|
friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output(
|
|
|
|
ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl);
|
2024-11-18 17:03:29 +08:00
|
|
|
#endif // _LIBCPP_HAS_LOCALIZATION
|
2021-06-11 09:55:11 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
|
|
|
#endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
|