113 {}) {
115 const auto quote = options.
quote;
116 if (field.
len < 2 || field[0] != quote) {
117 return writer.write_all(field);
118 }
119
123 size_t ni = 1;
124 size_t written = 0;
125
126 if (0 < data.len) {
127 curChar = data[0];
128 if (1 < data.len) {
129 nextChar = data[1];
130 }
131 }
132
133 char c;
136 ni++;
137 curChar = nextChar;
138 if (ni < data.len) {
139 nextChar = data[ni];
140 }
141 else {
143 }
144 };
145
146 if (c != quote) {
147 if (
auto r =
writer.write(c); r.is_error()) {
148 return r.error();
149 }
150 ++written;
151 continue;
152 }
153
154 if (nextChar == quote) {
156 ni += 1;
157 curChar = nextChar;
158 if (ni < data.len) {
159 nextChar = data[ni];
160 }
161 else {
163 }
164 };
165
166 if (
auto r =
writer.write(c); r.is_error()) {
167 return r.error();
168 }
169 ++written;
170 }
171 }
172
174 }
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 ...