diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-25 18:57:40 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-25 18:57:40 +0100 |
commit | 7352e5e6481964817643d02756186dd206c7b848 (patch) | |
tree | 98eeb7b21fd8e032f64c23d985444a822b9746ca | |
parent | 67c3618e593f88eb8177404475586735902d693f (diff) | |
parent | 93a8af2431529d145919c5898971c503d6c73e93 (diff) |
Merge branch 'master' of somweyr.de:ousia
-rw-r--r-- | src/core/common/VariantReader.cpp | 12 | ||||
-rw-r--r-- | src/core/model/Document.cpp | 108 | ||||
-rw-r--r-- | src/core/model/Domain.cpp | 39 | ||||
-rw-r--r-- | src/core/model/Domain.hpp | 15 | ||||
-rw-r--r-- | test/core/common/VariantReaderTest.cpp | 152 | ||||
-rw-r--r-- | test/core/model/DocumentTest.cpp | 2 | ||||
-rw-r--r-- | test/core/model/DomainTest.cpp | 8 | ||||
-rw-r--r-- | test/core/model/TestAdvanced.hpp | 6 | ||||
-rw-r--r-- | test/core/model/TestDomain.hpp | 6 |
9 files changed, 265 insertions, 83 deletions
diff --git a/src/core/common/VariantReader.cpp b/src/core/common/VariantReader.cpp index 7320973..c0368f1 100644 --- a/src/core/common/VariantReader.cpp +++ b/src/core/common/VariantReader.cpp @@ -559,6 +559,7 @@ std::pair<bool, Variant::cardinalityType> VariantReader::parseCardinality( switch (c) { case '}': case ',': + card.merge({start}); reader.resetPeek(); break; case '-': { @@ -569,6 +570,7 @@ std::pair<bool, Variant::cardinalityType> VariantReader::parseCardinality( error(reader, logger, ERR_UNEXPECTED_END, Variant::cardinalityType{}); } + reader.resetPeek(); Number n2; if (!n2.parse(reader, logger, cardDelims) || !n2.isInt() || n2.intValue() < 0) { @@ -576,8 +578,16 @@ std::pair<bool, Variant::cardinalityType> VariantReader::parseCardinality( "Invalid number for cardinality!", Variant::cardinalityType{}); } - unsigned int end = (unsigned int)n2.intValue(); + if (end <= start) { + return error(reader, logger, + std::string("The start of the range (") + + std::to_string(start) + + ") was bigger (or equal) to the end " + "of the range (" + + std::to_string(end) + ")!", + Variant::cardinalityType{}); + } card.merge({start, end}); break; } diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index 8c2ff2e..f452695 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -141,11 +141,15 @@ bool DocumentEntity::doValidate(Logger &logger) const { // if we have no descriptor, this is invalid. if (descriptor == nullptr) { - logger.error("This entity has no descriptor!"); + logger.error("This entity has no descriptor!", *subInst); // in this case we have to stop the validation process, because without // a constructor we can not check anything else. return false; } + // if we have an invalid descriptor we can not proceed either. + if (!descriptor->validate(logger)) { + return false; + } // check the attribute primitive content. bool valid; if (descriptor->getAttributesDescriptor() == nullptr) { @@ -176,8 +180,9 @@ bool DocumentEntity::doValidate(Logger &logger) const case 0: if (!fieldDescs[f]->isOptional()) { logger.error(std::string("Primitive Field \"") + - fieldDescs[f]->getName() + - "\" had no content!"); + fieldDescs[f]->getName() + + "\" had no content!", + *subInst); valid = false; } continue; @@ -185,16 +190,18 @@ bool DocumentEntity::doValidate(Logger &logger) const break; default: logger.error(std::string("Primitive Field \"") + - fieldDescs[f]->getName() + - "\" had more than one child!"); + fieldDescs[f]->getName() + + "\" had more than one child!", + *subInst); valid = false; continue; } // if we are here we know that exactly one child exists. if (!fields[f][0]->isa(RttiTypes::DocumentPrimitive)) { logger.error(std::string("Primitive Field \"") + - fieldDescs[f]->getName() + - "\" has non primitive content!"); + fieldDescs[f]->getName() + + "\" has non primitive content!", + *subInst); valid = false; } else { Handle<DocumentPrimitive> primitive = @@ -217,14 +224,16 @@ bool DocumentEntity::doValidate(Logger &logger) const * cardinality. */ for (auto &ac : fieldDescs[f]->getChildren()) { - const size_t min = ac->getCardinality().min(); + const size_t min = ac->getCardinality().asCardinality().min(); if (min > 0) { - logger.error( - std::string("Field \"") + fieldDescs[f]->getName() + - "\" was empty but needs at least " + - std::to_string(min) + " elements of class \"" + - ac->getName() + "\" according to the definition of \"" + - descriptor->getName() + "\""); + logger.error(std::string("Field \"") + + fieldDescs[f]->getName() + + "\" was empty but needs at least " + + std::to_string(min) + + " elements of class \"" + ac->getName() + + "\" according to the definition of \"" + + descriptor->getName() + "\"", + *subInst); valid = false; } } @@ -244,8 +253,9 @@ bool DocumentEntity::doValidate(Logger &logger) const // check if the parent reference is correct. if (rc->getParent() != subInst) { logger.error(std::string("A child of field \"") + - fieldDescs[f]->getName() + - "\" has the wrong parent reference!"); + fieldDescs[f]->getName() + + "\" has the wrong parent reference!", + *rc); valid = false; } if (rc->isa(RttiTypes::Anchor)) { @@ -254,8 +264,9 @@ bool DocumentEntity::doValidate(Logger &logger) const } if (rc->isa(RttiTypes::DocumentPrimitive)) { logger.error(std::string("Non-primitive Field \"") + - fieldDescs[f]->getName() + - "\" had primitive content!"); + fieldDescs[f]->getName() + + "\" had primitive content!", + *rc); valid = false; continue; } @@ -280,11 +291,13 @@ bool DocumentEntity::doValidate(Logger &logger) const } } if (!allowed) { - logger.error(std::string("An instance of \"") + - c->getDescriptor()->getName() + - "\" is not allowed as child of an instance of \"" + - descriptor->getName() + "\" in field \"" + - fieldDescs[f]->getName() + "\""); + logger.error( + std::string("An instance of \"") + + c->getDescriptor()->getName() + + "\" is not allowed as child of an instance of \"" + + descriptor->getName() + "\" in field \"" + + fieldDescs[f]->getName() + "\"", + *rc); valid = false; continue; } @@ -304,13 +317,15 @@ bool DocumentEntity::doValidate(Logger &logger) const if (n != nums.end()) { num = n->second; } - if (!ac->getCardinality().contains(num)) { - logger.error( - std::string("Field \"") + fieldDescs[f]->getName() + - "\" had " + std::to_string(num) + " elements of class \"" + - ac->getName() + - "\", which is invalid according to the definition of \"" + - descriptor->getName() + "\""); + if (!ac->getCardinality().asCardinality().contains(num)) { + logger.error(std::string("Field \"") + + fieldDescs[f]->getName() + "\" had " + + std::to_string(num) + " elements of class \"" + + ac->getName() + + "\", which is invalid according to the " + "definition of \"" + + descriptor->getName() + "\"", + *subInst); valid = false; continue; } @@ -461,13 +476,13 @@ bool StructureNode::doValidate(Logger &logger) const } // check the parent. if (getParent() == nullptr) { - logger.error("The parent is not set!"); + logger.error("The parent is not set!", *this); valid = false; } if (!getParent()->isa(RttiTypes::StructuredEntity) && !getParent()->isa(RttiTypes::AnnotationEntity) && !getParent()->isa(RttiTypes::Document)) { - logger.error("The parent does not have a valid type!"); + logger.error("The parent does not have a valid type!", *this); valid = false; } return valid; @@ -519,7 +534,7 @@ bool Anchor::doValidate(Logger &logger) const bool valid = true; // check name if (getName().empty()) { - logger.error("An Anchor needs a name!"); + logger.error("An Anchor needs a name!", *this); valid = false; } return valid & StructureNode::doValidate(logger); @@ -550,10 +565,10 @@ bool AnnotationEntity::doValidate(Logger &logger) const } // check if this AnnotationEntity is correctly registered at its document. if (getParent() == nullptr) { - logger.error("The parent is not set!"); + logger.error("The parent is not set!", *this); valid = false; } else if (!getParent()->isa(RttiTypes::Document)) { - logger.error("The parent is not a document!"); + logger.error("The parent is not a document!", *this); valid = false; } else { Handle<Document> doc = getParent().cast<Document>(); @@ -565,26 +580,29 @@ bool AnnotationEntity::doValidate(Logger &logger) const } } if (!found) { - logger.error("This annotation was not registered at the document."); + logger.error("This annotation was not registered at the document.", + *this); valid = false; } // check if the Anchors are part of the right document. if (start == nullptr) { - logger.error("This annotation has no start Anchor!"); + logger.error("This annotation has no start Anchor!", *this); valid = false; } else if (!doc->hasChild(start)) { logger.error( "This annotations start anchor was not part of the same " - "document!"); + "document!", + *this); valid = false; } if (end == nullptr) { - logger.error("This annotation has no end Anchor!"); + logger.error("This annotation has no end Anchor!", *this); valid = false; } else if (!doc->hasChild(end)) { logger.error( "This annotations end anchor was not part of the same " - "document!"); + "document!", + *this); valid = false; } } @@ -608,7 +626,7 @@ bool Document::doValidate(Logger &logger) const // An empty document is always invalid. TODO: Is this a smart choice? bool valid = true; if (root == nullptr) { - logger.error("This document is empty (it has no root)!"); + logger.error("This document is empty (it has no root)!", *this); valid = false; } else { // check if the root is allowed to be a root. @@ -616,14 +634,16 @@ bool Document::doValidate(Logger &logger) const .cast<StructuredClass>() ->hasRootPermission()) { logger.error(std::string("A node of type \"") + - root->getDescriptor()->getName() + - "\" is not allowed to be the Document root!"); + root->getDescriptor()->getName() + + "\" is not allowed to be the Document root!", + *root); valid = false; } // check if it has this document as parent. if (root->getParent() != this) { logger.error( - "The document root does not have the document as parent!"); + "The document root does not have the document as parent!", + *root); valid = false; } // then call validate on the root diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index 516bdde..360aa83 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -59,10 +59,10 @@ bool FieldDescriptor::doValidate(Logger &logger) const bool valid = true; // check parent type if (getParent() == nullptr) { - logger.error("This field has no parent!"); + logger.error("This field has no parent!", *this); valid = false; } else if (!getParent()->isa(RttiTypes::Descriptor)) { - logger.error("The parent of this field is not a descriptor!"); + logger.error("The parent of this field is not a descriptor!", *this); valid = false; } // check name @@ -74,20 +74,20 @@ bool FieldDescriptor::doValidate(Logger &logger) const if (children.size() > 0) { logger.error( "This field is supposed to be primitive but has " - "registered child classes!"); + "registered child classes!", *this); valid = false; } if (primitiveType == nullptr) { logger.error( "This field is supposed to be primitive but has " - "no primitive type!"); + "no primitive type!", *this); valid = false; } } else { if (primitiveType != nullptr) { logger.error( "This field is supposed to be non-primitive but has " - "a primitive type!"); + "a primitive type!", *this); valid = false; } } @@ -101,7 +101,7 @@ bool FieldDescriptor::doValidate(Logger &logger) const if (!names.insert(c->getName()).second) { logger.error(std::string("Field \"") + getName() + "\" had multiple children with the name \"" + - c->getName() + "\""); + c->getName() + "\"", *this); valid = false; } } @@ -138,15 +138,15 @@ bool Descriptor::doValidate(Logger &logger) const bool valid = true; // check parent type if (getParent() == nullptr) { - logger.error("This Descriptor has no parent!"); + logger.error("This Descriptor has no parent!", *this); valid = false; } else if (!getParent()->isa(RttiTypes::Domain)) { - logger.error("The parent of this Descriptor is not a Domain!"); + logger.error("The parent of this Descriptor is not a Domain!", *this); valid = false; } // check name if (getName().empty()) { - logger.error("The name of this Descriptor is empty!"); + logger.error("The name of this Descriptor is empty!", *this); valid = false; } else { valid = valid & validateName(logger); @@ -159,7 +159,7 @@ bool Descriptor::doValidate(Logger &logger) const "field \"" + fd->getName() + "\" as child but the field does not " - "have the Descriptor as parent."); + "have the Descriptor as parent.", *this); valid = false; } } @@ -305,13 +305,12 @@ Rooted<FieldDescriptor> Descriptor::createFieldDescriptor( /* Class StructuredClass */ StructuredClass::StructuredClass(Manager &mgr, std::string name, - Handle<Domain> domain, - const Cardinality &cardinality, + Handle<Domain> domain, Variant cardinality, Handle<StructType> attributesDescriptor, Handle<StructuredClass> superclass, bool transparent, bool root) : Descriptor(mgr, std::move(name), domain, attributesDescriptor), - cardinality(cardinality), + cardinality(std::move(cardinality)), superclass(acquire(superclass)), subclasses(this), transparent(transparent), @@ -333,10 +332,15 @@ bool StructuredClass::doValidate(Logger &logger) const if (sub->getSuperclass() != this) { logger.error(std::string("Struct \"") + sub->getName() + "\" is registered as subclass of \"" + getName() + - "\" but does not have it as superclass!"); + "\" but does not have it as superclass!", *this); valid = false; } } + // check the cardinality. + if(!cardinality.isCardinality()){ + logger.error(cardinality.toString() + " is not a cardinality!", *this); + valid = false; + } // check the validity of this superclass. if (superclass != nullptr) { valid = valid & superclass->validate(logger); @@ -495,13 +499,14 @@ bool Domain::removeStructuredClass(Handle<StructuredClass> s) } Rooted<StructuredClass> Domain::createStructuredClass( - std::string name, const Cardinality &cardinality, + std::string name, Variant cardinality, Handle<StructType> attributesDescriptor, Handle<StructuredClass> superclass, bool transparent, bool root) { return Rooted<StructuredClass>{new StructuredClass( - getManager(), std::move(name), this, cardinality, attributesDescriptor, - superclass, std::move(transparent), std::move(root))}; + getManager(), std::move(name), this, std::move(cardinality), + attributesDescriptor, superclass, std::move(transparent), + std::move(root))}; } void Domain::addAnnotationClass(Handle<AnnotationClass> a) diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index 076abf9..541a428 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -614,20 +614,19 @@ public: * cardinalities independent of context? Should we not have at least have the * possibility to define it context-dependently? */ -typedef RangeSet<size_t> Cardinality; /** * This is the default cardinality. */ -static Cardinality createAny() +static Variant::cardinalityType createAny() { - Cardinality any; + Variant::cardinalityType any; any.merge(Range<size_t>::typeRangeFrom(0)); return std::move(any); } -static const Cardinality AnyCardinality = createAny(); +static const Variant AnyCardinality = createAny(); /** * A StructuredClass specifies nodes in the StructureTree of a document that @@ -706,7 +705,7 @@ class StructuredClass : public Descriptor { friend Domain; private: - const Cardinality cardinality; + const Variant cardinality; Owned<StructuredClass> superclass; NodeVector<StructuredClass> subclasses; bool transparent; @@ -754,7 +753,7 @@ public: */ StructuredClass(Manager &mgr, std::string name = "", Handle<Domain> domain = nullptr, - const Cardinality &cardinality = AnyCardinality, + Variant cardinality = AnyCardinality, Handle<StructType> attributesDescriptor = nullptr, Handle<StructuredClass> superclass = nullptr, bool transparent = false, bool root = false); @@ -764,7 +763,7 @@ public: * * @return the Cardinality of this StructuredClass (as a RangeSet). */ - const Cardinality &getCardinality() const { return cardinality; } + const Variant &getCardinality() const { return cardinality; } /** * Returns the superclass of this StructuredClass. This is not the same as @@ -1012,7 +1011,7 @@ public: * @return the newly created StructuredClass. */ Rooted<StructuredClass> createStructuredClass( - std::string name, const Cardinality &cardinality = AnyCardinality, + std::string name, Variant cardinality = AnyCardinality, Handle<StructType> attributesDescriptor = nullptr, Handle<StructuredClass> superclass = nullptr, bool transparent = false, bool root = false); diff --git a/test/core/common/VariantReaderTest.cpp b/test/core/common/VariantReaderTest.cpp index 241aa56..14442e9 100644 --- a/test/core/common/VariantReaderTest.cpp +++ b/test/core/common/VariantReaderTest.cpp @@ -25,7 +25,7 @@ namespace ousia { static TerminalLogger logger{std::cerr, true}; -//static Logger logger; +// static Logger logger; TEST(VariantReader, readString) { @@ -576,6 +576,153 @@ TEST(VariantReader, parseObject) } } +TEST(VariantReader, parseCardinality) +{ + Logger logger; + // Primitive cardinality. + { + CharReader reader(" { 5 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + + Variant::cardinalityType card{}; + card.merge({5}); + ASSERT_EQ(card, res.second); + } + // Range cardinality + { + CharReader reader(" { 5-10 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + + Variant::cardinalityType card{}; + card.merge({5, 10}); + ASSERT_EQ(card, res.second); + } + // Larger than + { + CharReader reader(" { >9 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + + Variant::cardinalityType card{}; + card.merge(Variant::rangeType::typeRangeFrom(10)); + ASSERT_EQ(card, res.second); + } + // Smaller than + { + CharReader reader(" { <9 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + + Variant::cardinalityType card{}; + card.merge(Variant::rangeType::typeRangeUntil(8)); + ASSERT_EQ(card, res.second); + } + // Kleene-Star + { + CharReader reader(" { * } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + + Variant::cardinalityType card{}; + card.merge(Variant::rangeType::typeRange()); + ASSERT_EQ(card, res.second); + } + // More complex parse + { + CharReader reader(" { 1 , 4- 6 ,>8 } some other text"); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + + Variant::cardinalityType card{}; + card.merge({1}); + card.merge({4, 6}); + card.merge(Variant::rangeType::typeRangeFrom(9)); + ASSERT_EQ(card, res.second); + } + // More complex parses that are equivalent. + { + Variant::cardinalityType card{}; + card.merge(Variant::rangeType::typeRange()); + { + CharReader reader(" { * } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + ASSERT_EQ(card, res.second); + } + { + CharReader reader = CharReader(" { 1-4, 8, 9-12, 10, * } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + ASSERT_EQ(card, res.second); + } + { + CharReader reader = CharReader(" { 0, >0 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + ASSERT_EQ(card, res.second); + } + { + CharReader reader = CharReader(" { <10, 10, >10 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + ASSERT_EQ(card, res.second); + } + { + CharReader reader = CharReader(" { 0,1-2, 3-4, >4 } "); + auto res = VariantReader::parseCardinality(reader, logger); + ASSERT_TRUE(res.first); + ASSERT_EQ(card, res.second); + } + } + // Invalid cardinalities. + { + CharReader reader(" 5 } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { 5 , } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { 5- } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { -3 } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { 5-3 } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { 3-3 } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { > } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { < } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { , } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { 4 "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } + { + CharReader reader(" { m } "); + ASSERT_FALSE(VariantReader::parseCardinality(reader, logger).first); + } +} + TEST(VariantReader, parseGenericToken) { // Simple case, unescaped string @@ -614,7 +761,8 @@ TEST(VariantReader, parseGenericToken) // String with whitespaces at the beginning. { CharReader reader(" \' test\'"); - auto res = VariantReader::parseGenericToken(reader, logger, {';'}, true); + auto res = + VariantReader::parseGenericToken(reader, logger, {';'}, true); ASSERT_EQ(" test", res.second); } diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index a09068d..563f1b4 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -116,7 +116,7 @@ TEST(Document, validate) Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; Rooted<Domain> domain{new Domain(mgr, sys, "trivial")}; - Cardinality single; + Variant::cardinalityType single; single.merge({1}); // Set up the "root" StructuredClass. Rooted<StructuredClass> rootClass{new StructuredClass( diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp index fc71f91..8bf1a47 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/DomainTest.cpp @@ -151,8 +151,8 @@ TEST(Descriptor, pathToAdvanced) Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; // Construct the domain Rooted<Domain> domain{new Domain(mgr, sys, "nasty")}; - Cardinality any; - any.merge(Range<size_t>::typeRangeFrom(0)); + Variant::cardinalityType any; + any.merge(Range<size_t>::typeRange()); // Let's create the classes that we need first Rooted<StructuredClass> A{new StructuredClass( @@ -224,8 +224,8 @@ TEST(StructuredClass, isSubclassOf) Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; Rooted<Domain> domain{new Domain(mgr, sys, "inheritance")}; - Cardinality any; - any.merge(Range<size_t>::typeRangeFrom(0)); + Variant::cardinalityType any; + any.merge(Range<size_t>::typeRange()); Rooted<StructuredClass> A{new StructuredClass( mgr, "A", domain, any, {nullptr}, {nullptr}, false, true)}; // first branch diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 6111170..035ee8e 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -52,7 +52,7 @@ static Rooted<Domain> constructHeadingDomain(Manager &mgr, // set up domain node. Rooted<Domain> domain{new Domain(mgr, sys, "headings")}; // set up cardinality (every section may have at most one heading). - Cardinality card; + Variant::cardinalityType card; card.merge({0, 1}); // set up heading StructuredClass. Rooted<StructuredClass> heading{new StructuredClass( @@ -83,8 +83,8 @@ static Rooted<Domain> constructListDomain(Manager &mgr, // set up domain node. Rooted<Domain> domain{new Domain(mgr, sys, "list")}; // set up cardinality - Cardinality any; - any.merge(Range<size_t>::typeRangeFrom(0)); + Variant::cardinalityType any; + any.merge(Range<size_t>::typeRange()); // get book.paragraph Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph"); // set up item StructuredClass; diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp index 35f1ce1..a36f593 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestDomain.hpp @@ -34,10 +34,10 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // Start with the Domain itself. Rooted<Domain> domain{new Domain(mgr, sys, "book")}; // Set up the cardinalities we'll need. - Cardinality single; + Variant::cardinalityType single; single.merge({1}); - Cardinality any; - any.merge(Range<size_t>::typeRangeFrom(0)); + Variant::cardinalityType any; + any.merge(Range<size_t>::typeRange()); // Set up the "book" node. Rooted<StructuredClass> book{new StructuredClass( |