";
232 |
233 | if (!warningMessage.empty()) {
234 | myfile << "
";
235 | myfile.write(warningMessage.begin(), warningMessage.size());
236 | myfile << "
\n";
237 | }
238 |
239 | //** here we put the code
240 | myfile << "
\n";
241 |
242 |
243 | const char *c = begin;
244 | unsigned int line = 1;
245 | const char *bufferStart = c;
246 |
247 | auto tags_it = tags.cbegin();
248 | const char *next_start = tags_it != tags.cend() ? (begin + tags_it->pos) : end;
249 | const char *next_end = end;
250 | const char *next = next_start;
251 |
252 |
253 | auto flush = [&]() {
254 | if (bufferStart != c)
255 | myfile.write(bufferStart, c - bufferStart);
256 | bufferStart = c;
257 | };
258 |
259 | myfile << "" << 1 << " | ";
260 |
261 | std::deque stack;
262 |
263 |
264 | while (true) {
265 | if (c == next) {
266 | flush();
267 | while (!stack.empty() && c >= next_end) {
268 | const Tag *top = stack.back();
269 | stack.pop_back();
270 | top->close(myfile);
271 | next_end = end;
272 | if (!stack.empty()) {
273 | top = stack.back();
274 | next_end = begin + top->pos + top->len;
275 | }
276 | }
277 | if (c >= end)
278 | break;
279 | assert(c < end);
280 | while (c == next_start && tags_it != tags.cend()) {
281 | assert(c == begin + tags_it->pos);
282 | tags_it->open(myfile);
283 | if (tags_it->len) {
284 | stack.push_back(&(*tags_it));
285 | next_end = c + tags_it->len;
286 | }
287 |
288 | tags_it++;
289 | next_start = tags_it != tags.cend() ? (begin + tags_it->pos) : end;
290 | };
291 |
292 | next = std::min(next_end, next_start);
293 | // next = std::min(end, next);
294 | }
295 |
296 | switch (*c) {
297 | case '\n':
298 | flush();
299 | ++bufferStart; // skip the new line
300 | ++line;
301 | for (auto it = stack.crbegin(); it != stack.crend(); ++it)
302 | (*it)->close(myfile);
303 | myfile << " |
\n"
304 | "" << line << " | ";
306 | for (auto it = stack.cbegin(); it != stack.cend(); ++it)
307 | (*it)->open(myfile);
308 | break;
309 | case '&':
310 | flush();
311 | ++bufferStart;
312 | myfile << "&";
313 | break;
314 | case '<':
315 | flush();
316 | ++bufferStart;
317 | myfile << "<";
318 | break;
319 | case '>':
320 | flush();
321 | ++bufferStart;
322 | myfile << ">";
323 | break;
324 | default:
325 | break;
326 | }
327 | ++c;
328 | }
329 |
330 |
331 | myfile << " |
\n"
332 | "
"
333 | "
";
334 |
335 | if (!warningMessage.empty()) {
336 | myfile << "
";
337 | myfile.write(warningMessage.begin(), warningMessage.size());
338 | myfile << "
\n";
339 | }
340 |
341 | myfile << "\n
\n";
349 | }
350 |
--------------------------------------------------------------------------------
/generator/generator.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Copyright (C) 2012-2016 Woboq GmbH
3 | * Olivier Goffart