Skip to content

Commit 8e5f338

Browse files
committed
some small code improvements
1 parent 0dfb749 commit 8e5f338

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

include/libfolia/folia_subclasses.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public: \
671671
public:
672672
ADD_DEFAULT_CONSTRUCTORS( WordReference, AbstractWord );
673673
std::string tval() const { return _tval; };
674-
FoliaElement *ref() const { return _ref; };
674+
FoliaElement *ref() const { return _reference; };
675675
bool addable( const FoliaElement * ) const override;
676676
const bool& printable() const override {
677677
static bool t = true;
@@ -681,15 +681,15 @@ public: \
681681
FoliaElement *parseXml( const xmlNode *node ) override;
682682
xmlNode *xml( bool, bool=false ) const override;
683683
const UnicodeString private_text( const TextPolicy& tp ) const override {
684-
return _ref->private_text( tp );
684+
return _reference->private_text( tp );
685685
}
686686
const std::string& get_delimiter( const TextPolicy& tp ) const override {
687-
return _ref->get_delimiter( tp );
687+
return _reference->get_delimiter( tp );
688688
}
689689
bool space() const override {
690-
return _ref->space();
690+
return _reference->space();
691691
}
692-
FoliaElement *_ref = NULL;
692+
FoliaElement *_reference = NULL;
693693
std::string _tval;
694694
};
695695

src/folia_document.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ namespace folia {
13241324
+ prefix );
13251325
}
13261326
et = et_it->second;
1327-
properties *prop = element_props[et];
1327+
const properties *prop = element_props[et];
13281328
if ( prop->REQUIRED_ATTRIBS % Attrib::CLASS ) {
13291329
throw DocumentError( _source_name,
13301330
"setname may not be empty for " + prefix
@@ -2207,7 +2207,7 @@ namespace folia {
22072207
+ prefix );
22082208
}
22092209
auto et = et_it->second;
2210-
properties *prop = element_props[et];
2210+
const properties *prop = element_props[et];
22112211
if ( prop->REQUIRED_ATTRIBS % Attrib::CLASS ) {
22122212
throw DocumentError( _source_name,
22132213
"setname may not be empty for " + prefix

src/folia_subclasses.cxx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,8 @@ namespace folia {
10321032
}
10331033
// we must check wref children against the parent too
10341034
vector<WordReference*> wrefs = select<WordReference>();
1035-
for ( const auto& refs : wrefs ){
1036-
FoliaElement *ref = refs->ref();
1035+
for ( const auto *refs : wrefs ){
1036+
const FoliaElement *ref = refs->ref();
10371037
string tval = refs->tval();
10381038
if ( !tval.empty() ){
10391039
string watt = ref->str(parent->textclass());
@@ -1500,15 +1500,15 @@ namespace folia {
15001500
return true;
15011501
}
15021502
if ( !_tval.empty() ){
1503-
string watt = _ref->str(parent->textclass());
1503+
string watt = _reference->str(parent->textclass());
15041504
if ( watt.empty() ){
15051505
string msg = "no matching 't' value found in the '<w>' refered by "
1506-
"<wref id=\"" + _ref->id() + "\" t=\""+ _tval
1506+
"<wref id=\"" + _reference->id() + "\" t=\""+ _tval
15071507
+ "\"> for textclass '" + parent->textclass() + "'";
15081508
throw XmlError( this, msg );
15091509
}
15101510
else if ( watt != _tval ){
1511-
string msg = "the 't' value of <wref id=\"" + _ref->id()
1511+
string msg = "the 't' value of <wref id=\"" + _reference->id()
15121512
+ "\" t=\""+ _tval + "\"> for textclass '" + parent->textclass()
15131513
+ "' doesn't match any value of the refered word for that class";
15141514
throw XmlError( this, msg );
@@ -1537,30 +1537,30 @@ namespace folia {
15371537
throw XmlError( this,
15381538
"unsupported attribute(s) in wref: " + toString(atts) );
15391539
}
1540-
FoliaElement *ref = (*doc())[id];
1541-
if ( ref ) {
1542-
if ( !ref->referable() ){
1540+
FoliaElement *the_ref = (*doc())[id];
1541+
if ( the_ref ) {
1542+
if ( !the_ref->referable() ){
15431543
throw XmlError( this,
15441544
"WordReference id=" + id + " refers to a non-referable word: "
1545-
+ ref->xmltag() );
1545+
+ the_ref->xmltag() );
15461546
}
1547-
ref->increfcount();
1547+
the_ref->increfcount();
15481548
}
15491549
else {
15501550
throw XmlError( this,
15511551
"Unresolvable id " + id + " in WordReference" );
15521552
}
1553-
_ref = ref;
1553+
_reference = the_ref;
15541554
return this;
15551555
}
15561556

15571557
xmlNode *WordReference::xml( bool, bool ) const {
15581558
/// convert the WordReference to an xmlNode
15591559
xmlNode *e = AbstractElement::xml( false, false );
15601560
KWargs attribs;
1561-
attribs.add("id",_ref->id());
1561+
attribs.add("id",_reference->id());
15621562
try {
1563-
string txt = _ref->str(_ref->textclass());
1563+
string txt = _reference->str(_reference->textclass());
15641564
attribs.add("t",txt);
15651565
}
15661566
catch (...){};
@@ -2690,7 +2690,7 @@ namespace folia {
26902690
vector<FoliaElement*> res;
26912691
for ( const auto& el : data() ) {
26922692
if ( el->isinstance<WordReference>() ){
2693-
res.push_back( dynamic_cast<WordReference*>(el)->_ref );
2693+
res.push_back( dynamic_cast<WordReference*>(el)->_reference );
26942694
}
26952695
else if ( el->referable() ){
26962696
res.push_back( el );

0 commit comments

Comments
 (0)