diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-01 18:06:04 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2015-01-01 18:06:04 +0100 |
commit | 4484f6deea0e098a140e878484d020bec839d1bd (patch) | |
tree | f3e8b480a533b4158abe9918f16d9988c6b463b6 /src/plugins/xml/XmlParser.cpp | |
parent | 377b7b0213733307927bec9e39c8ccb063e6ba50 (diff) |
Using CharReader instead of inputstream in Parser function
Diffstat (limited to 'src/plugins/xml/XmlParser.cpp')
-rw-r--r-- | src/plugins/xml/XmlParser.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index 47ed97a..90ea7fa 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -182,14 +182,13 @@ std::set<std::string> XmlParser::mimetypes() return std::set<std::string>{{"text/vnd.ousia.oxm", "text/vnd.ousia.oxd"}}; } -Rooted<Node> XmlParser::parse(std::istream &is, ParserContext &ctx) +Rooted<Node> XmlParser::parse(CharReader &reader, ParserContext &ctx) { // Create the parser object ScopedExpatXmlParser p{"UTF-8"}; // Create the parser stack instance and pass the reference to the state // machine descriptor - CharReader reader(is); ParserStack stack{ctx, XML_HANDLERS}; XML_SetUserData(&p, &stack); @@ -207,18 +206,8 @@ Rooted<Node> XmlParser::parse(std::istream &is, ParserContext &ctx) throw LoggableException{"Internal error: XML parser out of memory!"}; } - // Read the input file line by line (this needs to be done to allow - // for nice error messages) - // TODO: Add a corresponding function to the reader - size_t bytesRead = 0; - char *tar = buf; - while (bytesRead < BUFFER_SIZE && reader.read(*tar)) { - bytesRead++; - if (*tar == '\n') { - break; - } - tar++; - } + // Read into the buffer + size_t bytesRead = reader.readRaw(buf, BUFFER_SIZE); // Parse the data and handle any XML error if (!XML_ParseBuffer(&p, bytesRead, bytesRead == 0)) { |