From f236e4d7401d55d18707ac3374f913ada41e5b7b Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 9 Apr 2015 16:02:21 +0200 Subject: added serialization support for attributes descriptors. --- src/core/model/Typesystem.cpp | 8 ++++++++ src/core/model/Typesystem.hpp | 26 +++++++++++++++++--------- src/core/parser/stack/OntologyHandler.cpp | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src/core') diff --git a/src/core/model/Typesystem.cpp b/src/core/model/Typesystem.cpp index df2b9fb..688cb60 100644 --- a/src/core/model/Typesystem.cpp +++ b/src/core/model/Typesystem.cpp @@ -618,6 +618,14 @@ bool StructType::cast(Variant &data, Logger &logger) const return buildFromArrayOrMap(data, logger, NullMagicCallback, true); } +NodeVector StructType::getOwnAttributes() const +{ + NodeVector res; + res.insert(res.end(), attributes.begin() + attributeStart, + attributes.end()); + return res; +} + ssize_t StructType::indexOf(const std::string &name) const { size_t res; diff --git a/src/core/model/Typesystem.hpp b/src/core/model/Typesystem.hpp index 559a74c..193726d 100644 --- a/src/core/model/Typesystem.hpp +++ b/src/core/model/Typesystem.hpp @@ -64,20 +64,20 @@ public: */ enum class MagicCallbackResult { /** - * A magic value with the given name could not be resolved. - */ + * A magic value with the given name could not be resolved. + */ NOT_FOUND, /** - * A magic value with the given name could be resolved, but is of the - * wrong type. - */ + * A magic value with the given name could be resolved, but is of the + * wrong type. + */ FOUND_INVALID, /** - * A magic value with the given name could be resolved and is of the - * correct type. - */ + * A magic value with the given name could be resolved and is of the + * correct type. + */ FOUND_VALID }; @@ -953,7 +953,15 @@ public: * * @return a const reference pointing at the attribute list. */ - const NodeVector &getAttributes() const { return attributes; }; + const NodeVector &getAttributes() const { return attributes; } + + /** + * Returns a vector of all attributes that belong to this StructType itself, + * excluding the attributes of the parent structure. + * + * @return a vector of all attributes that belong to this StructType itself. + */ + NodeVector getOwnAttributes() const; /** * Returns the index of the given attribute in a data array representing diff --git a/src/core/parser/stack/OntologyHandler.cpp b/src/core/parser/stack/OntologyHandler.cpp index 0a33c97..0cd8140 100644 --- a/src/core/parser/stack/OntologyHandler.cpp +++ b/src/core/parser/stack/OntologyHandler.cpp @@ -108,7 +108,7 @@ void OntologyAnnotationHandler::end() { scope().pop(logger()); } bool OntologyAttributesHandler::startCommand(Variant::mapType &args) { - // Fetch the current typesystem and create the struct node + // Fetch the current descriptor and add the attributes descriptor Rooted parent = scope().selectOrThrow(); Rooted attrDesc = parent->getAttributesDescriptor(); -- cgit v1.2.3