diff --git a/include/libfolia/folia_impl.h b/include/libfolia/folia_impl.h index 22cbd06..200bbab 100644 --- a/include/libfolia/folia_impl.h +++ b/include/libfolia/folia_impl.h @@ -150,20 +150,18 @@ namespace folia { template inline T *add_child( const std::string& txt ){ - /// create a new XmlText as child of 'this' + /// create a new node of type T as child of 'this' /*! \param txt an value to be assigned as a "text" attribute - \return a new FoliaElement + \return a pointer to a new T this will not compile for any class that has NO IMPLEMENTATION for - setvalue(). (which ar most classes) + setvalue(). (which are most classes) */ T *result = new T(this); result->setvalue( txt ); return result; } - bool isSubClass( ElementType ) const; - virtual void assignDoc( Document* ) = 0; virtual FoliaElement *parent() const = 0; virtual void set_parent( FoliaElement *p ) = 0; @@ -386,10 +384,13 @@ namespace folia { virtual Word *addWord( const std::string& ="" ) = 0; // corrections + virtual bool hasNew() const NOT_IMPLEMENTED; virtual New *getNew() const NOT_IMPLEMENTED; virtual FoliaElement *getNew( size_t ) const NOT_IMPLEMENTED; + virtual bool hasOriginal() const NOT_IMPLEMENTED; virtual Original *getOriginal() const NOT_IMPLEMENTED; virtual FoliaElement *getOriginal( size_t ) const NOT_IMPLEMENTED; + virtual bool hasCurrent() const NOT_IMPLEMENTED; virtual Current *getCurrent() const NOT_IMPLEMENTED; virtual FoliaElement *getCurrent( size_t ) const NOT_IMPLEMENTED; virtual Correction *incorrection() const NOT_IMPLEMENTED; diff --git a/src/folia_impl.cxx b/src/folia_impl.cxx index e6053fb..7ebff8d 100644 --- a/src/folia_impl.cxx +++ b/src/folia_impl.cxx @@ -2200,7 +2200,7 @@ namespace folia { const FoliaElement *last = _data.back(); if ( last && tp.debug() ){ DBG << "last is " << last << endl; - DBG << "isSubClass(AbstractWord) == " << last->isSubClass() << endl; + DBG << "isSubClass() == " << last->isSubClass() << endl; DBG << "last->space() == " << last->space() << endl; } if ( last diff --git a/src/folia_properties.cxx b/src/folia_properties.cxx index 9a7200f..b3a4fac 100644 --- a/src/folia_properties.cxx +++ b/src/folia_properties.cxx @@ -2340,17 +2340,6 @@ namespace folia { return false; } - bool FoliaElement::isSubClass( ElementType t ) const { - /// check if this FoliaElement is a subclass of the ElementType \e t - /*! - \param t an ElementType - \return true if our class is a subclass of t - This is about C++ class inheritance: is our class a derivative of c's - class? - */ - return folia::is_subtype( element_id(), t ); - } - bool isAttributeFeature( const string& att ){ /// check if an attribute is to be handled as a feature /*! diff --git a/src/folia_subclasses.cxx b/src/folia_subclasses.cxx index 893a7c7..fedcae3 100644 --- a/src/folia_subclasses.cxx +++ b/src/folia_subclasses.cxx @@ -2234,8 +2234,7 @@ namespace folia { if ( !AbstractElement::addable( parent ) ){ return false; } - vector v = parent->select(false); - if ( !v.empty() ){ + if ( parent->hasCurrent() ){ throw XmlError( this, "Cant't add New element to Correction if there is a Current item" ); } @@ -2253,8 +2252,7 @@ namespace folia { if ( !AbstractElement::addable( parent ) ){ return false; } - vector v = parent->select(false); - if ( !v.empty() ){ + if ( parent->hasCurrent() ){ throw XmlError( this, "Cant't add Original element to Correction if there is a Current item" ); } @@ -2272,13 +2270,11 @@ namespace folia { if ( !AbstractElement::addable( parent ) ){ return false; } - vector nv = parent->select(false); - if ( !nv.empty() ){ + if ( parent->hasNew() ){ throw XmlError( this, "Cant't add Current element to Correction if there is a New item" ); } - vector ov = parent->select(false); - if ( !ov.empty() ){ + if ( parent->hasOriginal() ){ throw XmlError( this, "Cant't add Current element to Correction if there is an Original item" ); }