mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-27 00:35:27 -04:00
Clean up code (#3431)
* Empty destructors are replaced with default destructors * A few loop variables made into const references to avoid copies * Add missing `override` spec for some `Command::execute` methods
This commit is contained in:
parent
7cbcea18e9
commit
b9e1088f74
27 changed files with 12 additions and 78 deletions
|
@ -62,10 +62,6 @@ Add::Add()
|
||||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to add."), QString("")});
|
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to add."), QString("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Add::~Add()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Add::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Add::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
TextStream inputTextStream(Utils::STDIN, QIODevice::ReadOnly);
|
TextStream inputTextStream(Utils::STDIN, QIODevice::ReadOnly);
|
||||||
|
|
|
@ -24,9 +24,8 @@ class Add : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Add();
|
Add();
|
||||||
~Add();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
|
|
||||||
static const QCommandLineOption UsernameOption;
|
static const QCommandLineOption UsernameOption;
|
||||||
static const QCommandLineOption UrlOption;
|
static const QCommandLineOption UrlOption;
|
||||||
|
|
|
@ -43,10 +43,6 @@ Clip::Clip()
|
||||||
{QString("timeout"), QObject::tr("Timeout in seconds before clearing the clipboard."), QString("[timeout]")});
|
{QString("timeout"), QObject::tr("Timeout in seconds before clearing the clipboard."), QString("[timeout]")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Clip::~Clip()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Clip::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Clip::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
const QStringList args = parser->positionalArguments();
|
const QStringList args = parser->positionalArguments();
|
||||||
|
|
|
@ -24,9 +24,8 @@ class Clip : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Clip();
|
Clip();
|
||||||
~Clip();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
|
|
||||||
static const QCommandLineOption TotpOption;
|
static const QCommandLineOption TotpOption;
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,14 +80,14 @@ QSharedPointer<QCommandLineParser> Command::getCommandLineParser(const QStringLi
|
||||||
|
|
||||||
QSharedPointer<QCommandLineParser> parser = QSharedPointer<QCommandLineParser>(new QCommandLineParser());
|
QSharedPointer<QCommandLineParser> parser = QSharedPointer<QCommandLineParser>(new QCommandLineParser());
|
||||||
parser->setApplicationDescription(description);
|
parser->setApplicationDescription(description);
|
||||||
for (CommandLineArgument positionalArgument : positionalArguments) {
|
for (const CommandLineArgument& positionalArgument : positionalArguments) {
|
||||||
parser->addPositionalArgument(
|
parser->addPositionalArgument(
|
||||||
positionalArgument.name, positionalArgument.description, positionalArgument.syntax);
|
positionalArgument.name, positionalArgument.description, positionalArgument.syntax);
|
||||||
}
|
}
|
||||||
for (CommandLineArgument optionalArgument : optionalArguments) {
|
for (const CommandLineArgument& optionalArgument : optionalArguments) {
|
||||||
parser->addPositionalArgument(optionalArgument.name, optionalArgument.description, optionalArgument.syntax);
|
parser->addPositionalArgument(optionalArgument.name, optionalArgument.description, optionalArgument.syntax);
|
||||||
}
|
}
|
||||||
for (QCommandLineOption option : options) {
|
for (const QCommandLineOption& option : options) {
|
||||||
parser->addOption(option);
|
parser->addOption(option);
|
||||||
}
|
}
|
||||||
parser->addHelpOption();
|
parser->addHelpOption();
|
||||||
|
|
|
@ -38,10 +38,6 @@ Create::Create()
|
||||||
options.append(Command::KeyFileOption);
|
options.append(Command::KeyFileOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
Create::~Create()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a database file using the command line. A key file and/or
|
* Create a database file using the command line. A key file and/or
|
||||||
* password can be specified to encrypt the password. If none is
|
* password can be specified to encrypt the password. If none is
|
||||||
|
|
|
@ -27,12 +27,10 @@ class Create : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Create();
|
Create();
|
||||||
~Create();
|
int execute(const QStringList& arguments) override;
|
||||||
int execute(const QStringList& arguments);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<PasswordKey> getPasswordFromStdin();
|
QSharedPointer<PasswordKey> getPasswordFromStdin();
|
||||||
QSharedPointer<FileKey> getFileKeyFromStdin();
|
|
||||||
bool loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey);
|
bool loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,6 @@ Diceware::Diceware()
|
||||||
options.append(Diceware::WordListOption);
|
options.append(Diceware::WordListOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
Diceware::~Diceware()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Diceware::execute(const QStringList& arguments)
|
int Diceware::execute(const QStringList& arguments)
|
||||||
{
|
{
|
||||||
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);
|
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);
|
||||||
|
|
|
@ -24,9 +24,8 @@ class Diceware : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Diceware();
|
Diceware();
|
||||||
~Diceware();
|
|
||||||
|
|
||||||
int execute(const QStringList& arguments);
|
int execute(const QStringList& arguments) override;
|
||||||
|
|
||||||
static const QCommandLineOption WordCountOption;
|
static const QCommandLineOption WordCountOption;
|
||||||
static const QCommandLineOption WordListOption;
|
static const QCommandLineOption WordListOption;
|
||||||
|
|
|
@ -47,10 +47,6 @@ Edit::Edit()
|
||||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to edit."), QString("")});
|
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to edit."), QString("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Edit::~Edit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||||
|
|
|
@ -24,8 +24,7 @@ class Edit : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Edit();
|
Edit();
|
||||||
~Edit();
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
|
||||||
|
|
||||||
static const QCommandLineOption TitleOption;
|
static const QCommandLineOption TitleOption;
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,10 +45,6 @@ Estimate::Estimate()
|
||||||
description = QObject::tr("Estimate the entropy of a password.");
|
description = QObject::tr("Estimate the entropy of a password.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Estimate::~Estimate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void estimate(const char* pwd, bool advanced)
|
static void estimate(const char* pwd, bool advanced)
|
||||||
{
|
{
|
||||||
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -24,7 +24,6 @@ class Estimate : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Estimate();
|
Estimate();
|
||||||
~Estimate();
|
|
||||||
int execute(const QStringList& arguments) override;
|
int execute(const QStringList& arguments) override;
|
||||||
|
|
||||||
static const QCommandLineOption AdvancedOption;
|
static const QCommandLineOption AdvancedOption;
|
||||||
|
|
|
@ -30,10 +30,6 @@ Extract::Extract()
|
||||||
description = QObject::tr("Extract and print the content of a database.");
|
description = QObject::tr("Extract and print the content of a database.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Extract::~Extract()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Extract::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser>)
|
int Extract::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser>)
|
||||||
{
|
{
|
||||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -24,9 +24,8 @@ class Extract : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Extract();
|
Extract();
|
||||||
~Extract();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSXC_EXTRACT_H
|
#endif // KEEPASSXC_EXTRACT_H
|
||||||
|
|
|
@ -75,10 +75,6 @@ Generate::Generate()
|
||||||
options.append(Generate::IncludeEveryGroupOption);
|
options.append(Generate::IncludeEveryGroupOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
Generate::~Generate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Generate::execute(const QStringList& arguments)
|
int Generate::execute(const QStringList& arguments)
|
||||||
{
|
{
|
||||||
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);
|
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);
|
||||||
|
|
|
@ -24,7 +24,6 @@ class Generate : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Generate();
|
Generate();
|
||||||
~Generate();
|
|
||||||
int execute(const QStringList& arguments) override;
|
int execute(const QStringList& arguments) override;
|
||||||
|
|
||||||
static const QCommandLineOption PasswordLengthOption;
|
static const QCommandLineOption PasswordLengthOption;
|
||||||
|
|
|
@ -45,10 +45,6 @@ List::List()
|
||||||
{QString("group"), QObject::tr("Path of the group to list. Default is /"), QString("[group]")});
|
{QString("group"), QObject::tr("Path of the group to list. Default is /"), QString("[group]")});
|
||||||
}
|
}
|
||||||
|
|
||||||
List::~List()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int List::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int List::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -24,9 +24,8 @@ class List : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
List();
|
List();
|
||||||
~List();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
|
|
||||||
static const QCommandLineOption RecursiveOption;
|
static const QCommandLineOption RecursiveOption;
|
||||||
static const QCommandLineOption FlattenOption;
|
static const QCommandLineOption FlattenOption;
|
||||||
|
|
|
@ -36,10 +36,6 @@ Locate::Locate()
|
||||||
positionalArguments.append({QString("term"), QObject::tr("Search term."), QString("")});
|
positionalArguments.append({QString("term"), QObject::tr("Search term."), QString("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Locate::~Locate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Locate::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Locate::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@ class Locate : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Locate();
|
Locate();
|
||||||
~Locate();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSXC_LOCATE_H
|
#endif // KEEPASSXC_LOCATE_H
|
||||||
|
|
|
@ -54,10 +54,6 @@ Merge::Merge()
|
||||||
positionalArguments.append({QString("database2"), QObject::tr("Path of the database to merge from."), QString("")});
|
positionalArguments.append({QString("database2"), QObject::tr("Path of the database to merge from."), QString("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Merge::~Merge()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Merge::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Merge::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||||
|
|
|
@ -24,9 +24,8 @@ class Merge : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Merge();
|
Merge();
|
||||||
~Merge();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||||
|
|
||||||
static const QCommandLineOption SameCredentialsOption;
|
static const QCommandLineOption SameCredentialsOption;
|
||||||
static const QCommandLineOption KeyFileFromOption;
|
static const QCommandLineOption KeyFileFromOption;
|
||||||
|
|
|
@ -35,10 +35,6 @@ Remove::Remove()
|
||||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to remove."), QString("")});
|
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to remove."), QString("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Remove::~Remove()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
bool quiet = parser->isSet(Command::QuietOption);
|
bool quiet = parser->isSet(Command::QuietOption);
|
||||||
|
|
|
@ -24,7 +24,6 @@ class Remove : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Remove();
|
Remove();
|
||||||
~Remove();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,10 +49,6 @@ Show::Show()
|
||||||
positionalArguments.append({QString("entry"), QObject::tr("Name of the entry to show."), QString("")});
|
positionalArguments.append({QString("entry"), QObject::tr("Name of the entry to show."), QString("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
Show::~Show()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Show::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
int Show::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||||
{
|
{
|
||||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -24,7 +24,6 @@ class Show : public DatabaseCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Show();
|
Show();
|
||||||
~Show();
|
|
||||||
|
|
||||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue