From c6fecd21e3a41b520a86b929aed04f4a4e61fcb2 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Wed, 28 Jan 2015 01:11:27 +0100 Subject: Returning again a single node as result of the import function (as this is already explicitly checked for). --- src/core/resource/ResourceManager.cpp | 17 +++++++++++------ src/core/resource/ResourceManager.hpp | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/core/resource') diff --git a/src/core/resource/ResourceManager.cpp b/src/core/resource/ResourceManager.cpp index a524be1..1d32a4d 100644 --- a/src/core/resource/ResourceManager.cpp +++ b/src/core/resource/ResourceManager.cpp @@ -188,13 +188,18 @@ NodeVector ResourceManager::parse( return parsedNodes; } -NodeVector ResourceManager::import(ParserContext &ctx, - const std::string &path, - const std::string &mimetype, - const std::string &rel, - const RttiSet &supportedTypes) +Rooted 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 res = + parse(ctx, path, mimetype, rel, supportedTypes, ParseMode::IMPORT); + if (res.size() == 1U) { + return res[0]; + } + return nullptr; } NodeVector 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 import(ParserContext &ctx, const std::string &path, + Rooted import(ParserContext &ctx, const std::string &path, const std::string &mimetype, const std::string &rel, const RttiSet &supportedTypes); -- cgit v1.2.3