diff options
Diffstat (limited to 'src/core/resource')
| -rw-r--r-- | src/core/resource/ResourceManager.cpp | 23 | ||||
| -rw-r--r-- | src/core/resource/ResourceManager.hpp | 4 | 
2 files changed, 18 insertions, 9 deletions
diff --git a/src/core/resource/ResourceManager.cpp b/src/core/resource/ResourceManager.cpp index 2484cb2..1d32a4d 100644 --- a/src/core/resource/ResourceManager.cpp +++ b/src/core/resource/ResourceManager.cpp @@ -122,8 +122,12 @@ NodeVector<Node> ResourceManager::parse(  				innerScope.checkUnwound(logger);  				innerScope.performDeferredResolution(logger); -				// Fetch the nodes that were parsed by this parser instance +				// Fetch the nodes that were parsed by this parser instance and +				// validate them  				parsedNodes = innerScope.getTopLevelNodes(); +				for (auto parsedNode : parsedNodes) { +					parsedNode->validate(logger); +				}  				// Make sure the number of elements is exactly one -- we can  				// only store one element per top-level node. @@ -184,13 +188,18 @@ NodeVector<Node> ResourceManager::parse(  	return parsedNodes;  } -NodeVector<Node> ResourceManager::import(ParserContext &ctx, -                                       const std::string &path, -                                       const std::string &mimetype, -                                       const std::string &rel, -                                       const RttiSet &supportedTypes) +Rooted<Node> ResourceManager::import(ParserContext &ctx, +                                     const std::string &path, +                                     const std::string &mimetype, +                                     const std::string &rel, +                                     const RttiSet &supportedTypes)  { -	return parse(ctx, path, mimetype, rel, supportedTypes, ParseMode::IMPORT); +	NodeVector<Node> res = +	    parse(ctx, path, mimetype, rel, supportedTypes, ParseMode::IMPORT); +	if (res.size() == 1U) { +		return res[0]; +	} +	return nullptr;  }  NodeVector<Node> ResourceManager::include(ParserContext &ctx, diff --git a/src/core/resource/ResourceManager.hpp b/src/core/resource/ResourceManager.hpp index 83556aa..1279bee 100644 --- a/src/core/resource/ResourceManager.hpp +++ b/src/core/resource/ResourceManager.hpp @@ -158,9 +158,9 @@ public:  	 * @param supportedTypes contains the types of the returned Node the caller  	 * can deal with. Note that only the types the parser claims to return are  	 * checked, not the actual result. -	 * @return the parsed nodes or an empty list if something went wrong. +	 * @return the parsed node or nullptr if something went wrong.  	 */ -	NodeVector<Node> import(ParserContext &ctx, const std::string &path, +	Rooted<Node> import(ParserContext &ctx, const std::string &path,  	                  const std::string &mimetype, const std::string &rel,  	                  const RttiSet &supportedTypes);  | 
