diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/parser/ParserContext.cpp | 2 | ||||
-rw-r--r-- | src/core/parser/ParserContext.hpp | 12 | ||||
-rw-r--r-- | src/core/resource/ResourceManager.cpp | 17 | ||||
-rw-r--r-- | src/core/resource/ResourceManager.hpp | 4 |
4 files changed, 21 insertions, 14 deletions
diff --git a/src/core/parser/ParserContext.cpp b/src/core/parser/ParserContext.cpp index b4e2a9a..14b02df 100644 --- a/src/core/parser/ParserContext.cpp +++ b/src/core/parser/ParserContext.cpp @@ -39,7 +39,7 @@ ParserContext::ParserContext(Registry ®istry, { } -NodeVector<Node> ParserContext::import(const std::string &path, +Rooted<Node> ParserContext::import(const std::string &path, const std::string mimetype, const std::string rel, const RttiSet &supportedTypes) diff --git a/src/core/parser/ParserContext.hpp b/src/core/parser/ParserContext.hpp index 2787225..1b889b1 100644 --- a/src/core/parser/ParserContext.hpp +++ b/src/core/parser/ParserContext.hpp @@ -117,8 +117,8 @@ public: * checked, not the actual result. * @return the parsed node or nullptr if something goes wrong. */ - NodeVector<Node> import(const std::string &path, const std::string mimetype, - const std::string rel, const RttiSet &supportedTypes); + Rooted<Node> import(const std::string &path, const std::string mimetype, + const std::string rel, const RttiSet &supportedTypes); /** * Parses a file with ParserContext and the current ParserScope. In contrast @@ -136,10 +136,12 @@ 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 node or nullptr if something goes wrong. + * @return the parsed nodes or an empty list if something goes wrong (or + * there were indeed no objects to be parsed). */ - NodeVector<Node> include(const std::string &path, const std::string mimetype, - const std::string rel, const RttiSet &supportedTypes); + NodeVector<Node> include(const std::string &path, + const std::string mimetype, const std::string rel, + const RttiSet &supportedTypes); /** * Clones the ParserContext instance but exchanges the ParserScope instance 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<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); |