Minor code improvements
Replaced use of postfix operators with prefix operators. Replaced manual declarations with Q_DISABLE_COPY_MOVE macro for FileHandler classes.
This commit is contained in:
parent
97379cfd17
commit
d910069a1b
19 changed files with 242 additions and 248 deletions
|
@ -189,7 +189,7 @@ bool CrissCross::checkVictory()
|
|||
streak = 0;
|
||||
for ( const auto& index : sequence ) {
|
||||
if ( this->board[ index ] == this->p_turn ) {
|
||||
streak ++;
|
||||
++streak;
|
||||
this->victory_sequence.push_back( index );
|
||||
} else {
|
||||
break;
|
||||
|
@ -210,7 +210,7 @@ void CrissCross::victory()
|
|||
{
|
||||
// disable all buttons except the victory sequence ones
|
||||
bool disable{ true };
|
||||
for ( unsigned i=0; i<9; i++ ) {
|
||||
for ( unsigned i=0; i<9; ++i ) {
|
||||
disable |= true;
|
||||
for ( const auto& j : this->victory_sequence ) {
|
||||
if ( i == j ) {
|
||||
|
@ -252,7 +252,7 @@ bool CrissCross::gameDraw() const
|
|||
unsigned empty_tiles{ 9 };
|
||||
for ( const auto& tile : this->board ) {
|
||||
if ( tile > 0 ) {
|
||||
empty_tiles --;
|
||||
-- empty_tiles;
|
||||
}
|
||||
}
|
||||
if ( empty_tiles == 0 ) {
|
||||
|
@ -290,7 +290,7 @@ void CrissCross::AI_playTurn()
|
|||
void CrissCross::AI_updateWeights()
|
||||
{
|
||||
// reset the weights
|
||||
for ( size_t i{0ul}; i<9ul; i++ ) {
|
||||
for ( size_t i{0ul}; i<9ul; ++i ) {
|
||||
this->board_weights[ i ] = 0;
|
||||
}
|
||||
// calculate the new weights
|
||||
|
@ -303,9 +303,9 @@ void CrissCross::AI_updateWeights()
|
|||
// check the tiles in the sequence
|
||||
for ( const auto index : sequence ) {
|
||||
if ( this->board[ index ] == this->p_turn ) {
|
||||
win_streak ++;
|
||||
++ win_streak;
|
||||
} else if ( this->board[ index ] > 0 ) {
|
||||
lose_streak ++;
|
||||
++ lose_streak;
|
||||
} else {
|
||||
empty_tiles.emplace_back( std::move(index) );
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ unsigned CrissCross::AI_makeChoice() const
|
|||
// lighter weight
|
||||
;
|
||||
}*/
|
||||
index ++;
|
||||
++ index;
|
||||
}
|
||||
// decide the movement (or better, randomly pick one)
|
||||
unsigned next_move;
|
||||
|
|
|
@ -185,17 +185,17 @@ void SnakeGame::newSnake_()
|
|||
case Direction::UP:
|
||||
case Direction::DOWN:
|
||||
if ( rnd ) {
|
||||
head_x ++;
|
||||
++ head_x;
|
||||
} else {
|
||||
head_x --;
|
||||
-- head_x;
|
||||
}
|
||||
break;
|
||||
case Direction::LEFT:
|
||||
case Direction::RIGHT:
|
||||
if ( rnd ) {
|
||||
head_y ++;
|
||||
++ head_y;
|
||||
} else {
|
||||
head_y --;
|
||||
-- head_y;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -272,7 +272,7 @@ void SnakeGame::processGameLogic()
|
|||
this->moving_countdown = this->moving_rate;
|
||||
}
|
||||
} else if ( this->game_mode == GameMode::Hunt ) {
|
||||
this->moving_countdown --;
|
||||
-- this->moving_countdown;
|
||||
if ( this->moving_countdown == 0u ) {
|
||||
this->moving_countdown = this->moving_rate;
|
||||
this->food.move( this->snake );
|
||||
|
@ -327,16 +327,16 @@ void SnakeGame::checkCollision( Snake& snake, Snake& adv_snake, const bool is_ad
|
|||
unsigned x_, y_;
|
||||
switch ( snake.direction() ) {
|
||||
case Direction::UP:
|
||||
y--;
|
||||
--y;
|
||||
break;
|
||||
case Direction::DOWN:
|
||||
y++;
|
||||
++y;
|
||||
break;
|
||||
case Direction::LEFT:
|
||||
x--;
|
||||
--x;
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
x++;
|
||||
++x;
|
||||
break;
|
||||
default:
|
||||
// should be unreachable
|
||||
|
@ -348,16 +348,16 @@ void SnakeGame::checkCollision( Snake& snake, Snake& adv_snake, const bool is_ad
|
|||
y_ = adv_snake.front().y;
|
||||
switch ( adv_snake.direction() ) {
|
||||
case Direction::UP:
|
||||
y_--;
|
||||
--y_;
|
||||
break;
|
||||
case Direction::DOWN:
|
||||
y_++;
|
||||
++y_;
|
||||
break;
|
||||
case Direction::LEFT:
|
||||
x_--;
|
||||
--x_;
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
x_++;
|
||||
++x_;
|
||||
break;
|
||||
default:
|
||||
// should be unreachable
|
||||
|
|
|
@ -40,13 +40,13 @@ bool Snake::inTile( const unsigned x, const unsigned y, const bool avoid_tail )
|
|||
size_t i{ 0 };
|
||||
size_t max{ this->size()-1ul };
|
||||
if ( !avoid_tail ) {
|
||||
max ++;
|
||||
++ max;
|
||||
}
|
||||
for ( auto bp{ this->cbegin() }; bp != this->cend(); ++bp ) {
|
||||
if ( bp->x == x && bp->y == y ) {
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
if ( i >= max ) {
|
||||
break;
|
||||
}
|
||||
|
@ -81,16 +81,16 @@ void Snake::grow( const bool is_borning )
|
|||
// one tile behind
|
||||
switch ( d ) {
|
||||
case Direction::UP:
|
||||
y ++;
|
||||
++ y;
|
||||
break;
|
||||
case Direction::DOWN:
|
||||
y --;
|
||||
-- y;
|
||||
break;
|
||||
case Direction::LEFT:
|
||||
x ++;
|
||||
++ x;
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
x --;
|
||||
-- x;
|
||||
break;
|
||||
default:
|
||||
// should be unreachable
|
||||
|
@ -366,7 +366,7 @@ void Snake::update( QGraphicsScene* field_scene, const bool dry , const bool is_
|
|||
throw("Unexpected direction: "+std::to_string(bp->direction));
|
||||
}
|
||||
prev_body_d = bp->direction;
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ void Snake::move( const Snake& adv_snake, const unsigned food_x, const unsigned
|
|||
|
||||
this->updateFieldMap( adv_snake, food_x, food_y );
|
||||
|
||||
for ( size_t i{0}; i<4ul; i++ ) {
|
||||
for ( size_t i{0}; i<4ul; ++i ) {
|
||||
this->collectData( dataset.at(i), classes.at(i), adv_snake, food_x, food_y );
|
||||
}
|
||||
|
||||
|
@ -415,10 +415,10 @@ Direction Snake::predictDirection( const std::array<std::array<float,7>,4>& data
|
|||
Direction class_label;
|
||||
|
||||
// process data
|
||||
for ( size_t i{0}; i<4ul; i++ ) {
|
||||
for ( size_t i{0}; i<4ul; ++i ) {
|
||||
const std::array<float, 7>& d = data.at(i);
|
||||
float& r = results[i];
|
||||
for ( size_t j{0}; j<7ul; j++ ) {
|
||||
for ( size_t j{0}; j<7ul; ++j ) {
|
||||
r += d.at(j) * weights.at(j);
|
||||
}
|
||||
}
|
||||
|
@ -434,12 +434,12 @@ Direction Snake::predictDirection( const std::array<std::array<float,7>,4>& data
|
|||
}
|
||||
}
|
||||
if ( max != min ) {
|
||||
for ( size_t i{0}; i<4ul; i++ ) {
|
||||
for ( size_t i{0}; i<4ul; ++i ) {
|
||||
results[i] = (results[i]-min) / (max-min);
|
||||
}
|
||||
} else {
|
||||
keep_current |= true;
|
||||
for ( size_t i{0}; i<4ul; i++ ) {
|
||||
for ( size_t i{0}; i<4ul; ++i ) {
|
||||
results[i] = 0.f;
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ Direction Snake::predictDirection( const std::array<std::array<float,7>,4>& data
|
|||
class_label = this->head_direction;
|
||||
} else {
|
||||
max = 0.f;
|
||||
for ( size_t i{0}; i<4ul; i++ ) {
|
||||
for ( size_t i{0}; i<4ul; ++i ) {
|
||||
if ( results[i] > max ) {
|
||||
class_label = classes.at(i);
|
||||
max = results[i];
|
||||
|
@ -731,8 +731,8 @@ 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 )
|
||||
{
|
||||
// reset to default state
|
||||
for ( size_t x{0}; x<16ul; x++ ) {
|
||||
for ( size_t y{0}; y<16ul; y++ ) {
|
||||
for ( size_t x{0}; x<16ul; ++x ) {
|
||||
for ( size_t y{0}; y<16ul; ++y ) {
|
||||
Tile& t = this->field_map.at(x).at(y);
|
||||
t.entity = Entity::N;
|
||||
t.s_index = 0u;
|
||||
|
@ -746,7 +746,7 @@ void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, cons
|
|||
Tile& t = this->field_map.at(bp->x).at(bp->y);
|
||||
t.entity = Entity::S;
|
||||
t.s_index = i;
|
||||
i--;
|
||||
--i;
|
||||
}
|
||||
// update adversary
|
||||
i = static_cast<unsigned>( adv_snake.size() );
|
||||
|
@ -754,7 +754,7 @@ void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, cons
|
|||
Tile& t = this->field_map.at(bp.x).at(bp.y);
|
||||
t.entity = Entity::A;
|
||||
t.s_index = i;
|
||||
i--;
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,7 +836,7 @@ std::array<unsigned,8> Snake::checkAround( const Direction& direction, const uns
|
|||
}
|
||||
|
||||
unsigned x_, y_;
|
||||
for ( size_t i{0}; i<8ul; i++ ) {
|
||||
for ( size_t i{0}; i<8ul; ++i ) {
|
||||
x_ = x;
|
||||
x_ += x_pattern.at(i);
|
||||
y_ = y;
|
||||
|
@ -1104,7 +1104,7 @@ unsigned Snake::isDeadHole( const unsigned start_x, const unsigned start_y, cons
|
|||
result = true;
|
||||
break;
|
||||
} else {
|
||||
steps ++;
|
||||
++ steps;
|
||||
if ( steps >= max_steps ) {
|
||||
break;
|
||||
}
|
||||
|
@ -1121,7 +1121,7 @@ unsigned Snake::isDeadHole( const unsigned start_x, const unsigned start_y, cons
|
|||
if ( !result ) {
|
||||
steps = 0;
|
||||
}
|
||||
i ++;
|
||||
++ i;
|
||||
if ( i == 2u ) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ void MainWindow::readConfigs()
|
|||
std::vector<std::string> aux, configs;
|
||||
try {
|
||||
// reset the lists when a config file is found
|
||||
for ( unsigned w=APACHE_ID; w<=IIS_ID; w++ ) {
|
||||
for ( unsigned w=APACHE_ID; w<=IIS_ID; ++w ) {
|
||||
for ( const int& f : {11,12,20,21} ) {
|
||||
this->craplog.setWarnlist( w, f, {} );
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ void MainWindow::backupDatabase() const
|
|||
}
|
||||
if ( proceed ) {
|
||||
// cascade rename
|
||||
for ( int n=this->db_backups_number-1; n>=0; n-- ) {
|
||||
for ( int n=this->db_backups_number-1; n>=0; --n ) {
|
||||
path = this->db_data_path+"/backups/collection.db."+std::to_string( n );
|
||||
if ( std::filesystem::exists( path ) ) {
|
||||
new_path = this->db_data_path+"/backups/collection.db."+std::to_string( n+1 );
|
||||
|
@ -2673,9 +2673,9 @@ void MainWindow::on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column)
|
|||
QTreeWidgetItemIterator i(this->ui->listLogFiles);
|
||||
while ( *i ) {
|
||||
if ( (*i)->checkState(0) == Qt::CheckState::Checked ) {
|
||||
n_checked++;
|
||||
++ n_checked;
|
||||
}
|
||||
++i;
|
||||
++ i;
|
||||
}
|
||||
if ( n_checked == 0ul ) {
|
||||
this->ui->checkBox_LogFiles_CheckAll->setCheckState(Qt::CheckState::Unchecked);
|
||||
|
@ -4362,7 +4362,7 @@ void MainWindow::refreshChartsPreview()
|
|||
return (rand()%10 > 8) ? rand()%100 : (rand()%10 > 6) ? rand()%50 : rand()%30;
|
||||
};
|
||||
int aux, max{0};
|
||||
for ( int i{0}; i<24; i++ ) {
|
||||
for ( int i{0}; i<24; ++i ) {
|
||||
aux = random_value();
|
||||
*bars_1 << aux;
|
||||
if ( aux > max ) {
|
||||
|
@ -4772,7 +4772,7 @@ void MainWindow::on_list_ConfApache_Warnlist_List_itemSelectionChanged()
|
|||
this->ui->button_ConfApache_Warnlist_Up->setEnabled( false );
|
||||
this->ui->button_ConfApache_Warnlist_Down->setEnabled( false );
|
||||
} else {
|
||||
for ( int i{0}; i<=max; i++ ) {
|
||||
for ( int i{0}; i<=max; ++i ) {
|
||||
if ( this->ui->list_ConfApache_Warnlist_List->item(i) == item ) {
|
||||
if ( i == 0 ) {
|
||||
this->ui->button_ConfApache_Warnlist_Up->setEnabled( false );
|
||||
|
@ -4919,7 +4919,7 @@ void MainWindow::on_list_ConfApache_Blacklist_List_itemSelectionChanged()
|
|||
this->ui->button_ConfApache_Blacklist_Up->setEnabled( false );
|
||||
this->ui->button_ConfApache_Blacklist_Down->setEnabled( false );
|
||||
} else {
|
||||
for ( int i{0}; i<=max; i++ ) {
|
||||
for ( int i{0}; i<=max; ++i ) {
|
||||
if ( this->ui->list_ConfApache_Blacklist_List->item(i) == item ) {
|
||||
if ( i == 0 ) {
|
||||
this->ui->button_ConfApache_Blacklist_Up->setEnabled( false );
|
||||
|
@ -5143,7 +5143,7 @@ void MainWindow::on_list_ConfNginx_Warnlist_List_itemSelectionChanged()
|
|||
this->ui->button_ConfNginx_Warnlist_Up->setEnabled( false );
|
||||
this->ui->button_ConfNginx_Warnlist_Down->setEnabled( false );
|
||||
} else {
|
||||
for ( int i{0}; i<=max; i++ ) {
|
||||
for ( int i{0}; i<=max; ++i ) {
|
||||
if ( this->ui->list_ConfNginx_Warnlist_List->item(i) == item ) {
|
||||
if ( i == 0 ) {
|
||||
this->ui->button_ConfNginx_Warnlist_Up->setEnabled( false );
|
||||
|
@ -5290,7 +5290,7 @@ void MainWindow::on_list_ConfNginx_Blacklist_List_itemSelectionChanged()
|
|||
this->ui->button_ConfNginx_Blacklist_Up->setEnabled( false );
|
||||
this->ui->button_ConfNginx_Blacklist_Down->setEnabled( false );
|
||||
} else {
|
||||
for ( int i{0}; i<=max; i++ ) {
|
||||
for ( int i{0}; i<=max; ++i ) {
|
||||
if ( this->ui->list_ConfNginx_Blacklist_List->item(i) == item ) {
|
||||
if ( i == 0 ) {
|
||||
this->ui->button_ConfNginx_Blacklist_Up->setEnabled( false );
|
||||
|
@ -5577,7 +5577,7 @@ void MainWindow::on_list_ConfIis_Warnlist_List_itemSelectionChanged()
|
|||
this->ui->button_ConfIis_Warnlist_Up->setEnabled( false );
|
||||
this->ui->button_ConfIis_Warnlist_Down->setEnabled( false );
|
||||
} else {
|
||||
for ( int i{0}; i<=max; i++ ) {
|
||||
for ( int i{0}; i<=max; ++i ) {
|
||||
if ( this->ui->list_ConfIis_Warnlist_List->item(i) == item ) {
|
||||
if ( i == 0 ) {
|
||||
this->ui->button_ConfIis_Warnlist_Up->setEnabled( false );
|
||||
|
@ -5724,7 +5724,7 @@ void MainWindow::on_list_ConfIis_Blacklist_List_itemSelectionChanged()
|
|||
this->ui->button_ConfIis_Blacklist_Up->setEnabled( false );
|
||||
this->ui->button_ConfIis_Blacklist_Down->setEnabled( false );
|
||||
} else {
|
||||
for ( int i{0}; i<=max; i++ ) {
|
||||
for ( int i{0}; i<=max; ++i ) {
|
||||
if ( this->ui->list_ConfIis_Blacklist_List->item(i) == item ) {
|
||||
if ( i == 0 ) {
|
||||
this->ui->button_ConfIis_Blacklist_Up->setEnabled( false );
|
||||
|
|
|
@ -33,7 +33,7 @@ Craplog::Craplog()
|
|||
//// INITIALIZATION ////
|
||||
////////////////////////
|
||||
// blacklists / whitelists
|
||||
for ( unsigned i{APACHE_ID}; i<=IIS_ID; i++ ) {
|
||||
for ( unsigned i{APACHE_ID}; i<=IIS_ID; ++i ) {
|
||||
this->warnlists.emplace( i, std::unordered_map<int, BWlist>(4) );
|
||||
this->blacklists.emplace( i, std::unordered_map<int, BWlist>(1) );
|
||||
// default data
|
||||
|
@ -185,7 +185,7 @@ void Craplog::blacklistRemove( const unsigned& web_server_id, const int& log_fie
|
|||
auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list;
|
||||
// move the item to the end, then pop it
|
||||
const size_t max{ list.size()-1ul };
|
||||
for ( size_t i{0}; i<max; i++ ) {
|
||||
for ( size_t i{0}; i<max; ++i ) {
|
||||
if ( list.at( i ) == item ) {
|
||||
list.at( i ) = list.at( i+1ul );
|
||||
list.at( i+1ul ) = item;
|
||||
|
@ -198,7 +198,7 @@ void Craplog::warnlistRemove( const unsigned& web_server_id, const int& log_fiel
|
|||
auto& list = this->warnlists.at( web_server_id ).at( log_field_id ).list;
|
||||
// move the item to the end, then pop it
|
||||
const size_t max{ list.size()-1ul };
|
||||
for ( size_t i{0}; i<max; i++ ) {
|
||||
for ( size_t i{0}; i<max; ++i ) {
|
||||
if ( list.at( i ) == item ) {
|
||||
list.at( i ) = list.at( i+1ul );
|
||||
list.at( i+1ul ) = item;
|
||||
|
@ -212,11 +212,11 @@ int Craplog::blacklistMoveUp( const unsigned& web_server_id, const int& log_fiel
|
|||
auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list;
|
||||
size_t i{ 1 };
|
||||
const size_t max{ list.size() };
|
||||
for ( ; i<max; i++ ) {
|
||||
for ( ; i<max; ++i ) {
|
||||
if ( list.at( i ) == item ) {
|
||||
list.at( i ) = list.at( i-1ul );
|
||||
list.at( i-1ul ) = item;
|
||||
i--;
|
||||
--i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -227,11 +227,11 @@ int Craplog::warnlistMoveUp( const unsigned& web_server_id, const int& log_field
|
|||
auto& list = this->warnlists.at( web_server_id ).at( log_field_id ).list;
|
||||
size_t i{ 1 };
|
||||
const size_t max{ list.size() };
|
||||
for ( ; i<max; i++ ) {
|
||||
for ( ; i<max; ++i ) {
|
||||
if ( list.at( i ) == item ) {
|
||||
list.at( i ) = list.at( i-1ul );
|
||||
list.at( i-1ul ) = item;
|
||||
i--;
|
||||
--i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -243,11 +243,11 @@ int Craplog::blacklistMoveDown( const unsigned& web_server_id, const int& log_fi
|
|||
auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list;
|
||||
size_t i{ 0 };
|
||||
const size_t max{ list.size()-1ul };
|
||||
for ( ; i<max; i++ ) {
|
||||
for ( ; i<max; ++i ) {
|
||||
if ( list.at( i ) == item ) {
|
||||
list.at( i ) = list.at( i+1ul );
|
||||
list.at( i+1ul ) = item;
|
||||
i++;
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -258,11 +258,11 @@ int Craplog::warnlistMoveDown( const unsigned& web_server_id, const int& log_fie
|
|||
auto& list = this->warnlists.at( web_server_id ).at( log_field_id ).list;
|
||||
size_t i{ 0 };
|
||||
const size_t max{ list.size()-1ul };
|
||||
for ( ; i<max; i++ ) {
|
||||
for ( ; i<max; ++i ) {
|
||||
if ( list.at( i ) == item ) {
|
||||
list.at( i ) = list.at( i+1ul );
|
||||
list.at( i+1ul ) = item;
|
||||
i++;
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ bool Craplog::isFileNameValid( const std::string& name ) const
|
|||
stop -= 3ul;
|
||||
}
|
||||
// serach for incremental numbers
|
||||
for ( size_t i{start}; i<=stop; i++ ) {
|
||||
for ( size_t i{start}; i<=stop; ++i ) {
|
||||
if ( ! CharOps::isNumeric( name.at( i ) ) ) {
|
||||
valid &= false;
|
||||
break;
|
||||
|
@ -623,7 +623,7 @@ bool Craplog::isFileNameValid( const std::string& name ) const
|
|||
}
|
||||
// search for date
|
||||
std::string date;
|
||||
for ( size_t i{start}; i<=stop; i++ ) {
|
||||
for ( size_t i{start}; i<=stop; ++i ) {
|
||||
if ( ! CharOps::isNumeric( name.at( i ) ) ) {
|
||||
valid &= false;
|
||||
break;
|
||||
|
@ -639,7 +639,7 @@ bool Craplog::isFileNameValid( const std::string& name ) const
|
|||
// using strftime to display time
|
||||
strftime( aux_date, 7, "%y%m%d", tmp );
|
||||
valid &= false;
|
||||
for ( size_t i{0}; i<6ul; i++ ) {
|
||||
for ( size_t i{0}; i<6ul; ++i ) {
|
||||
if ( date.at(i) != aux_date[i] ) {
|
||||
// different date, valid
|
||||
valid |= true;
|
||||
|
|
|
@ -66,14 +66,14 @@ std::string parseApacheEscapes( std::string_view string , const bool strftime=fa
|
|||
cc = string.at( i+1ul );
|
||||
if ( c == '\\' && (cc == '\\' || cc == '"') ) {
|
||||
str1.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
} else if ( c == '%' && cc == '%' ) {
|
||||
str1.push_back( c );
|
||||
i++;
|
||||
++i;
|
||||
} else {
|
||||
str1.push_back( c );
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
i = 0ul;
|
||||
max = str1.size()-1ul;
|
||||
|
@ -92,29 +92,29 @@ std::string parseApacheEscapes( std::string_view string , const bool strftime=fa
|
|||
// just the ones supported
|
||||
if ( cc == '\\' || cc == '"' ) {
|
||||
str2.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
} else {
|
||||
if ( strftime ) {
|
||||
// when parsing for strftime, any other backslashed characters result in a backslash+character
|
||||
str2.push_back( c );
|
||||
str2.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
|
||||
} else {
|
||||
if ( cc == 'n' ) {
|
||||
str2.push_back( '\n' );
|
||||
i++;
|
||||
++i;
|
||||
} else if ( cc == 'r' ) {
|
||||
// not supported
|
||||
throw LogFormatException( "LogDoctor doesn't support the usage of the Carriage Return: '\\r'" );
|
||||
} else if ( cc == 't' ) {
|
||||
str2.push_back( '\t' );
|
||||
i++;
|
||||
++i;
|
||||
} else {
|
||||
// any other backslashed characters result in a backslash+character
|
||||
str2.push_back( c );
|
||||
str2.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,21 +122,21 @@ std::string parseApacheEscapes( std::string_view string , const bool strftime=fa
|
|||
// strftime control-characters
|
||||
if ( cc == 'n' ) {
|
||||
str2.push_back( '\n' );
|
||||
i++;
|
||||
++i;
|
||||
} else if ( cc == 't' ) {
|
||||
str2.push_back( '\t' );
|
||||
i++;
|
||||
++i;
|
||||
} else {
|
||||
// any other characters result in a percent+character
|
||||
str2.push_back( c );
|
||||
str2.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
|
||||
} else {
|
||||
str2.push_back( c );
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
|
||||
str2.shrink_to_fit();
|
||||
|
@ -177,26 +177,26 @@ std::string parseNginxEscapes( std::string_view string )
|
|||
// just the ones supported by nginx
|
||||
if ( cc == '\\' || cc == '\'' || cc == '"' ) {
|
||||
str.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
} else if ( cc == 'n' ) {
|
||||
str.push_back( '\n' );
|
||||
i++;
|
||||
++i;
|
||||
} else if ( cc == 'r' ) {
|
||||
// not supported
|
||||
throw LogFormatException( "LogDoctor doesn't support the usage of the Carriage Return: '\\r'" );
|
||||
} else if ( cc == 't' ) {
|
||||
str.push_back( '\t' );
|
||||
i++;
|
||||
++i;
|
||||
} else {
|
||||
// not a control-character, resulting in a backslash+character
|
||||
str.push_back( c );
|
||||
str.push_back( cc );
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
} else {
|
||||
str.push_back( c );
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
|
||||
str.shrink_to_fit();
|
||||
|
@ -330,7 +330,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons
|
|||
|
||||
// append the current separator
|
||||
cur_sep += f_str.substr( start, aux-start );
|
||||
aux ++;
|
||||
++ aux;
|
||||
|
||||
char c = f_str.at( aux );
|
||||
// remove the per-status directives (if any)
|
||||
|
@ -344,7 +344,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons
|
|||
c = f_str.at( aux_aux );
|
||||
if ( CharOps::isNumeric( c ) || c == '!' || c == ',' ) {
|
||||
// skip these chars
|
||||
aux_aux ++;
|
||||
++ aux_aux;
|
||||
continue;
|
||||
} else {
|
||||
// stop
|
||||
|
@ -493,7 +493,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons
|
|||
cur_sep.clear();
|
||||
// append the field
|
||||
fields.push_back( cur_fld );
|
||||
n_fld ++;
|
||||
++ n_fld;
|
||||
|
||||
} else {
|
||||
// invalid, append as separator and keep hunting
|
||||
|
@ -514,7 +514,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons
|
|||
aux_stop = aux+1ul;
|
||||
if ( aux_fld == ">" || aux_fld == "<" ) {
|
||||
aux_fld += f_str.at( aux+1 );
|
||||
aux_stop ++;
|
||||
++ aux_stop;
|
||||
}
|
||||
// check if the module is valid
|
||||
if ( f_map.find( aux_fld ) != f_map.end() ) {
|
||||
|
@ -566,7 +566,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons
|
|||
|
||||
// append the field
|
||||
fields.push_back( cur_fld );
|
||||
n_fld++;
|
||||
++ n_fld;
|
||||
}
|
||||
|
||||
return LogsFormat(
|
||||
|
@ -582,7 +582,7 @@ QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) const
|
|||
|
||||
// append the initial characters
|
||||
sample += QString::fromStdString( log_format.initial );
|
||||
for ( size_t i{0ul}; i<log_format.separators.size(); i++ ) {
|
||||
for ( size_t i{0ul}; i<log_format.separators.size(); ++i ) {
|
||||
// append fields and separators
|
||||
sample += map.at( log_format.fields.at( i ) );
|
||||
sample += QString::fromStdString( log_format.separators.at( i ) );
|
||||
|
@ -624,14 +624,14 @@ LogsFormat FormatOps::processNginxFormatString( const std::string& f_str ) const
|
|||
final = parseNginxEscapes( f_str.substr( start ) );
|
||||
break;
|
||||
}
|
||||
aux ++;
|
||||
++ aux;
|
||||
// find the end of the current field
|
||||
stop = findNginxFieldEnd( f_str, aux );
|
||||
if ( stop == max ) {
|
||||
// this is the last field, and ther's no final separator
|
||||
finished |= true;
|
||||
}
|
||||
stop ++;
|
||||
++ stop;
|
||||
|
||||
cur_sep = f_str.substr( start, aux-start-1ul );
|
||||
cur_fld = f_str.substr( aux, stop-aux );
|
||||
|
@ -683,7 +683,7 @@ QString FormatOps::getNginxLogSample( const LogsFormat& log_format ) const
|
|||
|
||||
// append the initial characters
|
||||
sample += QString::fromStdString( log_format.initial );
|
||||
for ( size_t i{0}; i<log_format.separators.size(); i++ ) {
|
||||
for ( size_t i{0}; i<log_format.separators.size(); ++i ) {
|
||||
// append fields and separators
|
||||
sample += map.at( log_format.fields.at( i ) );
|
||||
sample += QString::fromStdString( log_format.separators.at( i ) );
|
||||
|
@ -740,7 +740,7 @@ LogsFormat FormatOps::processIisFormatString( const std::string& f_str, const in
|
|||
// set the current field
|
||||
cur_fld = f_str.substr( start, stop-start );
|
||||
// step over the separator
|
||||
stop++;
|
||||
++ stop;
|
||||
|
||||
// check if the module is valid
|
||||
if ( f_map.find( cur_fld ) != f_map.end() ) {
|
||||
|
@ -777,7 +777,7 @@ QString FormatOps::getIisLogSample( const LogsFormat& log_format ) const
|
|||
|
||||
// append the initial characters
|
||||
sample += QString::fromStdString( log_format.initial );
|
||||
for ( size_t i{0}; i<log_format.separators.size(); i++ ) {
|
||||
for ( size_t i{0}; i<log_format.separators.size(); ++i ) {
|
||||
// append fields and separators
|
||||
sample += map.at( log_format.fields.at( i ) );
|
||||
sample += QString::fromStdString( log_format.separators.at( i ) );
|
||||
|
|
|
@ -29,18 +29,18 @@ bool deepTypeCheck( const std::string& line, const LogsFormat& format )
|
|||
// check the initial part
|
||||
if ( ! format.initial.empty() ) {
|
||||
if ( StringOps::startsWith( line, format.initial ) ) {
|
||||
n_sep_found ++;
|
||||
++ n_sep_found;
|
||||
}
|
||||
} else {
|
||||
n_sep_found ++;
|
||||
n_blank_sep ++;
|
||||
++ n_sep_found;
|
||||
++ n_blank_sep;
|
||||
}
|
||||
// check the middle part
|
||||
for ( size_t i{0}; i<n_sep; i++ ) {
|
||||
for ( size_t i{0}; i<n_sep; ++i ) {
|
||||
sep = format.separators.at( i );
|
||||
if ( sep.empty() ) {
|
||||
n_sep_found ++;
|
||||
n_blank_sep ++;
|
||||
++ n_sep_found;
|
||||
++ n_blank_sep;
|
||||
continue;
|
||||
}
|
||||
aux_found_at2 = aux_found_at1;
|
||||
|
@ -58,7 +58,7 @@ bool deepTypeCheck( const std::string& line, const LogsFormat& format )
|
|||
aux_sep1 = StringOps::lstripUntil( aux_sep1, ' ' );
|
||||
}
|
||||
// iterate over following separators
|
||||
for ( size_t j{i+1ul}; j<n_sep; j++ ) {
|
||||
for ( size_t j{i+1ul}; j<n_sep; ++j ) {
|
||||
aux_sep2 = format.separators.at( j );
|
||||
aux_found_at2 = aux_sep2.find(' ');
|
||||
if ( aux_found_at2 == std::string::npos ) {
|
||||
|
@ -81,18 +81,18 @@ bool deepTypeCheck( const std::string& line, const LogsFormat& format )
|
|||
}
|
||||
}
|
||||
aux_found_at1 = found_at + sep.size();
|
||||
n_sep_found ++;
|
||||
++ n_sep_found;
|
||||
|
||||
}
|
||||
|
||||
// check the final part
|
||||
if ( ! format.final.empty() ) {
|
||||
if ( StringOps::endsWith( line, format.final ) ) {
|
||||
n_sep_found ++;
|
||||
++ n_sep_found;
|
||||
}
|
||||
} else {
|
||||
n_sep_found ++;
|
||||
n_blank_sep ++;
|
||||
++ n_sep_found;
|
||||
++ n_blank_sep;
|
||||
}
|
||||
|
||||
// add the initial and final seps now
|
||||
|
@ -124,9 +124,9 @@ LogType defineFileType( const std::vector<std::string>& lines, const LogsFormat&
|
|||
for ( const std::string& line : lines ) {
|
||||
// scan the given lines
|
||||
if ( deepTypeCheck( line, format ) ) {
|
||||
n_access++;
|
||||
++ n_access;
|
||||
} else {
|
||||
n_other++;
|
||||
++ n_other;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ LogLineData::LogLineData(const std::string& line, const LogsFormat& logs_format)
|
|||
|
||||
// update the stop for the next start
|
||||
stop += sep_size;
|
||||
sep_i++;
|
||||
++sep_i;
|
||||
if ( stop > line_size ) {
|
||||
// this was the final separator
|
||||
break;
|
||||
|
|
|
@ -193,7 +193,7 @@ void CraplogParser::parseLogLines()
|
|||
const auto parseLine = [this]( const std::string& line, const LogsFormat& logs_format ) {
|
||||
this->data_collection.emplace_back( LogLineData(line, logs_format) );
|
||||
this->parsed_size += line.size();
|
||||
this->parsed_lines ++;
|
||||
++ this->parsed_lines;
|
||||
};
|
||||
|
||||
|
||||
|
@ -219,10 +219,10 @@ void CraplogParser::parseLogLines()
|
|||
const size_t send_gap{ real_lines>1000ul ? real_lines/100 : real_lines>100ul ? real_lines/10 : 10 };
|
||||
const LogsFormat& lf {this->logs_format};
|
||||
this->data_collection.reserve( real_lines );
|
||||
for ( size_t i{0ul}; i<n_lines; i++ ) {
|
||||
for ( size_t i{0ul}; i<n_lines; ++i ) {
|
||||
std::string line = this->logs_lines.at( i );
|
||||
for ( size_t n{0ul}; n<nl; n++ ) {
|
||||
i++;
|
||||
for ( size_t n{0ul}; n<nl; ++n ) {
|
||||
++i;
|
||||
line += "\n" + this->logs_lines.at( i );
|
||||
}
|
||||
parseLine( line, lf );
|
||||
|
|
|
@ -153,7 +153,7 @@ void Crapview::sliceClicked( QPieSlice* slice )
|
|||
void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) const
|
||||
{
|
||||
std::vector<std::tuple<int, int>> updates; // { (rowid, warn) }
|
||||
for ( int i{0}; i<table->rowCount(); i++ ) {
|
||||
for ( int i{0}; i<table->rowCount(); ++i ) {
|
||||
QTableWidgetItem* item = table->item( i, 0 );
|
||||
if ( item->checkState() == Qt::CheckState::Checked && item->text() == TR::tr( BOOLS__FALSE.c_str() ) ) {
|
||||
// remove warning
|
||||
|
@ -188,13 +188,13 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
|
|||
int norm_count, warn_count, sum_count, max_count=0, n_rows=0;
|
||||
if ( hour.isEmpty() ) {
|
||||
// entire day
|
||||
for ( int i{0}; i<6; i++ ) {
|
||||
for ( int i{0}; i<6; ++i ) {
|
||||
sets.push_back( std::vector<QBarSet*>() );
|
||||
sets.back().push_back( new QBarSet("") );
|
||||
sets.back().push_back( new QBarSet("") );
|
||||
}
|
||||
for ( size_t h{0}; h<24ul; h++ ) {
|
||||
for ( size_t m{0}; m<6ul; m++ ) {
|
||||
for ( size_t h{0}; h<24ul; ++h ) {
|
||||
for ( size_t m{0}; m<6ul; ++m ) {
|
||||
const auto& data{ items.at( h ).at( m ) };
|
||||
norm_count = warn_count = 0;
|
||||
for ( const std::vector<QString>& line : data ) {
|
||||
|
@ -210,7 +210,7 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
|
|||
table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() )));
|
||||
int col{ 3 };
|
||||
const size_t max{ line.size() };
|
||||
for ( size_t i{7ul}; i<max; i++ ) {
|
||||
for ( size_t i{7ul}; i<max; ++i ) {
|
||||
QTableWidgetItem* itm;
|
||||
if ( (col == 7 || col >= 12) && !line.at(i).isEmpty() ) {
|
||||
itm = new QTableWidgetItem();
|
||||
|
@ -219,14 +219,14 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
|
|||
itm = new QTableWidgetItem( line.at( i ) );
|
||||
}
|
||||
table->setItem( n_rows, col, itm );
|
||||
col ++;
|
||||
++ col;
|
||||
}
|
||||
if ( line.at( 0ul ) == "0" ) {
|
||||
norm_count ++;
|
||||
++ norm_count;
|
||||
} else {
|
||||
warn_count ++;
|
||||
++ warn_count;
|
||||
}
|
||||
n_rows ++;
|
||||
++ n_rows;
|
||||
}
|
||||
sets.at( m ).at( 0ul )->append( norm_count );
|
||||
sets.at( m ).at( 1ul )->append( warn_count );
|
||||
|
@ -239,13 +239,13 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
|
|||
date = PrintSec::printableDate( year, this->getMonthNumber( month ), day );
|
||||
} else {
|
||||
// 1 hour
|
||||
for ( int i{0}; i<10; i++ ) {
|
||||
for ( int i{0}; i<10; ++i ) {
|
||||
sets.push_back( std::vector<QBarSet*>() );
|
||||
sets.back().push_back( new QBarSet("") );
|
||||
sets.back().push_back( new QBarSet("") );
|
||||
}
|
||||
for ( size_t g{0ul}; g<6ul; g++ ) {
|
||||
for ( size_t m{0ul}; m<10ul; m++ ) {
|
||||
for ( size_t g{0ul}; g<6ul; ++g ) {
|
||||
for ( size_t m{0ul}; m<10ul; ++m ) {
|
||||
const auto& data{ items.at( g ).at( m ) };
|
||||
norm_count = warn_count = 0;
|
||||
for ( const std::vector<QString>& line : data ) {
|
||||
|
@ -260,13 +260,13 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
|
|||
}
|
||||
table->setItem( n_rows, 1, new QTableWidgetItem( PrintSec::printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() )));
|
||||
table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() )));
|
||||
for ( size_t i{7ul}; i<line.size(); i++ ) {
|
||||
for ( size_t i{7ul}; i<line.size(); ++i ) {
|
||||
table->setItem( n_rows, i-4, new QTableWidgetItem( line.at( i ) ));
|
||||
}
|
||||
if ( line.at( 0ul ) == "0" ) {
|
||||
norm_count ++;
|
||||
++ norm_count;
|
||||
} else {
|
||||
warn_count ++;
|
||||
++ warn_count;
|
||||
}
|
||||
}
|
||||
sets.at( m ).at( 0ul )->append( norm_count );
|
||||
|
@ -286,10 +286,10 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
|
|||
//QColor cols[] = {QColor(18,175,194), QColor(237,80,61)};
|
||||
std::vector<QStackedBarSeries*> b_series;
|
||||
const size_t max{ sets.size() };
|
||||
for ( size_t i{0}; i<max; i++ ) {
|
||||
for ( size_t i{0}; i<max; ++i ) {
|
||||
const auto& set{ sets.at( i ) };
|
||||
b_series.push_back( new QStackedBarSeries() );
|
||||
for ( size_t w{0}; w<2ul; w++ ) {
|
||||
for ( size_t w{0}; w<2ul; ++w ) {
|
||||
QBarSet* b = set.at( w );
|
||||
b->setColor( cols[ w ] );
|
||||
b_series.at( i )->append( b );
|
||||
|
@ -374,7 +374,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
|
|||
QDateTime dt;
|
||||
std::vector<QString> data;
|
||||
for ( const auto& item : items ) {
|
||||
i++;
|
||||
++i;
|
||||
// append a value to the chart
|
||||
aux_time = std::get<0>(item);
|
||||
data = std::get<1>(item);
|
||||
|
@ -401,7 +401,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
|
|||
if ( first_count ) {
|
||||
first_count &= false;
|
||||
} else {
|
||||
count ++;
|
||||
++ count;
|
||||
}
|
||||
value += aux_value;
|
||||
if ( i == max_i ) {
|
||||
|
@ -426,7 +426,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
|
|||
table->setItem( n_rows, 5, new QTableWidgetItem( data.at(5ul) ));
|
||||
dt = QDateTime::fromMSecsSinceEpoch( aux_time );
|
||||
table->setItem( n_rows, 6, new QTableWidgetItem( dt.time().toString("hh:mm:ss") ));
|
||||
n_rows ++;
|
||||
++ n_rows;
|
||||
}
|
||||
}
|
||||
table->verticalHeader()->setVisible( false );
|
||||
|
@ -527,7 +527,7 @@ void Crapview::drawCount( QTableWidget* table, QChartView* chart, const QChart::
|
|||
ic->setData( Qt::DisplayRole, count );
|
||||
table->setItem( n_rows, 0, ic );
|
||||
table->setItem( n_rows, 1, new QTableWidgetItem( item ));
|
||||
n_rows ++;
|
||||
++ n_rows;
|
||||
}
|
||||
table->verticalHeader()->setVisible( false );
|
||||
|
||||
|
@ -594,7 +594,7 @@ void Crapview::drawDay( QChartView* chart, const QChart::ChartTheme& theme, cons
|
|||
|
||||
// build the bars upon data
|
||||
int count, max_count{0};
|
||||
for ( size_t h{0ul}; h<24ul; h++ ) {
|
||||
for ( size_t h{0ul}; h<24ul; ++h ) {
|
||||
auto& data = items.at( h );
|
||||
count = data.at( 0ul );
|
||||
*b_10 << count;
|
||||
|
@ -823,7 +823,7 @@ bool Crapview::calcGlobals( std::vector<std::tuple<QString,QString>>& recur_list
|
|||
// compose the results
|
||||
|
||||
// max request elements
|
||||
for ( size_t i{0}; i<4ul; i++ ) {
|
||||
for ( size_t i{0}; i<4ul; ++i ) {
|
||||
unsigned max{ 0 };
|
||||
QString max_str{ "-" };
|
||||
const auto& aux{ recurs.at( i ) };
|
||||
|
|
|
@ -115,18 +115,18 @@ std::optional<QString> parseNumericFilter( const QString& filter_str )
|
|||
size_t i{ 0ul };
|
||||
const size_t max{ str.size() };
|
||||
if ( char c=str.at(i); c == '=' || c == '!' || c == '<' || c == '>' ) {
|
||||
i ++;
|
||||
++i;
|
||||
if ( i >= max ) {
|
||||
return result;
|
||||
}
|
||||
if ( str.at(i) == '=' ) {
|
||||
i ++;
|
||||
++i;
|
||||
if ( i >= max ) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if ( str.at(i) == ' ' ) {
|
||||
i ++;
|
||||
++i;
|
||||
if ( i >= max ) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int DbQuery::getMinuteGap( const int minute, const int gap )
|
|||
m = gap * n;
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
++n;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ int DbQuery::countDays( const int from_year, const int from_month, const int fro
|
|||
n_days += to_day - from_day + 1;
|
||||
} else {
|
||||
n_days += getMonthDays( from_year, from_month ) - from_day; // first month's days
|
||||
for ( int month=from_month+1; month<to_month; month++ ) {
|
||||
for ( int month=from_month+1; month<to_month; ++month ) {
|
||||
n_days += getMonthDays( from_year, month );
|
||||
}
|
||||
n_days += to_day; // last month's days
|
||||
|
@ -103,17 +103,17 @@ int DbQuery::countDays( const int from_year, const int from_month, const int fro
|
|||
} else {
|
||||
n_days += getMonthDays( from_year, from_month ) - from_day;
|
||||
if ( from_month < 12 ) {
|
||||
for ( int month{from_month+1}; month<=12; month++ ) {
|
||||
for ( int month{from_month+1}; month<=12; ++month ) {
|
||||
n_days += getMonthDays( from_year, month );
|
||||
}
|
||||
}
|
||||
for ( int year{from_year+1}; year<=to_year; year++ ) {
|
||||
for ( int year{from_year+1}; year<=to_year; ++year ) {
|
||||
int last_month{ 12 };
|
||||
if ( year == to_year ) {
|
||||
last_month = to_month-1;
|
||||
n_days += to_day; // last month's days, added in advance
|
||||
}
|
||||
for ( int month{1}; month<=last_month; month++ ) {
|
||||
for ( int month{1}; month<=last_month; ++month ) {
|
||||
n_days += getMonthDays( year, month );
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ void DbQuery::getWarnCounts( std::optional<stats_warn_items_t>& result, const QS
|
|||
if ( hour_.isEmpty() ) {
|
||||
// entire day
|
||||
items.reserve( 24 );
|
||||
for ( size_t h{0}; h<24ul; h++ ) {
|
||||
for ( size_t h{0}; h<24ul; ++h ) {
|
||||
items.push_back( std::vector<std::vector<std::vector<QString>>>() );
|
||||
auto& aux{ items.at( h ) };
|
||||
aux.reserve( 6 );
|
||||
|
@ -472,10 +472,10 @@ void DbQuery::getWarnCounts( std::optional<stats_warn_items_t>& result, const QS
|
|||
while ( query.next() ) {
|
||||
std::vector<QString> aux;
|
||||
aux.reserve( 20 );
|
||||
for ( int i{1}; i<13; i++ ) {
|
||||
for ( int i{1}; i<13; ++i ) {
|
||||
aux.push_back( query.value( i ).toString() );
|
||||
}
|
||||
for ( int i{19}; i>12; i-- ) {
|
||||
for ( int i{19}; i>12; --i ) {
|
||||
aux.push_back( query.value( i ).toString() );
|
||||
}
|
||||
aux.push_back( query.value( 0 ).toString() );
|
||||
|
@ -494,11 +494,11 @@ void DbQuery::getWarnCounts( std::optional<stats_warn_items_t>& result, const QS
|
|||
} else {
|
||||
// 1 hour
|
||||
items.reserve( 6 );
|
||||
for ( size_t g{0}; g<6ul; g++ ) {
|
||||
for ( size_t g{0}; g<6ul; ++g ) {
|
||||
items.push_back( std::vector<std::vector<std::vector<QString>>>() );
|
||||
auto& aux{ items.at( g ) };
|
||||
aux.reserve( 10ul );
|
||||
for ( int m{0}; m<10; m++ ) {
|
||||
for ( int m{0}; m<10; ++m ) {
|
||||
aux.push_back( std::vector<std::vector<QString>>() );
|
||||
}
|
||||
}
|
||||
|
@ -515,10 +515,10 @@ void DbQuery::getWarnCounts( std::optional<stats_warn_items_t>& result, const QS
|
|||
while ( query.next() ) {
|
||||
std::vector<QString> aux;
|
||||
aux.reserve( 20 );
|
||||
for ( int i{1}; i<13; i++ ) {
|
||||
for ( int i{1}; i<13; ++i ) {
|
||||
aux.push_back( query.value( i ).toString() );
|
||||
}
|
||||
for ( int i{19}; i>12; i-- ) {
|
||||
for ( int i{19}; i>12; --i ) {
|
||||
aux.push_back( query.value( i ).toString() );
|
||||
}
|
||||
aux.push_back( query.value( 0 ).toString() );
|
||||
|
@ -714,9 +714,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
if ( aux_hour == hour ) {
|
||||
h=hour; m=minute; s=second-1;
|
||||
if ( s < 0 ) {
|
||||
s=59; m--;
|
||||
s=59; --m;
|
||||
if ( m < 0 ) {
|
||||
m=59; h--;
|
||||
m=59; --h;
|
||||
if ( h < 0 ) {
|
||||
h=m=s=0;
|
||||
}
|
||||
|
@ -737,9 +737,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
// append the second after the last one found, if it is not equal to the next
|
||||
h=hour; m=minute; s=second+1;
|
||||
if ( s > 59 ) {
|
||||
s=0; m++;
|
||||
s=0; ++m;
|
||||
if ( m > 59 ) {
|
||||
m=0; h++;
|
||||
m=0; ++h;
|
||||
if ( h > 23 ) {
|
||||
h=23;m=59;s=59;
|
||||
}
|
||||
|
@ -759,9 +759,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
// append the prev as zero
|
||||
h=hour; m=minute; s=second-1;
|
||||
if ( s < 0 ) {
|
||||
s=59; m--;
|
||||
s=59; --m;
|
||||
if ( m < 0 ) {
|
||||
m=59; h--;
|
||||
m=59; --h;
|
||||
if ( h < 0 ) {
|
||||
h=m=s=0;
|
||||
}
|
||||
|
@ -781,9 +781,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
// append the next as zero
|
||||
h=hour; m=minute; s=second+1;
|
||||
if ( s > 59 ) {
|
||||
s=0; m++;
|
||||
s=0; ++m;
|
||||
if ( m > 59 ) {
|
||||
m=0; h++;
|
||||
m=0; ++h;
|
||||
if ( h > 23 ) {
|
||||
h=23;m=59;s=59;
|
||||
}
|
||||
|
@ -805,9 +805,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
// append the second before the first found
|
||||
h=aux_hour; m=aux_minute; s=aux_second-1;
|
||||
if ( s < 0 ) {
|
||||
s=59; m--;
|
||||
s=59; --m;
|
||||
if ( m < 0 ) {
|
||||
m=59; h--;
|
||||
m=59; --h;
|
||||
if ( h < 0 ) {
|
||||
// abort
|
||||
h=m=s=0;
|
||||
|
@ -840,9 +840,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
// last one, append the prev
|
||||
h=hour; m=minute; s=second-1;
|
||||
if ( s < 0 ) {
|
||||
s=59; m--;
|
||||
s=59; --m;
|
||||
if ( m < 0 ) {
|
||||
m=59; h--;
|
||||
m=59; --h;
|
||||
if ( h < 0 ) {
|
||||
h=m=s=0;
|
||||
}
|
||||
|
@ -862,9 +862,9 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
// append 1 second after the last
|
||||
h=hour; m=minute; s=second+1;
|
||||
if ( s > 59 ) {
|
||||
s=0; m++;
|
||||
s=0; ++m;
|
||||
if ( m > 59 ) {
|
||||
m=0; h++;
|
||||
m=0; ++h;
|
||||
if ( h > 23 ) {
|
||||
h=23;m=59;s=59;
|
||||
}
|
||||
|
@ -878,13 +878,13 @@ void DbQuery::getSpeedData( std::optional<stats_speed_items_t>& result, const QS
|
|||
}
|
||||
}
|
||||
// append the last fictitious count
|
||||
day ++;
|
||||
++ day;
|
||||
if ( day > getMonthDays( year, month ) ) {
|
||||
day = 1;
|
||||
month ++;
|
||||
++ month;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
}
|
||||
time.setDate( QDate( year, month , day ) );
|
||||
|
@ -974,7 +974,7 @@ void DbQuery::getItemsCount( std::optional<stats_count_items_t>& result, const Q
|
|||
while ( query.next() ) {
|
||||
item = query.value(0).toString();
|
||||
if ( ! item.isEmpty() ) {
|
||||
aux_items[ item ] ++;
|
||||
++ aux_items[ item ];
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
|
@ -1138,9 +1138,9 @@ void DbQuery::getDaytimeCounts( std::optional<stats_day_items_t>& result, const
|
|||
hour = query.value(1).toInt();
|
||||
minute = query.value(2).toInt();
|
||||
// increase the count
|
||||
data.at( hour ).at( getMinuteGap( minute ) ) ++;
|
||||
++ data.at( hour ).at( getMinuteGap( minute ) );
|
||||
// append the day as newly found if not found yet
|
||||
days_l[ day ] ++;
|
||||
++ days_l[ day ];
|
||||
}
|
||||
n_days += static_cast<int>(days_l.size());
|
||||
} catch (...) {
|
||||
|
@ -1152,7 +1152,7 @@ void DbQuery::getDaytimeCounts( std::optional<stats_day_items_t>& result, const
|
|||
|
||||
|
||||
} else {
|
||||
for ( int m=1; m<=n_months; m++ ) {
|
||||
for ( int m=1; m<=n_months; ++m ) {
|
||||
stmt = QString("SELECT \"day\", \"hour\", \"minute\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3")
|
||||
.arg( web_server )
|
||||
.arg( year ).arg( month );
|
||||
|
@ -1217,15 +1217,15 @@ void DbQuery::getDaytimeCounts( std::optional<stats_day_items_t>& result, const
|
|||
hour = query.value(1).toInt();
|
||||
minute = query.value(2).toInt();
|
||||
// increase the count
|
||||
data.at( hour ).at( getMinuteGap( minute ) ) ++;
|
||||
++ data.at( hour ).at( getMinuteGap( minute ) );
|
||||
// append the day as newly found if not found yet
|
||||
days_l[ day ] ++;
|
||||
++ days_l[ day ];
|
||||
}
|
||||
n_days += static_cast<int>(days_l.size());
|
||||
month ++;
|
||||
++ month;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
} catch (...) {
|
||||
// something failed
|
||||
|
@ -1245,7 +1245,7 @@ void DbQuery::getDaytimeCounts( std::optional<stats_day_items_t>& result, const
|
|||
if ( count > 0 ) {
|
||||
count /= n_days;
|
||||
if ( count == 0 ) {
|
||||
count++;
|
||||
++ count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1404,7 +1404,7 @@ void DbQuery::getRelationalCountsDay( std::optional<stats_relat_items_t>& result
|
|||
|
||||
} else if ( ! query.last() ) {
|
||||
// no result found, fill with 0 values
|
||||
for ( int h{0}; h<24; h++ ) {
|
||||
for ( int h{0}; h<24; ++h ) {
|
||||
for ( int m{0}; m<60; m+=gap ) {
|
||||
time.setTime( QTime( h, m ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
|
@ -1425,7 +1425,7 @@ void DbQuery::getRelationalCountsDay( std::optional<stats_relat_items_t>& result
|
|||
aux_hour = query.value(0).toInt();
|
||||
aux_minute = getMinuteGap( query.value(1).toInt(), gap );
|
||||
if ( aux_hour == hour && aux_minute == minute ) {
|
||||
count ++;
|
||||
++ count;
|
||||
} else {
|
||||
if ( aux_hour == hour ) {
|
||||
// same hour new minute gap, append the last count
|
||||
|
@ -1447,13 +1447,13 @@ void DbQuery::getRelationalCountsDay( std::optional<stats_relat_items_t>& result
|
|||
time.setTime( QTime( hour, m ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
hour ++;
|
||||
++ hour;
|
||||
} else {
|
||||
// prepare to add missing gaps from 00:00 (+gap will be added to the minute)
|
||||
hour = 0;
|
||||
}
|
||||
// append any missing gap in every hour between the current and the next found (aux)
|
||||
for ( int h{hour}; h<aux_hour; h++ ) {
|
||||
for ( int h{hour}; h<aux_hour; ++h ) {
|
||||
for ( int m{0}; m<60; m+=gap ) {
|
||||
time.setTime( QTime( h, m ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
|
@ -1478,20 +1478,20 @@ void DbQuery::getRelationalCountsDay( std::optional<stats_relat_items_t>& result
|
|||
time.setTime( QTime( hour, m ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
for ( int h{hour+1}; h<24; h++ ) {
|
||||
for ( int h{hour+1}; h<24; ++h ) {
|
||||
for ( int m{0}; m<60; m+=gap ) {
|
||||
time.setTime( QTime( h, m ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
}
|
||||
// append the real last fictitious count
|
||||
day ++;
|
||||
++ day;
|
||||
if ( day > getMonthDays( year, month ) ) {
|
||||
day = 1;
|
||||
month ++;
|
||||
++ month;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
}
|
||||
time.setDate( QDate( year, month , day ) );
|
||||
|
@ -1647,7 +1647,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
|
||||
} else if ( ! query.last() ) {
|
||||
// no days found, append missing days with 0 value
|
||||
for ( int d{from_day}; d<=to_day; d++ ) {
|
||||
for ( int d{from_day}; d<=to_day; ++d ) {
|
||||
time.setDate( QDate( year, month , d ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
|
@ -1663,13 +1663,13 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
while ( query.next() ) {
|
||||
aux_day = query.value(0).toInt();
|
||||
if ( aux_day == day ) {
|
||||
count ++;
|
||||
++ count;
|
||||
} else {
|
||||
if ( day > 0 ) {
|
||||
// any loop-round except the first
|
||||
time.setDate( QDate( year, month , day ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) );
|
||||
for ( int d{day+1}; d<aux_day; d++ ) {
|
||||
for ( int d{day+1}; d<aux_day; ++d ) {
|
||||
// append any missing day with a zero value
|
||||
time.setDate( QDate( year, month , d ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
|
@ -1680,20 +1680,20 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
m = month,
|
||||
y = year;
|
||||
if ( d < 1 ) {
|
||||
m --;
|
||||
-- m;
|
||||
if ( m < 1 ) {
|
||||
m = 12;
|
||||
y --;
|
||||
-- y;
|
||||
}
|
||||
d = getMonthDays( y, m );
|
||||
}
|
||||
for ( ; d!=aux_day; d++ ) {
|
||||
for ( ; d!=aux_day; ++d ) {
|
||||
if ( d > getMonthDays( y, m ) ) {
|
||||
d = 1;
|
||||
m ++;
|
||||
++ m;
|
||||
if ( m > 12 ) {
|
||||
m = 1;
|
||||
y ++;
|
||||
++ y;
|
||||
}
|
||||
}
|
||||
time.setDate( QDate( y, m , d ) );
|
||||
|
@ -1708,12 +1708,12 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
time.setDate( QDate( year, month , day ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) );
|
||||
// append any missing day from the last found until 1 day before the last one
|
||||
day++;
|
||||
++ day;
|
||||
if ( day > getMonthDays( year, month ) ) {
|
||||
month ++;
|
||||
++ month;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
day = getMonthDays( year, month );
|
||||
}
|
||||
|
@ -1723,17 +1723,17 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
y{ year };
|
||||
if ( m > 12 ) {
|
||||
m = 1;
|
||||
y ++;
|
||||
++ y;
|
||||
}
|
||||
to_day = getMonthDays( y, m );
|
||||
}
|
||||
for ( ; day!=to_day; day++ ) {
|
||||
for ( ; day!=to_day; ++day ) {
|
||||
if ( day > getMonthDays( year, month ) ) {
|
||||
day = 1;
|
||||
month ++;
|
||||
++ month;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
}
|
||||
time.setDate( QDate( year, month , day ) );
|
||||
|
@ -1749,7 +1749,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
|
||||
} else {
|
||||
data.reserve( countDays( from_year, from_month, from_day, to_year, to_month, to_day ) );
|
||||
for ( int m{1}; m<=n_months; m++ ) {
|
||||
for ( int m{1}; m<=n_months; ++m ) {
|
||||
stmt = QString("SELECT \"day\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3")
|
||||
.arg( web_server )
|
||||
.arg( year ).arg( month );
|
||||
|
@ -1835,7 +1835,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
// last month, only get the days until the ending day
|
||||
t_d = to_day;
|
||||
}
|
||||
for ( ; f_d<=t_d; f_d++ ) {
|
||||
for ( ; f_d<=t_d; ++f_d ) {
|
||||
time.setDate( QDate( year, month , f_d ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
|
@ -1848,13 +1848,13 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
while ( query.next() ) {
|
||||
aux_day = query.value(0).toInt();
|
||||
if ( aux_day == day ) {
|
||||
count ++;
|
||||
++ count;
|
||||
} else {
|
||||
if ( day > 0 ) {
|
||||
// any loop-round except the first
|
||||
time.setDate( QDate( year, month , day ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) );
|
||||
for ( int d{day+1}; d<aux_day; d++ ) {
|
||||
for ( int d{day+1}; d<aux_day; ++d ) {
|
||||
// append any missing day with a zero value
|
||||
time.setDate( QDate( year, month , d ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
|
@ -1862,7 +1862,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
} else {
|
||||
// append any missing day until the next found day
|
||||
day = 1;
|
||||
for ( int d{day}; d<aux_day; d++ ) {
|
||||
for ( int d{day}; d<aux_day; ++d ) {
|
||||
time.setDate( QDate( year, month , d ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
|
@ -1877,16 +1877,16 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) );
|
||||
}
|
||||
// append any missing day to the end of the month with a zero value
|
||||
for ( int d{day+1}; d<=getMonthDays(year,month); d++ ) {
|
||||
for ( int d{day+1}; d<=getMonthDays(year,month); ++d ) {
|
||||
time.setDate( QDate( year, month , d ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
}
|
||||
}
|
||||
// increase the month
|
||||
month ++;
|
||||
++ month;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
} catch (...) {
|
||||
// something failed
|
||||
|
@ -1902,7 +1902,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional<stats_relat_items_t>& res
|
|||
month = to_month +1;
|
||||
if ( month > 12 ) {
|
||||
month = 1;
|
||||
year ++;
|
||||
++ year;
|
||||
}
|
||||
time.setDate( QDate( year, month , day ) );
|
||||
data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) );
|
||||
|
@ -2060,15 +2060,15 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
day = d;
|
||||
}
|
||||
if ( d == day ) {
|
||||
day_count ++;
|
||||
++ day_count;
|
||||
} else {
|
||||
n_days ++;
|
||||
++ n_days;
|
||||
// sum the day count to the total count
|
||||
req_count += day_count;
|
||||
// sum the day count to the relative day of the week count
|
||||
week_day = QDate(year,month,day).dayOfWeek();
|
||||
traf_day.at( week_day ) += day_count;
|
||||
num_day_count.at( week_day ) ++;
|
||||
++ num_day_count.at( week_day );
|
||||
// check the max date count
|
||||
const QString m_str{ (month<10) ? QString("0%1").arg(month) : QString("%1").arg(month) };
|
||||
const QString d_str{ (day<10) ? QString("0%1").arg(day) : QString("%1").arg(day) };
|
||||
|
@ -2087,7 +2087,7 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
hour = h;
|
||||
}
|
||||
if ( h == hour ) {
|
||||
hour_count ++;
|
||||
++ hour_count;
|
||||
} else {
|
||||
traf_hour.at( hour ) += hour_count;
|
||||
hour_count = 1;
|
||||
|
@ -2101,7 +2101,7 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
max_tt = tt;
|
||||
}
|
||||
tot_tt += tt;
|
||||
num_tt ++;
|
||||
++ num_tt;
|
||||
}
|
||||
|
||||
// sum the bytes sent
|
||||
|
@ -2110,7 +2110,7 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
max_bs = bs;
|
||||
}
|
||||
tot_bs += bs;
|
||||
num_bs ++;
|
||||
++ num_bs;
|
||||
}
|
||||
|
||||
// sum the bytes received
|
||||
|
@ -2119,27 +2119,27 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
max_br = br;
|
||||
}
|
||||
tot_br += br;
|
||||
num_br ++;
|
||||
++ num_br;
|
||||
}
|
||||
|
||||
// process the protocol
|
||||
if ( ! protocol.isEmpty() ) {
|
||||
recurs.at( 0 )[ protocol ] ++;
|
||||
++ recurs.at( 0 )[ protocol ];
|
||||
}
|
||||
|
||||
// process the method
|
||||
if ( ! method.isEmpty() ) {
|
||||
recurs.at( 1 )[ method ] ++;
|
||||
++ recurs.at( 1 )[ method ];
|
||||
}
|
||||
|
||||
// process the uri
|
||||
if ( ! uri.isEmpty() ) {
|
||||
recurs.at( 2 )[ uri ] ++;
|
||||
++ recurs.at( 2 )[ uri ];
|
||||
}
|
||||
|
||||
// process the user-agent
|
||||
if ( ! user_agent.isEmpty() ) {
|
||||
recurs.at( 3 )[ user_agent ] ++;
|
||||
++ recurs.at( 3 )[ user_agent ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2156,7 +2156,7 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
// sum the day count to the relative day of the week count
|
||||
week_day = QDate(year,month,day).dayOfWeek();
|
||||
traf_day.at( week_day ) += day_count;
|
||||
num_day_count.at( week_day ) ++;
|
||||
++ num_day_count.at( week_day );
|
||||
|
||||
// check the max date count
|
||||
const QString m_str{ (month<10) ? QString("0%1").arg(month) : QString("%1").arg(month) };
|
||||
|
@ -2177,14 +2177,14 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map<int, st
|
|||
if ( successful ) {
|
||||
|
||||
// process the hours of the day
|
||||
for ( int i{0}; i<24; i++ ) {
|
||||
for ( int i{0}; i<24; ++i ) {
|
||||
if ( n_days > 0 ) {
|
||||
traf_hour.at( i ) /= n_days;
|
||||
}
|
||||
}
|
||||
|
||||
// process the day of the week
|
||||
for ( int i{1}; i<8; i++ ) {
|
||||
for ( int i{1}; i<8; ++i ) {
|
||||
const int& x{ num_day_count.at( i ) };
|
||||
if ( x > 0 ) {
|
||||
traf_day.at( i ) /= x;
|
||||
|
|
|
@ -76,7 +76,7 @@ void TextBrowser::makePreview( QString& content ) const
|
|||
/*if ( this->wide_lines ) {
|
||||
content += "<br/>";
|
||||
}*/
|
||||
for ( int i{0}; i<32; i++ ) {
|
||||
for ( int i{0}; i<32; ++i ) {
|
||||
content += "<p>";
|
||||
|
||||
content += "<b>";
|
||||
|
|
|
@ -71,7 +71,7 @@ void testUtilities()
|
|||
{
|
||||
const auto every_other_char_but = [](const std::vector<char>& in)->std::vector<char>{
|
||||
std::vector<char> out( 128-in.size() );
|
||||
for (char c{0}; c<127; c++) {
|
||||
for (char c{0}; c<127; ++c) {
|
||||
if (const auto it = std::find(in.cbegin(),in.cend(),c); it == in.cend()) {
|
||||
out.push_back( c );
|
||||
}
|
||||
|
|
|
@ -47,10 +47,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
FileHandler(const FileHandler&) = delete;
|
||||
FileHandler(FileHandler&&) = delete;
|
||||
FileHandler& operator=(const FileHandler&) = delete;
|
||||
FileHandler& operator=(FileHandler&&) = delete;
|
||||
Q_DISABLE_COPY_MOVE(FileHandler)
|
||||
|
||||
inline operator FILE*()
|
||||
{
|
||||
|
@ -144,7 +141,7 @@ void readFile( const std::string& path, std::string& content )
|
|||
successful = false;
|
||||
break;
|
||||
}*/
|
||||
for ( unsigned i{0u}; i<have; i++ ) {
|
||||
for ( unsigned i{0u}; i<have; ++i ) {
|
||||
content.push_back( out[i] );
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
FileHandler(const FileHandler&) = delete;
|
||||
FileHandler(FileHandler&&) = delete;
|
||||
FileHandler& operator=(const FileHandler&) = delete;
|
||||
FileHandler& operator=(FileHandler&&) = delete;
|
||||
Q_DISABLE_COPY_MOVE(FileHandler)
|
||||
|
||||
inline Stream& operator*()
|
||||
{
|
||||
|
@ -196,7 +193,7 @@ void randomLines( const std::string& path, std::vector<std::string>& lines, cons
|
|||
srand( (unsigned)time(&nTime) );
|
||||
size_t index;
|
||||
std::vector<size_t> picked_indexes;
|
||||
for( size_t i=0ul; i<n_lines ; i++ ) {
|
||||
for( size_t i=0ul; i<n_lines ; ++i ) {
|
||||
while (true) {
|
||||
index = static_cast<size_t>(rand()) % max;
|
||||
if ( VecOps::contains<size_t>( picked_indexes, index ) ) {
|
||||
|
@ -206,7 +203,7 @@ void randomLines( const std::string& path, std::vector<std::string>& lines, cons
|
|||
}
|
||||
const std::string& line{ aux_lines.at( index ) };
|
||||
if ( StringOps::startsWith( line, '#' ) ) { // leave the "#" check for IIS logs
|
||||
i--;
|
||||
-- i;
|
||||
continue;
|
||||
}
|
||||
lines.push_back( line );
|
||||
|
|
|
@ -29,12 +29,12 @@ QString printableSize( const size_t bytes )
|
|||
}
|
||||
size_t n_decimals{ 3ul };
|
||||
if ( size >= 100.0 ) {
|
||||
n_decimals --;
|
||||
-- n_decimals;
|
||||
if ( size >= 1000.0 ) {
|
||||
n_decimals --;
|
||||
-- n_decimals;
|
||||
if ( size >= 10000.0 ) {
|
||||
n_decimals --;
|
||||
cut_index --; // no decimals, no "dot"
|
||||
-- n_decimals;
|
||||
-- cut_index; // no decimals, no "dot"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +69,12 @@ QString printableSpeed( const double bytes, const double secs_ )
|
|||
}
|
||||
size_t n_decimals{ 3ul };
|
||||
if ( speed >= 100.0 ) {
|
||||
n_decimals --;
|
||||
-- n_decimals;
|
||||
if ( speed >= 1000.0 ) {
|
||||
n_decimals --;
|
||||
-- n_decimals;
|
||||
if ( speed >= 10000.0 ) {
|
||||
n_decimals --;
|
||||
cut_index --; // no decimals, no "dot"
|
||||
-- n_decimals;
|
||||
-- cut_index; // no decimals, no "dot"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co
|
|||
StringOps::splitrip( lines, content );
|
||||
size_t lines_left{ lines.size() };
|
||||
for ( const std::string& line : lines ) {
|
||||
lines_left --;
|
||||
-- lines_left;
|
||||
// check if the line is commented, usually from IIS logs
|
||||
if ( StringOps::startsWith( line, '#' ) && !StringOps::startsWith( logs_format.initial, '#' ) ) {
|
||||
rich_line = QString("<p>%1</p>").arg( QString::fromStdString( line ) );
|
||||
|
@ -74,7 +74,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co
|
|||
}
|
||||
if ( stop == std::string::npos ) {
|
||||
// separator not found, skip to the next one
|
||||
i++;
|
||||
++i;
|
||||
stop = start;
|
||||
continue;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co
|
|||
break;
|
||||
}
|
||||
aux_start = aux_stop + 1;
|
||||
c++;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co
|
|||
stop = aux_stop;
|
||||
} else {
|
||||
stop += sep_size;
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
if ( stop > line_size ) {
|
||||
// this was the final separator
|
||||
|
|
|
@ -10,7 +10,7 @@ size_t count( std::string_view str, std::string_view flag )
|
|||
{
|
||||
const size_t flg_size{ flag.size() };
|
||||
size_t count{ 0ul };
|
||||
for ( size_t start{0ul}; (start=str.find(flag, start)) != std::string::npos; count++ ) {
|
||||
for ( size_t start{0ul}; (start=str.find(flag, start)) != std::string::npos; ++count ) {
|
||||
start += flg_size;
|
||||
}
|
||||
return count;
|
||||
|
@ -74,7 +74,7 @@ std::string lstripUntil( const std::string& str, const char delim, const bool in
|
|||
{
|
||||
if (size_t start{ str.find( delim ) }; start != std::string::npos ) {
|
||||
if ( inclusive ) {
|
||||
start ++;
|
||||
++ start;
|
||||
if ( consecutives ) {
|
||||
if (str[start] == delim) {
|
||||
start = str.find_first_not_of( delim, start );
|
||||
|
|
Loading…
Reference in a new issue