Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Nov 30, 2024
2 parents 8335e2f + 2d8fc5a commit d989a42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
9 changes: 5 additions & 4 deletions include/libfolia/folia_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ namespace folia {
return element_id() == F::PROPS.ELEMENT_ID;
}

template <typename F>
template <typename T>
bool isSubClass() const {
return is_subtype( element_id(), F::PROPS.ELEMENT_ID );
const FoliaElement *tmp = dynamic_cast<const T*>(this);
return tmp != nullptr;
}

template <typename T>
Expand Down Expand Up @@ -575,7 +576,7 @@ namespace folia {
static FoliaElement *createElement( ElementType, Document * =0 );
static FoliaElement *createElement( const std::string&, Document * =0 );

};
}; // class FoliaElement

class AbstractElement: public virtual FoliaElement {
friend void destroy( FoliaElement * );
Expand Down Expand Up @@ -843,7 +844,7 @@ namespace folia {
SPACE_FLAGS _preserve_spaces;
std::vector<FoliaElement*> _data;
const properties& _props;
};
}; // class AbstractElement

template <typename T1, typename T2>
bool isSubClass(){
Expand Down
21 changes: 17 additions & 4 deletions src/folia_utils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1009,14 +1009,27 @@ namespace folia {
return false;
}
{
Word *w = new Word();
Word *w = new Word();
if ( !w->isSubClass<Word>() ){
cerr << "Word::isSubClass<Word>() failed" << endl;
return false;
}
// assert( w->isSubClass<AbstractWord>() == 1 );
//assert( w->isSubClass<AbstractStructureElement>() == 1 );
//assert( w->isSubClass<AbstractElement>() == 1 );
if ( !w->isSubClass<FoliaElement>() ){
cerr << "Word::isSubClass<FoliaElement() failed" << endl;
return false;
}
if ( !w->isSubClass<AbstractWord>() ){
cerr << "Word::isSubClass<AbstractWord>() failed" << endl;
return false;
}
if ( !w->isSubClass<AbstractElement>() ){
cerr << "Word::isSubClass<AbstractElement() failed" << endl;
return false;
}
if ( !w->isSubClass<AbstractStructureElement>() ){
cerr << "Word::isSubClass<AbstractStructureElement() failed" << endl;
return false;
}
if ( w->isSubClass<Feature>() ){
cerr << "Word::isSubClass<Feature>() failed" << endl;
return false;
Expand Down

0 comments on commit d989a42

Please sign in to comment.