Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:54

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
0010 #define _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
0011 
0012 #include <__config>
0013 
0014 #if _LIBCPP_HAS_LOCALIZATION
0015 
0016 #  include <ios>
0017 
0018 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #    pragma GCC system_header
0020 #  endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 template <class _CharT, class _OutputIterator>
0025 _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output(
0026     _OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) {
0027   streamsize __sz = __oe - __ob;
0028   streamsize __ns = __iob.width();
0029   if (__ns > __sz)
0030     __ns -= __sz;
0031   else
0032     __ns = 0;
0033   for (; __ob < __op; ++__ob, ++__s)
0034     *__s = *__ob;
0035   for (; __ns; --__ns, ++__s)
0036     *__s = __fl;
0037   for (; __ob < __oe; ++__ob, ++__s)
0038     *__s = *__ob;
0039   __iob.width(0);
0040   return __s;
0041 }
0042 
0043 template <class _CharT, class _Traits>
0044 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output(
0045     ostreambuf_iterator<_CharT, _Traits> __s,
0046     const _CharT* __ob,
0047     const _CharT* __op,
0048     const _CharT* __oe,
0049     ios_base& __iob,
0050     _CharT __fl) {
0051   if (__s.__sbuf_ == nullptr)
0052     return __s;
0053   streamsize __sz = __oe - __ob;
0054   streamsize __ns = __iob.width();
0055   if (__ns > __sz)
0056     __ns -= __sz;
0057   else
0058     __ns = 0;
0059   streamsize __np = __op - __ob;
0060   if (__np > 0) {
0061     if (__s.__sbuf_->sputn(__ob, __np) != __np) {
0062       __s.__sbuf_ = nullptr;
0063       return __s;
0064     }
0065   }
0066   if (__ns > 0) {
0067     basic_string<_CharT, _Traits> __sp(__ns, __fl);
0068     if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) {
0069       __s.__sbuf_ = nullptr;
0070       return __s;
0071     }
0072   }
0073   __np = __oe - __op;
0074   if (__np > 0) {
0075     if (__s.__sbuf_->sputn(__op, __np) != __np) {
0076       __s.__sbuf_ = nullptr;
0077       return __s;
0078     }
0079   }
0080   __iob.width(0);
0081   return __s;
0082 }
0083 
0084 _LIBCPP_END_NAMESPACE_STD
0085 
0086 #endif // _LIBCPP_HAS_LOCALIZATION
0087 
0088 #endif // _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H