Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
    modernizing C++, updated to latest ticcutils
  • Loading branch information
kosloot committed Dec 5, 2024
1 parent 539832a commit e78fb1a
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 30 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/timbl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ on:
schedule:
- cron: "0 20 3 * 5" # run test once a month
push:
branches: [master]
branches:
- master
- develop
paths:
- configure.ac
- 'src/**'
Expand Down Expand Up @@ -46,6 +48,7 @@ jobs:

- uses: LanguageMachines/ticcactions/cpp-submodule-build@v1
with:
branch: ${{ github.ref_name }}
module: ticcutils

- uses: LanguageMachines/ticcactions/setup-cppcheck@v1
Expand Down
4 changes: 2 additions & 2 deletions include/timbl/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace Timbl {
class SparseValueProbClass {
friend std::ostream& operator<< ( std::ostream&, SparseValueProbClass * );
public:
typedef std::map< size_t, double > IDmaptype;
typedef IDmaptype::const_iterator IDiterator;
using IDmaptype = std::map< size_t, double >;
using IDiterator = IDmaptype::const_iterator;
explicit SparseValueProbClass( size_t d ): dimension(d) {};
void Assign( const size_t i, const double d ) { vc_map[i] = d; };
void Clear() { vc_map.clear(); };
Expand Down
2 changes: 1 addition & 1 deletion include/timbl/IBtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace Timbl {
const IBtree *search_node( const FeatureValue * ) const;
};

typedef std::unordered_map<size_t, const IBtree*> FI_map;
using FI_map = std::unordered_map<size_t, const IBtree*>;

class InstanceBase_base: public MsgClass {
friend class IG_InstanceBase;
Expand Down
2 changes: 1 addition & 1 deletion include/timbl/MBLClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "timbl/neighborSet.h"
#include "timbl/Options.h"

typedef struct _xmlNode xmlNode;
using xmlNode = struct _xmlNode;

namespace Hash {
class UnicodeHash;
Expand Down
4 changes: 2 additions & 2 deletions include/timbl/Matrices.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ template <class T> std::ostream& operator << (std::ostream&,

template <class Class>
class SparseSymetricMatrix {
typedef std::map< Class, double > CDmap;
typedef std::map< Class, CDmap > CCDmap;
using CDmap = std::map< Class, double >;
using CCDmap = std::map< Class, CDmap >;
friend std::ostream& operator << <> ( std::ostream&,
const SparseSymetricMatrix<Class>& );

Expand Down
28 changes: 14 additions & 14 deletions include/timbl/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace Timbl {
OptionClassT& operator = (const OptionClassT&);
};

typedef OptionClassT<bool> BoolOption;
using BoolOption= OptionClassT<bool>;

template <>
inline std::ostream& OptionClassT<bool>::show_opt( std::ostream &os ) const {
Expand All @@ -99,7 +99,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<VerbosityFlags> VerbosityOption;
using VerbosityOption = OptionClassT<VerbosityFlags>;

template <>
inline std::ostream& OptionClassT<VerbosityFlags>::show_full( std::ostream &os ) const {
Expand All @@ -109,7 +109,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<InputFormatType> InputFormatOption;
using InputFormatOption = OptionClassT<InputFormatType>;

template <>
inline std::ostream& InputFormatOption::show_full( std::ostream &os ) const {
Expand All @@ -126,7 +126,7 @@ namespace Timbl {
}


typedef OptionClassT<MetricType> MetricOption;
using MetricOption = OptionClassT<MetricType>;

template <>
inline std::ostream& OptionClassT<MetricType>::show_full( std::ostream &os )const {
Expand All @@ -142,7 +142,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<AlgorithmType> AlgorithmOption;
using AlgorithmOption = OptionClassT<AlgorithmType>;

template <>
inline std::ostream& OptionClassT<AlgorithmType>::show_full( std::ostream &os ) const {
Expand All @@ -158,7 +158,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<DecayType> DecayOption;
using DecayOption = OptionClassT<DecayType>;

template <>
inline std::ostream& DecayOption::show_full( std::ostream &os ) const {
Expand All @@ -174,7 +174,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<SmoothingType> SmoothOption;
using SmoothOption = OptionClassT<SmoothingType>;

template <>
inline std::ostream& SmoothOption::show_full( std::ostream &os ) const {
Expand All @@ -190,7 +190,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<WeightType> WeightOption;
using WeightOption = OptionClassT<WeightType>;

template <>
inline std::ostream& OptionClassT<WeightType>::show_full( std::ostream &os ) const {
Expand All @@ -206,7 +206,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<OrdeningType> OrdeningOption;
using OrdeningOption = OptionClassT<OrdeningType>;

template <>
inline std::ostream& OptionClassT<OrdeningType>::show_full( std::ostream &os ) const {
Expand All @@ -222,7 +222,7 @@ namespace Timbl {
return os;
}

typedef OptionClassT<normType> NormalisationOption;
using NormalisationOption = OptionClassT<normType>;

template <>
inline std::ostream& NormalisationOption::show_full( std::ostream &os ) const {
Expand Down Expand Up @@ -360,10 +360,10 @@ namespace Timbl {
OptionClassLT& operator = (const OptionClassLT&);
};

typedef OptionClassLT<int> IntegerOption;
typedef OptionClassLT<unsigned int> UnsignedOption;
typedef OptionClassLT<size_t> SizeOption;
typedef OptionClassLT<double> RealOption;
using IntegerOption = OptionClassLT<int>;
using UnsignedOption = OptionClassLT<unsigned int>;
using SizeOption = OptionClassLT<size_t>;
using RealOption = OptionClassLT<double>;

enum SetOptRes { Opt_OK, Opt_Frozen, Opt_Unknown, Opt_Ill_Val};

Expand Down
4 changes: 2 additions & 2 deletions include/timbl/Targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ namespace Timbl {
friend std::ostream& operator<<( std::ostream&, const ClassDistribution * );
friend class WClassDistribution;
public:
typedef std::map<size_t, Vfield *> VDlist;
typedef VDlist::const_iterator dist_iterator;
using VDlist = std::map<size_t, Vfield *>;
using dist_iterator = VDlist::const_iterator;
ClassDistribution( ): total_items(0) {};
ClassDistribution( const ClassDistribution& );
virtual ~ClassDistribution(){ clear(); };
Expand Down
4 changes: 2 additions & 2 deletions include/timbl/TimblAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ namespace Timbl{
bool string_to( const std::string&, Algorithm& );
bool string_to( const std::string&, Weighting& );

typedef ClassDistribution ValueDistribution; // for backward compatability
typedef WClassDistribution WValueDistribution; // for backward compatability
using ValueDistribution = ClassDistribution; // for backward compatability
using WValueDistribution = WClassDistribution; // for backward compatability
}
#endif // TIMBL_API_H
4 changes: 2 additions & 2 deletions include/timbl/TimblExperiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ namespace Timbl {
}
};

typedef std::map<FeatureValue*,std::set<std::streamsize>, fCmp> fileIndex;
typedef std::map<FeatureValue*, fileIndex, fCmp > fileDoubleIndex;
using fileIndex = std::map<FeatureValue*,std::set<std::streamsize>, fCmp>;
using fileDoubleIndex = std::map<FeatureValue*, fileIndex, fCmp >;
std::ostream& operator<< ( std::ostream&, const fileIndex& );
std::ostream& operator<< ( std::ostream&, const fileDoubleIndex& );

Expand Down
6 changes: 3 additions & 3 deletions src/IBtree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace icu;

namespace Timbl {
using namespace Common;

using TiCC::operator<<;
IBtree::IBtree():
FValue(0), TValue(0), TDistribution(0),
link(0), next(0)
Expand Down Expand Up @@ -339,8 +339,8 @@ namespace Timbl {

void InstanceBase_base::toXML( ostream &os ) {
// save an IBtree for later use.
TiCC::XmlDoc doc( "root" );
xmlNode *root = doc.getRoot();
xmlDoc *doc = TiCC::create_xmlDocument( "root" );
xmlNode *root = TiCC::getRoot( doc );
xmlAddChild( root,
TiCC::XmlNewComment( "Version " + TiCC::toString(Version) ) );
bool dummy;
Expand Down

0 comments on commit e78fb1a

Please sign in to comment.