This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

123
cppdraft/quoted/manip.md Normal file
View File

@@ -0,0 +1,123 @@
[quoted.manip]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#quoted.manip)
### 31.7.9 Quoted manipulators [quoted.manip]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7614)
[*Note [1](#note-1)*:
Quoted manipulators provide string insertion and extraction of quoted strings (for example, XML and CSV formats)[.](#1.sentence-1)
Quoted manipulators are useful in ensuring that the content of a string with embedded spaces remains unchanged if inserted and then extracted via stream I/O[.](#1.sentence-2)
— *end note*]
[🔗](#lib:quoted)
`template<class charT>
unspecified quoted(const charT* s, charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits, class Allocator>
unspecified quoted(const basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits>
unspecified quoted(basic_string_view<charT, traits> s,
charT delim = charT('"'), charT escape = charT('\\'));
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7632)
*Returns*: An object of unspecified type such that if out is an instance
of basic_ostream with member type char_type the same ascharT and with member type traits_type, which in the second and third
forms is the same as traits, then the expressionout << quoted(s, delim, escape) behaves as a [formatted output function](ostream.formatted.reqmts "31.7.6.3.1Common requirements[ostream.formatted.reqmts]") of out[.](#2.sentence-1)
This forms a character sequence seq, initially
consisting of the following elements:
- [(2.1)](#2.1)
delim[.](#2.1.sentence-1)
- [(2.2)](#2.2)
Each character in s[.](#2.2.sentence-1)
If the character to be output is equal toescape or delim, as determined by traits_type::eq, first
output escape[.](#2.2.sentence-2)
- [(2.3)](#2.3)
delim[.](#2.3.sentence-1)
Let x be the number of elements initially in seq[.](#2.sentence-3)
Then padding is determined for seq as described
in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1Common requirements"), seq is inserted as if by callingout.rdbuf()->sputn(seq, n), where n is the larger ofout.width() and x, and out.width(0) is called[.](#2.sentence-4)
The expression out << quoted(s, delim, escape) has typebasic_ostream<charT, traits>& and value out[.](#2.sentence-5)
[🔗](#lib:quoted_)
`template<class charT, class traits, class Allocator>
unspecified quoted(basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\'));
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7666)
*Returns*: An object of unspecified type such that:
- [(3.1)](#3.1)
If in is an instance of basic_istream with member typeschar_type and traits_type the same as charT and traits, respectively, then the expressionin >> quoted(s, delim, escape) behaves as if it extracts the following
characters from in usingoperator>>(basic_istream<charT, traits>&, charT&) ([[istream.extractors]](istream.extractors "31.7.5.3.3basic_­istream::operator>>"))
which may throw ios_base::failure ([[ios.failure]](ios.failure "31.5.2.2.1Class ios_­base::failure")):
* [(3.1.1)](#3.1.1)
If the first character extracted is equal to delim, as
determined by traits_type::eq, then:
+
[(3.1.1.1)](#3.1.1.1)
Turn off the skipws flag[.](#3.1.1.1.sentence-1)
+
[(3.1.1.2)](#3.1.1.2)
s.clear()
+
[(3.1.1.3)](#3.1.1.3)
Until an unescaped delim character is reached or !in,
extract characters from in and append them to s, except that
if an escape is reached, ignore it and append the next character tos[.](#3.1.1.3.sentence-1)
+
[(3.1.1.4)](#3.1.1.4)
Discard the final delim character[.](#3.1.1.4.sentence-1)
+
[(3.1.1.5)](#3.1.1.5)
Restore the skipws flag to its original value[.](#3.1.1.5.sentence-1)
* [(3.1.2)](#3.1.2)
Otherwise, in >> s[.](#3.1.2.sentence-1)
- [(3.2)](#3.2)
If out is an instance of basic_ostream with member typeschar_type and traits_type the same as charT andtraits, respectively, then the expressionout << quoted(s, delim, escape) behaves as specified for theconst basic_string<charT, traits, Allocator>& overload of thequoted function[.](#3.2.sentence-1)
- [(3.3)](#3.3)
The expression in >> quoted(s, delim, escape) has typebasic_istream<charT, traits>& and value in[.](#3.3.sentence-1)
- [(3.4)](#3.4)
The expression out << quoted(s, delim, escape) has typebasic_ostream<charT, traits>& and value out[.](#3.4.sentence-1)