MythTV
master
|
Definition for a single command line option. More...
#include <libmythbase/mythcommandlineparser.h>
Public Member Functions | |
CommandLineArg (const QString &name, QMetaType::Type type, QVariant def, QString help, QString longhelp) | |
Default constructor for CommandLineArg class. More... | |
CommandLineArg (const QString &name, QMetaType::Type type, QVariant def) | |
Reduced constructor for CommandLineArg class. More... | |
CommandLineArg (const QString &name) | |
Dummy constructor for CommandLineArg class. More... | |
~CommandLineArg () override=default | |
CommandLineArg * | SetGroup (const QString &group) |
void | AddKeyword (const QString &keyword) |
QString | GetName (void) const |
QString | GetUsedKeyword (void) const |
int | GetKeywordLength (void) const |
Return length of full keyword string for use in determining indent of help text. More... | |
QString | GetHelpString (int off, const QString &group="", bool force=false) const |
Return string containing help text with desired offset. More... | |
QString | GetLongHelpString (QString keyword) const |
Return string containing extended help text. More... | |
bool | Set (const QString &opt) |
Set option as provided on command line with no value. More... | |
bool | Set (const QString &opt, const QByteArray &val) |
Set option as provided on command line with value. More... | |
void | Set (const QVariant &val) |
CommandLineArg * | SetParent (const QString &opt) |
Set argument as child of given parent. More... | |
CommandLineArg * | SetParent (const QStringList &opts) |
Set argument as child of multiple parents. More... | |
CommandLineArg * | SetParentOf (const QString &opt) |
Set argument as parent of given child. More... | |
CommandLineArg * | SetParentOf (const QStringList &opts) |
Set argument as parent of multiple children. More... | |
CommandLineArg * | SetChild (const QString &opt) |
Set argument as parent of given child. More... | |
CommandLineArg * | SetChild (const QStringList &opt) |
Set argument as parent of multiple children. More... | |
CommandLineArg * | SetChildOf (const QString &opt) |
Set argument as child of given parent. More... | |
CommandLineArg * | SetChildOf (const QStringList &opts) |
Set argument as child of multiple parents. More... | |
CommandLineArg * | SetRequiredChild (const QString &opt) |
Set argument as parent of given child and mark as required. More... | |
CommandLineArg * | SetRequiredChild (const QStringList &opt) |
Set argument as parent of multiple children and mark as required. More... | |
CommandLineArg * | SetRequiredChildOf (const QString &opt) |
Set argument as child required by given parent. More... | |
CommandLineArg * | SetRequiredChildOf (const QStringList &opt) |
Set argument as child required by multiple parents. More... | |
CommandLineArg * | SetRequires (const QString &opt) |
Set argument as requiring given option. More... | |
CommandLineArg * | SetRequires (const QStringList &opts) |
Set argument as requiring multiple options. More... | |
CommandLineArg * | SetBlocks (const QString &opt) |
Set argument as incompatible with given option. More... | |
CommandLineArg * | SetBlocks (const QStringList &opts) |
Set argument as incompatible with multiple options. More... | |
CommandLineArg * | SetDeprecated (QString depstr="") |
Set option as deprecated. More... | |
CommandLineArg * | SetRemoved (QString remstr="", QString remver="") |
Set option as removed. More... | |
void | PrintVerbose (void) const |
Internal use. More... | |
Public Member Functions inherited from ReferenceCounter | |
ReferenceCounter (const QString &debugName, bool logDebug=true) | |
Creates reference counter with an initial value of 1. More... | |
virtual int | IncrRef (void) |
Increments reference count. More... | |
virtual int | DecrRef (void) |
Decrements reference count and deletes on 0. More... | |
Static Public Member Functions | |
static void | AllowOneOf (const QList< CommandLineArg * > &args) |
Mark a list of arguments as mutually exclusive. More... | |
Static Public Member Functions inherited from ReferenceCounter | |
static void | PrintDebug (void) |
Print out any leaks if that level of debugging is enabled. More... | |
Private Member Functions | |
QString | GetKeywordString (void) const |
Return string containing all possible keyword triggers for this argument. More... | |
void | SetParentOf (CommandLineArg *other, bool forward=true) |
Internal use, set argument as parent of given child. More... | |
void | SetChildOf (CommandLineArg *other, bool forward=true) |
Internal use, set argument as child of given parent. More... | |
void | SetRequires (CommandLineArg *other, bool forward=true) |
Internal use, set argument as requiring given option. More... | |
void | SetBlocks (CommandLineArg *other, bool forward=true) |
Internal use, set argument as incompatible with given option. More... | |
void | Convert (void) |
Convert stored string value from QByteArray to QString. More... | |
QString | GetPreferredKeyword (void) const |
Return the longest keyword for the argument. More... | |
bool | TestLinks (void) const |
Test all related arguments to make sure specified requirements are fulfilled. More... | |
void | CleanupLinks (void) |
Clear out references to other arguments in preparation for deletion. More... | |
void | PrintRemovedWarning (QString &keyword) const |
Internal use. More... | |
void | PrintDeprecatedWarning (QString &keyword) const |
Internal use. More... | |
Private Attributes | |
bool | m_given {false} |
bool | m_converted {false} |
QString | m_name |
QString | m_group |
QString | m_deprecated |
QString | m_removed |
QString | m_removedversion |
QMetaType::Type | m_type {QMetaType::UnknownType} |
QVariant | m_default |
QVariant | m_stored |
QStringList | m_keywords |
QString | m_usedKeyword |
QList< CommandLineArg * > | m_parents |
QList< CommandLineArg * > | m_children |
QList< CommandLineArg * > | m_requires |
QList< CommandLineArg * > | m_requiredby |
QList< CommandLineArg * > | m_blocks |
QString | m_help |
QString | m_longhelp |
Friends | |
class | MythCommandLineParser |
Additional Inherited Members | |
Protected Member Functions inherited from ReferenceCounter | |
virtual | ~ReferenceCounter (void) |
Called on destruction, will warn if object deleted with references in place. More... | |
Protected Attributes inherited from ReferenceCounter | |
bool | m_logDebug |
This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More... | |
QAtomicInt | m_referenceCount {1} |
Definition for a single command line option.
This class contains instructions for the command line parser about what options to process from the command line. Each instance can correspond to multiple argument keywords, and stores a default value, whether it has been supplied, help text, and optional interdependencies with other CommandLineArgs.
Definition at line 21 of file mythcommandlineparser.h.
CommandLineArg::CommandLineArg | ( | const QString & | name, |
QMetaType::Type | type, | ||
QVariant | def, | ||
QString | help, | ||
QString | longhelp | ||
) |
Default constructor for CommandLineArg class.
This constructor is for use with command line parser, defining an option that can be used on the command line, and should be reported in –help printouts
Definition at line 284 of file mythcommandlineparser.cpp.
Referenced by SetBlocks(), SetChild(), SetChildOf(), SetParent(), SetParentOf(), SetRequiredChild(), SetRequiredChildOf(), and SetRequires().
CommandLineArg::CommandLineArg | ( | const QString & | name, |
QMetaType::Type | type, | ||
QVariant | def | ||
) |
Reduced constructor for CommandLineArg class.
This constructor is for internal use within the command line parser. It is intended for use in supplementary data storage for information not supplied directly on the command line.
Definition at line 301 of file mythcommandlineparser.cpp.
|
explicit |
Dummy constructor for CommandLineArg class.
This constructor is for internal use within the command line parser. It is used as a placeholder for defining relations between different command line arguments, and is reconciled with the proper argument of the same name prior to parsing inputs.
Definition at line 317 of file mythcommandlineparser.cpp.
|
overridedefault |
|
inline |
Definition at line 30 of file mythcommandlineparser.h.
Referenced by MythCommandLineParser::addLogging(), MythCommandLineParser::addMouse(), MythCommandLineParser::addWindowed(), MythFrontendCommandLineParser::LoadArguments(), MythFillDatabaseCommandLineParser::LoadArguments(), MythTranscodeCommandLineParser::LoadArguments(), MythExternRecorderCommandLineParser::LoadArguments(), MythCommFlagCommandLineParser::LoadArguments(), MythFileRecorderCommandLineParser::LoadArguments(), and MythUtilCommandLineParser::LoadArguments().
|
inline |
Definition at line 32 of file mythcommandlineparser.h.
Referenced by MythCommandLineParser::add().
|
inline |
Definition at line 34 of file mythcommandlineparser.h.
Referenced by MythCommandLineParser::Parse().
|
inline |
Definition at line 35 of file mythcommandlineparser.h.
int CommandLineArg::GetKeywordLength | ( | void | ) | const |
Return length of full keyword string for use in determining indent of help text.
Definition at line 336 of file mythcommandlineparser.cpp.
QString CommandLineArg::GetHelpString | ( | int | off, |
const QString & | group = "" , |
||
bool | force = false |
||
) | const |
Return string containing help text with desired offset.
This function returns a string containing all usable keywords and the shortened help text, for use with the general help printout showing all options. It automatically accounts for terminal width, and wraps the text accordingly.
The group option acts as a filter, only returning text if the argument is part of the group the parser is currently printing options for.
Child arguments will not produce help text on their own, but only indented beneath each of the marked parent arguments. The force option specifies that the function is being called by the parent argument, and help should be output.
Definition at line 362 of file mythcommandlineparser.cpp.
QString CommandLineArg::GetLongHelpString | ( | QString | keyword | ) | const |
Return string containing extended help text.
This function returns a longer version of the help text than that provided with the list of arguments, intended for more detailed, specific information. This also documents the type of argument it takes, default value, and any relational dependencies with other arguments it might have.
Definition at line 437 of file mythcommandlineparser.cpp.
bool CommandLineArg::Set | ( | const QString & | opt | ) |
Set option as provided on command line with no value.
This specifies that an option is given, but there is no corresponding value, meaning this can only be used on a boolean, integer, and string arguments. All other will return false.
Definition at line 545 of file mythcommandlineparser.cpp.
Referenced by MythCommandLineParser::Parse(), and MythCommandLineParser::SetValue().
bool CommandLineArg::Set | ( | const QString & | opt, |
const QByteArray & | val | ||
) |
Set option as provided on command line with value.
Definition at line 578 of file mythcommandlineparser.cpp.
|
inline |
Definition at line 43 of file mythcommandlineparser.h.
CommandLineArg * CommandLineArg::SetParent | ( | const QString & | opt | ) |
Set argument as child of given parent.
Definition at line 678 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetParent | ( | const QStringList & | opts | ) |
Set argument as child of multiple parents.
Definition at line 686 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetParentOf | ( | const QString & | opt | ) |
Set argument as parent of given child.
Definition at line 661 of file mythcommandlineparser.cpp.
Referenced by MythTVSetupCommandLineParser::LoadArguments(), and SetChildOf().
CommandLineArg * CommandLineArg::SetParentOf | ( | const QStringList & | opts | ) |
Set argument as parent of multiple children.
Definition at line 669 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetChild | ( | const QString & | opt | ) |
Set argument as parent of given child.
Definition at line 712 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetChild | ( | const QStringList & | opt | ) |
Set argument as parent of multiple children.
Definition at line 720 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetChildOf | ( | const QString & | opt | ) |
Set argument as child of given parent.
Definition at line 695 of file mythcommandlineparser.cpp.
Referenced by MythMetadataLookupCommandLineParser::LoadArguments(), MythTranscodeCommandLineParser::LoadArguments(), MythAVTestCommandLineParser::LoadArguments(), MythUtilCommandLineParser::LoadArguments(), and SetParentOf().
CommandLineArg * CommandLineArg::SetChildOf | ( | const QStringList & | opts | ) |
Set argument as child of multiple parents.
Definition at line 703 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetRequiredChild | ( | const QString & | opt | ) |
Set argument as parent of given child and mark as required.
Definition at line 729 of file mythcommandlineparser.cpp.
Referenced by MythAVTestCommandLineParser::LoadArguments().
CommandLineArg * CommandLineArg::SetRequiredChild | ( | const QStringList & | opt | ) |
Set argument as parent of multiple children and mark as required.
Definition at line 738 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetRequiredChildOf | ( | const QString & | opt | ) |
Set argument as child required by given parent.
Definition at line 750 of file mythcommandlineparser.cpp.
Referenced by MythFillDatabaseCommandLineParser::LoadArguments(), and MythUtilCommandLineParser::LoadArguments().
CommandLineArg * CommandLineArg::SetRequiredChildOf | ( | const QStringList & | opt | ) |
Set argument as child required by multiple parents.
Definition at line 759 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetRequires | ( | const QString & | opt | ) |
Set argument as requiring given option.
Definition at line 771 of file mythcommandlineparser.cpp.
Referenced by MythCommandLineParser::addRecording(), MythTranscodeCommandLineParser::LoadArguments(), and MythFillDatabaseCommandLineParser::LoadArguments().
CommandLineArg * CommandLineArg::SetRequires | ( | const QStringList & | opts | ) |
Set argument as requiring multiple options.
Definition at line 779 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetBlocks | ( | const QString & | opt | ) |
Set argument as incompatible with given option.
Definition at line 788 of file mythcommandlineparser.cpp.
Referenced by MythCommandLineParser::addLogging(), MythCommandLineParser::addMouse(), MythMetadataLookupCommandLineParser::LoadArguments(), MythFrontendCommandLineParser::LoadArguments(), MythFillDatabaseCommandLineParser::LoadArguments(), MythTVSetupCommandLineParser::LoadArguments(), and SetBlocks().
CommandLineArg * CommandLineArg::SetBlocks | ( | const QStringList & | opts | ) |
Set argument as incompatible with multiple options.
Definition at line 796 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetDeprecated | ( | QString | depstr = "" | ) |
Set option as deprecated.
Definition at line 805 of file mythcommandlineparser.cpp.
CommandLineArg * CommandLineArg::SetRemoved | ( | QString | remstr = "" , |
QString | remver = "" |
||
) |
Set option as removed.
Definition at line 815 of file mythcommandlineparser.cpp.
Referenced by MythCommandLineParser::addLogging(), MythShutdownCommandLineParser::LoadArguments(), MythLCDServerCommandLineParser::LoadArguments(), and MythFillDatabaseCommandLineParser::LoadArguments().
|
static |
Mark a list of arguments as mutually exclusive.
Definition at line 939 of file mythcommandlineparser.cpp.
Referenced by MythMetadataLookupCommandLineParser::LoadArguments(), MythShutdownCommandLineParser::LoadArguments(), MythCommFlagCommandLineParser::LoadArguments(), MythBackendCommandLineParser::LoadArguments(), and MythUtilCommandLineParser::LoadArguments().
void CommandLineArg::PrintVerbose | ( | void | ) | const |
Internal use.
Print processed input in verbose mode.
Definition at line 1146 of file mythcommandlineparser.cpp.
|
private |
Return string containing all possible keyword triggers for this argument.
Definition at line 326 of file mythcommandlineparser.cpp.
Referenced by GetHelpString(), and GetKeywordLength().
|
private |
Internal use, set argument as parent of given child.
This option is intended for internal use only, as part of reconciling dummy options with their matched real counterparts.
Definition at line 829 of file mythcommandlineparser.cpp.
|
private |
Internal use, set argument as child of given parent.
This option is intended for internal use only, as part of reconciling dummy options with their matched real counterparts.
Definition at line 857 of file mythcommandlineparser.cpp.
|
private |
Internal use, set argument as requiring given option.
This option is intended for internal use only, as part of reconciling dummy options with their matched real counterparts.
Definition at line 885 of file mythcommandlineparser.cpp.
|
private |
Internal use, set argument as incompatible with given option.
This option is intended for internal use only, as part of reconciling dummy options with their matched real counterparts.
Definition at line 914 of file mythcommandlineparser.cpp.
|
private |
Convert stored string value from QByteArray to QString.
This is a work around to delay string processing until after QApplication has been initialized, to allow the locale to be configured and unicode handling to work properly
Definition at line 967 of file mythcommandlineparser.cpp.
Referenced by MythCommandLineParser::toMap(), MythCommandLineParser::toString(), and MythCommandLineParser::toStringList().
|
private |
Return the longest keyword for the argument.
This is used to determine which keyword to use when listing relations to other options. The longest keyword is presumed to be the most descriptive.
Definition at line 1031 of file mythcommandlineparser.cpp.
|
private |
Test all related arguments to make sure specified requirements are fulfilled.
Definition at line 1053 of file mythcommandlineparser.cpp.
|
private |
Clear out references to other arguments in preparation for deletion.
Definition at line 1125 of file mythcommandlineparser.cpp.
|
private |
Internal use.
Print warning for removed option.
Definition at line 1236 of file mythcommandlineparser.cpp.
Referenced by GetLongHelpString(), and MythCommandLineParser::Parse().
|
private |
Internal use.
Print warning for deprecated option.
Definition at line 1252 of file mythcommandlineparser.cpp.
Referenced by GetLongHelpString(), and MythCommandLineParser::Parse().
|
friend |
Definition at line 73 of file mythcommandlineparser.h.
Definition at line 92 of file mythcommandlineparser.h.
Referenced by Convert(), MythCommandLineParser::operator[](), PrintVerbose(), Set(), TestLinks(), MythCommandLineParser::toBool(), MythCommandLineParser::toDateTime(), MythCommandLineParser::toDouble(), MythCommandLineParser::toInt(), MythCommandLineParser::toLongLong(), MythCommandLineParser::toMap(), MythCommandLineParser::toSize(), MythCommandLineParser::toString(), MythCommandLineParser::toStringList(), and MythCommandLineParser::toUInt().
Definition at line 93 of file mythcommandlineparser.h.
Referenced by CommandLineArg(), Convert(), MythCommandLineParser::toMap(), MythCommandLineParser::toString(), and MythCommandLineParser::toStringList().
|
private |
Definition at line 94 of file mythcommandlineparser.h.
Referenced by PrintVerbose(), SetBlocks(), SetChildOf(), SetParentOf(), and SetRequires().
|
private |
Definition at line 95 of file mythcommandlineparser.h.
Referenced by GetHelpString().
|
private |
Definition at line 96 of file mythcommandlineparser.h.
Referenced by GetHelpString(), GetLongHelpString(), MythCommandLineParser::Parse(), PrintDeprecatedWarning(), and SetDeprecated().
|
private |
Definition at line 97 of file mythcommandlineparser.h.
Referenced by GetHelpString(), GetLongHelpString(), MythCommandLineParser::Parse(), PrintRemovedWarning(), and SetRemoved().
|
private |
Definition at line 98 of file mythcommandlineparser.h.
Referenced by PrintRemovedWarning(), and SetRemoved().
|
private |
Definition at line 99 of file mythcommandlineparser.h.
Referenced by CommandLineArg(), Convert(), GetLongHelpString(), PrintVerbose(), Set(), MythCommandLineParser::SetValue(), MythCommandLineParser::toBool(), and MythCommandLineParser::toStringList().
|
private |
Definition at line 100 of file mythcommandlineparser.h.
Referenced by GetLongHelpString(), MythCommandLineParser::operator[](), Set(), MythCommandLineParser::toBool(), MythCommandLineParser::toDateTime(), MythCommandLineParser::toDouble(), MythCommandLineParser::toInt(), MythCommandLineParser::toLongLong(), MythCommandLineParser::toMap(), MythCommandLineParser::toSize(), MythCommandLineParser::toString(), MythCommandLineParser::toStringList(), and MythCommandLineParser::toUInt().
|
private |
Definition at line 101 of file mythcommandlineparser.h.
Referenced by Convert(), MythCommandLineParser::operator[](), MythCommandLineParser::Parse(), PrintVerbose(), Set(), MythCommandLineParser::toBool(), MythCommandLineParser::toDateTime(), MythCommandLineParser::toDouble(), MythCommandLineParser::toInt(), MythCommandLineParser::toLongLong(), MythCommandLineParser::toMap(), MythCommandLineParser::toSize(), MythCommandLineParser::toString(), MythCommandLineParser::toStringList(), and MythCommandLineParser::toUInt().
|
private |
Definition at line 103 of file mythcommandlineparser.h.
Referenced by GetKeywordString(), GetLongHelpString(), and GetPreferredKeyword().
|
private |
Definition at line 104 of file mythcommandlineparser.h.
Referenced by Set(), and TestLinks().
|
private |
Definition at line 106 of file mythcommandlineparser.h.
Referenced by CleanupLinks(), GetHelpString(), GetKeywordLength(), GetLongHelpString(), SetChildOf(), SetParent(), SetRequiredChildOf(), and TestLinks().
|
private |
Definition at line 107 of file mythcommandlineparser.h.
Referenced by CleanupLinks(), GetHelpString(), GetLongHelpString(), SetChild(), SetParentOf(), and SetRequiredChild().
|
private |
Definition at line 108 of file mythcommandlineparser.h.
Referenced by CleanupLinks(), GetLongHelpString(), SetRequiredChild(), SetRequires(), and TestLinks().
|
private |
Definition at line 109 of file mythcommandlineparser.h.
Referenced by CleanupLinks(), and SetRequiredChildOf().
|
private |
Definition at line 110 of file mythcommandlineparser.h.
Referenced by CleanupLinks(), GetLongHelpString(), SetBlocks(), and TestLinks().
|
private |
Definition at line 112 of file mythcommandlineparser.h.
Referenced by GetHelpString(), and GetLongHelpString().
|
private |
Definition at line 113 of file mythcommandlineparser.h.
Referenced by GetLongHelpString().