Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Dec 4, 2024
1 parent dc71e18 commit 1948779
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
11 changes: 6 additions & 5 deletions include/libfolia/folia_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,18 @@ namespace folia {

template <typename T>
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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/folia_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<AbstractWord>() << endl;
DBG << "isSubClass<AbstractWord>() == " << last->isSubClass<AbstractWord>() << endl;
DBG << "last->space() == " << last->space() << endl;
}
if ( last
Expand Down
11 changes: 0 additions & 11 deletions src/folia_properties.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*!
Expand Down
12 changes: 4 additions & 8 deletions src/folia_subclasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2234,8 +2234,7 @@ namespace folia {
if ( !AbstractElement::addable( parent ) ){
return false;
}
vector<Current*> v = parent->select<Current>(false);
if ( !v.empty() ){
if ( parent->hasCurrent() ){
throw XmlError( this,
"Cant't add New element to Correction if there is a Current item" );
}
Expand All @@ -2253,8 +2252,7 @@ namespace folia {
if ( !AbstractElement::addable( parent ) ){
return false;
}
vector<Current*> v = parent->select<Current>(false);
if ( !v.empty() ){
if ( parent->hasCurrent() ){
throw XmlError( this,
"Cant't add Original element to Correction if there is a Current item" );
}
Expand All @@ -2272,13 +2270,11 @@ namespace folia {
if ( !AbstractElement::addable( parent ) ){
return false;
}
vector<New*> nv = parent->select<New>(false);
if ( !nv.empty() ){
if ( parent->hasNew() ){
throw XmlError( this,
"Cant't add Current element to Correction if there is a New item" );
}
vector<Original*> ov = parent->select<Original>(false);
if ( !ov.empty() ){
if ( parent->hasOriginal() ){
throw XmlError( this,
"Cant't add Current element to Correction if there is an Original item" );
}
Expand Down

0 comments on commit 1948779

Please sign in to comment.