Warning: This file is not a C or C++ file. It does not have highlighting.
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___ITERATOR_OSTREAMBUF_ITERATOR_H |
11 | #define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H |
12 | |
13 | #include <__config> |
14 | #include <__cstddef/ptrdiff_t.h> |
15 | #include <__fwd/ios.h> |
16 | #include <__fwd/ostream.h> |
17 | #include <__fwd/streambuf.h> |
18 | #include <__iterator/iterator.h> |
19 | #include <__iterator/iterator_traits.h> |
20 | #include <iosfwd> // for forward declaration of ostreambuf_iterator |
21 | |
22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
23 | # pragma GCC system_header |
24 | #endif |
25 | |
26 | _LIBCPP_BEGIN_NAMESPACE_STD |
27 | |
28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
29 | template <class _CharT, class _Traits> |
30 | class ostreambuf_iterator |
31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
32 | : public iterator<output_iterator_tag, void, void, void, void> |
33 | #endif |
34 | { |
35 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
36 | |
37 | public: |
38 | typedef output_iterator_tag iterator_category; |
39 | typedef void value_type; |
40 | #if _LIBCPP_STD_VER >= 20 |
41 | typedef ptrdiff_t difference_type; |
42 | #else |
43 | typedef void difference_type; |
44 | #endif |
45 | typedef void pointer; |
46 | typedef void reference; |
47 | typedef _CharT char_type; |
48 | typedef _Traits traits_type; |
49 | typedef basic_streambuf<_CharT, _Traits> streambuf_type; |
50 | typedef basic_ostream<_CharT, _Traits> ostream_type; |
51 | |
52 | private: |
53 | streambuf_type* __sbuf_; |
54 | |
55 | public: |
56 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator(ostream_type& __s) _NOEXCEPT : __sbuf_(__s.rdbuf()) {} |
57 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT : __sbuf_(__s) {} |
58 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator=(_CharT __c) { |
59 | if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof())) |
60 | __sbuf_ = nullptr; |
61 | return *this; |
62 | } |
63 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator*() { return *this; } |
64 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++() { return *this; } |
65 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; } |
66 | _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; } |
67 | |
68 | #if _LIBCPP_HAS_LOCALIZATION |
69 | template <class _Ch, class _Tr> |
70 | friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output( |
71 | ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl); |
72 | #endif // _LIBCPP_HAS_LOCALIZATION |
73 | }; |
74 | |
75 | _LIBCPP_END_NAMESPACE_STD |
76 | |
77 | #endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H |
78 |
Warning: This file is not a C or C++ file. It does not have highlighting.