95 {}) {
97 const auto quote = options.
quote;
98 if (field.
len < 2 || field[0] != quote) {
99 return writer.write_all(field);
100 }
101
105 size_t ni = 1;
106 size_t written = 0;
107
108 if (0 < data.len) {
109 curChar = data[0];
110 if (1 < data.len) {
111 nextChar = data[1];
112 }
113 }
114
115 char c;
118 ni++;
119 curChar = nextChar;
120 if (ni < data.len) {
121 nextChar = data[ni];
122 }
123 else {
125 }
126 };
127
128 if (c != quote) {
129 if (
auto r =
writer.write(c); r.is_error()) {
130 return r.error();
131 }
132 ++written;
133 continue;
134 }
135
136 if (nextChar == quote) {
138 ni += 1;
139 curChar = nextChar;
140 if (ni < data.len) {
141 nextChar = data[ni];
142 }
143 else {
145 }
146 };
147
148 if (
auto r =
writer.write(c); r.is_error()) {
149 return r.error();
150 }
151 ++written;
152 }
153 }
154
156 }
constexpr auto nullopt
Placeholder value for an empty Optional.
io::Writer< csv::impl::Writer< WI > > writer(io::Writer< WI > &underlying, Options opts={})
Creates a CSV writer which will encode the data before writing it out.
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...
#define mtdefer
Defer statement that will mtdefer execution until the scope is left, at which point the code will run...
Success< void > success()
Creates a successful void Result object.
Slice< const char > unquote_quoted(Slice< const char > data, Options opts)
Represents a value that may or may not exist (an "Optional" value) Similar concept to std::optional,...
bool copy_if_present(std::remove_const_t< T > &out) const noexcept
Copies a value to a reference output destination if a value is present Designed to be used by simple ...