14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===--------------------------- iomanip ----------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_IOMANIP 124684ddb6SLionel Sambuc#define _LIBCPP_IOMANIP 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc iomanip synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambucnamespace std { 184684ddb6SLionel Sambuc 194684ddb6SLionel Sambuc// types T1, T2, ... are unspecified implementation types 204684ddb6SLionel SambucT1 resetiosflags(ios_base::fmtflags mask); 214684ddb6SLionel SambucT2 setiosflags (ios_base::fmtflags mask); 224684ddb6SLionel SambucT3 setbase(int base); 234684ddb6SLionel Sambuctemplate<charT> T4 setfill(charT c); 244684ddb6SLionel SambucT5 setprecision(int n); 254684ddb6SLionel SambucT6 setw(int n); 264684ddb6SLionel Sambuctemplate <class moneyT> T7 get_money(moneyT& mon, bool intl = false); 274684ddb6SLionel Sambuctemplate <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false); 284684ddb6SLionel Sambuctemplate <class charT> T9 get_time(struct tm* tmb, const charT* fmt); 294684ddb6SLionel Sambuctemplate <class charT> T10 put_time(const struct tm* tmb, const charT* fmt); 304684ddb6SLionel Sambuc 314684ddb6SLionel Sambuctemplate <class charT> 324684ddb6SLionel Sambuc T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14 334684ddb6SLionel Sambuc 344684ddb6SLionel Sambuctemplate <class charT, class traits, class Allocator> 354684ddb6SLionel Sambuc T12 quoted(const basic_string<charT, traits, Allocator>& s, 364684ddb6SLionel Sambuc charT delim=charT('"'), charT escape=charT('\\')); // C++14 374684ddb6SLionel Sambuc 384684ddb6SLionel Sambuctemplate <class charT, class traits, class Allocator> 394684ddb6SLionel Sambuc T13 quoted(basic_string<charT, traits, Allocator>& s, 404684ddb6SLionel Sambuc charT delim=charT('"'), charT escape=charT('\\')); // C++14 414684ddb6SLionel Sambuc 424684ddb6SLionel Sambuc} // std 434684ddb6SLionel Sambuc 444684ddb6SLionel Sambuc*/ 454684ddb6SLionel Sambuc 464684ddb6SLionel Sambuc#include <__config> 474684ddb6SLionel Sambuc#include <istream> 484684ddb6SLionel Sambuc 494684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 504684ddb6SLionel Sambuc#pragma GCC system_header 514684ddb6SLionel Sambuc#endif 524684ddb6SLionel Sambuc 534684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 544684ddb6SLionel Sambuc 554684ddb6SLionel Sambuc// resetiosflags 564684ddb6SLionel Sambuc 574684ddb6SLionel Sambucclass __iom_t1 584684ddb6SLionel Sambuc{ 594684ddb6SLionel Sambuc ios_base::fmtflags __mask_; 604684ddb6SLionel Sambucpublic: 614684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 624684ddb6SLionel Sambuc explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {} 634684ddb6SLionel Sambuc 644684ddb6SLionel Sambuc template <class _CharT, class _Traits> 654684ddb6SLionel Sambuc friend 664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 674684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& 684684ddb6SLionel Sambuc operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x) 694684ddb6SLionel Sambuc { 704684ddb6SLionel Sambuc __is.unsetf(__x.__mask_); 714684ddb6SLionel Sambuc return __is; 724684ddb6SLionel Sambuc } 734684ddb6SLionel Sambuc 744684ddb6SLionel Sambuc template <class _CharT, class _Traits> 754684ddb6SLionel Sambuc friend 764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 774684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 784684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x) 794684ddb6SLionel Sambuc { 804684ddb6SLionel Sambuc __os.unsetf(__x.__mask_); 814684ddb6SLionel Sambuc return __os; 824684ddb6SLionel Sambuc } 834684ddb6SLionel Sambuc}; 844684ddb6SLionel Sambuc 854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 864684ddb6SLionel Sambuc__iom_t1 874684ddb6SLionel Sambucresetiosflags(ios_base::fmtflags __mask) 884684ddb6SLionel Sambuc{ 894684ddb6SLionel Sambuc return __iom_t1(__mask); 904684ddb6SLionel Sambuc} 914684ddb6SLionel Sambuc 924684ddb6SLionel Sambuc// setiosflags 934684ddb6SLionel Sambuc 944684ddb6SLionel Sambucclass __iom_t2 954684ddb6SLionel Sambuc{ 964684ddb6SLionel Sambuc ios_base::fmtflags __mask_; 974684ddb6SLionel Sambucpublic: 984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 994684ddb6SLionel Sambuc explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {} 1004684ddb6SLionel Sambuc 1014684ddb6SLionel Sambuc template <class _CharT, class _Traits> 1024684ddb6SLionel Sambuc friend 1034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1044684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& 1054684ddb6SLionel Sambuc operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x) 1064684ddb6SLionel Sambuc { 1074684ddb6SLionel Sambuc __is.setf(__x.__mask_); 1084684ddb6SLionel Sambuc return __is; 1094684ddb6SLionel Sambuc } 1104684ddb6SLionel Sambuc 1114684ddb6SLionel Sambuc template <class _CharT, class _Traits> 1124684ddb6SLionel Sambuc friend 1134684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1144684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 1154684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x) 1164684ddb6SLionel Sambuc { 1174684ddb6SLionel Sambuc __os.setf(__x.__mask_); 1184684ddb6SLionel Sambuc return __os; 1194684ddb6SLionel Sambuc } 1204684ddb6SLionel Sambuc}; 1214684ddb6SLionel Sambuc 1224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1234684ddb6SLionel Sambuc__iom_t2 1244684ddb6SLionel Sambucsetiosflags(ios_base::fmtflags __mask) 1254684ddb6SLionel Sambuc{ 1264684ddb6SLionel Sambuc return __iom_t2(__mask); 1274684ddb6SLionel Sambuc} 1284684ddb6SLionel Sambuc 1294684ddb6SLionel Sambuc// setbase 1304684ddb6SLionel Sambuc 1314684ddb6SLionel Sambucclass __iom_t3 1324684ddb6SLionel Sambuc{ 1334684ddb6SLionel Sambuc int __base_; 1344684ddb6SLionel Sambucpublic: 1354684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1364684ddb6SLionel Sambuc explicit __iom_t3(int __b) : __base_(__b) {} 1374684ddb6SLionel Sambuc 1384684ddb6SLionel Sambuc template <class _CharT, class _Traits> 1394684ddb6SLionel Sambuc friend 1404684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1414684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& 1424684ddb6SLionel Sambuc operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x) 1434684ddb6SLionel Sambuc { 1444684ddb6SLionel Sambuc __is.setf(__x.__base_ == 8 ? ios_base::oct : 1454684ddb6SLionel Sambuc __x.__base_ == 10 ? ios_base::dec : 1464684ddb6SLionel Sambuc __x.__base_ == 16 ? ios_base::hex : 1474684ddb6SLionel Sambuc ios_base::fmtflags(0), ios_base::basefield); 1484684ddb6SLionel Sambuc return __is; 1494684ddb6SLionel Sambuc } 1504684ddb6SLionel Sambuc 1514684ddb6SLionel Sambuc template <class _CharT, class _Traits> 1524684ddb6SLionel Sambuc friend 1534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1544684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 1554684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x) 1564684ddb6SLionel Sambuc { 1574684ddb6SLionel Sambuc __os.setf(__x.__base_ == 8 ? ios_base::oct : 1584684ddb6SLionel Sambuc __x.__base_ == 10 ? ios_base::dec : 1594684ddb6SLionel Sambuc __x.__base_ == 16 ? ios_base::hex : 1604684ddb6SLionel Sambuc ios_base::fmtflags(0), ios_base::basefield); 1614684ddb6SLionel Sambuc return __os; 1624684ddb6SLionel Sambuc } 1634684ddb6SLionel Sambuc}; 1644684ddb6SLionel Sambuc 1654684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1664684ddb6SLionel Sambuc__iom_t3 1674684ddb6SLionel Sambucsetbase(int __base) 1684684ddb6SLionel Sambuc{ 1694684ddb6SLionel Sambuc return __iom_t3(__base); 1704684ddb6SLionel Sambuc} 1714684ddb6SLionel Sambuc 1724684ddb6SLionel Sambuc// setfill 1734684ddb6SLionel Sambuc 1744684ddb6SLionel Sambuctemplate<class _CharT> 1754684ddb6SLionel Sambucclass __iom_t4 1764684ddb6SLionel Sambuc{ 1774684ddb6SLionel Sambuc _CharT __fill_; 1784684ddb6SLionel Sambucpublic: 1794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1804684ddb6SLionel Sambuc explicit __iom_t4(_CharT __c) : __fill_(__c) {} 1814684ddb6SLionel Sambuc 1824684ddb6SLionel Sambuc template <class _Traits> 1834684ddb6SLionel Sambuc friend 1844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1854684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 1864684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x) 1874684ddb6SLionel Sambuc { 1884684ddb6SLionel Sambuc __os.fill(__x.__fill_); 1894684ddb6SLionel Sambuc return __os; 1904684ddb6SLionel Sambuc } 1914684ddb6SLionel Sambuc}; 1924684ddb6SLionel Sambuc 1934684ddb6SLionel Sambuctemplate<class _CharT> 1944684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1954684ddb6SLionel Sambuc__iom_t4<_CharT> 1964684ddb6SLionel Sambucsetfill(_CharT __c) 1974684ddb6SLionel Sambuc{ 1984684ddb6SLionel Sambuc return __iom_t4<_CharT>(__c); 1994684ddb6SLionel Sambuc} 2004684ddb6SLionel Sambuc 2014684ddb6SLionel Sambuc// setprecision 2024684ddb6SLionel Sambuc 2034684ddb6SLionel Sambucclass __iom_t5 2044684ddb6SLionel Sambuc{ 2054684ddb6SLionel Sambuc int __n_; 2064684ddb6SLionel Sambucpublic: 2074684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2084684ddb6SLionel Sambuc explicit __iom_t5(int __n) : __n_(__n) {} 2094684ddb6SLionel Sambuc 2104684ddb6SLionel Sambuc template <class _CharT, class _Traits> 2114684ddb6SLionel Sambuc friend 2124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2134684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& 2144684ddb6SLionel Sambuc operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x) 2154684ddb6SLionel Sambuc { 2164684ddb6SLionel Sambuc __is.precision(__x.__n_); 2174684ddb6SLionel Sambuc return __is; 2184684ddb6SLionel Sambuc } 2194684ddb6SLionel Sambuc 2204684ddb6SLionel Sambuc template <class _CharT, class _Traits> 2214684ddb6SLionel Sambuc friend 2224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2234684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 2244684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x) 2254684ddb6SLionel Sambuc { 2264684ddb6SLionel Sambuc __os.precision(__x.__n_); 2274684ddb6SLionel Sambuc return __os; 2284684ddb6SLionel Sambuc } 2294684ddb6SLionel Sambuc}; 2304684ddb6SLionel Sambuc 2314684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2324684ddb6SLionel Sambuc__iom_t5 2334684ddb6SLionel Sambucsetprecision(int __n) 2344684ddb6SLionel Sambuc{ 2354684ddb6SLionel Sambuc return __iom_t5(__n); 2364684ddb6SLionel Sambuc} 2374684ddb6SLionel Sambuc 2384684ddb6SLionel Sambuc// setw 2394684ddb6SLionel Sambuc 2404684ddb6SLionel Sambucclass __iom_t6 2414684ddb6SLionel Sambuc{ 2424684ddb6SLionel Sambuc int __n_; 2434684ddb6SLionel Sambucpublic: 2444684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2454684ddb6SLionel Sambuc explicit __iom_t6(int __n) : __n_(__n) {} 2464684ddb6SLionel Sambuc 2474684ddb6SLionel Sambuc template <class _CharT, class _Traits> 2484684ddb6SLionel Sambuc friend 2494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2504684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& 2514684ddb6SLionel Sambuc operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x) 2524684ddb6SLionel Sambuc { 2534684ddb6SLionel Sambuc __is.width(__x.__n_); 2544684ddb6SLionel Sambuc return __is; 2554684ddb6SLionel Sambuc } 2564684ddb6SLionel Sambuc 2574684ddb6SLionel Sambuc template <class _CharT, class _Traits> 2584684ddb6SLionel Sambuc friend 2594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2604684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 2614684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x) 2624684ddb6SLionel Sambuc { 2634684ddb6SLionel Sambuc __os.width(__x.__n_); 2644684ddb6SLionel Sambuc return __os; 2654684ddb6SLionel Sambuc } 2664684ddb6SLionel Sambuc}; 2674684ddb6SLionel Sambuc 2684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2694684ddb6SLionel Sambuc__iom_t6 2704684ddb6SLionel Sambucsetw(int __n) 2714684ddb6SLionel Sambuc{ 2724684ddb6SLionel Sambuc return __iom_t6(__n); 2734684ddb6SLionel Sambuc} 2744684ddb6SLionel Sambuc 2754684ddb6SLionel Sambuc// get_money 2764684ddb6SLionel Sambuc 2774684ddb6SLionel Sambuctemplate <class _MoneyT> class __iom_t7; 2784684ddb6SLionel Sambuc 2794684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _MoneyT> 2804684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 2814684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x); 2824684ddb6SLionel Sambuc 2834684ddb6SLionel Sambuctemplate <class _MoneyT> 2844684ddb6SLionel Sambucclass __iom_t7 2854684ddb6SLionel Sambuc{ 2864684ddb6SLionel Sambuc _MoneyT& __mon_; 2874684ddb6SLionel Sambuc bool __intl_; 2884684ddb6SLionel Sambucpublic: 2894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2904684ddb6SLionel Sambuc __iom_t7(_MoneyT& __mon, bool __intl) 2914684ddb6SLionel Sambuc : __mon_(__mon), __intl_(__intl) {} 2924684ddb6SLionel Sambuc 2934684ddb6SLionel Sambuc template <class _CharT, class _Traits, class _Mp> 2944684ddb6SLionel Sambuc friend 2954684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& 2964684ddb6SLionel Sambuc operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x); 2974684ddb6SLionel Sambuc}; 2984684ddb6SLionel Sambuc 2994684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _MoneyT> 3004684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 3014684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) 3024684ddb6SLionel Sambuc{ 3034684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3044684ddb6SLionel Sambuc try 3054684ddb6SLionel Sambuc { 3064684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3074684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __s(__is); 3084684ddb6SLionel Sambuc if (__s) 3094684ddb6SLionel Sambuc { 3104684ddb6SLionel Sambuc typedef istreambuf_iterator<_CharT, _Traits> _Ip; 3114684ddb6SLionel Sambuc typedef money_get<_CharT, _Ip> _Fp; 3124684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 3134684ddb6SLionel Sambuc const _Fp& __mf = use_facet<_Fp>(__is.getloc()); 3144684ddb6SLionel Sambuc __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_); 3154684ddb6SLionel Sambuc __is.setstate(__err); 3164684ddb6SLionel Sambuc } 3174684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3184684ddb6SLionel Sambuc } 3194684ddb6SLionel Sambuc catch (...) 3204684ddb6SLionel Sambuc { 3214684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 3224684ddb6SLionel Sambuc } 3234684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3244684ddb6SLionel Sambuc return __is; 3254684ddb6SLionel Sambuc} 3264684ddb6SLionel Sambuc 3274684ddb6SLionel Sambuctemplate <class _MoneyT> 3284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3294684ddb6SLionel Sambuc__iom_t7<_MoneyT> 3304684ddb6SLionel Sambucget_money(_MoneyT& __mon, bool __intl = false) 3314684ddb6SLionel Sambuc{ 3324684ddb6SLionel Sambuc return __iom_t7<_MoneyT>(__mon, __intl); 3334684ddb6SLionel Sambuc} 3344684ddb6SLionel Sambuc 3354684ddb6SLionel Sambuc// put_money 3364684ddb6SLionel Sambuc 3374684ddb6SLionel Sambuctemplate <class _MoneyT> class __iom_t8; 3384684ddb6SLionel Sambuc 3394684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _MoneyT> 3404684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 3414684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x); 3424684ddb6SLionel Sambuc 3434684ddb6SLionel Sambuctemplate <class _MoneyT> 3444684ddb6SLionel Sambucclass __iom_t8 3454684ddb6SLionel Sambuc{ 3464684ddb6SLionel Sambuc const _MoneyT& __mon_; 3474684ddb6SLionel Sambuc bool __intl_; 3484684ddb6SLionel Sambucpublic: 3494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3504684ddb6SLionel Sambuc __iom_t8(const _MoneyT& __mon, bool __intl) 3514684ddb6SLionel Sambuc : __mon_(__mon), __intl_(__intl) {} 3524684ddb6SLionel Sambuc 3534684ddb6SLionel Sambuc template <class _CharT, class _Traits, class _Mp> 3544684ddb6SLionel Sambuc friend 3554684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& 3564684ddb6SLionel Sambuc operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x); 3574684ddb6SLionel Sambuc}; 3584684ddb6SLionel Sambuc 3594684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _MoneyT> 3604684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 3614684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) 3624684ddb6SLionel Sambuc{ 3634684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3644684ddb6SLionel Sambuc try 3654684ddb6SLionel Sambuc { 3664684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3674684ddb6SLionel Sambuc typename basic_ostream<_CharT, _Traits>::sentry __s(__os); 3684684ddb6SLionel Sambuc if (__s) 3694684ddb6SLionel Sambuc { 3704684ddb6SLionel Sambuc typedef ostreambuf_iterator<_CharT, _Traits> _Op; 3714684ddb6SLionel Sambuc typedef money_put<_CharT, _Op> _Fp; 3724684ddb6SLionel Sambuc const _Fp& __mf = use_facet<_Fp>(__os.getloc()); 3734684ddb6SLionel Sambuc if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed()) 3744684ddb6SLionel Sambuc __os.setstate(ios_base::badbit); 3754684ddb6SLionel Sambuc } 3764684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3774684ddb6SLionel Sambuc } 3784684ddb6SLionel Sambuc catch (...) 3794684ddb6SLionel Sambuc { 3804684ddb6SLionel Sambuc __os.__set_badbit_and_consider_rethrow(); 3814684ddb6SLionel Sambuc } 3824684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3834684ddb6SLionel Sambuc return __os; 3844684ddb6SLionel Sambuc} 3854684ddb6SLionel Sambuc 3864684ddb6SLionel Sambuctemplate <class _MoneyT> 3874684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3884684ddb6SLionel Sambuc__iom_t8<_MoneyT> 3894684ddb6SLionel Sambucput_money(const _MoneyT& __mon, bool __intl = false) 3904684ddb6SLionel Sambuc{ 3914684ddb6SLionel Sambuc return __iom_t8<_MoneyT>(__mon, __intl); 3924684ddb6SLionel Sambuc} 3934684ddb6SLionel Sambuc 3944684ddb6SLionel Sambuc// get_time 3954684ddb6SLionel Sambuc 3964684ddb6SLionel Sambuctemplate <class _CharT> class __iom_t9; 3974684ddb6SLionel Sambuc 3984684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3994684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 4004684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x); 4014684ddb6SLionel Sambuc 4024684ddb6SLionel Sambuctemplate <class _CharT> 4034684ddb6SLionel Sambucclass __iom_t9 4044684ddb6SLionel Sambuc{ 4054684ddb6SLionel Sambuc tm* __tm_; 4064684ddb6SLionel Sambuc const _CharT* __fmt_; 4074684ddb6SLionel Sambucpublic: 4084684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4094684ddb6SLionel Sambuc __iom_t9(tm* __tm, const _CharT* __fmt) 4104684ddb6SLionel Sambuc : __tm_(__tm), __fmt_(__fmt) {} 4114684ddb6SLionel Sambuc 4124684ddb6SLionel Sambuc template <class _Cp, class _Traits> 4134684ddb6SLionel Sambuc friend 4144684ddb6SLionel Sambuc basic_istream<_Cp, _Traits>& 4154684ddb6SLionel Sambuc operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x); 4164684ddb6SLionel Sambuc}; 4174684ddb6SLionel Sambuc 4184684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4194684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 4204684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) 4214684ddb6SLionel Sambuc{ 4224684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4234684ddb6SLionel Sambuc try 4244684ddb6SLionel Sambuc { 4254684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4264684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __s(__is); 4274684ddb6SLionel Sambuc if (__s) 4284684ddb6SLionel Sambuc { 4294684ddb6SLionel Sambuc typedef istreambuf_iterator<_CharT, _Traits> _Ip; 4304684ddb6SLionel Sambuc typedef time_get<_CharT, _Ip> _Fp; 4314684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 4324684ddb6SLionel Sambuc const _Fp& __tf = use_facet<_Fp>(__is.getloc()); 4334684ddb6SLionel Sambuc __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, 4344684ddb6SLionel Sambuc __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)); 4354684ddb6SLionel Sambuc __is.setstate(__err); 4364684ddb6SLionel Sambuc } 4374684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4384684ddb6SLionel Sambuc } 4394684ddb6SLionel Sambuc catch (...) 4404684ddb6SLionel Sambuc { 4414684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 4424684ddb6SLionel Sambuc } 4434684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4444684ddb6SLionel Sambuc return __is; 4454684ddb6SLionel Sambuc} 4464684ddb6SLionel Sambuc 4474684ddb6SLionel Sambuctemplate <class _CharT> 4484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4494684ddb6SLionel Sambuc__iom_t9<_CharT> 4504684ddb6SLionel Sambucget_time(tm* __tm, const _CharT* __fmt) 4514684ddb6SLionel Sambuc{ 4524684ddb6SLionel Sambuc return __iom_t9<_CharT>(__tm, __fmt); 4534684ddb6SLionel Sambuc} 4544684ddb6SLionel Sambuc 4554684ddb6SLionel Sambuc// put_time 4564684ddb6SLionel Sambuc 4574684ddb6SLionel Sambuctemplate <class _CharT> class __iom_t10; 4584684ddb6SLionel Sambuc 4594684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4604684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 4614684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x); 4624684ddb6SLionel Sambuc 4634684ddb6SLionel Sambuctemplate <class _CharT> 4644684ddb6SLionel Sambucclass __iom_t10 4654684ddb6SLionel Sambuc{ 4664684ddb6SLionel Sambuc const tm* __tm_; 4674684ddb6SLionel Sambuc const _CharT* __fmt_; 4684684ddb6SLionel Sambucpublic: 4694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4704684ddb6SLionel Sambuc __iom_t10(const tm* __tm, const _CharT* __fmt) 4714684ddb6SLionel Sambuc : __tm_(__tm), __fmt_(__fmt) {} 4724684ddb6SLionel Sambuc 4734684ddb6SLionel Sambuc template <class _Cp, class _Traits> 4744684ddb6SLionel Sambuc friend 4754684ddb6SLionel Sambuc basic_ostream<_Cp, _Traits>& 4764684ddb6SLionel Sambuc operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x); 4774684ddb6SLionel Sambuc}; 4784684ddb6SLionel Sambuc 4794684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4804684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 4814684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) 4824684ddb6SLionel Sambuc{ 4834684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4844684ddb6SLionel Sambuc try 4854684ddb6SLionel Sambuc { 4864684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4874684ddb6SLionel Sambuc typename basic_ostream<_CharT, _Traits>::sentry __s(__os); 4884684ddb6SLionel Sambuc if (__s) 4894684ddb6SLionel Sambuc { 4904684ddb6SLionel Sambuc typedef ostreambuf_iterator<_CharT, _Traits> _Op; 4914684ddb6SLionel Sambuc typedef time_put<_CharT, _Op> _Fp; 4924684ddb6SLionel Sambuc const _Fp& __tf = use_facet<_Fp>(__os.getloc()); 4934684ddb6SLionel Sambuc if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_, 4944684ddb6SLionel Sambuc __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed()) 4954684ddb6SLionel Sambuc __os.setstate(ios_base::badbit); 4964684ddb6SLionel Sambuc } 4974684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4984684ddb6SLionel Sambuc } 4994684ddb6SLionel Sambuc catch (...) 5004684ddb6SLionel Sambuc { 5014684ddb6SLionel Sambuc __os.__set_badbit_and_consider_rethrow(); 5024684ddb6SLionel Sambuc } 5034684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5044684ddb6SLionel Sambuc return __os; 5054684ddb6SLionel Sambuc} 5064684ddb6SLionel Sambuc 5074684ddb6SLionel Sambuctemplate <class _CharT> 5084684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5094684ddb6SLionel Sambuc__iom_t10<_CharT> 5104684ddb6SLionel Sambucput_time(const tm* __tm, const _CharT* __fmt) 5114684ddb6SLionel Sambuc{ 5124684ddb6SLionel Sambuc return __iom_t10<_CharT>(__tm, __fmt); 5134684ddb6SLionel Sambuc} 5144684ddb6SLionel Sambuc 5154684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 5164684ddb6SLionel Sambuc 5174684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _ForwardIterator> 5184684ddb6SLionel Sambucstd::basic_ostream<_CharT, _Traits> & 5194684ddb6SLionel Sambuc__quoted_output ( basic_ostream<_CharT, _Traits> &__os, 5204684ddb6SLionel Sambuc _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) 5214684ddb6SLionel Sambuc{ 522*0a6a1f1dSLionel Sambuc _VSTD::basic_string<_CharT, _Traits> __str; 523*0a6a1f1dSLionel Sambuc __str.push_back(__delim); 5244684ddb6SLionel Sambuc for ( ; __first != __last; ++ __first ) 5254684ddb6SLionel Sambuc { 5264684ddb6SLionel Sambuc if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) 527*0a6a1f1dSLionel Sambuc __str.push_back(__escape); 528*0a6a1f1dSLionel Sambuc __str.push_back(*__first); 5294684ddb6SLionel Sambuc } 530*0a6a1f1dSLionel Sambuc __str.push_back(__delim); 531*0a6a1f1dSLionel Sambuc return __put_character_sequence(__os, __str.data(), __str.size()); 5324684ddb6SLionel Sambuc} 5334684ddb6SLionel Sambuc 5344684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _String> 5354684ddb6SLionel Sambucbasic_istream<_CharT, _Traits> & 5364684ddb6SLionel Sambuc__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape ) 5374684ddb6SLionel Sambuc{ 5384684ddb6SLionel Sambuc __string.clear (); 5394684ddb6SLionel Sambuc _CharT __c; 5404684ddb6SLionel Sambuc __is >> __c; 5414684ddb6SLionel Sambuc if ( __is.fail ()) 5424684ddb6SLionel Sambuc return __is; 5434684ddb6SLionel Sambuc 5444684ddb6SLionel Sambuc if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string 5454684ddb6SLionel Sambuc { 5464684ddb6SLionel Sambuc __is.unget (); 5474684ddb6SLionel Sambuc __is >> __string; 5484684ddb6SLionel Sambuc return __is; 5494684ddb6SLionel Sambuc } 5504684ddb6SLionel Sambuc 5514684ddb6SLionel Sambuc __save_flags<_CharT, _Traits> sf(__is); 5524684ddb6SLionel Sambuc noskipws (__is); 5534684ddb6SLionel Sambuc while (true) 5544684ddb6SLionel Sambuc { 5554684ddb6SLionel Sambuc __is >> __c; 5564684ddb6SLionel Sambuc if ( __is.fail ()) 5574684ddb6SLionel Sambuc break; 5584684ddb6SLionel Sambuc if (_Traits::eq (__c, __escape)) 5594684ddb6SLionel Sambuc { 5604684ddb6SLionel Sambuc __is >> __c; 5614684ddb6SLionel Sambuc if ( __is.fail ()) 5624684ddb6SLionel Sambuc break; 5634684ddb6SLionel Sambuc } 5644684ddb6SLionel Sambuc else if (_Traits::eq (__c, __delim)) 5654684ddb6SLionel Sambuc break; 5664684ddb6SLionel Sambuc __string.push_back ( __c ); 5674684ddb6SLionel Sambuc } 5684684ddb6SLionel Sambuc return __is; 5694684ddb6SLionel Sambuc} 5704684ddb6SLionel Sambuc 5714684ddb6SLionel Sambuc 5724684ddb6SLionel Sambuctemplate <class _CharT, class _Iter, class _Traits=char_traits<_CharT>> 5734684ddb6SLionel Sambucstruct __quoted_output_proxy 5744684ddb6SLionel Sambuc{ 5754684ddb6SLionel Sambuc _Iter __first; 5764684ddb6SLionel Sambuc _Iter __last; 5774684ddb6SLionel Sambuc _CharT __delim; 5784684ddb6SLionel Sambuc _CharT __escape; 5794684ddb6SLionel Sambuc 5804684ddb6SLionel Sambuc __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) 5814684ddb6SLionel Sambuc : __first(__f), __last(__l), __delim(__d), __escape(__e) {} 5824684ddb6SLionel Sambuc // This would be a nice place for a string_ref 5834684ddb6SLionel Sambuc}; 5844684ddb6SLionel Sambuc 5854684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Iter> 5864684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& operator<<( 5874684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& __os, 5884684ddb6SLionel Sambuc const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy) 5894684ddb6SLionel Sambuc{ 5904684ddb6SLionel Sambuc return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape); 5914684ddb6SLionel Sambuc} 5924684ddb6SLionel Sambuc 5934684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 5944684ddb6SLionel Sambucstruct __quoted_proxy 5954684ddb6SLionel Sambuc{ 5964684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> &__string; 5974684ddb6SLionel Sambuc _CharT __delim; 5984684ddb6SLionel Sambuc _CharT __escape; 5994684ddb6SLionel Sambuc 6004684ddb6SLionel Sambuc __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e) 6014684ddb6SLionel Sambuc : __string(__s), __delim(__d), __escape(__e) {} 6024684ddb6SLionel Sambuc}; 6034684ddb6SLionel Sambuc 6044684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 6054684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY 6064684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& operator<<( 6074684ddb6SLionel Sambuc basic_ostream<_CharT, _Traits>& __os, 6084684ddb6SLionel Sambuc const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) 6094684ddb6SLionel Sambuc{ 6104684ddb6SLionel Sambuc return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape); 6114684ddb6SLionel Sambuc} 6124684ddb6SLionel Sambuc 6134684ddb6SLionel Sambuc// extractor for non-const basic_string& proxies 6144684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 6154684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY 6164684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& operator>>( 6174684ddb6SLionel Sambuc basic_istream<_CharT, _Traits>& __is, 6184684ddb6SLionel Sambuc const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) 6194684ddb6SLionel Sambuc{ 6204684ddb6SLionel Sambuc return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape ); 6214684ddb6SLionel Sambuc} 6224684ddb6SLionel Sambuc 6234684ddb6SLionel Sambuc 6244684ddb6SLionel Sambuctemplate <class _CharT> 6254684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY 6264684ddb6SLionel Sambuc__quoted_output_proxy<_CharT, const _CharT *> 6274684ddb6SLionel Sambucquoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\')) 6284684ddb6SLionel Sambuc{ 6294684ddb6SLionel Sambuc const _CharT *__end = __s; 6304684ddb6SLionel Sambuc while ( *__end ) ++__end; 6314684ddb6SLionel Sambuc return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); 6324684ddb6SLionel Sambuc} 6334684ddb6SLionel Sambuc 6344684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 6354684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY 6364684ddb6SLionel Sambuc__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> 6374684ddb6SLionel Sambucquoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) 6384684ddb6SLionel Sambuc{ 6394684ddb6SLionel Sambuc return __quoted_output_proxy<_CharT, 6404684ddb6SLionel Sambuc typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> 6414684ddb6SLionel Sambuc ( __s.cbegin(), __s.cend (), __delim, __escape ); 6424684ddb6SLionel Sambuc} 6434684ddb6SLionel Sambuc 6444684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 6454684ddb6SLionel Sambuc__quoted_proxy<_CharT, _Traits, _Allocator> 6464684ddb6SLionel Sambucquoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) 6474684ddb6SLionel Sambuc{ 6484684ddb6SLionel Sambuc return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); 6494684ddb6SLionel Sambuc} 6504684ddb6SLionel Sambuc#endif 6514684ddb6SLionel Sambuc 6524684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 6534684ddb6SLionel Sambuc 6544684ddb6SLionel Sambuc#endif // _LIBCPP_IOMANIP 655