reformatted to Mozilla code style
This commit is contained in:
committed by
borgmanJeremy
parent
c0e2e48db4
commit
c8d15205be
@@ -21,69 +21,72 @@
|
||||
#include "src/cli/commandoption.h"
|
||||
#include <QMap>
|
||||
|
||||
class CommandLineParser {
|
||||
class CommandLineParser
|
||||
{
|
||||
public:
|
||||
CommandLineParser();
|
||||
CommandLineParser();
|
||||
|
||||
bool parse(const QStringList &args);
|
||||
bool parse(const QStringList& args);
|
||||
|
||||
CommandArgument rootArgument() const { return CommandArgument(); }
|
||||
CommandArgument rootArgument() const { return CommandArgument(); }
|
||||
|
||||
CommandOption addVersionOption();
|
||||
CommandOption addHelpOption();
|
||||
CommandOption addVersionOption();
|
||||
CommandOption addHelpOption();
|
||||
|
||||
bool AddArgument(const CommandArgument &arg,
|
||||
const CommandArgument &parent = CommandArgument());
|
||||
bool AddArgument(const CommandArgument& arg,
|
||||
const CommandArgument& parent = CommandArgument());
|
||||
|
||||
bool AddOption(const CommandOption &option,
|
||||
const CommandArgument &parent = CommandArgument());
|
||||
bool AddOption(const CommandOption& option,
|
||||
const CommandArgument& parent = CommandArgument());
|
||||
|
||||
bool AddOptions(const QList<CommandOption> &options,
|
||||
const CommandArgument &parent = CommandArgument());
|
||||
bool AddOptions(const QList<CommandOption>& options,
|
||||
const CommandArgument& parent = CommandArgument());
|
||||
|
||||
void setGeneralErrorMessage(const QString &msg);
|
||||
void setDescription(const QString &description);
|
||||
void setGeneralErrorMessage(const QString& msg);
|
||||
void setDescription(const QString& description);
|
||||
|
||||
bool isSet(const CommandArgument &arg) const;
|
||||
bool isSet(const CommandOption &option) const;
|
||||
QString value(const CommandOption &option) const;
|
||||
bool isSet(const CommandArgument& arg) const;
|
||||
bool isSet(const CommandOption& option) const;
|
||||
QString value(const CommandOption& option) const;
|
||||
|
||||
private:
|
||||
bool m_withHelp = false;
|
||||
bool m_withVersion = false;
|
||||
QString m_description;
|
||||
QString m_generalErrorMessage;
|
||||
bool m_withHelp = false;
|
||||
bool m_withVersion = false;
|
||||
QString m_description;
|
||||
QString m_generalErrorMessage;
|
||||
|
||||
struct Node {
|
||||
explicit Node(const CommandArgument &arg) : argument(arg) {}
|
||||
Node() {}
|
||||
bool operator==(const Node &n) const {
|
||||
return argument == n.argument &&
|
||||
options == n.options &&
|
||||
subNodes == n.subNodes;
|
||||
}
|
||||
CommandArgument argument;
|
||||
QList<CommandOption> options;
|
||||
QList<Node> subNodes;
|
||||
};
|
||||
struct Node
|
||||
{
|
||||
explicit Node(const CommandArgument& arg)
|
||||
: argument(arg)
|
||||
{}
|
||||
Node() {}
|
||||
bool operator==(const Node& n) const
|
||||
{
|
||||
return argument == n.argument && options == n.options &&
|
||||
subNodes == n.subNodes;
|
||||
}
|
||||
CommandArgument argument;
|
||||
QList<CommandOption> options;
|
||||
QList<Node> subNodes;
|
||||
};
|
||||
|
||||
Node m_parseTree;
|
||||
QList<CommandOption> m_foundOptions;
|
||||
QList<CommandArgument> m_foundArgs;
|
||||
Node m_parseTree;
|
||||
QList<CommandOption> m_foundOptions;
|
||||
QList<CommandArgument> m_foundArgs;
|
||||
|
||||
// helper functions
|
||||
void printVersion();
|
||||
void printHelp(QStringList args, const Node *node);
|
||||
Node* findParent(const CommandArgument &parent);
|
||||
Node* recursiveParentSearch(const CommandArgument &parent,
|
||||
Node &node) const;
|
||||
bool processIfOptionIsHelp(const QStringList &args,
|
||||
QStringList::const_iterator &actualIt,
|
||||
Node * &actualNode);
|
||||
bool processArgs(const QStringList &args,
|
||||
QStringList::const_iterator &actualIt,
|
||||
Node * &actualNode);
|
||||
bool processOptions(const QStringList &args,
|
||||
QStringList::const_iterator &actualIt,
|
||||
Node *const actualNode);
|
||||
// helper functions
|
||||
void printVersion();
|
||||
void printHelp(QStringList args, const Node* node);
|
||||
Node* findParent(const CommandArgument& parent);
|
||||
Node* recursiveParentSearch(const CommandArgument& parent, Node& node) const;
|
||||
bool processIfOptionIsHelp(const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node*& actualNode);
|
||||
bool processArgs(const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node*& actualNode);
|
||||
bool processOptions(const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node* const actualNode);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user