]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/bits/ostream_insert.h
arm.c (arm_legitimate_index_p): Add VFP load/store index range case.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / ostream_insert.h
CommitLineData
11202768
PC
1// Helpers for ostream inserters -*- C++ -*-
2
bc2631e0 3// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
11202768
PC
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
11202768
PC
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
11202768
PC
24
25/** @file ostream_insert.h
26 * This is an internal header file, included by other library headers.
27 * You should not attempt to use it directly.
28 */
29
30#ifndef _OSTREAM_INSERT_H
31#define _OSTREAM_INSERT_H 1
32
33#pragma GCC system_header
34
35#include <iosfwd>
fba10f59 36#include <cxxabi-forced.h>
11202768
PC
37
38_GLIBCXX_BEGIN_NAMESPACE(std)
39
40 template<typename _CharT, typename _Traits>
41 inline void
42 __ostream_write(basic_ostream<_CharT, _Traits>& __out,
43 const _CharT* __s, streamsize __n)
44 {
45 typedef basic_ostream<_CharT, _Traits> __ostream_type;
46 typedef typename __ostream_type::ios_base __ios_base;
47
48 const streamsize __put = __out.rdbuf()->sputn(__s, __n);
49 if (__put != __n)
50 __out.setstate(__ios_base::badbit);
51 }
52
53 template<typename _CharT, typename _Traits>
54 inline void
55 __ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n)
56 {
57 typedef basic_ostream<_CharT, _Traits> __ostream_type;
58 typedef typename __ostream_type::ios_base __ios_base;
59
60 const _CharT __c = __out.fill();
61 for (; __n > 0; --__n)
62 {
63 const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c);
64 if (_Traits::eq_int_type(__put, _Traits::eof()))
65 {
66 __out.setstate(__ios_base::badbit);
67 break;
68 }
69 }
70 }
71
72 template<typename _CharT, typename _Traits>
73 basic_ostream<_CharT, _Traits>&
74 __ostream_insert(basic_ostream<_CharT, _Traits>& __out,
75 const _CharT* __s, streamsize __n)
76 {
77 typedef basic_ostream<_CharT, _Traits> __ostream_type;
78 typedef typename __ostream_type::ios_base __ios_base;
79
80 typename __ostream_type::sentry __cerb(__out);
880b527f 81 if (__cerb)
11202768 82 {
bc2631e0 83 __try
11202768
PC
84 {
85 const streamsize __w = __out.width();
86 if (__w > __n)
87 {
88 const bool __left = ((__out.flags()
89 & __ios_base::adjustfield)
90 == __ios_base::left);
91 if (!__left)
92 __ostream_fill(__out, __w - __n);
93 if (__out.good())
94 __ostream_write(__out, __s, __n);
95 if (__left && __out.good())
96 __ostream_fill(__out, __w - __n);
97 }
98 else
99 __ostream_write(__out, __s, __n);
100 __out.width(0);
101 }
bc2631e0 102 __catch(__cxxabiv1::__forced_unwind&)
d05f74f1
JM
103 {
104 __out._M_setstate(__ios_base::badbit);
105 __throw_exception_again;
106 }
bc2631e0 107 __catch(...)
11202768
PC
108 { __out._M_setstate(__ios_base::badbit); }
109 }
110 return __out;
111 }
112
84b31797
PC
113 // Inhibit implicit instantiations for required instantiations,
114 // which are defined via explicit instantiations elsewhere.
115 // NB: This syntax is a GNU extension.
116#if _GLIBCXX_EXTERN_TEMPLATE
117 extern template ostream& __ostream_insert(ostream&, const char*, streamsize);
118
119#ifdef _GLIBCXX_USE_WCHAR_T
120 extern template wostream& __ostream_insert(wostream&, const wchar_t*,
121 streamsize);
122#endif
123#endif
124
11202768
PC
125_GLIBCXX_END_NAMESPACE
126
127#endif /* _OSTREAM_INSERT_H */