1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
10 #define _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
14 #if _LIBCPP_HAS_LOCALIZATION
18 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
22 _LIBCPP_BEGIN_NAMESPACE_STD
24 template <class _CharT
, class _OutputIterator
>
25 _LIBCPP_HIDE_FROM_ABI _OutputIterator
__pad_and_output(
26 _OutputIterator __s
, const _CharT
* __ob
, const _CharT
* __op
, const _CharT
* __oe
, ios_base
& __iob
, _CharT __fl
) {
27 streamsize __sz
= __oe
- __ob
;
28 streamsize __ns
= __iob
.width();
33 for (; __ob
< __op
; ++__ob
, ++__s
)
35 for (; __ns
; --__ns
, ++__s
)
37 for (; __ob
< __oe
; ++__ob
, ++__s
)
43 template <class _CharT
, class _Traits
>
44 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator
<_CharT
, _Traits
> __pad_and_output(
45 ostreambuf_iterator
<_CharT
, _Traits
> __s
,
51 if (__s
.__sbuf_
== nullptr)
53 streamsize __sz
= __oe
- __ob
;
54 streamsize __ns
= __iob
.width();
59 streamsize __np
= __op
- __ob
;
61 if (__s
.__sbuf_
->sputn(__ob
, __np
) != __np
) {
62 __s
.__sbuf_
= nullptr;
67 basic_string
<_CharT
, _Traits
> __sp(__ns
, __fl
);
68 if (__s
.__sbuf_
->sputn(__sp
.data(), __ns
) != __ns
) {
69 __s
.__sbuf_
= nullptr;
75 if (__s
.__sbuf_
->sputn(__op
, __np
) != __np
) {
76 __s
.__sbuf_
= nullptr;
84 _LIBCPP_END_NAMESPACE_STD
86 #endif // _LIBCPP_HAS_LOCALIZATION
88 #endif // _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H