Minor code improvements

This commit is contained in:
Valentino Orlandi 2024-01-21 21:14:38 +01:00
parent fc92115597
commit 8a0bb2046d
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
3 changed files with 19 additions and 21 deletions

View File

@ -23,9 +23,9 @@ void DbQuery::setDialogLevel(const int new_level ) noexcept
this->dialog_level = new_level;
}
void DbQuery::setDbPath( const std::string& path ) noexcept
void DbQuery::setDbPath( std::string&& path ) noexcept
{
this->db_path = path;
this->db_path = std::move(path);
this->db_name = QString::fromStdString( this->db_path.substr( this->db_path.find_last_of( '/' ) + 1ul ) );
}

View File

@ -24,25 +24,25 @@ public:
// convert log fields IDs to log fields
const std::unordered_map<int, std::string> FIELDS{
{0, FIELDS__WARNING},
{10,FIELDS__PROTOCOL}, {11,FIELDS__METHOD},
{12,FIELDS__URI}, {13,FIELDS__QUERY}, {14,FIELDS__RESPONSE_CODE},
{15,FIELDS__TIME_TAKEN}, {16,FIELDS__BYTES_SENT}, {17,FIELDS__BYTES_RECEIVED},
{18,FIELDS__REFERRER}, {22,FIELDS__COOKIE},
{20,FIELDS__CLIENT}, {21,FIELDS__USER_AGENT} };
{0, FIELDS__WARNING},
{10,FIELDS__PROTOCOL}, {11,FIELDS__METHOD},
{12,FIELDS__URI}, {13,FIELDS__QUERY}, {14,FIELDS__RESPONSE_CODE},
{15,FIELDS__TIME_TAKEN}, {16,FIELDS__BYTES_SENT}, {17,FIELDS__BYTES_RECEIVED},
{18,FIELDS__REFERRER}, {22,FIELDS__COOKIE},
{20,FIELDS__CLIENT}, {21,FIELDS__USER_AGENT} };
// convert month numbers to month names
const std::unordered_map<int, std::string> MONTHS{
{1, MONTHS__JANUARY}, {2, MONTHS__FEBRUARY}, {3, MONTHS__MARCH},
{4, MONTHS__APRIL}, {5, MONTHS__MAY}, {6, MONTHS__JUNE},
{7, MONTHS__JULY}, {8, MONTHS__AUGUST}, {9, MONTHS__SEPTEMBER},
{10,MONTHS__OCTOBER}, {11,MONTHS__NOVEMBER}, {12,MONTHS__DECEMBER} };
{1, MONTHS__JANUARY}, {2, MONTHS__FEBRUARY}, {3, MONTHS__MARCH},
{4, MONTHS__APRIL}, {5, MONTHS__MAY}, {6, MONTHS__JUNE},
{7, MONTHS__JULY}, {8, MONTHS__AUGUST}, {9, MONTHS__SEPTEMBER},
{10,MONTHS__OCTOBER}, {11,MONTHS__NOVEMBER}, {12,MONTHS__DECEMBER} };
// convert week-day numbers to day names
const std::unordered_map<int, std::string> DAYS{
{1, DAYS__SUNDAY}, {2, DAYS__MONDAY}, {3, DAYS__TUESDAY},
{4, DAYS__WEDNESDAY}, {5, DAYS__THURSDAY}, {6, DAYS__FRIDAY},
{7, DAYS__SATURDAY} };
{1, DAYS__SUNDAY}, {2, DAYS__MONDAY}, {3, DAYS__TUESDAY},
{4, DAYS__WEDNESDAY}, {5, DAYS__THURSDAY}, {6, DAYS__FRIDAY},
{7, DAYS__SATURDAY} };
//! Returns the Dialogs level
@ -53,7 +53,7 @@ public:
/*!
\see Crapview::setDbPath()
*/
void setDbPath( const std::string& path ) noexcept;
void setDbPath( std::string&& path ) noexcept;
/*const std::string getDbPath( const int web_server );*/

View File

@ -149,11 +149,9 @@ QString printableDate( const int year, const int month, const int day ) noexcept
QString printableBool( const int value ) noexcept
{
if ( value == 0 ) {
return TR::tr( BOOLS__FALSE.c_str() );
} else {
return TR::tr( BOOLS__TRUE.c_str() );
}
return value == 0
? TR::tr( BOOLS__FALSE.c_str() )
: TR::tr( BOOLS__TRUE.c_str() );
}
} // namespace PrintSec