Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
    modernizing, expanded tests, cleanup
    cleaning up XmlTools.
    update FileUtils to use filesystem::remove
    updating enum_types handling.
    reworking LogStream
    C++ code quality (C++17)
  • Loading branch information
kosloot committed Dec 5, 2024
1 parent 286bea5 commit 2b0256e
Show file tree
Hide file tree
Showing 18 changed files with 346 additions and 287 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ticcutils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ on:
schedule:
- cron: "0 22 3 * 5" # run test once a month
push:
branches: [master]
branches:
- master
- develop
paths:
- configure.ac
- 'src/**'
Expand Down
14 changes: 3 additions & 11 deletions include/ticcutils/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace TiCC {
class CL_Options {
friend std::ostream& operator<<( std::ostream&, const CL_Options& );
public:
typedef std::vector<CL_item>::const_iterator const_iterator;
using const_iterator = std::vector<CL_item>::const_iterator;
CL_Options();
CL_Options( const std::string&, const std::string& );
void allow_args( const std::string& = "", const std::string& = "" );
Expand All @@ -126,14 +126,6 @@ namespace TiCC {
}
void add_short_options( const std::string& s );
void add_long_options( const std::string& s );
void set_short_options( const std::string& s ){
// misnomer, kept for backward compatability
add_short_options( s );
}
void set_long_options( const std::string& s ){
// misnomer, kept for backward compatability
add_long_options( s );
}
const std::string& prog_name() const {
/// return the stored name of the calling program (normally argv[0])
return _prog_name;
Expand Down Expand Up @@ -334,8 +326,8 @@ namespace TiCC {
bool extract_internal( const std::string&, std::string& );
std::vector<CL_item> Opts;
std::vector<std::string> MassOpts;
CL_Options( const CL_Options& );
CL_Options& operator=( const CL_Options& );
CL_Options( const CL_Options& ) = delete;
CL_Options& operator=( const CL_Options& ) = delete;
std::set<char> valid_chars;
std::set<char> valid_chars_par;
std::set<char> valid_chars_opt;
Expand Down
4 changes: 2 additions & 2 deletions include/ticcutils/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ namespace TiCC {
/// There is an implicit \b global section when the section is unnamed.
class Configuration {
public:
typedef std::map<std::string,std::string> ssMap;
typedef std::map<std::string, ssMap> sssMap;
using ssMap = std::map<std::string,std::string>;
using sssMap = std::map<std::string, ssMap>;
Configuration();
void merge( const Configuration&, bool = false );
bool fill( const std::string& );
Expand Down
4 changes: 2 additions & 2 deletions include/ticcutils/FileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ namespace TiCC {
std::string _temp_name;
std::ofstream *_os;
bool _keep;
tmp_stream( const tmp_stream& );
tmp_stream operator=( const tmp_stream& );
tmp_stream( const tmp_stream& ) = delete;
tmp_stream operator=( const tmp_stream& ) = delete;
};

}
Expand Down
8 changes: 3 additions & 5 deletions include/ticcutils/LogBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,11 @@ template <class charT, class traits = std::char_traits<charT> >
std::string ass_mess;
void buffer_out();
// prohibit copying and assignment
basic_log_buffer( const basic_log_buffer& );
basic_log_buffer& operator=( const basic_log_buffer& );
basic_log_buffer( const basic_log_buffer& ) = delete;
basic_log_buffer& operator=( const basic_log_buffer& ) = delete;
};

typedef basic_log_buffer<char, std::char_traits<char> > LogBuffer;
typedef basic_log_buffer<wchar_t, std::char_traits<wchar_t> > wLogBuffer;

using LogBuffer = basic_log_buffer<char, std::char_traits<char>>;

template <class charT, class traits >
basic_log_buffer<charT,traits>::~basic_log_buffer(){
Expand Down
48 changes: 21 additions & 27 deletions include/ticcutils/LogStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,28 @@ namespace TiCC {
public:
explicit LogStream();
explicit LogStream( int );
explicit LogStream( const std::string&, LogFlag = StampBoth );
explicit LogStream( const char *cs, LogFlag lf = StampBoth ):
LogStream( std::string( cs ), lf ) {};
LogStream( std::ostream&,
const std::string& = "",
LogFlag = StampBoth );
LogStream( const LogStream&, const std::string&, LogFlag );
LogStream( const LogStream&, const std::string& );
LogStream( const LogStream * );
LogStream *create( const std::string&, std::ios_base::openmode = std::ios::out );
bool set_single_threaded_mode();
bool single_threaded() const { return single_threaded_mode; };
void setthreshold( LogLevel t ){ buf.Threshold( t ); };
LogLevel getthreshold() const { return buf.Threshold(); };
void setlevel( LogLevel l ){ buf.Level( l ); };
LogLevel getlevel() const{ return buf.Level(); };
void set_threshold( LogLevel t ){ buf.Threshold( t ); };
LogLevel get_threshold() const { return buf.Threshold(); };
void set_level( LogLevel l ){ buf.Level( l ); };
LogLevel get_level() const{ return buf.Level(); };
void associate( std::ostream& os ) { buf.AssocStream( os ); };
// std::ostream& associate() const { return buf.AssocStream(); };
void setstamp( LogFlag f ){ buf.StampFlag( f ); };
LogFlag getstamp() const { return buf.StampFlag(); };
void message( const std::string& s ){ buf.Message( s ); };
void addmessage( const std::string& );
void addmessage( const int );
const std::string& message() const { return buf.Message(); };
void set_stamp( LogFlag f ){ buf.StampFlag( f ); };
LogFlag get_stamp() const { return buf.StampFlag(); };
void set_message( const std::string& s ){ buf.Message( s ); };
void add_message( const std::string& );
void add_message( const int );
const std::string& get_message() const { return buf.Message(); };
static bool Problems();
private:
LogBuffer buf;
// prohibit assignment
LogStream& operator=( const LogStream& );
LogStream& operator=( const LogStream& ) = delete;
bool IsBlocking();
bool single_threaded_mode;
};
Expand All @@ -79,7 +73,7 @@ namespace TiCC {
bool IsActive( LogStream * );

/// \brief create a LogStream
class Log{
class Log {
public:
explicit Log( LogStream * );
explicit Log( LogStream& l );
Expand All @@ -88,8 +82,8 @@ namespace TiCC {
private:
LogStream *my_stream;
LogLevel my_level;
Log( const Log& );
Log& operator=( const Log& );
Log( const Log& ) = delete;
Log& operator=( const Log& ) = delete;
};

/// \brief create a debugging LogStream
Expand All @@ -102,8 +96,8 @@ namespace TiCC {
private:
LogStream *my_stream;
LogLevel my_level;
Dbg( const Dbg& );
Dbg& operator=( const Dbg& );
Dbg( const Dbg& ) = delete;
Dbg& operator=( const Dbg& ) = delete;
};

/// \brief a debugging LogStream for heavy output
Expand All @@ -116,8 +110,8 @@ namespace TiCC {
private:
LogStream *my_stream;
LogLevel my_level;
xDbg( const xDbg& );
xDbg& operator=( const xDbg& );
xDbg( const xDbg& ) = delete;
xDbg& operator=( const xDbg& ) = delete;
};

/// \brief a debugging LogStream for extreme output
Expand All @@ -130,8 +124,8 @@ namespace TiCC {
private:
LogStream *my_stream;
LogLevel my_level;
xxDbg( const xxDbg& );
xxDbg& operator=( const xxDbg& );
xxDbg( const xxDbg& ) = delete;
xxDbg& operator=( const xxDbg& ) = delete;
};

}
Expand Down
8 changes: 4 additions & 4 deletions include/ticcutils/UniHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ namespace Hash {
private:
const icu::UnicodeString _value;
unsigned int _ID;
UniInfo( const UniInfo& ) =delete;
UniInfo& operator=( const UniInfo& ) =delete;
UniInfo( const UniInfo& ) = delete;
UniInfo& operator=( const UniInfo& ) = delete;
};

/// \brief The UnicodeHash class is used to enumerate Unicode strings.
Expand Down Expand Up @@ -85,8 +85,8 @@ namespace Hash {
unsigned int _num_of_tokens;
std::vector<UniInfo*> _rev_index;
Tries::UniTrie<UniInfo> _tree;
UnicodeHash( const UnicodeHash& ) =delete;
UnicodeHash& operator=( const UnicodeHash& ) =delete;
UnicodeHash( const UnicodeHash& ) = delete;
UnicodeHash& operator=( const UnicodeHash& ) = delete;
};

}
Expand Down
2 changes: 1 addition & 1 deletion include/ticcutils/Unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace TiCC {
bool set_debug( bool b ){ bool r = _debug; _debug = b; return r; };
private:
// inhibit copies!
UnicodeRegexMatcher( const UnicodeRegexMatcher& ) =delete;
UnicodeRegexMatcher( const UnicodeRegexMatcher& ) = delete;
UnicodeRegexMatcher& operator=( const UnicodeRegexMatcher& ) = delete;
RegexPattern *_pattern;
RegexMatcher *_matcher;
Expand Down
Loading

0 comments on commit 2b0256e

Please sign in to comment.