From 67c3618e593f88eb8177404475586735902d693f Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 25 Jan 2015 18:57:19 +0100 Subject: Restructures parser classes a little, removed Registry from ParserContext, gave a ResourceManager instance to the Project, using ResourceRequest when including or linking files, thought through how "including" and "linking" are handled --- src/plugins/xml/XmlParser.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/plugins/xml/XmlParser.cpp') diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index 78d9df8..17bc470 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -32,8 +32,6 @@ namespace ousia { -using namespace ousia::model; - /* Document structure */ static const State STATE_DOCUMENT = 0; static const State STATE_HEAD = 1; @@ -235,24 +233,18 @@ public: /* Adapter Expat -> ParserStack */ -struct XMLParserUserData { - SourceId sourceId; -}; - static SourceLocation syncLoggerPosition(XML_Parser p) { // Fetch the parser stack and the associated user data ParserStack *stack = static_cast(XML_GetUserData(p)); - XMLParserUserData *ud = - static_cast(stack->getUserData()); // Fetch the current location in the XML file size_t offs = XML_GetCurrentByteIndex(p); // Build the source location and update the default location of the current // logger instance - SourceLocation loc{ud->sourceId, offs}; - stack->getContext().logger.setDefaultLocation(loc); + SourceLocation loc{stack->getContext().getSourceId(), offs}; + stack->getContext().getLogger().setDefaultLocation(loc); return loc; } @@ -269,7 +261,7 @@ static void xmlStartElementHandler(void *p, const XML_Char *name, while (*attr) { const std::string key{*(attr++)}; std::pair value = VariantReader::parseGenericString( - *(attr++), stack->getContext().logger); + *(attr++), stack->getContext().getLogger()); args.emplace(std::make_pair(key, value.second)); } stack->start(std::string(name), args, loc); @@ -305,10 +297,7 @@ Rooted XmlParser::doParse(CharReader &reader, ParserContext &ctx) // Create the parser stack instance and pass the reference to the state // machine descriptor - XMLParserUserData data; - data.sourceId = reader.getSourceId(); - - ParserStack stack{ctx, XML_HANDLERS, &data}; + ParserStack stack{ctx, XML_HANDLERS}; XML_SetUserData(&p, &stack); XML_UseParserAsHandlerArg(&p); -- cgit v1.2.3