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