From Jason Turner

[quoted.manip]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmprvh2_uqt/{from.md → to.md} +74 -0
tmp/tmprvh2_uqt/{from.md → to.md} RENAMED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Quoted manipulators <a id="quoted.manip">[[quoted.manip]]</a>
2
+
3
+ Quoted manipulators provide string insertion and extraction of quoted
4
+ strings (for example, XML and CSV formats). Quoted manipulators are
5
+ useful in ensuring that the content of a string with embedded spaces
6
+ remains unchanged if inserted and then extracted via stream I/O.
7
+
8
+ ``` cpp
9
+ template <class charT>
10
+ unspecified quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\'));
11
+ template <class charT, class traits, class Allocator>
12
+ unspecified quoted(const basic_string<charT, traits, Allocator>& s,
13
+ charT delim=charT('"'), charT escape=charT('\\'));
14
+ ```
15
+
16
+ *Returns:* An object of unspecified type such that if `out` is an
17
+ instance of `basic_ostream` with member type `char_type` the same as
18
+ `charT` and with member type `traits_type`, which in the second form is
19
+ the same as `traits`, then the expression
20
+ `out << quoted(s, delim, escape)` behaves as a formatted output
21
+ function ([[ostream.formatted.reqmts]]) of `out`. This forms a
22
+ character sequence `seq`, initially consisting of the following
23
+ elements:
24
+
25
+ - `delim`.
26
+ - Each character in `s`. If the character to be output is equal to
27
+ `escape` or `delim`, as determined by `traits_type::eq`, first output
28
+ `escape`.
29
+ - `delim`.
30
+
31
+ Let `x` be the number of elements initially in `seq`. Then padding is
32
+ determined for `seq` as described in  [[ostream.formatted.reqmts]],
33
+ `seq` is inserted as if by calling `out.rdbuf()->sputn(seq, n)`, where
34
+ `n` is the larger of `out.width()` and `x`, and `out.width(0)` is
35
+ called. The expression `out << quoted(s, delim, escape)` shall have type
36
+ `basic_ostream<charT, traits>&` and value `out`.
37
+
38
+ ``` cpp
39
+ template <class charT, class traits, class Allocator>
40
+ unspecified quoted(basic_string<charT, traits, Allocator>& s,
41
+ charT delim=charT('"'), charT escape=charT('\\'));
42
+ ```
43
+
44
+ *Returns:* An object of unspecified type such that:
45
+
46
+ - If `in` is an instance of `basic_istream` with member types
47
+ `char_type` and `traits_type` the same as `charT` and `traits`,
48
+ respectively, then the expression `in >> quoted(s, delim, escape)`
49
+ behaves as if it extracts the following characters from `in` using
50
+ `basic_istream::operator>>` ([[istream::extractors]]) which may throw
51
+ `ios_base::failure` ([[ios::failure]]):
52
+ - If the first character extracted is equal to `delim`, as determined
53
+ by `traits_type::eq`, then:
54
+ - Turn off the `skipws` flag.
55
+ - `s.clear()`
56
+ - Until an unescaped `delim` character is reached or `!in`, extract
57
+ characters from `in` and append them to `s`, except that if an
58
+ `escape` is reached, ignore it and append the next character to
59
+ `s`.
60
+ - Discard the final `delim` character.
61
+ - Restore the `skipws` flag to its original value.
62
+ - Otherwise, `in >> s`.
63
+ - If `out` is an instance of `basic_ostream` with member types
64
+ `char_type` and `traits_type` the same as `charT` and `traits`,
65
+ respectively, then the expression `out << quoted(s, delim, escape)`
66
+ behaves as specified for the
67
+ `const basic_string<charT, traits, Allocator>&` overload of the
68
+ `quoted` function.
69
+
70
+ The expression `in >> quoted(s, delim, escape)` shall have type
71
+ `basic_istream<charT, traits>&` and value `in`. The expression
72
+ `out << quoted(s, delim, escape)` shall have type
73
+ `basic_ostream<charT, traits>&` and value `out`.
74
+