1 | // -*- C++ -*- |
2 | //===----------------------------------------------------------------------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP_IOMANIP |
11 | #define _LIBCPP_IOMANIP |
12 | |
13 | /* |
14 | iomanip synopsis |
15 | |
16 | namespace std { |
17 | |
18 | // types T1, T2, ... are unspecified implementation types |
19 | T1 resetiosflags(ios_base::fmtflags mask); |
20 | T2 setiosflags (ios_base::fmtflags mask); |
21 | T3 setbase(int base); |
22 | template<charT> T4 setfill(charT c); |
23 | T5 setprecision(int n); |
24 | T6 setw(int n); |
25 | template <class moneyT> T7 get_money(moneyT& mon, bool intl = false); |
26 | template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false); |
27 | template <class charT> T9 get_time(struct tm* tmb, const charT* fmt); |
28 | template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt); |
29 | |
30 | template <class charT> |
31 | T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14 |
32 | |
33 | template <class charT, class traits, class Allocator> |
34 | T12 quoted(const basic_string<charT, traits, Allocator>& s, |
35 | charT delim=charT('"'), charT escape=charT('\\')); // C++14 |
36 | |
37 | template <class charT, class traits, class Allocator> |
38 | T13 quoted(basic_string<charT, traits, Allocator>& s, |
39 | charT delim=charT('"'), charT escape=charT('\\')); // C++14 |
40 | |
41 | } // std |
42 | |
43 | */ |
44 | |
45 | #include <__config> |
46 | #include <istream> |
47 | #include <version> |
48 | |
49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
50 | # pragma GCC system_header |
51 | #endif |
52 | |
53 | _LIBCPP_BEGIN_NAMESPACE_STD |
54 | |
55 | // resetiosflags |
56 | |
57 | class __iom_t1 { |
58 | ios_base::fmtflags __mask_; |
59 | |
60 | public: |
61 | _LIBCPP_HIDE_FROM_ABI explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {} |
62 | |
63 | template <class _CharT, class _Traits> |
64 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
65 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x) { |
66 | __is.unsetf(__x.__mask_); |
67 | return __is; |
68 | } |
69 | |
70 | template <class _CharT, class _Traits> |
71 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
72 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x) { |
73 | __os.unsetf(__x.__mask_); |
74 | return __os; |
75 | } |
76 | }; |
77 | |
78 | inline _LIBCPP_HIDE_FROM_ABI __iom_t1 resetiosflags(ios_base::fmtflags __mask) { return __iom_t1(__mask); } |
79 | |
80 | // setiosflags |
81 | |
82 | class __iom_t2 { |
83 | ios_base::fmtflags __mask_; |
84 | |
85 | public: |
86 | _LIBCPP_HIDE_FROM_ABI explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {} |
87 | |
88 | template <class _CharT, class _Traits> |
89 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
90 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x) { |
91 | __is.setf(__x.__mask_); |
92 | return __is; |
93 | } |
94 | |
95 | template <class _CharT, class _Traits> |
96 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
97 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x) { |
98 | __os.setf(__x.__mask_); |
99 | return __os; |
100 | } |
101 | }; |
102 | |
103 | inline _LIBCPP_HIDE_FROM_ABI __iom_t2 setiosflags(ios_base::fmtflags __mask) { return __iom_t2(__mask); } |
104 | |
105 | // setbase |
106 | |
107 | class __iom_t3 { |
108 | int __base_; |
109 | |
110 | public: |
111 | _LIBCPP_HIDE_FROM_ABI explicit __iom_t3(int __b) : __base_(__b) {} |
112 | |
113 | template <class _CharT, class _Traits> |
114 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
115 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x) { |
116 | __is.setf(__x.__base_ == 8 ? ios_base::oct |
117 | : __x.__base_ == 10 ? ios_base::dec |
118 | : __x.__base_ == 16 ? ios_base::hex |
119 | : ios_base::fmtflags(0), |
120 | ios_base::basefield); |
121 | return __is; |
122 | } |
123 | |
124 | template <class _CharT, class _Traits> |
125 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
126 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x) { |
127 | __os.setf(__x.__base_ == 8 ? ios_base::oct |
128 | : __x.__base_ == 10 ? ios_base::dec |
129 | : __x.__base_ == 16 ? ios_base::hex |
130 | : ios_base::fmtflags(0), |
131 | ios_base::basefield); |
132 | return __os; |
133 | } |
134 | }; |
135 | |
136 | inline _LIBCPP_HIDE_FROM_ABI __iom_t3 setbase(int __base) { return __iom_t3(__base); } |
137 | |
138 | // setfill |
139 | |
140 | template <class _CharT> |
141 | class __iom_t4 { |
142 | _CharT __fill_; |
143 | |
144 | public: |
145 | _LIBCPP_HIDE_FROM_ABI explicit __iom_t4(_CharT __c) : __fill_(__c) {} |
146 | |
147 | template <class _Traits> |
148 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
149 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x) { |
150 | __os.fill(__x.__fill_); |
151 | return __os; |
152 | } |
153 | }; |
154 | |
155 | template <class _CharT> |
156 | inline _LIBCPP_HIDE_FROM_ABI __iom_t4<_CharT> setfill(_CharT __c) { |
157 | return __iom_t4<_CharT>(__c); |
158 | } |
159 | |
160 | // setprecision |
161 | |
162 | class __iom_t5 { |
163 | int __n_; |
164 | |
165 | public: |
166 | _LIBCPP_HIDE_FROM_ABI explicit __iom_t5(int __n) : __n_(__n) {} |
167 | |
168 | template <class _CharT, class _Traits> |
169 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
170 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x) { |
171 | __is.precision(__x.__n_); |
172 | return __is; |
173 | } |
174 | |
175 | template <class _CharT, class _Traits> |
176 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
177 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x) { |
178 | __os.precision(__x.__n_); |
179 | return __os; |
180 | } |
181 | }; |
182 | |
183 | inline _LIBCPP_HIDE_FROM_ABI __iom_t5 setprecision(int __n) { return __iom_t5(__n); } |
184 | |
185 | // setw |
186 | |
187 | class __iom_t6 { |
188 | int __n_; |
189 | |
190 | public: |
191 | _LIBCPP_HIDE_FROM_ABI explicit __iom_t6(int __n) : __n_(__n) {} |
192 | |
193 | template <class _CharT, class _Traits> |
194 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
195 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x) { |
196 | __is.width(__x.__n_); |
197 | return __is; |
198 | } |
199 | |
200 | template <class _CharT, class _Traits> |
201 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
202 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x) { |
203 | __os.width(__x.__n_); |
204 | return __os; |
205 | } |
206 | }; |
207 | |
208 | inline _LIBCPP_HIDE_FROM_ABI __iom_t6 setw(int __n) { return __iom_t6(__n); } |
209 | |
210 | // get_money |
211 | |
212 | template <class _MoneyT> |
213 | class __iom_t7; |
214 | |
215 | template <class _CharT, class _Traits, class _MoneyT> |
216 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
217 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x); |
218 | |
219 | template <class _MoneyT> |
220 | class __iom_t7 { |
221 | _MoneyT& __mon_; |
222 | bool __intl_; |
223 | |
224 | public: |
225 | _LIBCPP_HIDE_FROM_ABI __iom_t7(_MoneyT& __mon, bool __intl) : __mon_(__mon), __intl_(__intl) {} |
226 | |
227 | template <class _CharT, class _Traits, class _Mp> |
228 | friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x); |
229 | }; |
230 | |
231 | template <class _CharT, class _Traits, class _MoneyT> |
232 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
233 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { |
234 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
235 | try { |
236 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
237 | typename basic_istream<_CharT, _Traits>::sentry __s(__is); |
238 | if (__s) { |
239 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
240 | typedef money_get<_CharT, _Ip> _Fp; |
241 | ios_base::iostate __err = ios_base::goodbit; |
242 | const _Fp& __mf = std::use_facet<_Fp>(__is.getloc()); |
243 | __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_); |
244 | __is.setstate(__err); |
245 | } |
246 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
247 | } catch (...) { |
248 | __is.__set_badbit_and_consider_rethrow(); |
249 | } |
250 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
251 | return __is; |
252 | } |
253 | |
254 | template <class _MoneyT> |
255 | inline _LIBCPP_HIDE_FROM_ABI __iom_t7<_MoneyT> get_money(_MoneyT& __mon, bool __intl = false) { |
256 | return __iom_t7<_MoneyT>(__mon, __intl); |
257 | } |
258 | |
259 | // put_money |
260 | |
261 | template <class _MoneyT> |
262 | class __iom_t8; |
263 | |
264 | template <class _CharT, class _Traits, class _MoneyT> |
265 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
266 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x); |
267 | |
268 | template <class _MoneyT> |
269 | class __iom_t8 { |
270 | const _MoneyT& __mon_; |
271 | bool __intl_; |
272 | |
273 | public: |
274 | _LIBCPP_HIDE_FROM_ABI __iom_t8(const _MoneyT& __mon, bool __intl) : __mon_(__mon), __intl_(__intl) {} |
275 | |
276 | template <class _CharT, class _Traits, class _Mp> |
277 | friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x); |
278 | }; |
279 | |
280 | template <class _CharT, class _Traits, class _MoneyT> |
281 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
282 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { |
283 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
284 | try { |
285 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
286 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
287 | if (__s) { |
288 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
289 | typedef money_put<_CharT, _Op> _Fp; |
290 | const _Fp& __mf = std::use_facet<_Fp>(__os.getloc()); |
291 | if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed()) |
292 | __os.setstate(ios_base::badbit); |
293 | } |
294 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
295 | } catch (...) { |
296 | __os.__set_badbit_and_consider_rethrow(); |
297 | } |
298 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
299 | return __os; |
300 | } |
301 | |
302 | template <class _MoneyT> |
303 | inline _LIBCPP_HIDE_FROM_ABI __iom_t8<_MoneyT> put_money(const _MoneyT& __mon, bool __intl = false) { |
304 | return __iom_t8<_MoneyT>(__mon, __intl); |
305 | } |
306 | |
307 | // get_time |
308 | |
309 | template <class _CharT> |
310 | class __iom_t9; |
311 | |
312 | template <class _CharT, class _Traits> |
313 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
314 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x); |
315 | |
316 | template <class _CharT> |
317 | class __iom_t9 { |
318 | tm* __tm_; |
319 | const _CharT* __fmt_; |
320 | |
321 | public: |
322 | _LIBCPP_HIDE_FROM_ABI __iom_t9(tm* __tm, const _CharT* __fmt) : __tm_(__tm), __fmt_(__fmt) {} |
323 | |
324 | template <class _Cp, class _Traits> |
325 | friend basic_istream<_Cp, _Traits>& operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x); |
326 | }; |
327 | |
328 | template <class _CharT, class _Traits> |
329 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
330 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { |
331 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
332 | try { |
333 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
334 | typename basic_istream<_CharT, _Traits>::sentry __s(__is); |
335 | if (__s) { |
336 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
337 | typedef time_get<_CharT, _Ip> _Fp; |
338 | ios_base::iostate __err = ios_base::goodbit; |
339 | const _Fp& __tf = std::use_facet<_Fp>(__is.getloc()); |
340 | __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)); |
341 | __is.setstate(__err); |
342 | } |
343 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
344 | } catch (...) { |
345 | __is.__set_badbit_and_consider_rethrow(); |
346 | } |
347 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
348 | return __is; |
349 | } |
350 | |
351 | template <class _CharT> |
352 | inline _LIBCPP_HIDE_FROM_ABI __iom_t9<_CharT> get_time(tm* __tm, const _CharT* __fmt) { |
353 | return __iom_t9<_CharT>(__tm, __fmt); |
354 | } |
355 | |
356 | // put_time |
357 | |
358 | template <class _CharT> |
359 | class __iom_t10; |
360 | |
361 | template <class _CharT, class _Traits> |
362 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
363 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x); |
364 | |
365 | template <class _CharT> |
366 | class __iom_t10 { |
367 | const tm* __tm_; |
368 | const _CharT* __fmt_; |
369 | |
370 | public: |
371 | _LIBCPP_HIDE_FROM_ABI __iom_t10(const tm* __tm, const _CharT* __fmt) : __tm_(__tm), __fmt_(__fmt) {} |
372 | |
373 | template <class _Cp, class _Traits> |
374 | friend basic_ostream<_Cp, _Traits>& operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x); |
375 | }; |
376 | |
377 | template <class _CharT, class _Traits> |
378 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
379 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { |
380 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
381 | try { |
382 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
383 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
384 | if (__s) { |
385 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
386 | typedef time_put<_CharT, _Op> _Fp; |
387 | const _Fp& __tf = std::use_facet<_Fp>(__os.getloc()); |
388 | if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)) |
389 | .failed()) |
390 | __os.setstate(ios_base::badbit); |
391 | } |
392 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
393 | } catch (...) { |
394 | __os.__set_badbit_and_consider_rethrow(); |
395 | } |
396 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
397 | return __os; |
398 | } |
399 | |
400 | template <class _CharT> |
401 | inline _LIBCPP_HIDE_FROM_ABI __iom_t10<_CharT> put_time(const tm* __tm, const _CharT* __fmt) { |
402 | return __iom_t10<_CharT>(__tm, __fmt); |
403 | } |
404 | |
405 | template <class _CharT, class _Traits> |
406 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& __quoted_output( |
407 | basic_ostream<_CharT, _Traits>& __os, |
408 | const _CharT* __first, |
409 | const _CharT* __last, |
410 | _CharT __delim, |
411 | _CharT __escape) { |
412 | basic_string<_CharT, _Traits> __str; |
413 | __str.push_back(__delim); |
414 | for (; __first != __last; ++__first) { |
415 | if (_Traits::eq(*__first, __escape) || _Traits::eq(*__first, __delim)) |
416 | __str.push_back(__escape); |
417 | __str.push_back(*__first); |
418 | } |
419 | __str.push_back(__delim); |
420 | return std::__put_character_sequence(__os, __str.data(), __str.size()); |
421 | } |
422 | |
423 | template <class _CharT, class _Traits, class _String> |
424 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
425 | __quoted_input(basic_istream<_CharT, _Traits>& __is, _String& __string, _CharT __delim, _CharT __escape) { |
426 | __string.clear(); |
427 | _CharT __c; |
428 | __is >> __c; |
429 | if (__is.fail()) |
430 | return __is; |
431 | |
432 | if (!_Traits::eq(__c, __delim)) { |
433 | // no delimiter, read the whole string |
434 | __is.unget(); |
435 | __is >> __string; |
436 | return __is; |
437 | } |
438 | |
439 | __save_flags<_CharT, _Traits> __sf(__is); |
440 | std::noskipws(str&: __is); |
441 | while (true) { |
442 | __is >> __c; |
443 | if (__is.fail()) |
444 | break; |
445 | if (_Traits::eq(__c, __escape)) { |
446 | __is >> __c; |
447 | if (__is.fail()) |
448 | break; |
449 | } else if (_Traits::eq(__c, __delim)) |
450 | break; |
451 | __string.push_back(__c); |
452 | } |
453 | return __is; |
454 | } |
455 | |
456 | template <class _CharT, class _Traits> |
457 | struct _LIBCPP_HIDDEN __quoted_output_proxy { |
458 | const _CharT* __first_; |
459 | const _CharT* __last_; |
460 | _CharT __delim_; |
461 | _CharT __escape_; |
462 | |
463 | _LIBCPP_HIDE_FROM_ABI explicit __quoted_output_proxy(const _CharT* __f, const _CharT* __l, _CharT __d, _CharT __e) |
464 | : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {} |
465 | |
466 | template <class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value, int> = 0> |
467 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>& |
468 | operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) { |
469 | return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_); |
470 | } |
471 | }; |
472 | |
473 | template <class _CharT, class _Traits, class _Allocator> |
474 | struct _LIBCPP_HIDDEN __quoted_proxy { |
475 | basic_string<_CharT, _Traits, _Allocator>& __string_; |
476 | _CharT __delim_; |
477 | _CharT __escape_; |
478 | |
479 | _LIBCPP_HIDE_FROM_ABI explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __d, _CharT __e) |
480 | : __string_(__s), __delim_(__d), __escape_(__e) {} |
481 | |
482 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
483 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __quoted_proxy& __p) { |
484 | return std::__quoted_output( |
485 | __os, __p.__string_.data(), __p.__string_.data() + __p.__string_.size(), __p.__delim_, __p.__escape_); |
486 | } |
487 | |
488 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
489 | operator>>(basic_istream<_CharT, _Traits>& __is, const __quoted_proxy& __p) { |
490 | return std::__quoted_input(__is, __p.__string_, __p.__delim_, __p.__escape_); |
491 | } |
492 | }; |
493 | |
494 | template <class _CharT, class _Traits, class _Allocator> |
495 | _LIBCPP_HIDE_FROM_ABI __quoted_output_proxy<_CharT, _Traits> |
496 | __quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, |
497 | _CharT __delim = _CharT('"'), |
498 | _CharT __escape = _CharT('\\')) { |
499 | return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape); |
500 | } |
501 | |
502 | template <class _CharT, class _Traits, class _Allocator> |
503 | _LIBCPP_HIDE_FROM_ABI __quoted_proxy<_CharT, _Traits, _Allocator> |
504 | __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { |
505 | return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); |
506 | } |
507 | |
508 | #if _LIBCPP_STD_VER >= 14 |
509 | |
510 | template <class _CharT> |
511 | _LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { |
512 | const _CharT* __end = __s; |
513 | while (*__end) |
514 | ++__end; |
515 | return __quoted_output_proxy<_CharT, void>(__s, __end, __delim, __escape); |
516 | } |
517 | |
518 | template <class _CharT, class _Traits, class _Allocator> |
519 | _LIBCPP_HIDE_FROM_ABI auto |
520 | quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, |
521 | _CharT __delim = _CharT('"'), |
522 | _CharT __escape = _CharT('\\')) { |
523 | return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape); |
524 | } |
525 | |
526 | template <class _CharT, class _Traits, class _Allocator> |
527 | _LIBCPP_HIDE_FROM_ABI auto |
528 | quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { |
529 | return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); |
530 | } |
531 | |
532 | template <class _CharT, class _Traits> |
533 | _LIBCPP_HIDE_FROM_ABI auto |
534 | quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { |
535 | return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape); |
536 | } |
537 | |
538 | #endif // _LIBCPP_STD_VER >= 14 |
539 | |
540 | _LIBCPP_END_NAMESPACE_STD |
541 | |
542 | #endif // _LIBCPP_IOMANIP |
543 | |