Version upgrade 4.00 #45

Merged
elB4RTO merged 113 commits from devel into main 2024-02-17 16:13:26 +01:00
45 changed files with 357 additions and 353 deletions
Showing only changes of commit e9977b8ca3 - Show all commits

View file

@ -181,7 +181,7 @@ void CrissCross::nextTurn()
}
bool CrissCross::checkVictory()
bool CrissCross::checkVictory() noexcept
{
bool result{ false };
unsigned streak;
@ -206,7 +206,7 @@ bool CrissCross::checkVictory()
return result;
}
void CrissCross::victory()
void CrissCross::victory() noexcept
{
// disable all buttons except the victory sequence ones
bool disable{ true };
@ -246,7 +246,7 @@ void CrissCross::victory()
}
bool CrissCross::gameDraw() const
bool CrissCross::gameDraw() const noexcept
{
bool result{ false };
unsigned empty_tiles{ 9 };
@ -262,7 +262,7 @@ bool CrissCross::gameDraw() const
return result;
}
void CrissCross::draw()
void CrissCross::draw() noexcept
{
// disable all buttons
for ( const auto& button : this->board_buttons ) {
@ -281,13 +281,13 @@ void CrissCross::draw()
////////////
//// AI ////
void CrissCross::AI_playTurn()
void CrissCross::AI_playTurn() noexcept
{
this->AI_updateWeights();
emit this->board_buttons[ this->AI_makeChoice() ]->clicked();
}
void CrissCross::AI_updateWeights()
void CrissCross::AI_updateWeights() noexcept
{
// reset the weights
for ( size_t i{0ul}; i<9ul; ++i ) {
@ -322,7 +322,7 @@ void CrissCross::AI_updateWeights()
}
}
unsigned CrissCross::AI_makeChoice() const
unsigned CrissCross::AI_makeChoice() const noexcept
{
// get a list of the heaviest tiles
std::vector<unsigned> moves;

View file

@ -97,36 +97,36 @@ private:
//! Checks whether somebody won or not
bool checkVictory();
bool checkVictory() noexcept;
//! Checks whether the game is draw or not
bool gameDraw() const;
bool gameDraw() const noexcept;
//! Someone won, process the victory
void victory();
void victory() noexcept;
//! The match is over but nobody won, the game is draw
void draw();
void draw() noexcept;
////////////
//// AI ////
//! Main function for the AI to play its turn
void AI_playTurn();
void AI_playTurn() noexcept;
//! Updates the weights of the tiles
/*!
\see AI_playTurn();
*/
void AI_updateWeights();
void AI_updateWeights() noexcept;
//! Makes the choice depending on the weights
/*!
\return The tile to select
\see AI_playTurn();
*/
unsigned AI_makeChoice() const;
unsigned AI_makeChoice() const noexcept;
};

View file

@ -31,23 +31,23 @@ const Food& Food::operator=( const Food& other )
}
unsigned Food::X() const
unsigned Food::X() const noexcept
{
return this->x;
}
unsigned Food::Y() const
unsigned Food::Y() const noexcept
{
return this->y;
}
QGraphicsPixmapItem* Food::getImageItem() const
QGraphicsPixmapItem* Food::getImageItem() const noexcept
{
return this->image;
}
bool Food::inTile( const unsigned x, const unsigned y ) const
bool Food::inTile( const unsigned x, const unsigned y ) const noexcept
{
if ( this->x == x && this->y == y ) {
return true;
@ -57,7 +57,7 @@ bool Food::inTile( const unsigned x, const unsigned y ) const
}
void Food::update( const unsigned new_x, const unsigned new_y )
void Food::update( const unsigned new_x, const unsigned new_y ) noexcept
{
this->x = new_x;
this->y = new_y;
@ -65,7 +65,7 @@ void Food::update( const unsigned new_x, const unsigned new_y )
}
void Food::spawn( const Snake& snake, const Snake& snake_ )
void Food::spawn( const Snake& snake, const Snake& snake_ ) noexcept
{
// pick a new random position
unsigned new_x, new_y;

View file

@ -16,24 +16,24 @@ public:
const Food& operator=( const Food& other );
//! Returns the position on the X-axis
unsigned X() const;
unsigned X() const noexcept;
//! Returns the position on the Y-axis
unsigned Y() const;
unsigned Y() const noexcept;
//!< Returns the image
QGraphicsPixmapItem* getImageItem() const;
QGraphicsPixmapItem* getImageItem() const noexcept;
//! Checks whether is there a part of the snake in the given position
bool inTile( const unsigned x, const unsigned y ) const;
bool inTile( const unsigned x, const unsigned y ) const noexcept;
//! Spawns the egg/rat in a new position
void spawn( const Snake& snake, const Snake& snake_ );
void spawn( const Snake& snake, const Snake& snake_ ) noexcept;
//! Moves the rat
void move( const Snake& snake );
//! Updates the position and direction of the entity
void update( const unsigned new_x, const unsigned new_y );
void update( const unsigned new_x, const unsigned new_y ) noexcept;
private:

View file

@ -48,14 +48,14 @@ void SnakeGame::closeEvent( QCloseEvent* event )
}
void SnakeGame::keyPressEvent( QKeyEvent* event )
void SnakeGame::keyPressEvent( QKeyEvent* event ) noexcept
{
// store the key pressed if needed
if ( this->playing ) {
switch ( event->key() ) {
case Qt::Key_Up:
case Qt::Key_W:
if ( this->key_events.empty() ) { // leave me here
if ( this->key_events.empty() ) {
this->key_events.push( 0 );
} else if ( this->key_events.back() != 0 ) {
this->key_events.push( 0 );
@ -219,7 +219,7 @@ void SnakeGame::newSnake_()
this->snake_.update( this->field_scene.get(), true, true );
}
void SnakeGame::newFood( const bool& movable )
void SnakeGame::newFood( const bool& movable ) noexcept
{
// put some food on the field for it to eat
this->food = Food( movable );
@ -283,7 +283,7 @@ void SnakeGame::processGameLogic()
}
void SnakeGame::processNextKeyEvent()
void SnakeGame::processNextKeyEvent() noexcept
{
// update direction if needed
switch ( this->key_events.front() ) {

View file

@ -55,7 +55,7 @@ private:
and W/S/A/D letters
\see key_events, processNextKeyEvent()
*/
void keyPressEvent( QKeyEvent* event ) override;
void keyPressEvent( QKeyEvent* event ) noexcept override;
//! Stores the key events
std::queue<unsigned short> key_events;
@ -64,7 +64,7 @@ private:
/*!
\see key_events, keyPressEvent()
*/
void processNextKeyEvent();
void processNextKeyEvent() noexcept;
//////////////////
@ -119,7 +119,7 @@ private:
//! Instance of the egg/rat which will be eat by the snake
Food food;
void newFood( const bool& movable );
void newFood( const bool& movable ) noexcept;
bool spawn_food{ false };

View file

@ -5,7 +5,7 @@
#include <QGraphicsScene>
void BodyPart::update( const unsigned new_x, const unsigned new_y, const Direction& new_direction ) {
void BodyPart::update( const unsigned new_x, const unsigned new_y, const Direction& new_direction ) noexcept {
this->x = new_x;
this->y = new_y;
this->image->setOffset( 16+(new_x*32), 16+(new_y*32) );
@ -14,7 +14,7 @@ void BodyPart::update( const unsigned new_x, const unsigned new_y, const Directi
}
Snake::Snake( const bool is_adversary )
Snake::Snake( const bool is_adversary ) noexcept
: adversary( is_adversary )
{
if ( is_adversary ) {
@ -24,7 +24,7 @@ Snake::Snake( const bool is_adversary )
}
const QPixmap& Snake::getHeadImage() const
const QPixmap& Snake::getHeadImage() const noexcept
{
if ( this->adversary ) {
return this->img_snakeHead_;
@ -34,7 +34,7 @@ const QPixmap& Snake::getHeadImage() const
}
bool Snake::inTile( const unsigned x, const unsigned y, const bool avoid_tail ) const
bool Snake::inTile( const unsigned x, const unsigned y, const bool avoid_tail ) const noexcept
{
if ( this->size() > 0 ) {
size_t i{ 0 };
@ -56,16 +56,16 @@ bool Snake::inTile( const unsigned x, const unsigned y, const bool avoid_tail )
}
void Snake::setDirection( const Direction new_direction )
void Snake::setDirection( const Direction new_direction ) noexcept
{
this->head_direction = new_direction;
}
const Direction& Snake::direction() const
const Direction& Snake::direction() const noexcept
{
return this->head_direction;
}
void Snake::willGrow()
void Snake::willGrow() noexcept
{
this->will_grow |= true;
}
@ -408,7 +408,7 @@ void Snake::move( const Snake& adv_snake, const unsigned food_x, const unsigned
}
Direction Snake::predictDirection( const std::array<std::array<float,7>,4>& data, const std::array<float,7>& weights, const std::array<Direction,4>& classes ) const
Direction Snake::predictDirection( const std::array<std::array<float,7>,4>& data, const std::array<float,7>& weights, const std::array<Direction,4>& classes ) const noexcept
{
float results[]{ 1.f, 1.f, 1.f, 1.f };
bool keep_current{ false };
@ -728,7 +728,7 @@ void Snake::collectData( std::array<float,7>& data, const Direction& direction,
}
void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, const unsigned& food_y )
void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, const unsigned& food_y ) noexcept
{
// reset to default state
for ( size_t x{0}; x<16ul; ++x ) {
@ -759,7 +759,7 @@ void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, cons
}
bool Snake::inTileAdv(const unsigned x, const unsigned y ) const
bool Snake::inTileAdv(const unsigned x, const unsigned y ) const noexcept
{
if ( x < 16 && y < 16 ) {
switch ( this->field_map.at(x).at(y).entity ) {
@ -772,7 +772,7 @@ bool Snake::inTileAdv(const unsigned x, const unsigned y ) const
return false;
}
bool Snake::inTileMinusSteps(const unsigned x, const unsigned y, const unsigned steps ) const
bool Snake::inTileMinusSteps(const unsigned x, const unsigned y, const unsigned steps ) const noexcept
{
switch ( this->field_map.at(x).at(y).entity ) {
case Entity::S:

View file

@ -28,31 +28,31 @@ struct BodyPart final {
Direction prev_direction; //!< The previous direction of the part
QGraphicsPixmapItem* image; //!< The image which graphically represents the part
//! Updates the position and direction of the part
void update( const unsigned new_x, const unsigned new_y, const Direction& new_direction );
void update( const unsigned new_x, const unsigned new_y, const Direction& new_direction ) noexcept;
};
class Snake final : public std::vector<BodyPart>
{
public:
explicit Snake( const bool is_adversary=false );
explicit Snake( const bool is_adversary=false ) noexcept;
const QPixmap& getHeadImage() const;
const QPixmap& getHeadImage() const noexcept;
//! Checks whether is there a part of the snake in the given position
bool inTile( const unsigned x, const unsigned y, const bool avoid_tail=true ) const;
bool inTile( const unsigned x, const unsigned y, const bool avoid_tail=true ) const noexcept;
//! Sets the new direction (of the head)
void setDirection( const Direction new_direction );
void setDirection( const Direction new_direction ) noexcept;
//! Returns the current direction (of the head)
const Direction& direction() const;
const Direction& direction() const noexcept;
//! Updates the position and direction of the entire snake
void update( QGraphicsScene* field_scene=nullptr, const bool dry=false, const bool is_borning=false );
// Schedules to grow the snake on the next update
void willGrow();
void willGrow() noexcept;
// [AI] Chooses a new direction for the snake
void move( const Snake& adv_snake, const unsigned food_x, const unsigned food_y );
@ -98,13 +98,13 @@ private:
std::array<std::array<Tile, 16>, 16> field_map;
// [AI] Updates the map of the field
void updateFieldMap( const Snake& adv_snake, const unsigned& food_x, const unsigned& food_y );
void updateFieldMap( const Snake& adv_snake, const unsigned& food_x, const unsigned& food_y ) noexcept;
// [AI] As inTile(), but works on the field_map and only checks the adersary
bool inTileAdv( const unsigned x, const unsigned y ) const;
bool inTileAdv( const unsigned x, const unsigned y ) const noexcept;
// [AI] Checks whether is there a snake in the tile, without counting as much trailing BodyParts as the number of steps
bool inTileMinusSteps( const unsigned x, const unsigned y, const unsigned steps ) const;
bool inTileMinusSteps( const unsigned x, const unsigned y, const unsigned steps ) const noexcept;
// [AI] Checks which of the surrounding positions are blocked
std::array<unsigned, 8> checkAround( const Direction& direction, const unsigned x, const unsigned y ) const;
@ -116,7 +116,7 @@ private:
void collectData( std::array<float, 7>& data, const Direction& direction, const Snake& adv_snake, const unsigned food_x, const unsigned food_y ) const;
// [AI] Processes the collected data to predict the best movement
Direction predictDirection( const std::array<std::array<float, 7>, 4>& data, const std::array<float, 7>& weights, const std::array<Direction, 4>& classes ) const;
Direction predictDirection( const std::array<std::array<float, 7>, 4>& data, const std::array<float, 7>& weights, const std::array<Direction, 4>& classes ) const noexcept;
};

View file

@ -67,7 +67,7 @@ std::unordered_map<std::string, QString> Craphelp::getColorScheme( const int sch
}
void Craphelp::helpLogsFormat( const std::string& path, const QFont& font, const int color_scheme_id ) const
void Craphelp::helpLogsFormat( const std::string& path, const QFont& font, const int color_scheme_id ) const noexcept
{
std::unordered_map<std::string, QString> color_scheme{ this->getColorScheme( color_scheme_id ) };
std::string aux;
@ -111,7 +111,7 @@ void Craphelp::helpLogsFormat( const std::string& path, const QFont& font, const
}
void Craphelp::helpLogsFormatDefault( std::string_view file_name, const QFont& font, const int color_scheme_id ) const
void Craphelp::helpLogsFormatDefault( std::string_view file_name, const QFont& font, const int color_scheme_id ) const noexcept
{
std::unordered_map<std::string, QString> color_scheme = this->getColorScheme( color_scheme_id );
std::string aux;
@ -162,7 +162,7 @@ void Craphelp::helpLogsFormatDefault( std::string_view file_name, const QFont& f
void Craphelp::defaultApacheFormat( std::string& str ) const
void Craphelp::defaultApacheFormat( std::string& str ) const noexcept
{
str.append(
"<!DOCTYPE html>"
@ -420,7 +420,7 @@ void Craphelp::defaultApacheFormat( std::string& str ) const
);
}
void Craphelp::defaultNginxFormat( std::string& str ) const
void Craphelp::defaultNginxFormat( std::string& str ) const noexcept
{
str.append(
"<!DOCTYPE html>"
@ -618,7 +618,7 @@ void Craphelp::defaultNginxFormat( std::string& str ) const
);
}
void Craphelp::defaultIisFormat( std::string& str ) const
void Craphelp::defaultIisFormat( std::string& str ) const noexcept
{
str.append(
"<!DOCTYPE html>"

View file

@ -29,7 +29,7 @@ public:
\param font The font to be used
\param color_scheme_id The ID of the color-scheme to be used
*/
void helpLogsFormat( const std::string& path, const QFont& font, const int color_scheme_id ) const;
void helpLogsFormat( const std::string& path, const QFont& font, const int color_scheme_id ) const noexcept;
//! Provides help about log formats
/*!
@ -39,16 +39,16 @@ public:
\param font The font to be used
\param color_scheme_id The ID of the color-scheme to be used
*/
void helpLogsFormatDefault( std::string_view file_name, const QFont& font, const int color_scheme_id ) const;
void helpLogsFormatDefault( std::string_view file_name, const QFont& font, const int color_scheme_id ) const noexcept;
private:
QSharedPointer<Ui::Craphelp> ui;
std::unordered_map<std::string, QString> getColorScheme( const int scheme_id ) const;
void defaultApacheFormat( std::string& str ) const;
void defaultNginxFormat( std::string& str ) const;
void defaultIisFormat( std::string& str ) const;
void defaultApacheFormat( std::string& str ) const noexcept;
void defaultNginxFormat( std::string& str ) const noexcept;
void defaultIisFormat( std::string& str ) const noexcept;
};

View file

@ -86,40 +86,40 @@ Craplog::Craplog()
//////////////////
//// SETTINGS ////
int Craplog::getDialogsLevel() const
int Craplog::getDialogsLevel() const noexcept
{
return this->dialogs_level;
}
void Craplog::setDialogsLevel( const int new_level )
void Craplog::setDialogsLevel( const int new_level ) noexcept
{
this->dialogs_level = new_level;
this->hashOps.setDialogLevel( new_level );
}
const std::string& Craplog::getStatsDatabasePath() const
const std::string& Craplog::getStatsDatabasePath() const noexcept
{
return this->db_stats_path;
}
const std::string& Craplog::getHashesDatabasePath() const
const std::string& Craplog::getHashesDatabasePath() const noexcept
{
return this->db_hashes_path;
}
void Craplog::setStatsDatabasePath( const std::string& path )
void Craplog::setStatsDatabasePath( const std::string& path ) noexcept
{
this->db_stats_path = path + "/collection.db";
}
void Craplog::setHashesDatabasePath( const std::string& path )
void Craplog::setHashesDatabasePath( const std::string& path ) noexcept
{
this->db_hashes_path = path + "/hashes.db";
}
size_t Craplog::getWarningSize() const
size_t Craplog::getWarningSize() const noexcept
{
return this->warning_size;
}
void Craplog::setWarningSize(const size_t new_size )
void Craplog::setWarningSize(const size_t new_size ) noexcept
{
this->warning_size = new_size;
}
@ -127,29 +127,29 @@ void Craplog::setWarningSize(const size_t new_size )
////////////////////
//// WARN/BLACK ////
bool Craplog::isBlacklistUsed( const unsigned& web_server_id, const int& log_field_id ) const
bool Craplog::isBlacklistUsed( const unsigned& web_server_id, const int& log_field_id ) const noexcept
{
return this->blacklists.at( web_server_id ).at( log_field_id ).used;
}
bool Craplog::isWarnlistUsed( const unsigned& web_server_id, const int& log_field_id ) const
bool Craplog::isWarnlistUsed( const unsigned& web_server_id, const int& log_field_id ) const noexcept
{
return this->warnlists.at( web_server_id ).at( log_field_id ).used;
}
void Craplog::setBlacklistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used )
void Craplog::setBlacklistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used ) noexcept
{
this->blacklists.at( web_server_id ).at( log_field_id ).used = used;
}
void Craplog::setWarnlistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used )
void Craplog::setWarnlistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used ) noexcept
{
this->warnlists.at( web_server_id ).at( log_field_id ).used = used;
}
const std::vector<std::string>& Craplog::getBlacklist( const unsigned& web_server_id, const int& log_field_id ) const
const std::vector<std::string>& Craplog::getBlacklist( const unsigned& web_server_id, const int& log_field_id ) const noexcept
{
return this->blacklists.at( web_server_id ).at( log_field_id ).list;
}
const std::vector<std::string>& Craplog::getWarnlist( const unsigned& web_server_id, const int& log_field_id ) const
const std::vector<std::string>& Craplog::getWarnlist( const unsigned& web_server_id, const int& log_field_id ) const noexcept
{
return this->warnlists.at( web_server_id ).at( log_field_id ).list;
}
@ -180,7 +180,7 @@ void Craplog::warnlistAdd( const unsigned& web_server_id, const int& log_field_i
this->sanitizeBWitem( log_field_id, new_item ) );
}
void Craplog::blacklistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item )
void Craplog::blacklistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept
{
auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list;
// move the item to the end, then pop it
@ -193,7 +193,7 @@ void Craplog::blacklistRemove( const unsigned& web_server_id, const int& log_fie
}
list.pop_back();
}
void Craplog::warnlistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item )
void Craplog::warnlistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept
{
auto& list = this->warnlists.at( web_server_id ).at( log_field_id ).list;
// move the item to the end, then pop it
@ -207,7 +207,7 @@ void Craplog::warnlistRemove( const unsigned& web_server_id, const int& log_fiel
list.pop_back();
}
int Craplog::blacklistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item )
int Craplog::blacklistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept
{
auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list;
size_t i{ 1 };
@ -222,7 +222,7 @@ int Craplog::blacklistMoveUp( const unsigned& web_server_id, const int& log_fiel
}
return static_cast<int>( i );
}
int Craplog::warnlistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item )
int Craplog::warnlistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept
{
auto& list = this->warnlists.at( web_server_id ).at( log_field_id ).list;
size_t i{ 1 };
@ -238,7 +238,7 @@ int Craplog::warnlistMoveUp( const unsigned& web_server_id, const int& log_field
return static_cast<int>( i );
}
int Craplog::blacklistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item )
int Craplog::blacklistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept
{
auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list;
size_t i{ 0 };
@ -253,7 +253,7 @@ int Craplog::blacklistMoveDown( const unsigned& web_server_id, const int& log_fi
}
return static_cast<int>( i );
}
int Craplog::warnlistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item )
int Craplog::warnlistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept
{
auto& list = this->warnlists.at( web_server_id ).at( log_field_id ).list;
size_t i{ 0 };
@ -312,19 +312,19 @@ std::string Craplog::sanitizeBWitem( const int& log_field_id, const std::string&
/////////////////
//// FORMATS ////
// get the logs format string
const std::string& Craplog::getLogsFormatString( const unsigned& web_server_id ) const
const std::string& Craplog::getLogsFormatString( const unsigned& web_server_id ) const noexcept
{
return this->logs_format_strings.at( web_server_id );
}
// get the logs format
const LogsFormat& Craplog::getLogsFormat(const unsigned& web_server_id ) const
const LogsFormat& Craplog::getLogsFormat(const unsigned& web_server_id ) const noexcept
{
return this->logs_formats.at( web_server_id );
}
// set the logs format
bool Craplog::setApacheLogFormat( const std::string& format_string )
bool Craplog::setApacheLogFormat( const std::string& format_string ) noexcept
{
// apache
bool success{ true };
@ -341,7 +341,7 @@ bool Craplog::setApacheLogFormat( const std::string& format_string )
}
return success;
}
bool Craplog::setNginxLogFormat( const std::string& format_string )
bool Craplog::setNginxLogFormat( const std::string& format_string ) noexcept
{
// nginx
bool success{ true };
@ -358,7 +358,7 @@ bool Craplog::setNginxLogFormat( const std::string& format_string )
}
return success;
}
bool Craplog::setIisLogFormat( const std::string& format_string, const int log_module )
bool Craplog::setIisLogFormat( const std::string& format_string, const int log_module ) noexcept
{
// iis
bool success{ true };
@ -392,7 +392,7 @@ QString Craplog::getLogsFormatSample( const unsigned& web_server_id ) const
}
}
bool Craplog::checkCurrentLogsFormat() const
bool Craplog::checkCurrentLogsFormat() const noexcept
{
if ( this->current_LF.string.empty() ) {
// format string not set
@ -412,25 +412,25 @@ bool Craplog::checkCurrentLogsFormat() const
// set the current Web Server
void Craplog::setCurrentWSID( const unsigned web_server_id )
void Craplog::setCurrentWSID( const unsigned web_server_id ) noexcept
{
this->current_WS = web_server_id;
this->setCurrentLogFormat();
}
unsigned Craplog::getCurrentWSID() const
unsigned Craplog::getCurrentWSID() const noexcept
{
return this->current_WS;
}
// set the current access logs format
void Craplog::setCurrentLogFormat()
void Craplog::setCurrentLogFormat() noexcept
{
this->current_LF = this->logs_formats.at( this->current_WS );
}
// get the current access logs format
const LogsFormat& Craplog::getCurrentLogFormat() const
const LogsFormat& Craplog::getCurrentLogFormat() const noexcept
{
return this->current_LF;
}
@ -438,11 +438,11 @@ const LogsFormat& Craplog::getCurrentLogFormat() const
///////////////////
//// LOGS PATH ////
const std::string& Craplog::getLogsPath( const unsigned& web_server ) const
const std::string& Craplog::getLogsPath( const unsigned& web_server ) const noexcept
{
return this->logs_paths.at( web_server );
}
void Craplog::setLogsPath( const unsigned& web_server, const std::string& new_path )
void Craplog::setLogsPath( const unsigned& web_server, const std::string& new_path ) noexcept
{
this->logs_paths.at( web_server ) = new_path;
}
@ -451,13 +451,13 @@ void Craplog::setLogsPath( const unsigned& web_server, const std::string& new_pa
///////////////////
//// LOGS LIST ////
// return the size of the list
size_t Craplog::getLogsListSize() const
size_t Craplog::getLogsListSize() const noexcept
{
return this->logs_list.size();
}
// return the current list
const std::vector<LogFile>& Craplog::getLogsList() const
const std::vector<LogFile>& Craplog::getLogsList() const noexcept
{
return this->logs_list;
}
@ -476,7 +476,7 @@ const LogFile& Craplog::getLogFileItem( const QString& file_name ) const
// set a file as selected
bool Craplog::setLogFileSelected( const QString& file_name )
bool Craplog::setLogFileSelected( const QString& file_name ) noexcept
{
const auto item{ std::find_if
( this->logs_list.begin(), this->logs_list.end(),
@ -489,7 +489,7 @@ bool Craplog::setLogFileSelected( const QString& file_name )
return false;
}
void Craplog::clearLogFilesSelection()
void Craplog::clearLogFilesSelection() noexcept
{
std::ignore = std::for_each(
this->logs_list.begin(), this->logs_list.end(),
@ -539,13 +539,13 @@ void Craplog::scanLogsDir()
worker_thread->start();
}
void Craplog::appendLogFile( const LogFile log_file )
void Craplog::appendLogFile( const LogFile log_file ) noexcept
{
this->logs_list.push_back( std::move( log_file ) );
emit this->pushLogFile( this->logs_list.back() );
}
void Craplog::logsDirScanned()
void Craplog::logsDirScanned() noexcept
{
emit this->finishedRefreshing();
}
@ -808,7 +808,7 @@ bool Craplog::checkStuff()
return this->proceed;
}
void Craplog::showWorkerDialog( const WorkerDialog dialog_type, const QStringList args ) const
void Craplog::showWorkerDialog( const WorkerDialog dialog_type, const QStringList args ) const noexcept
{
switch ( dialog_type ) {
case WorkerDialog::errGeneric:
@ -825,12 +825,14 @@ void Craplog::showWorkerDialog( const WorkerDialog dialog_type, const QStringLis
break;
case WorkerDialog::errDatabaseFailedOpening:
if ( args.size() < 2 ) {
// do not throw, just print to stderr
GenericException{ "call to showWorkerDialog() with invalid number of list items", true };
}
DialogSec::errDatabaseFailedOpening( args.at(0), args.at(1) );
break;
case WorkerDialog::errDatabaseFailedExecuting:
if ( args.size() < 3 ) {
// do not throw, just print to stderr
GenericException{ "call to showWorkerDialog() with invalid number of list items", true };
}
DialogSec::errDatabaseFailedExecuting( args.at(0), args.at(1), args.at(2) );
@ -914,23 +916,23 @@ void Craplog::stopWorking( const bool successful )
emit this->finishedWorking();
}
bool Craplog::editedDatabase() const
bool Craplog::editedDatabase() const noexcept
{
return this->db_edited;
}
size_t Craplog::getParsedSize()
size_t Craplog::getParsedSize() noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
return this->parsed_size;
}
size_t Craplog::getParsedLines()
size_t Craplog::getParsedLines() noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
return this->parsed_lines;
}
QString Craplog::getParsingSpeed()
QString Craplog::getParsingSpeed() noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
auto stop{ ( is_parsing )
@ -947,30 +949,30 @@ QString Craplog::getParsingSpeed()
);
}
void Craplog::workerStartedParsing()
void Craplog::workerStartedParsing() noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
this->is_parsing |= true;
this->parsing_time_start = std::chrono::system_clock::now();
}
void Craplog::workerFinishedParsing()
void Craplog::workerFinishedParsing() noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
this->parsing_time_stop = std::chrono::system_clock::now();
this->is_parsing &= false;
}
bool Craplog::isParsing() const
bool Craplog::isParsing() const noexcept
{
return this->is_parsing;
}
void Craplog::updatePerfData( const size_t parsed_size, const size_t parsed_lines )
void Craplog::updatePerfData( const size_t parsed_size, const size_t parsed_lines ) noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
this->parsed_size = parsed_size;
this->parsed_lines = parsed_lines;
}
void Craplog::updateChartData( const size_t total_size, const size_t total_lines, const size_t warnlisted_size, const size_t blacklisted_size )
void Craplog::updateChartData( const size_t total_size, const size_t total_lines, const size_t warnlisted_size, const size_t blacklisted_size ) noexcept
{
std::unique_lock<std::mutex> lock( this->mutex );
this->total_size = total_size;

View file

@ -29,31 +29,31 @@ public:
//// DIALOGS ////
//! Returns the Dialogs level
int getDialogsLevel() const;
int getDialogsLevel() const noexcept;
//! Sets the new Dialogs level
void setDialogsLevel( const int new_level );
void setDialogsLevel( const int new_level ) noexcept;
///////////////////
//// DATABASES ////
//! Returns the path of the logs Collection database
const std::string& getStatsDatabasePath() const;
const std::string& getStatsDatabasePath() const noexcept;
//! Returns the path of the log files' Hashes database
const std::string& getHashesDatabasePath() const;
const std::string& getHashesDatabasePath() const noexcept;
//! Sets the new path for the logs Collection database
/*!
\param The new path of the database file
*/
void setStatsDatabasePath( const std::string& path );
void setStatsDatabasePath( const std::string& path ) noexcept;
//! Sets the new path for the log files' Hashes database
/*!
\param The new path of the database file
*/
void setHashesDatabasePath( const std::string& path );
void setHashesDatabasePath( const std::string& path ) noexcept;
////////////////////////
@ -63,26 +63,26 @@ public:
/*!
\param web_server_id The new currently used Web Server
*/
void setCurrentWSID( const unsigned web_server_id );
void setCurrentWSID( const unsigned web_server_id ) noexcept;
//! Returns the currently used Web Server ID
/*!
\return The Web Server ID
*/
unsigned getCurrentWSID() const;
unsigned getCurrentWSID() const noexcept;
//! Uses the current Web Server to set the relative logs format
/*!
\see LogsFormat
*/
void setCurrentLogFormat();
void setCurrentLogFormat() noexcept;
//! Returns the currently used LogsFormat
/*!
\return The LogsFormat
\see LogsFormat
*/
const LogsFormat& getCurrentLogFormat() const;
const LogsFormat& getCurrentLogFormat() const noexcept;
////////////////////
@ -93,14 +93,14 @@ public:
\param web_server The ID of the Web Server
\return The path of the logs' folder
*/
const std::string& getLogsPath( const unsigned& web_server ) const;
const std::string& getLogsPath( const unsigned& web_server ) const noexcept;
//! Sets a new path for the given Web Server to search the logs in
/*!
\param web_server The ID of the Web Server
\param new_path The new path
*/
void setLogsPath( const unsigned& web_server, const std::string& new_path );
void setLogsPath( const unsigned& web_server, const std::string& new_path ) noexcept;
///////////////////
@ -123,14 +123,14 @@ public:
\return The list of log files
\see LogFile, logs_list
*/
const std::vector<LogFile>& getLogsList() const;
const std::vector<LogFile>& getLogsList() const noexcept;
//! Returns the amount of log files in the list
/*!
\return The number of files actually in the list
\see logs_list
*/
size_t getLogsListSize() const;
size_t getLogsListSize() const noexcept;
//! Returns the LogFile instance of the given file
/*!
@ -149,14 +149,14 @@ public:
\return Wheter the given file name has been found in the list
\see LogFile, logs_list
*/
bool setLogFileSelected( const QString& file_name );
bool setLogFileSelected( const QString& file_name ) noexcept;
//! Sets all files in the list as unselected
/*!
\return Wheter the given file name has been found in the list
\see LogFile, logs_list
*/
void clearLogFilesSelection();
void clearLogFilesSelection() noexcept;
//////////////////////
@ -168,7 +168,7 @@ public:
\return Whether the process was successful or not
\see FormatOps, FormatOps::LogsFormat, FormatOps::processApacheFormatString()
*/
bool setApacheLogFormat( const std::string& format_string );
bool setApacheLogFormat( const std::string& format_string ) noexcept;
//! Sets the Nginx LogsFormat from the given format string
/*!
@ -176,7 +176,7 @@ public:
\return Whether the process was successful or not
\see FormatOps, FormatOps::LogsFormat, FormatOps::processNginxFormatString()
*/
bool setNginxLogFormat( const std::string& format_string );
bool setNginxLogFormat( const std::string& format_string ) noexcept;
//! Sets the IIS LogsFormat from the given format string
/*!
@ -185,7 +185,7 @@ public:
\return Whether the process was successful or not
\see FormatOps, FormatOps::LogsFormat, FormatOps::processIisFormatString()
*/
bool setIisLogFormat( const std::string& format_string, const int log_module );
bool setIisLogFormat( const std::string& format_string, const int log_module ) noexcept;
//! Returns the logs format string for the given Web Server
/*!
@ -193,7 +193,7 @@ public:
\return The format string
\see FormatOps::LogsFormat
*/
const std::string& getLogsFormatString( const unsigned& web_server_id ) const;
const std::string& getLogsFormatString( const unsigned& web_server_id ) const noexcept;
//! Returns the LogsFormat currently set for the given Web Server
/*!
@ -201,7 +201,7 @@ public:
\return The LogsFormat instance
\see LogsFormat
*/
const LogsFormat& getLogsFormat( const unsigned& web_server_id ) const;
const LogsFormat& getLogsFormat( const unsigned& web_server_id ) const noexcept;
//! Returns a sample log line for the given Web Server using the relative LogsFormat
/*!
@ -213,7 +213,7 @@ public:
QString getLogsFormatSample( const unsigned& web_server_id ) const;
//! Checks whether the current Logs Format is valid or not
bool checkCurrentLogsFormat() const;
bool checkCurrentLogsFormat() const noexcept;
@ -221,10 +221,10 @@ public:
//// WARNING SIZE ////
//! Returns the currently set warning size for the log files
size_t getWarningSize() const;
size_t getWarningSize() const noexcept;
//! Sets the new warning size for the log files
void setWarningSize( const size_t new_size );
void setWarningSize( const size_t new_size ) noexcept;
////////////////////
@ -243,7 +243,7 @@ public:
\return Whether the list is used or not
\see BWlist
*/
bool isBlacklistUsed( const unsigned& web_server_id, const int& log_field_id ) const;
bool isBlacklistUsed( const unsigned& web_server_id, const int& log_field_id ) const noexcept;
//! Returns whether the relative warnlist is set to be used or not
/*!
@ -252,7 +252,7 @@ public:
\return Whether the list is used or not
\see BWlist
*/
bool isWarnlistUsed( const unsigned& web_server_id, const int& log_field_id ) const;
bool isWarnlistUsed( const unsigned& web_server_id, const int& log_field_id ) const noexcept;
//! Sets the relative blacklist to be used or not
/*!
@ -261,7 +261,7 @@ public:
\param used Whether the list is to be used or not
\see BWlist
*/
void setBlacklistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used );
void setBlacklistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used ) noexcept;
//! Sets the relative warnlist to be used or not
/*!
@ -270,7 +270,7 @@ public:
\param used Whether the list is to be used or not
\see BWlist
*/
void setWarnlistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used );
void setWarnlistUsed( const unsigned& web_server_id, const int& log_field_id, const bool used ) noexcept;
//! Returns the relative items list
/*!
@ -279,7 +279,7 @@ public:
\return The list of items in the given blacklist
\see BWlist
*/
const std::vector<std::string>& getBlacklist( const unsigned& web_server_id, const int& log_field_id ) const;
const std::vector<std::string>& getBlacklist( const unsigned& web_server_id, const int& log_field_id ) const noexcept;
//! Returns the relative items list
/*!
@ -288,7 +288,7 @@ public:
\return The list of items in the givenwarnlist
\see BWlist
*/
const std::vector<std::string>& getWarnlist( const unsigned& web_server_id, const int& log_field_id ) const;
const std::vector<std::string>& getWarnlist( const unsigned& web_server_id, const int& log_field_id ) const noexcept;
//! Sets the relative items list
/*!
@ -333,7 +333,7 @@ public:
\param item The item to remove from the list
\see BWlist
*/
void blacklistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item );
void blacklistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept;
//! Removes an item from the relative list
/*!
@ -342,7 +342,7 @@ public:
\param item The item to remove from the list
\see BWlist
*/
void warnlistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item );
void warnlistRemove( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept;
//! Moves an item one position up in the relative list
/*!
@ -351,7 +351,7 @@ public:
\param item The item to move
\see BWlist
*/
int blacklistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item );
int blacklistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept;
//! Moves an item one position up in the relative list
/*!
@ -360,7 +360,7 @@ public:
\param item The item to move
\see BWlist
*/
int warnlistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item );
int warnlistMoveUp( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept;
//! Moves an item one position down in the relative list
/*!
@ -369,7 +369,7 @@ public:
\param item The item to move
\see BWlist
*/
int blacklistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item );
int blacklistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept;
//! Moves an item one position down in the relative list
/*!
@ -378,7 +378,7 @@ public:
\param item The item to move
\see BWlist
*/
int warnlistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item );
int warnlistMoveDown( const unsigned& web_server_id, const int& log_field_id, const std::string& item ) noexcept;
//////////////
@ -393,23 +393,23 @@ public:
bool checkStuff();
//! Returns whether the database has been edited or not during the process
bool isParsing() const;
bool isParsing() const noexcept;
//! Returns whether the database has been edited or not during the process
bool editedDatabase() const;
bool editedDatabase() const noexcept;
//////////////////////
//// PERFORMANCES ////
//! Returns the total logs size
size_t getParsedSize();
size_t getParsedSize() noexcept;
//! Returns the parsed logs lines
size_t getParsedLines();
size_t getParsedLines() noexcept;
//! Returns the speed on parsing logs
QString getParsingSpeed();
QString getParsingSpeed() noexcept;
//! Builds and draws the chart to be displayed in the main window
/*!
@ -434,28 +434,28 @@ public slots:
void scanLogsDir();
void appendLogFile( const LogFile log_file );
void appendLogFile( const LogFile log_file ) noexcept;
void logsDirScanned();
void logsDirScanned() noexcept;
void startWorking();
void workerStartedParsing();
void workerStartedParsing() noexcept;
void workerFinishedParsing();
void workerFinishedParsing() noexcept;
void stopWorking( const bool successful );
void updatePerfData( const size_t parsed_size,
const size_t parsed_lines );
const size_t parsed_lines ) noexcept;
void updateChartData( const size_t total_size,
const size_t total_lines,
const size_t warnlisted_size,
const size_t blacklisted_size );
const size_t blacklisted_size ) noexcept;
void showWorkerDialog( const WorkerDialog dialog_type,
const QStringList args ) const;
const QStringList args ) const noexcept;
private:

View file

@ -575,7 +575,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons
}
// sample
QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) const
QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) const noexcept
{
QString sample;
const auto& map{ this->APACHE_ALF_SAMPLES };
@ -676,7 +676,7 @@ LogsFormat FormatOps::processNginxFormatString( const std::string& f_str ) const
countNewLines( initial, final, separators ) );
}
// sample
QString FormatOps::getNginxLogSample( const LogsFormat& log_format ) const
QString FormatOps::getNginxLogSample( const LogsFormat& log_format ) const noexcept
{
QString sample;
const auto& map{ this->NGINX_ALF_SAMPLES };
@ -770,7 +770,7 @@ LogsFormat FormatOps::processIisFormatString( const std::string& f_str, const in
f_str, initial, final, separators, fields, 0 );
}
// sample
QString FormatOps::getIisLogSample( const LogsFormat& log_format ) const
QString FormatOps::getIisLogSample( const LogsFormat& log_format ) const noexcept
{
QString sample;
const auto& map{ this->IIS_ALF_SAMPLES };

View file

@ -55,7 +55,7 @@ public:
\return The sample line
\see LogsFormat, Craplog::getLogsFormatSample()
*/
QString getApacheLogSample( const LogsFormat& log_format ) const;
QString getApacheLogSample( const LogsFormat& log_format ) const noexcept;
//! Returns a log line sample based on the given format
/*!
@ -63,7 +63,7 @@ public:
\return The sample line
\see LogsFormat, Craplog::getLogsFormatSample()
*/
QString getNginxLogSample( const LogsFormat& log_format ) const;
QString getNginxLogSample( const LogsFormat& log_format ) const noexcept;
//! Returns a log line sample based on the given format
/*!
@ -71,7 +71,7 @@ public:
\return The sample line
\see LogsFormat, Craplog::getLogsFormatSample()
*/
QString getIisLogSample( const LogsFormat& log_format ) const;
QString getIisLogSample( const LogsFormat& log_format ) const noexcept;
private:

View file

@ -19,14 +19,14 @@
#include <QSqlError>
void HashOps::setDialogLevel( const int new_level )
void HashOps::setDialogLevel( const int new_level ) noexcept
{
this->dialog_level = new_level;
}
// reads the database holding the already used hashes
bool HashOps::loadUsedHashesLists( const std::string& db_path )
bool HashOps::loadUsedHashesLists( const std::string& db_path ) noexcept
{
bool successful{ true };
const QString db_name{ QString::fromStdString( db_path.substr( db_path.find_last_of( '/' ) + 1ul ) ) };
@ -136,7 +136,7 @@ void HashOps::digestFile( const std::string& file_path, std::string& hash )
// check if the given hash is from a file which has been used already
bool HashOps::hasBeenUsed( const std::string &file_hash, const unsigned& web_server_id) const
bool HashOps::hasBeenUsed( const std::string &file_hash, const unsigned& web_server_id) const noexcept
{
const auto& ws_hashes{ this->hashes.at( web_server_id ) };
return std::any_of(
@ -147,7 +147,7 @@ bool HashOps::hasBeenUsed( const std::string &file_hash, const unsigned& web_ser
// insert the given hash/es in the relative list
bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const unsigned& web_server_id )
bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const unsigned& web_server_id ) noexcept
{
bool successful{ true };
try {

View file

@ -21,14 +21,14 @@ class HashOps final
public:
//! Sets the new Dialogs level
void setDialogLevel( const int new_level );
void setDialogLevel( const int new_level ) noexcept;
//! Retrieves the lists of hashes from the database file
/*!
\param db_path The path of the log files' Hashes database
\return Whether the operation has been successful or not
*/
bool loadUsedHashesLists( const std::string& db_path );
bool loadUsedHashesLists( const std::string& db_path ) noexcept;
//! Returns the hash resulting from the content of the given file
/*!
@ -45,7 +45,7 @@ public:
\param web_server_id The ID of the Web Server which generated the file
\return Whether the hash is already in the list or not
*/
bool hasBeenUsed( const std::string& file_hash, const unsigned& web_server_id ) const;
bool hasBeenUsed( const std::string& file_hash, const unsigned& web_server_id ) const noexcept;
//! Inserts multiple hashes in the corresponding database table
/*!
@ -79,7 +79,7 @@ private:
// Called by insertUsedHashes()
// Inserts a hash in the corresponding database table
bool insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const unsigned& web_server_id );
bool insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const unsigned& web_server_id ) noexcept;
};

View file

@ -27,9 +27,9 @@ enum class LogType
//! Holds informations about a log file
struct LogFile final {
explicit LogFile() = default;
explicit LogFile() noexcept = default;
explicit LogFile
(const bool sel,const bool used,const size_t sz,const QString& nm,const std::string& hs,const std::string& pt)
(const bool sel,const bool used,const size_t sz,const QString& nm,const std::string& hs,const std::string& pt) noexcept
:selected{sel},used_already{used},size_{sz},name_{nm},hash_{hs},path_{pt}{}
//! Wheter the file has been selected to be used or not
inline bool isSelected() const noexcept
@ -68,9 +68,9 @@ Q_DECLARE_METATYPE( LogFile )
//! Holds informations about a log format
struct LogsFormat final {
explicit LogsFormat() = default;
explicit LogsFormat() noexcept = default;
explicit LogsFormat
(const std::string& str,const std::string& itl,const std::string& fnl,const std::vector<std::string>& seps,const std::vector<std::string>& flds,const unsigned nl)
(const std::string& str,const std::string& itl,const std::string& fnl,const std::vector<std::string>& seps,const std::vector<std::string>& flds,const unsigned nl) noexcept
:string{str},initial{itl},final{fnl},separators{seps},fields{flds},new_lines{nl}{}
std::string string; //!< The logs format string
std::string initial; //!< The initial separator

View file

@ -20,7 +20,7 @@ namespace /*private*/
\return Whether the line respects the format or not
\see defineFileType(), FormatOps::LogsFormat
*/
bool deepTypeCheck( const std::string& line, const LogsFormat& format )
bool deepTypeCheck( const std::string& line, const LogsFormat& format ) noexcept
{
size_t n_sep{ format.separators.size() },
n_sep_found{0}, n_blank_sep{0},
@ -112,7 +112,7 @@ bool deepTypeCheck( const std::string& line, const LogsFormat& format )
} // namespace (private)
LogType defineFileType( const std::vector<std::string>& lines, const LogsFormat& format )
LogType defineFileType( const std::vector<std::string>& lines, const LogsFormat& format ) noexcept
{
if ( lines.empty() ) {
// empty file, already handled by craplog, should be unreachable

View file

@ -22,7 +22,7 @@ namespace LogOps
LogType defineFileType(
const std::vector<std::string>& lines,
const LogsFormat& format
);
) noexcept;
} // namespace LogOps

View file

@ -274,7 +274,7 @@ LogLineData::LogLineData(const std::string& line, const LogsFormat& logs_format)
}
}
void LogLineData::storeUriQuery(std::string&& str)
void LogLineData::storeUriQuery(std::string&& str) noexcept
{
if ( ! str.empty() ) {
if ( const auto pos{ str.find( '?' ) }; pos != std::string::npos ) {
@ -286,7 +286,7 @@ void LogLineData::storeUriQuery(std::string&& str)
}
}
void LogLineData::storeMalformedRequestOneSpace(std::string&& str)
void LogLineData::storeMalformedRequestOneSpace(std::string&& str) noexcept
{
const size_t pos{ str.find( ' ' ) };
std::string field1{ str.substr( 0ul, pos ) },
@ -351,7 +351,7 @@ void LogLineData::storeMalformedRequestOneSpace(std::string&& str)
}
}
void LogLineData::storeMalformedRequestMultiSpace(std::string&& str)
void LogLineData::storeMalformedRequestMultiSpace(std::string&& str) noexcept
{
const size_t pos1{ str.find( ' ' ) },
pos2{ str.rfind( ' ' ) };
@ -510,7 +510,7 @@ void LogLineData::storeMalformedRequestMultiSpace(std::string&& str)
}
}
size_t LogLineData::size() const
size_t LogLineData::size() const noexcept
{
return this->year
+ this->month

View file

@ -40,12 +40,12 @@ struct FieldData final
FieldData& operator=(FieldData&& rhs) noexcept = default;
Q_DISABLE_COPY(FieldData)
inline operator bool() const
inline operator bool() const noexcept
{ return this->is_set; }
inline const std::string& operator *() const
inline const std::string& operator *() const noexcept
{ return this->data; }
inline size_t operator +(const FieldData& rhs) const
inline size_t operator +(const FieldData& rhs) const noexcept
{ return this->data.size() + rhs.data.size(); }
private:
@ -54,7 +54,7 @@ private:
};
inline size_t operator +(const size_t lhs, const FieldData& rhs)
inline size_t operator +(const size_t lhs, const FieldData& rhs) noexcept
{
return lhs + (*rhs).size();
}
@ -73,7 +73,7 @@ struct LogLineData final
LogLineData& operator=(LogLineData&& rhs) noexcept = delete;
Q_DISABLE_COPY(LogLineData)
size_t size() const;
size_t size() const noexcept;
// date and time
FieldData year; // 1
@ -101,10 +101,10 @@ struct LogLineData final
private:
FieldData& data(const int& id);
void storeUriQuery(std::string&& str);
void storeUriQuery(std::string&& str) noexcept;
void storeMalformedRequestOneSpace(std::string&& str);
void storeMalformedRequestMultiSpace(std::string&& str);
void storeMalformedRequestOneSpace(std::string&& str) noexcept;
void storeMalformedRequestMultiSpace(std::string&& str) noexcept;
inline static const std::unordered_map<std::string, int> field2id{
// date-time

View file

@ -34,7 +34,7 @@ CraplogParser::CraplogParser( const unsigned web_server_id, const unsigned dialo
}
void CraplogParser::sendPerfData()
void CraplogParser::sendPerfData() noexcept
{
emit this->perfData(
this->parsed_size,
@ -42,7 +42,7 @@ void CraplogParser::sendPerfData()
);
}
void CraplogParser::sendChartData()
void CraplogParser::sendChartData() noexcept
{
emit this->chartData(
this->total_size,

View file

@ -67,9 +67,9 @@ public slots:
void work();
virtual void sendPerfData();
void sendPerfData() noexcept;
virtual void sendChartData();
void sendChartData() noexcept;
private:

View file

@ -8,29 +8,29 @@
#include <QTableWidget>
int Crapview::getDialogsLevel() const
int Crapview::getDialogsLevel() const noexcept
{
return this->dialogs_level;
}
void Crapview::setDialogsLevel( const int new_level )
void Crapview::setDialogsLevel( const int new_level ) noexcept
{
this->dialogs_level = new_level;
}
void Crapview::setDbPath( const std::string& path )
void Crapview::setDbPath( const std::string& path ) noexcept
{
this->dbQuery.setDbPath( path + "/collection.db" );
}
QString Crapview::getLogFieldString ( const size_t field_id ) const
QString Crapview::getLogFieldString ( const size_t field_id ) const noexcept
{
return TR::tr( this->dbQuery.FIELDS.at( field_id ).c_str() );
}
int Crapview::getLogFieldID ( const QString& field_str ) const
int Crapview::getLogFieldID ( const QString& field_str ) const noexcept
{
int f{ 0 };
for ( const auto& [id,str] : this->dbQuery.FIELDS ) {
@ -43,7 +43,7 @@ int Crapview::getLogFieldID ( const QString& field_str ) const
}
int Crapview::getMonthNumber( const QString& month_str ) const
int Crapview::getMonthNumber( const QString& month_str ) const noexcept
{
int m{ 0 };
for ( const auto& [num,str] : this->dbQuery.MONTHS ) {
@ -67,12 +67,12 @@ void Crapview::refreshDates()
this->dates = std::move( result.value() );
}
}
void Crapview::clearDates()
void Crapview::clearDates() noexcept
{
this->dates.clear();
}
QStringList Crapview::getYears( const QString& web_server ) const
QStringList Crapview::getYears( const QString& web_server ) const noexcept
{
QStringList years;
if ( ! this->dates.empty() ) {
@ -86,7 +86,7 @@ QStringList Crapview::getYears( const QString& web_server ) const
}
return years;
}
QStringList Crapview::getMonths( const QString& web_server, const QString& year ) const
QStringList Crapview::getMonths( const QString& web_server, const QString& year ) const noexcept
{
QStringList months;
if ( ! this->dates.empty() ) {
@ -104,7 +104,7 @@ QStringList Crapview::getMonths( const QString& web_server, const QString& year
}
return months;
}
QStringList Crapview::getDays( const QString& web_server, const QString& year, const QString& month ) const
QStringList Crapview::getDays( const QString& web_server, const QString& year, const QString& month ) const noexcept
{
QStringList days;
if ( ! this->dates.empty() ) {
@ -124,12 +124,12 @@ QStringList Crapview::getDays( const QString& web_server, const QString& year, c
}
return days;
}
QStringList Crapview::getHours() const
QStringList Crapview::getHours() const noexcept
{
return QStringList{"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
}
QStringList Crapview::getFields( const std::string& tab ) const
QStringList Crapview::getFields( const std::string& tab ) const noexcept
{
QStringList list;
const auto& f{ this->fields.at( tab ) };

View file

@ -24,10 +24,10 @@ class Crapview final : public QObject
public:
//! Returns the Dialogs level
int getDialogsLevel() const;
int getDialogsLevel() const noexcept;
//! Sets the new Dialogs level
void setDialogsLevel( const int new_level );
void setDialogsLevel( const int new_level ) noexcept;
/*//! Sets the new charts theme to use
@ -38,7 +38,7 @@ public:
/*!
\see DbQuery::setDbPath()
*/
void setDbPath( const std::string& path );
void setDbPath( const std::string& path ) noexcept;
//! Returns the printable log field corresponding to the given ID
@ -47,14 +47,14 @@ public:
\param field_id The ID of the log fiels
\return The printable field
*/
QString getLogFieldString ( const size_t field_id ) const;
QString getLogFieldString ( const size_t field_id ) const noexcept;
//! Returns the log field ID corresponding to the given printable field
/*!
\param field_str The log field
\return The ID of the log field
*/
int getLogFieldID ( const QString& field_str ) const;
int getLogFieldID ( const QString& field_str ) const noexcept;
//! Returns the month number corresponding to the given printable month
@ -62,14 +62,14 @@ public:
\param month_Str The printable month name
\return The month number
*/
int getMonthNumber( const QString& month_str ) const;
int getMonthNumber( const QString& month_str ) const noexcept;
//! Refreshes the list of the dates which are available in the database
void refreshDates();
//! Erases the list of available dates
void clearDates();
void clearDates() noexcept;
//! Returns le list of available years, for the given web server
@ -77,7 +77,7 @@ public:
\param web_server The printable Web Server name
\return The list of yearss which are avaliable
*/
QStringList getYears( const QString& web_server ) const;
QStringList getYears( const QString& web_server ) const noexcept;
//! Returns le list of available months in the given year, for the given web server
/*!
@ -85,7 +85,7 @@ public:
\param year The year
\return The list of printable month names which are avaliable
*/
QStringList getMonths( const QString& web_server, const QString& year ) const;
QStringList getMonths( const QString& web_server, const QString& year ) const noexcept;
//! Returns le list of available days in the given month and year, for the given web server
/*!
@ -94,13 +94,13 @@ public:
\param month The printable month name
\return The list of days which are avaliable
*/
QStringList getDays( const QString& web_server, const QString& year, const QString& month ) const;
QStringList getDays( const QString& web_server, const QString& year, const QString& month ) const noexcept;
//! Returns all the hours of the day
/*!
\return The list of all the hours
*/
QStringList getHours() const;
QStringList getHours() const noexcept;
//! Returns a list of the fields for the given tab
@ -108,7 +108,7 @@ public:
\param tab The stats tab
\return The list of fields
*/
QStringList getFields( const std::string& tab ) const;
QStringList getFields( const std::string& tab ) const noexcept;
//! Updates the database applying the changes which have been made to the table

View file

@ -9,7 +9,7 @@
namespace FilterOps
{
std::optional<QString> parseNull( const QString& filter_str, const bool to_clean )
std::optional<QString> parseNull( const QString& filter_str, const bool to_clean ) noexcept
{
std::optional<QString> result;
const QString aux{ ( to_clean )
@ -26,7 +26,7 @@ std::optional<QString> parseNull( const QString& filter_str, const bool to_clean
}
std::optional<QString> parseBooleanFilter( const QString& filter_str )
std::optional<QString> parseBooleanFilter( const QString& filter_str ) noexcept
{
using opt_t = std::optional<QString>;
opt_t result;
@ -61,7 +61,7 @@ std::optional<QString> parseBooleanFilter( const QString& filter_str )
}
std::optional<QString> parseNumericFilter( const QString& filter_str )
std::optional<QString> parseNumericFilter( const QString& filter_str ) noexcept
{
using opt_t = std::optional<QString>;
opt_t result;
@ -140,7 +140,7 @@ std::optional<QString> parseNumericFilter( const QString& filter_str )
}
std::optional<QString> parseTextualFilter( const QString& filter_str )
std::optional<QString> parseTextualFilter( const QString& filter_str ) noexcept
{
using opt_t =std::optional<QString>;
opt_t result;

View file

@ -23,7 +23,7 @@ namespace FilterOps
\param to_clean Whether the filter_str should be cleaned before parsing (trimmed and uppercased)
\return The resulting filter to apply to the query, if valid
*/
std::optional<QString> parseNull( const QString& filter_str, const bool to_clean=true );
std::optional<QString> parseNull( const QString& filter_str, const bool to_clean=true ) noexcept;
//! Parses a filter for a database field with boolean type
/*!
@ -33,7 +33,7 @@ std::optional<QString> parseNull( const QString& filter_str, const bool to_clean
\param field_str The given filter
\return The resulting filter to apply to the query, if valid
*/
std::optional<QString> parseBooleanFilter( const QString& filter_str );
std::optional<QString> parseBooleanFilter( const QString& filter_str ) noexcept;
//! Parses a filter for a log field with integer type
/*!
@ -44,7 +44,7 @@ std::optional<QString> parseBooleanFilter( const QString& filter_str );
\param field_str The given filter
\return The resulting filter to apply to the query, if valid
*/
std::optional<QString> parseNumericFilter( const QString& filter_str );
std::optional<QString> parseNumericFilter( const QString& filter_str ) noexcept;
//! Parses a filter for a log field with text type
/*!
@ -53,7 +53,7 @@ std::optional<QString> parseNumericFilter( const QString& filter_str );
\param field_str The given filter
\return The resulting filter to apply to the query, if valid
*/
std::optional<QString> parseTextualFilter( const QString& filter_str );
std::optional<QString> parseTextualFilter( const QString& filter_str ) noexcept;
}

View file

@ -18,12 +18,12 @@
#include <vector>
void DbQuery::setDialogLevel(const int new_level )
void DbQuery::setDialogLevel(const int new_level ) noexcept
{
this->dialog_level = new_level;
}
void DbQuery::setDbPath( const std::string& path )
void DbQuery::setDbPath( const std::string& path ) noexcept
{
this->db_path = path;
this->db_name = QString::fromStdString( this->db_path.substr( this->db_path.find_last_of( '/' ) + 1ul ) );
@ -72,7 +72,7 @@ int DbQuery::getMonthDays( const int year, const int month )
}
int DbQuery::getMonthNumber( const QString& month_str ) const
int DbQuery::getMonthNumber( const QString& month_str ) const noexcept
{
int m{ 0 };
for ( const auto& [num,str] : this->MONTHS ) {
@ -121,7 +121,7 @@ int DbQuery::countDays( const int from_year, const int from_month, const int fro
return n_days;
}
int DbQuery::countMonths( const int from_year, const int from_month, const int to_year, const int to_month )
int DbQuery::countMonths( const int from_year, const int from_month, const int to_year, const int to_month ) noexcept
{
int n_months{ 0 };
if ( from_year == to_year ) {
@ -170,7 +170,7 @@ int DbQuery::countMonths( const QString& from_year, const QString& from_month, c
return f;
}*/
QString DbQuery::getDbField( const QString& tr_fld ) const
QString DbQuery::getDbField( const QString& tr_fld ) const noexcept
{
QString f;
for ( const auto& [id,str] : this->FIELDS ) {
@ -185,7 +185,7 @@ QString DbQuery::getDbField( const QString& tr_fld ) const
// get a fresh map of available dates
void DbQuery::refreshDates( std::optional<stats_dates_t>& result )
void DbQuery::refreshDates( std::optional<stats_dates_t>& result ) noexcept
{
bool successful{ true };
stats_dates_t dates{ // std::unordered_map<int, std::unordered_map<int, std::unordered_map<int, std::vector<int>>>>

View file

@ -46,14 +46,14 @@ public:
//! Returns the Dialogs level
void setDialogLevel( const int new_level );
void setDialogLevel( const int new_level ) noexcept;
//! Sets the path for the logs Collection database
/*!
\see Crapview::setDbPath()
*/
void setDbPath( const std::string& path );
void setDbPath( const std::string& path ) noexcept;
/*const std::string getDbPath( const int web_server );*/
@ -79,7 +79,7 @@ public:
/*!
\param result Holds the data only if the operation completed succssfully
*/
void refreshDates( std::optional<stats_dates_t>& result );
void refreshDates( std::optional<stats_dates_t>& result ) noexcept;
//! Updates the database applying the changes made in the Warnings statistics table
@ -297,7 +297,7 @@ private:
\param tr_fld The log field, hendles translated text
\return The database field
*/
QString getDbField( const QString& tr_fld ) const;
QString getDbField( const QString& tr_fld ) const noexcept;
/*const int getLogFieldID ( const QString& field_str );*/
@ -326,7 +326,7 @@ private:
\param month_str The month
\return The month number
*/
int getMonthNumber( const QString& month_str ) const;
int getMonthNumber( const QString& month_str ) const noexcept;
//! Returns the number of days in a given period
@ -342,7 +342,8 @@ private:
*/
static int countDays(
const int from_year, const int from_month, const int from_day,
const int to_year, const int to_month, const int to_day );
const int to_year, const int to_month, const int to_day
);
//! Returns the number of months in a given period
@ -355,7 +356,8 @@ private:
*/
static int countMonths(
const int from_year, const int from_month,
const int to_year, const int to_month );
const int to_year, const int to_month
) noexcept;
};

View file

@ -3,60 +3,60 @@
// getters
bool TextBrowser::getWideLinesUsage() const
bool TextBrowser::getWideLinesUsage() const noexcept
{
return this->wide_lines;
}
int TextBrowser::getColorSchemeID() const
int TextBrowser::getColorSchemeID() const noexcept
{
return this->color_scheme_id;
}
const std::unordered_map<std::string, QString>& TextBrowser::getColorScheme() const
const std::unordered_map<std::string, QString>& TextBrowser::getColorScheme() const noexcept
{
return this->color_scheme;
}
/*const int& TextBrowser::getFontSize()
/*const int& TextBrowser::getFontSize() noexcept
{
return this->font_size;
}*/
const QString& TextBrowser::getFontFamily() const
const QString& TextBrowser::getFontFamily() const noexcept
{
return this->font_family;
}
const QFont& TextBrowser::getFont() const
const QFont& TextBrowser::getFont() const noexcept
{
return this->font;
}
// setters
void TextBrowser::setWideLinesUsage( const bool& use_wide_lines )
void TextBrowser::setWideLinesUsage( const bool& use_wide_lines ) noexcept
{
this->wide_lines = use_wide_lines;
}
void TextBrowser::setColorScheme( const int& color_scheme_id, const std::unordered_map<std::string, QString>& color_scheme )
void TextBrowser::setColorScheme( const int& color_scheme_id, const std::unordered_map<std::string, QString>& color_scheme ) noexcept
{
this->color_scheme_id = color_scheme_id;
this->color_scheme = color_scheme;
}
/*void TextBrowser::setFontSize( const int& font_size )
/*void TextBrowser::setFontSize( const int& font_size ) noexcept
{
this->font_size = font_size;
}
void TextBrowser::setFontFamily( const QString& font_family )
void TextBrowser::setFontFamily( const QString& font_family ) noexcept
{
this->font_family = font_family;
}*/
void TextBrowser::setFont( const QFont& font )
void TextBrowser::setFont( const QFont& font ) noexcept
{
this->font = font;
this->font_family = font.family();
@ -64,7 +64,7 @@ void TextBrowser::setFont( const QFont& font )
// preview
void TextBrowser::makePreview( QString& content ) const
void TextBrowser::makePreview( QString& content ) const noexcept
{
content += QString("<!DOCTYPE html><html><head></head><body");
if ( this->color_scheme_id > 0 ) {

View file

@ -20,37 +20,37 @@ public:
//// GETTERS ////
//! Returns whether the wide lines option is set to be used or not
bool getWideLinesUsage() const;
bool getWideLinesUsage() const noexcept;
//! Returns the ID of the color scheme in use
int getColorSchemeID() const;
int getColorSchemeID() const noexcept;
//! Returns the color scheme in use
const std::unordered_map<std::string, QString>& getColorScheme() const;
const std::unordered_map<std::string, QString>& getColorScheme() const noexcept;
/*const int& getFontSize();*/
/*const int& getFontSize() noexcept;*/
//! Returns the family of the font in use
const QString& getFontFamily() const;
const QString& getFontFamily() const noexcept;
//! Returns the font in use
const QFont& getFont() const;
const QFont& getFont() const noexcept;
/////////////////
//// SETTERS ////
//! Sets whether to use wide lines or not
void setWideLinesUsage( const bool& use_wide_lines );
void setWideLinesUsage( const bool& use_wide_lines ) noexcept;
//! Stes the given color scheme as the one in use
void setColorScheme( const int& color_scheme_id, const std::unordered_map<std::string, QString>& color_scheme );
void setColorScheme( const int& color_scheme_id, const std::unordered_map<std::string, QString>& color_scheme ) noexcept;
/*void setFontSize( const int& font_size );
void setFontFamily( const QString& font_family );*/
/*void setFontSize( const int& font_size ) noexcept;
void setFontFamily( const QString& font_family ) noexcept;*/
//! Sets the given font as the one in use
void setFont( const QFont& font );
void setFont( const QFont& font ) noexcept;
/////////////////
@ -60,7 +60,7 @@ public:
/*!
\param content Will hold the preview string
*/
void makePreview( QString& content ) const;
void makePreview( QString& content ) const noexcept;
private:

View file

@ -13,7 +13,7 @@ Crapnote::Crapnote(QWidget *parent)
}
void Crapnote::setTextFont( const QFont& font )
void Crapnote::setTextFont( const QFont& font ) noexcept
{
QFont f{ font };
f.setPointSize( this->font_size );

View file

@ -22,7 +22,7 @@ public:
explicit Crapnote( QWidget* parent=nullptr );
//! Sets the given font
void setTextFont( const QFont& font );
void setTextFont( const QFont& font ) noexcept;
//! Sets the given color-scheme
void setColorScheme( const int& color_scheme_id );

View file

@ -14,7 +14,7 @@ namespace CharOps
\param chr The target character
\return The result of the check
*/
inline bool isNumeric( const char& chr )
inline bool isNumeric( const char& chr ) noexcept
{
return chr > 47 && chr < 58; // 0-9
}
@ -24,7 +24,7 @@ inline bool isNumeric( const char& chr )
\param chr The target character
\return The result of the check
*/
inline bool isAlphabetic( const char& chr )
inline bool isAlphabetic( const char& chr ) noexcept
{
return (chr > 96 && chr < 123) // a-z
|| (chr > 64 && chr < 91); // A-Z
@ -35,7 +35,7 @@ inline bool isAlphabetic( const char& chr )
\param chr The target character
\return The result of the check
*/
inline bool isAlnum( const char& chr )
inline bool isAlnum( const char& chr ) noexcept
{
return isAlphabetic( chr )
|| isNumeric( chr );
@ -46,7 +46,7 @@ inline bool isAlnum( const char& chr )
\param chr The target character
\return The result of the check
*/
inline bool isHex( const char& chr )
inline bool isHex( const char& chr ) noexcept
{
return (chr > 47 && chr < 58) // 0-9
|| (chr > 64 && chr < 71) // A-F
@ -58,7 +58,7 @@ inline bool isHex( const char& chr )
\param chr The target character
\return The result of the check
*/
inline bool isIP( const char& chr )
inline bool isIP( const char& chr ) noexcept
{
return chr == 46 // .
|| chr == 58 // :

View file

@ -27,7 +27,7 @@ namespace /*private*/
\return The result of the check: 0 if failed with an error, 1 if all the integrity checks passed, 2 if a rebuild is needed
\see checkCollectionDatabase(), checkHashesDatabase(), newCollectionDatabase(), newHashesDatabase()
*/
int checkDatabaseTablesNames( QSqlDatabase& db, const QString& db_name )
int checkDatabaseTablesNames( QSqlDatabase& db, const QString& db_name ) noexcept
{
bool make_new{false}, ok{true};
QSqlQuery query{ QSqlQuery( db ) };
@ -94,7 +94,7 @@ int checkDatabaseTablesNames( QSqlDatabase& db, const QString& db_name )
\return The result of the operation
\see checkCollectionDatabase(), checkHashesDatabase()
*/
bool newCollectionDatabase( QSqlDatabase& db, const QString& db_name, const std::vector<QString>& ws_names )
bool newCollectionDatabase( QSqlDatabase& db, const QString& db_name, const std::vector<QString>& ws_names ) noexcept
{
bool successful{ true };
// create the database
@ -161,7 +161,7 @@ bool newCollectionDatabase( QSqlDatabase& db, const QString& db_name, const std:
\return The result of the operation
\see checkCollectionDatabase(), checkHashesDatabase()
*/
bool newHashesDatabase( QSqlDatabase& db, const QString& db_name, const std::vector<QString>& ws_names )
bool newHashesDatabase( QSqlDatabase& db, const QString& db_name, const std::vector<QString>& ws_names ) noexcept
{
bool successful{ true };
// create the database
@ -205,7 +205,7 @@ bool newHashesDatabase( QSqlDatabase& db, const QString& db_name, const std::vec
} // namespace (private)
bool checkCollectionDatabase( const std::string& db_path )
bool checkCollectionDatabase( const std::string& db_path ) noexcept
{
bool make_new{false}, ok{true};
std::error_code err;
@ -375,7 +375,7 @@ bool checkCollectionDatabase( const std::string& db_path )
}
bool checkHashesDatabase( const std::string& db_path )
bool checkHashesDatabase( const std::string& db_path ) noexcept
{
bool make_new{false}, ok{true};
std::error_code err;
@ -513,7 +513,7 @@ bool checkHashesDatabase( const std::string& db_path )
}
bool checkDatabaseFile( const std::string& db_path, const QString& db_name )
bool checkDatabaseFile( const std::string& db_path, const QString& db_name ) noexcept
{
if ( ! IOutils::exists( db_path ) ) {
// path doesn't exists

View file

@ -21,7 +21,7 @@ namespace CheckSec
\return The result of the check
\see IOutils::exists(), IOutils::isFile(), IOutils::checkFile()
*/
bool checkDatabaseFile( const std::string& db_path, const QString& db_name );
bool checkDatabaseFile( const std::string& db_path, const QString& db_name ) noexcept;
//! Checks the structure's integrity of the Collection database
/*!
@ -29,7 +29,7 @@ bool checkDatabaseFile( const std::string& db_path, const QString& db_name );
\return The result of the check
\see checkDatabaseTablesNames(), newCollectionDatabase(), newHashesDatabase()
*/
bool checkCollectionDatabase( const std::string& db_path );
bool checkCollectionDatabase( const std::string& db_path ) noexcept;
//! Checks the structure's integrity of the Hashes database
/*!
@ -37,7 +37,7 @@ bool checkCollectionDatabase( const std::string& db_path );
\return The result of the check
\see checkDatabaseTablesNames(), newCollectionDatabase(), newHashesDatabase()
*/
bool checkHashesDatabase( const std::string& db_path );
bool checkHashesDatabase( const std::string& db_path ) noexcept;
} // namespace CheckSec

View file

@ -14,7 +14,7 @@
namespace ColorSec
{
std::unordered_map<std::string, QColor> getColors()
std::unordered_map<std::string, QColor> getColors() noexcept
{
return {
// greyscale
@ -31,7 +31,7 @@ std::unordered_map<std::string, QColor> getColors()
}
std::unordered_map<int, std::unordered_map<std::string, QString>> getColorSchemes()
std::unordered_map<int, std::unordered_map<std::string, QString>> getColorSchemes() noexcept
{
return {
// none

View file

@ -19,10 +19,10 @@ namespace ColorSec
{
//! Provides a map with pre-made colors
std::unordered_map<std::string, QColor> getColors();
std::unordered_map<std::string, QColor> getColors() noexcept;
//! Provides a map with pre-made color-schemes for the TextBrowser
std::unordered_map<int, std::unordered_map<std::string, QString>> getColorSchemes();
std::unordered_map<int, std::unordered_map<std::string, QString>> getColorSchemes() noexcept;
//! Applies the choosen theme to the given chart
/*!

View file

@ -53,7 +53,7 @@ public:
namespace IOutils
{
bool checkFile( std::string_view path, const bool readable, const bool writable )
bool checkFile( std::string_view path, const bool readable, const bool writable ) noexcept
{
if ( isFile( path ) ) {
// check the needed permissions
@ -74,7 +74,7 @@ bool checkFile( std::string_view path, const bool readable, const bool writable
}
bool checkDir( std::string_view path, const bool readable, const bool writable )
bool checkDir( std::string_view path, const bool readable, const bool writable ) noexcept
{
if ( isDir( path ) ) {
// check the needed permissions
@ -95,7 +95,7 @@ bool checkDir( std::string_view path, const bool readable, const bool writable )
}
bool makeDir( std::string_view path, std::error_code& err ) noexcept(true)
bool makeDir( std::string_view path, std::error_code& err ) noexcept
{
try {
const bool failed{ !std::filesystem::create_directories( path, err ) };
@ -110,7 +110,7 @@ bool makeDir( std::string_view path, std::error_code& err ) noexcept(true)
// rename an entry with a trailing '.copy'
bool renameAsCopy( std::string_view path, std::error_code& err ) noexcept(true)
bool renameAsCopy( std::string_view path, std::error_code& err ) noexcept
{
try {
std::string new_path{ path };

View file

@ -19,7 +19,7 @@ namespace IOutils
\param path The path of the entry
\return The result of the check
*/
inline bool exists( std::string_view path )
inline bool exists( std::string_view path ) noexcept
{
return path.empty()
? false
@ -31,7 +31,7 @@ inline bool exists( std::string_view path )
\param path The path of the entry
\return The result of the check
*/
inline bool isFile( std::string_view path )
inline bool isFile( std::string_view path ) noexcept
{
return exists( path )
? std::filesystem::is_regular_file( path )
@ -43,7 +43,7 @@ inline bool isFile( std::string_view path )
\param path The path of the entry
\return The result of the checks
*/
inline bool isDir( std::string_view path )
inline bool isDir( std::string_view path ) noexcept
{
return exists( path )
? std::filesystem::is_directory( path )
@ -57,7 +57,7 @@ inline bool isDir( std::string_view path )
\param writable Set to true to check for writability
\return The result of the checks
*/
bool checkFile( std::string_view path, const bool readable=false, const bool writable=false );
bool checkFile( std::string_view path, const bool readable=false, const bool writable=false ) noexcept;
//! Checks if a path exists, if it points to a folder and if the user has read and/or write permissions on it
/*!
@ -66,14 +66,14 @@ bool checkFile( std::string_view path, const bool readable=false, const bool wri
\param writable Set to true to check for writability
\return The result of the checks
*/
bool checkDir( std::string_view path, const bool readable=false, const bool writable=false );
bool checkDir( std::string_view path, const bool readable=false, const bool writable=false ) noexcept;
//! Creates a directory
/*!
\param path The path of the new entry
\return Wheter the operation was successful or not
*/
bool makeDir( std::string_view path, std::error_code& err ) noexcept(true);
bool makeDir( std::string_view path, std::error_code& err ) noexcept;
//! Renames an entry with a trailing '.copy'
/*!
@ -81,7 +81,7 @@ bool makeDir( std::string_view path, std::error_code& err ) noexcept(true);
\param err Will hold the error, if any
\return Wheter the operation was successful or not
*/
bool renameAsCopy( std::string_view path, std::error_code& err ) noexcept(true);
bool renameAsCopy( std::string_view path, std::error_code& err ) noexcept;
//! Randomly pick lines from a file
/*!

View file

@ -9,7 +9,7 @@
namespace PrintSec
{
QString printableSize( const size_t bytes )
QString printableSize( const size_t bytes ) noexcept
{
std::string size_sfx{" B"};
double size{ static_cast<double>(bytes) };
@ -48,7 +48,7 @@ QString printableSize( const size_t bytes )
}
QString printableSpeed( const double bytes, const double secs_ )
QString printableSpeed( const double bytes, const double secs_ ) noexcept
{
std::string speed_sfx{" B/s"};
const double secs{ ( secs_ > 0.0 ) ? secs_ : ( secs_ < 0.0 ) ? -secs_ : 0.1 };
@ -88,7 +88,7 @@ QString printableSpeed( const double bytes, const double secs_ )
}
QString printableTime( const unsigned seconds )
QString printableTime( const unsigned seconds ) noexcept
{
const unsigned mins{ seconds / 60u };
const unsigned secs{ seconds - (mins*60u) };
@ -103,7 +103,7 @@ QString printableTime( const unsigned seconds )
}
QString printableTime( const int hour, const int minute, const int second )
QString printableTime( const int hour, const int minute, const int second ) noexcept
{
return QString("%1:%2:%3").arg(
(hour<10)
@ -119,7 +119,7 @@ QString printableTime( const int hour, const int minute, const int second )
}
QString printableDate( const QString& year, const int month, const QString& day )
QString printableDate( const QString& year, const int month, const QString& day ) noexcept
{
return QString("%1-%2-%3").arg(
year,
@ -133,7 +133,7 @@ QString printableDate( const QString& year, const int month, const QString& day
}
QString printableDate( const int year, const int month, const int day )
QString printableDate( const int year, const int month, const int day ) noexcept
{
return QString("%1-%2-%3").arg(
QString::number( year ),
@ -147,7 +147,7 @@ QString printableDate( const int year, const int month, const int day )
}
QString printableBool( const int value )
QString printableBool( const int value ) noexcept
{
if ( value == 0 ) {
return TR::tr( BOOLS__FALSE.c_str() );

View file

@ -21,7 +21,7 @@ namespace PrintSec
*/
QString printableSize(
const size_t bytes
);
) noexcept;
//! Formats the speed including the suffix, for display purposes
@ -32,7 +32,7 @@ QString printableSize(
*/
QString printableSpeed(
const double bytes, const double seconds
);
) noexcept;
//! Formats the time, for display purposes
@ -42,7 +42,7 @@ QString printableSpeed(
*/
QString printableTime(
const unsigned seconds
);
) noexcept;
//! Returns a string of the given time in the format HH:MM:SS
@ -54,7 +54,7 @@ QString printableTime(
*/
QString printableTime(
const int hour, const int minute, const int second
);
) noexcept;
//! Returns a string of the given date in the format YYYY-MM-DD
@ -67,7 +67,7 @@ QString printableTime(
*/
QString printableDate(
const QString& year, const int month, const QString& day
);
) noexcept;
//! Returns a string of the given date in the format YYYY-MM-DD
@ -79,7 +79,7 @@ QString printableDate(
*/
QString printableDate(
const int year, const int month, const int day
);
) noexcept;
//! Returns a string corresponding to the given value
@ -90,7 +90,7 @@ QString printableDate(
*/
QString printableBool(
const int value
);
) noexcept;
} // namespace PrintSec

View file

@ -6,7 +6,7 @@
namespace StringOps
{
size_t count( std::string_view str, std::string_view flag )
size_t count( std::string_view str, std::string_view flag ) noexcept
{
const size_t flg_size{ flag.size() };
size_t count{ 0ul };
@ -17,7 +17,7 @@ size_t count( std::string_view str, std::string_view flag )
}
std::string strip( const std::string& str, const char chr )
std::string strip( const std::string& str, const char chr ) noexcept
{
if (const size_t start{ str.find_first_not_of( chr ) }; start != std::string::npos ) {
const size_t stop{ str.find_last_not_of( chr ) };
@ -26,7 +26,7 @@ std::string strip( const std::string& str, const char chr )
return std::string{};
}
std::string strip( const std::string& str, std::string_view chars )
std::string strip( const std::string& str, std::string_view chars ) noexcept
{
if (const size_t start{ str.find_first_not_of( chars ) }; start != std::string::npos ) {
const size_t stop{ str.find_last_not_of( chars ) };
@ -36,7 +36,7 @@ std::string strip( const std::string& str, std::string_view chars )
}
std::string lstrip( const std::string& str, const char chr )
std::string lstrip( const std::string& str, const char chr ) noexcept
{
if (const size_t start{ str.find_first_not_of( chr ) }; start != std::string::npos ) {
return str.substr( start );
@ -44,7 +44,7 @@ std::string lstrip( const std::string& str, const char chr )
return std::string{};
}
std::string lstrip( const std::string& str, std::string_view chars )
std::string lstrip( const std::string& str, std::string_view chars ) noexcept
{
if (const size_t start{ str.find_first_not_of( chars ) }; start != std::string::npos ) {
return str.substr( start );
@ -53,7 +53,7 @@ std::string lstrip( const std::string& str, std::string_view chars )
}
std::string rstrip( const std::string &str, const char chr )
std::string rstrip( const std::string &str, const char chr ) noexcept
{
if (const size_t stop{ str.find_last_not_of( chr ) }; stop != std::string::npos ) {
return str.substr( 0ul, stop+1ul );
@ -61,7 +61,7 @@ std::string rstrip( const std::string &str, const char chr )
return std::string{};
}
std::string rstrip( const std::string& str, std::string_view chars )
std::string rstrip( const std::string& str, std::string_view chars ) noexcept
{
if (const size_t stop{ str.find_last_not_of( chars ) }; stop != std::string::npos ) {
return str.substr( 0ul, stop+1ul );
@ -70,7 +70,7 @@ std::string rstrip( const std::string& str, std::string_view chars )
}
std::string lstripUntil( const std::string& str, const char delim, const bool inclusive, const bool consecutives )
std::string lstripUntil( const std::string& str, const char delim, const bool inclusive, const bool consecutives ) noexcept
{
if (size_t start{ str.find( delim ) }; start != std::string::npos ) {
if ( inclusive ) {
@ -90,7 +90,7 @@ std::string lstripUntil( const std::string& str, const char delim, const bool in
}
void split( std::vector<std::string>& list, const std::string& target_str, const char separator )
void split( std::vector<std::string>& list, const std::string& target_str, const char separator ) noexcept
{
if ( target_str.empty() ) {
return;
@ -108,7 +108,7 @@ void split( std::vector<std::string>& list, const std::string& target_str, const
}
}
void split( std::vector<std::string>& list, const std::string& target_str, std::string_view separator )
void split( std::vector<std::string>& list, const std::string& target_str, std::string_view separator ) noexcept
{
if ( target_str.empty() ) {
return;
@ -129,7 +129,7 @@ void split( std::vector<std::string>& list, const std::string& target_str, std::
}
void splitrip( std::vector<std::string>& list, const std::string& target_str, const char separator, std::string_view strips )
void splitrip( std::vector<std::string>& list, const std::string& target_str, const char separator, std::string_view strips ) noexcept
{
split( list, strip( target_str, strips ), separator );
std::transform( list.begin(), list.end(), list.begin(),
@ -137,7 +137,7 @@ void splitrip( std::vector<std::string>& list, const std::string& target_str, co
{ return strip( str, strips ); } );
}
void splitrip( std::vector<std::string>& list, const std::string& target_str, std::string_view separator, std::string_view strips )
void splitrip( std::vector<std::string>& list, const std::string& target_str, std::string_view separator, std::string_view strips ) noexcept
{
split( list, strip( target_str, strips ), separator );
std::transform( list.begin(), list.end(), list.begin(),
@ -146,7 +146,7 @@ void splitrip( std::vector<std::string>& list, const std::string& target_str, st
}
std::string replace( std::string_view str, std::string_view target, std::string_view replace )
std::string replace( std::string_view str, std::string_view target, std::string_view replace ) noexcept
{
std::string s{ str };
const size_t t_size{ target.size() };
@ -160,7 +160,7 @@ std::string replace( std::string_view str, std::string_view target, std::string_
}
std::string toUpper( std::string_view str )
std::string toUpper( std::string_view str ) noexcept
{
std::string up{ str };
std::transform( up.begin(), up.end(), up.begin(),
@ -170,7 +170,7 @@ std::string toUpper( std::string_view str )
}
std::string toLower( std::string_view str )
std::string toLower( std::string_view str ) noexcept
{
std::string low{ str };
std::transform( low.begin(), low.end(), low.begin(),

View file

@ -21,7 +21,7 @@ namespace StringOps
\param flag The character to find
\return The number of occurrences
*/
inline size_t count( std::string_view str, const char flag )
inline size_t count( std::string_view str, const char flag ) noexcept
{
return static_cast<size_t>( std::count( str.cbegin(), str.cend(), flag ) );
}
@ -32,14 +32,14 @@ inline size_t count( std::string_view str, const char flag )
\param flag The string to find
\return The number of occurrences
*/
size_t count( std::string_view str, std::string_view flag );
size_t count( std::string_view str, std::string_view flag ) noexcept;
//! Checks whether a string only contains numeric characters
/*!
\param str The target string
\return The result of the check
*/
inline bool isNumeric( std::string_view str )
inline bool isNumeric( std::string_view str ) noexcept
{
return str.empty()
? false
@ -51,7 +51,7 @@ inline bool isNumeric( std::string_view str )
\param str The target string
\return The result of the check
*/
inline bool isAlphabetic( std::string_view str )
inline bool isAlphabetic( std::string_view str ) noexcept
{
return str.empty()
? false
@ -63,7 +63,7 @@ inline bool isAlphabetic( std::string_view str )
\param str The target string
\return The result of the check
*/
inline bool isAlnum( std::string_view str )
inline bool isAlnum( std::string_view str ) noexcept
{
return str.empty()
? false
@ -77,7 +77,7 @@ inline bool isAlnum( std::string_view str )
\param str The target string
\return The result of the check
*/
inline bool isIP( std::string_view str )
inline bool isIP( std::string_view str ) noexcept
{
return str.empty()
? false
@ -90,7 +90,7 @@ inline bool isIP( std::string_view str )
\param flag The character to search for
\return The result of the check
*/
inline bool startsWith( std::string_view str, const char flag )
inline bool startsWith( std::string_view str, const char flag ) noexcept
{
return str.front() == flag;
}
@ -102,7 +102,7 @@ inline bool startsWith( std::string_view str, const char flag )
\param flag The sequence to search for
\return The result of the check
*/
inline bool startsWith( std::string_view str, std::string_view flag )
inline bool startsWith( std::string_view str, std::string_view flag ) noexcept
{
return str.rfind( flag, 0ul ) == 0ul;
}
@ -113,7 +113,7 @@ inline bool startsWith( std::string_view str, std::string_view flag )
\param flag The character to search for
\return The result of the check
*/
inline bool endsWith( std::string_view str, const char flag )
inline bool endsWith( std::string_view str, const char flag ) noexcept
{
return str.back() == flag;
}
@ -125,7 +125,7 @@ inline bool endsWith( std::string_view str, const char flag )
\param flag The sequence to search for
\return The result of the check
*/
inline bool endsWith( std::string_view str, std::string_view flag )
inline bool endsWith( std::string_view str, std::string_view flag ) noexcept
{
return str.rfind( flag ) == str.size()-flag.size();
}
@ -136,7 +136,7 @@ inline bool endsWith( std::string_view str, std::string_view flag )
\param flag The sequence to search for
\return The result of the check
*/
inline bool contains( std::string_view str, std::string_view flag )
inline bool contains( std::string_view str, std::string_view flag ) noexcept
{
return str.find( flag ) != std::string::npos;
}
@ -147,7 +147,7 @@ inline bool contains( std::string_view str, std::string_view flag )
\param chr The character to strip away
\return The result string
*/
std::string strip( const std::string& str, const char chr );
std::string strip( const std::string& str, const char chr ) noexcept;
//! Strips the given characters from both the left and the right side of a string
/*!
@ -155,7 +155,7 @@ std::string strip( const std::string& str, const char chr );
\param chars The characters to strip away
\return The result string
*/
std::string strip( const std::string& str, std::string_view chars=" \n\t\b\r\v" );
std::string strip( const std::string& str, std::string_view chars=" \n\t\b\r\v" ) noexcept;
//! Strips the given character from the left side of a string
/*!
@ -163,7 +163,7 @@ std::string strip( const std::string& str, std::string_view chars=" \n\t\b\r\v"
\param chr The character to strip away
\return The result string
*/
std::string lstrip( const std::string& str, const char chr );
std::string lstrip( const std::string& str, const char chr ) noexcept;
//! Strips the given characters from the left side of a string
/*!
@ -171,7 +171,7 @@ std::string lstrip( const std::string& str, const char chr );
\param chars The characters to strip away
\return The result string
*/
std::string lstrip( const std::string& str, std::string_view chars=" \n\t\b\r\v" );
std::string lstrip( const std::string& str, std::string_view chars=" \n\t\b\r\v" ) noexcept;
//! Strips the given character from the right side of a string
/*!
@ -179,7 +179,7 @@ std::string lstrip( const std::string& str, std::string_view chars=" \n\t\b\r\v"
\param chr The character to strip away
\return The result string
*/
std::string rstrip( const std::string &str, const char chr );
std::string rstrip( const std::string &str, const char chr ) noexcept;
//! Strips the given characters from the right side of a string
/*!
@ -187,7 +187,7 @@ std::string rstrip( const std::string &str, const char chr );
\param chars The characters to strip away
\return The result string
*/
std::string rstrip( const std::string& str, std::string_view chars=" \n\t\b\r\v" );
std::string rstrip( const std::string& str, std::string_view chars=" \n\t\b\r\v" ) noexcept;
//! Strips everything from a string starting from the left side untill the delimiter is found (a.k.a. cut)
/*!
@ -197,7 +197,7 @@ std::string rstrip( const std::string& str, std::string_view chars=" \n\t\b\r\v"
\param consecutives Whether to strip all the occurrences of the delimiter if they're consecutive, only applies if inclusive
\return The result string
*/
std::string lstripUntil( const std::string& str, const char delim, const bool inclusive=true, const bool consecutives=true );
std::string lstripUntil( const std::string& str, const char delim, const bool inclusive=true, const bool consecutives=true ) noexcept;
//! Splits a string using a separator
/*!
@ -205,7 +205,7 @@ std::string lstripUntil( const std::string& str, const char delim, const bool in
\param target_str The target string
\param separator The character to use as separator
*/
void split( std::vector<std::string>& list, const std::string& target_str, const char separator='\n' );
void split( std::vector<std::string>& list, const std::string& target_str, const char separator='\n' ) noexcept;
//! Splits a string using a separator
/*!
@ -213,7 +213,7 @@ void split( std::vector<std::string>& list, const std::string& target_str, const
\param target_str The target string
\param separator The sequence to use as separator
*/
void split( std::vector<std::string>& list, const std::string& target_str, std::string_view separator );
void split( std::vector<std::string>& list, const std::string& target_str, std::string_view separator ) noexcept;
//! Splits a string and strips all the splitted items
/*!
@ -222,7 +222,7 @@ void split( std::vector<std::string>& list, const std::string& target_str, std::
\param separator The sequence to use as separator
\param strip The characters to strip away
*/
void splitrip( std::vector<std::string>& list, const std::string& target_str, const char separator='\n', std::string_view strips=" \n\t\b\r\v" );
void splitrip( std::vector<std::string>& list, const std::string& target_str, const char separator='\n', std::string_view strips=" \n\t\b\r\v" ) noexcept;
//! Splits a string and strips all the splitted items
/*!
@ -231,7 +231,7 @@ void splitrip( std::vector<std::string>& list, const std::string& target_str, co
\param separator The sequence to use as separator
\param strip The characters to strip away
*/
void splitrip( std::vector<std::string>& list, const std::string& target_str, std::string_view separator, std::string_view strips=" \n\t\b\r\v" );
void splitrip( std::vector<std::string>& list, const std::string& target_str, std::string_view separator, std::string_view strips=" \n\t\b\r\v" ) noexcept;
//! Replaces all the occurrences of a sequence with another
/*!
@ -240,21 +240,21 @@ void splitrip( std::vector<std::string>& list, const std::string& target_str, st
\param replace The sequence to be used to replace the target
\return The result string
*/
std::string replace( std::string_view str, std::string_view target, std::string_view replace );
std::string replace( std::string_view str, std::string_view target, std::string_view replace ) noexcept;
//! Converts a string to upper case
/*!
\param str The target string
\return The result string
*/
std::string toUpper( std::string_view str );
std::string toUpper( std::string_view str ) noexcept;
//! Converts a string to lower case
/*!
\param str The target string
\return The result string
*/
std::string toLower( std::string_view str );
std::string toLower( std::string_view str ) noexcept;
} // namespace StringOps

View file

@ -20,7 +20,7 @@ namespace VecOps
\return Whether the list does contain the flag or not
*/
template <typename T>
inline bool contains( const std::vector<T>& list, const T& flag )
inline bool contains( const std::vector<T>& list, const T& flag ) noexcept
{
return std::any_of( list.cbegin(), list.cend(),
[&flag]( const T& item )