diff options
author | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2022-03-05 02:15:20 +0300 |
---|---|---|
committer | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2022-03-05 07:06:28 +0300 |
commit | 9d93b97222de6c3b0ace44fdd65dfc1fb59200e3 (patch) | |
tree | ed268f18eec348c1f9683a89f8734243ebfd898e /libcxx | |
parent | 564c7fa1b7999bf7a6f8c50579535c71cca73e02 (diff) |
[libc++] [NFC] Formatting preliminary to D120135 (std::quoted)
This just gets some of the non-functional formatting out of the way
before the meat of D120135.
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/include/__string | 13 | ||||
-rw-r--r-- | libcxx/include/iomanip | 99 |
2 files changed, 50 insertions, 62 deletions
diff --git a/libcxx/include/__string b/libcxx/include/__string index bde5e5c1907c..8dc8f2fcd6b8 100644 --- a/libcxx/include/__string +++ b/libcxx/include/__string @@ -1155,17 +1155,16 @@ size_t __do_string_hash(_Ptr __p, _Ptr __e) return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type)); } -template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> > +template <class _CharT, class _Iter, class _Traits = char_traits<_CharT> > struct __quoted_output_proxy { - _Iter __first; - _Iter __last; - _CharT __delim; - _CharT __escape; + _Iter __first_; + _Iter __last_; + _CharT __delim_; + _CharT __escape_; explicit __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) - : __first(__f), __last(__l), __delim(__d), __escape(__e) {} - // This would be a nice place for a string_ref + : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {} }; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip index e3b4e8d7f3c3..ca88ab495988 100644 --- a/libcxx/include/iomanip +++ b/libcxx/include/iomanip @@ -514,15 +514,14 @@ put_time(const tm* __tm, const _CharT* __fmt) } template <class _CharT, class _Traits, class _ForwardIterator> -basic_ostream<_CharT, _Traits> & -__quoted_output ( basic_ostream<_CharT, _Traits> &__os, - _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) +basic_ostream<_CharT, _Traits>& +__quoted_output(basic_ostream<_CharT, _Traits>& __os, + _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape) { basic_string<_CharT, _Traits> __str; __str.push_back(__delim); - for ( ; __first != __last; ++ __first ) - { - if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) + for (; __first != __last; ++__first) { + if (_Traits::eq(*__first, __escape) || _Traits::eq(*__first, __delim)) __str.push_back(__escape); __str.push_back(*__first); } @@ -531,69 +530,65 @@ __quoted_output ( basic_ostream<_CharT, _Traits> &__os, } template <class _CharT, class _Traits, class _String> -basic_istream<_CharT, _Traits> & -__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape ) +basic_istream<_CharT, _Traits>& +__quoted_input(basic_istream<_CharT, _Traits>& __is, _String& __string, _CharT __delim, _CharT __escape) { - __string.clear (); + __string.clear(); _CharT __c; __is >> __c; - if ( __is.fail ()) + if (__is.fail()) return __is; - if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string - { - __is.unget (); + if (!_Traits::eq(__c, __delim)) { + // no delimiter, read the whole string + __is.unget(); __is >> __string; return __is; } __save_flags<_CharT, _Traits> sf(__is); std::noskipws(__is); - while (true) - { + while (true) { __is >> __c; - if ( __is.fail ()) + if (__is.fail()) break; - if (_Traits::eq (__c, __escape)) - { + if (_Traits::eq(__c, __escape)) { __is >> __c; - if ( __is.fail ()) + if (__is.fail()) break; - } - else if (_Traits::eq (__c, __delim)) + } else if (_Traits::eq(__c, __delim)) break; - __string.push_back ( __c ); - } + __string.push_back(__c); + } return __is; } - template <class _CharT, class _Traits, class _Iter> basic_ostream<_CharT, _Traits>& operator<<( basic_ostream<_CharT, _Traits>& __os, - const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy) + const __quoted_output_proxy<_CharT, _Iter, _Traits>& __proxy) { - return std::__quoted_output(__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape); + return std::__quoted_output(__os, __proxy.__first_, __proxy.__last_, __proxy.__delim_, __proxy.__escape_); } template <class _CharT, class _Traits, class _Allocator> struct __quoted_proxy { - basic_string<_CharT, _Traits, _Allocator> &__string; - _CharT __delim; - _CharT __escape; + basic_string<_CharT, _Traits, _Allocator>& __string_; + _CharT __delim_; + _CharT __escape_; - explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e) - : __string(__s), __delim(__d), __escape(__e) {} + explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __d, _CharT __e) + : __string_(__s), __delim_(__d), __escape_(__e) {} }; template <class _CharT, class _Traits, class _Allocator> _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<( basic_ostream<_CharT, _Traits>& __os, - const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) + const __quoted_proxy<_CharT, _Traits, _Allocator>& __proxy) { - return std::__quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape); + return std::__quoted_output(__os, __proxy.__string_.cbegin(), __proxy.__string_.cend(), __proxy.__delim_, __proxy.__escape_); } // extractor for non-const basic_string& proxies @@ -601,48 +596,43 @@ template <class _CharT, class _Traits, class _Allocator> _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& operator>>( basic_istream<_CharT, _Traits>& __is, - const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) + const __quoted_proxy<_CharT, _Traits, _Allocator>& __proxy) { - return std::__quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape ); + return std::__quoted_input(__is, __proxy.__string_, __proxy.__delim_, __proxy.__escape_); } - template <class _CharT> _LIBCPP_INLINE_VISIBILITY __quoted_output_proxy<_CharT, const _CharT *> -quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\')) +quoted(const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { const _CharT *__end = __s; - while ( *__end ) ++__end; - return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); + while (*__end) ++__end; + return __quoted_output_proxy<_CharT, const _CharT *>(__s, __end, __delim, __escape); } - template <class _CharT, class _Traits, class _Allocator> _LIBCPP_INLINE_VISIBILITY __quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> -__quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +__quoted(const basic_string <_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { - return __quoted_output_proxy<_CharT, - typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> - ( __s.cbegin(), __s.cend (), __delim, __escape ); + return __quoted_output_proxy<_CharT, typename basic_string<_CharT, _Traits, _Allocator>::const_iterator>(__s.cbegin(), __s.cend(), __delim, __escape); } template <class _CharT, class _Traits, class _Allocator> _LIBCPP_INLINE_VISIBILITY __quoted_proxy<_CharT, _Traits, _Allocator> -__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +__quoted(basic_string <_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { - return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); + return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); } - #if _LIBCPP_STD_VER > 11 template <class _CharT, class _Traits, class _Allocator> _LIBCPP_INLINE_VISIBILITY -__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> -quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +__quoted_output_proxy<_CharT, typename basic_string<_CharT, _Traits, _Allocator>::const_iterator> +quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { return std::__quoted(__s, __delim, __escape); } @@ -650,20 +640,19 @@ quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = template <class _CharT, class _Traits, class _Allocator> _LIBCPP_INLINE_VISIBILITY __quoted_proxy<_CharT, _Traits, _Allocator> -quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { return std::__quoted(__s, __delim, __escape); } template <class _CharT, class _Traits> __quoted_output_proxy<_CharT, const _CharT *, _Traits> -quoted (basic_string_view <_CharT, _Traits> __sv, - _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { - return __quoted_output_proxy<_CharT, const _CharT *, _Traits> - ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape ); + return __quoted_output_proxy<_CharT, const _CharT *, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape); } -#endif + +#endif // _LIBCPP_STD_VER > 11 _LIBCPP_END_NAMESPACE_STD |