MCPcopy Create free account
hub / github.com/davisking/dlib / parse

Method parse

dlib/xml_parser/xml_parser_kernel_1.h:285–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283// ----------------------------------------------------------------------------------------
284
285 void xml_parser::
286 parse (
287 std::istream& in
288 )
289 {
290 DLIB_CASSERT ( in.fail() == false ,
291 "\tvoid xml_parser::parse"
292 << "\n\tthe input stream must not be in the fail state"
293 << "\n\tthis: " << this
294 );
295
296
297 // save which exceptions in will throw and make it so it won't throw any
298 // for the life of this function
299 std::ios::iostate old_exceptions = in.exceptions();
300 // set it to not throw anything
301 in.exceptions(std::ios::goodbit);
302
303
304 try
305 {
306 unsigned long line_number = 1;
307
308 // skip any whitespace before the start of the document
309 while (in.peek() == ' ' || in.peek() == '\t' || in.peek() == '\n' || in.peek() == '\r' )
310 {
311 if (in.peek() == '\n')
312 ++line_number;
313 in.get();
314 }
315
316
317
318 stack tags; // this stack contains the last start tag seen
319 bool seen_fatal_error = false;
320 bool seen_root_tag = false; // this is true after we have seen the root tag
321
322
323
324 // notify all the document_handlers that we are about to being parsing
325 for (unsigned long i = 0; i < dh_list.size(); ++i)
326 {
327 dh_list[i]->start_document();
328 }
329
330
331 std::string chars_buf; // used to collect chars data between consecutive
332 // chars and chars_cdata tokens so that
333 // document_handlers receive all chars data between
334 // tags in one call
335
336 // variables to be used with the parsing functions
337 attrib_list atts;
338 std::string name;
339 std::string target;
340 std::string data;
341
342

Callers

nothing calls this directly

Calls 14

currentMethod · 0.80
eraseMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45
start_documentMethod · 0.45
start_elementMethod · 0.45
end_elementMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
errorMethod · 0.45
charactersMethod · 0.45

Tested by

no test coverage detected