CommandLineArg Class Reference

Definition for a single command line option. More...

#include <mythcommandlineparser.h>

Inheritance diagram for CommandLineArg:
ReferenceCounter

List of all members.

Public Member Functions

 CommandLineArg (QString name, QVariant::Type type, QVariant def, QString help, QString longhelp)
 Default constructor for CommandLineArg class.
 CommandLineArg (QString name, QVariant::Type type, QVariant def)
 Reduced constructor for CommandLineArg class.
 CommandLineArg (QString name)
 Dummy constructor for CommandLineArg class.
 ~CommandLineArg ()
CommandLineArgSetGroup (QString group)
void AddKeyword (QString keyword)
QString GetName (void) const
int GetKeywordLength (void) const
 Return length of full keyword string for use in determining indent of help text.
QString GetHelpString (int off, QString group="", bool force=false) const
 Return string containing help text with desired offset.
QString GetLongHelpString (QString keyword) const
 Return string containing extended help text.
bool Set (QString opt)
 Set option as provided on command line with no value.
bool Set (QString opt, QByteArray val)
 Set option as provided on command line with value.
void Set (QVariant val)
CommandLineArgSetParent (QString opt)
 Set argument as child of given parent.
CommandLineArgSetParent (QStringList opts)
 Set argument as child of multiple parents.
CommandLineArgSetParentOf (QString opt)
 Set argument as parent of given child.
CommandLineArgSetParentOf (QStringList opts)
 Set argument as parent of multiple children.
CommandLineArgSetChild (QString opt)
 Set argument as parent of given child.
CommandLineArgSetChild (QStringList opt)
 Set argument as parent of multiple children.
CommandLineArgSetChildOf (QString opt)
 Set argument as child of given parent.
CommandLineArgSetChildOf (QStringList opts)
 Set argument as child of multiple parents.
CommandLineArgSetRequiredChild (QString opt)
 Set argument as parent of given child and mark as required.
CommandLineArgSetRequiredChild (QStringList opt)
 Set argument as parent of multiple children and mark as required.
CommandLineArgSetRequiredChildOf (QString opt)
 Set argument as child required by given parent.
CommandLineArgSetRequiredChildOf (QStringList opt)
 Set argument as child required by multiple parents.
CommandLineArgSetRequires (QString opt)
 Set argument as requiring given option.
CommandLineArgSetRequires (QStringList opts)
 Set argument as requiring multiple options.
CommandLineArgSetBlocks (QString opt)
 Set argument as incompatible with given option.
CommandLineArgSetBlocks (QStringList opts)
 Set argument as incompatible with multiple options.
CommandLineArgSetDeprecated (QString depstr="")
 Set option as deprecated.
CommandLineArgSetRemoved (QString remstr="", QString remver="")
 Set option as removed.
void PrintVerbose (void) const
 Internal use.

Static Public Member Functions

static void AllowOneOf (QList< CommandLineArg * > args)
 Mark a list of arguments as mutually exclusive.

Private Member Functions

QString GetKeywordString (void) const
 Return string containing all possible keyword triggers for this argument.
void SetParentOf (CommandLineArg *other, bool forward=true)
 Internal use, set argument as parent of given child.
void SetChildOf (CommandLineArg *other, bool forward=true)
 Internal use, set argument as child of given parent.
void SetRequires (CommandLineArg *other, bool forward=true)
 Internal use, set argument as requiring given option.
void SetBlocks (CommandLineArg *other, bool forward=true)
 Internal use, set argument as incompatible with given option.
void Convert (void)
 Convert stored string value from QByteArray to QString.
QString GetPreferredKeyword (void) const
 Return the longest keyword for the argument.
bool TestLinks (void) const
 Test all related arguments to make sure specified requirements are fulfilled.
void CleanupLinks (void)
 Clear out references to other arguments in preparation for deletion.
void PrintRemovedWarning (QString &keyword) const
 Internal use.
void PrintDeprecatedWarning (QString &keyword) const
 Internal use.

Private Attributes

bool m_given
bool m_converted
QString m_name
QString m_group
QString m_deprecated
QString m_removed
QString m_removedversion
QVariant::Type m_type
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

Detailed Description

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 18 of file mythcommandlineparser.h.


Constructor & Destructor Documentation

CommandLineArg::CommandLineArg ( QString  name,
QVariant::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 144 of file mythcommandlineparser.cpp.

Referenced by SetBlocks(), SetChild(), SetChildOf(), SetParent(), SetParentOf(), SetRequiredChild(), SetRequiredChildOf(), and SetRequires().

CommandLineArg::CommandLineArg ( QString  name,
QVariant::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 161 of file mythcommandlineparser.cpp.

CommandLineArg::CommandLineArg ( QString  name  ) 

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 178 of file mythcommandlineparser.cpp.

CommandLineArg::~CommandLineArg (  )  [inline]

Definition at line 25 of file mythcommandlineparser.h.


Member Function Documentation

CommandLineArg* CommandLineArg::SetGroup ( QString  group  )  [inline]
void CommandLineArg::AddKeyword ( QString  keyword  )  [inline]

Definition at line 29 of file mythcommandlineparser.h.

Referenced by MythCommandLineParser::add().

QString CommandLineArg::GetName ( void   )  const [inline]

Definition at line 31 of file mythcommandlineparser.h.

Referenced by MythCommandLineParser::Parse().

int CommandLineArg::GetKeywordLength ( void   )  const

Return length of full keyword string for use in determining indent of help text.

Definition at line 198 of file mythcommandlineparser.cpp.

QString CommandLineArg::GetHelpString ( int  off,
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 224 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 283 of file mythcommandlineparser.cpp.

bool CommandLineArg::Set ( 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 386 of file mythcommandlineparser.cpp.

Referenced by MythCommandLineParser::Parse(), and MythCommandLineParser::SetValue().

bool CommandLineArg::Set ( QString  opt,
QByteArray  val 
)

Set option as provided on command line with value.

Definition at line 419 of file mythcommandlineparser.cpp.

void CommandLineArg::Set ( QVariant  val  )  [inline]

Definition at line 39 of file mythcommandlineparser.h.

CommandLineArg * CommandLineArg::SetParent ( QString  opt  ) 

Set argument as child of given parent.

Definition at line 520 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetParent ( QStringList  opts  ) 

Set argument as child of multiple parents.

Definition at line 528 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetParentOf ( QString  opt  ) 

Set argument as parent of given child.

Definition at line 502 of file mythcommandlineparser.cpp.

Referenced by MythTVSetupCommandLineParser::LoadArguments(), and SetChildOf().

CommandLineArg * CommandLineArg::SetParentOf ( QStringList  opts  ) 

Set argument as parent of multiple children.

Definition at line 510 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetChild ( QString  opt  ) 

Set argument as parent of given child.

Definition at line 556 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetChild ( QStringList  opt  ) 

Set argument as parent of multiple children.

Definition at line 564 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetChildOf ( QString  opt  ) 
CommandLineArg * CommandLineArg::SetChildOf ( QStringList  opts  ) 

Set argument as child of multiple parents.

Definition at line 546 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetRequiredChild ( QString  opt  ) 

Set argument as parent of given child and mark as required.

Definition at line 574 of file mythcommandlineparser.cpp.

Referenced by MythAVTestCommandLineParser::LoadArguments().

CommandLineArg * CommandLineArg::SetRequiredChild ( QStringList  opt  ) 

Set argument as parent of multiple children and mark as required.

Definition at line 583 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetRequiredChildOf ( QString  opt  ) 

Set argument as child required by given parent.

Definition at line 596 of file mythcommandlineparser.cpp.

Referenced by MythUtilCommandLineParser::LoadArguments(), and MythFillDatabaseCommandLineParser::LoadArguments().

CommandLineArg * CommandLineArg::SetRequiredChildOf ( QStringList  opt  ) 

Set argument as child required by multiple parents.

Definition at line 605 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetRequires ( QString  opt  ) 
CommandLineArg * CommandLineArg::SetRequires ( QStringList  opts  ) 

Set argument as requiring multiple options.

Definition at line 626 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetBlocks ( QString  opt  ) 
CommandLineArg * CommandLineArg::SetBlocks ( QStringList  opts  ) 

Set argument as incompatible with multiple options.

Definition at line 644 of file mythcommandlineparser.cpp.

CommandLineArg * CommandLineArg::SetDeprecated ( QString  depstr = ""  ) 

Set option as deprecated.

Definition at line 654 of file mythcommandlineparser.cpp.

Referenced by MythFillDatabaseCommandLineParser::LoadArguments().

CommandLineArg * CommandLineArg::SetRemoved ( QString  remstr = "",
QString  remver = "" 
)
void CommandLineArg::AllowOneOf ( QList< CommandLineArg * >  args  )  [static]
void CommandLineArg::PrintVerbose ( void   )  const

Internal use.

Print processed input in verbose mode.

Definition at line 990 of file mythcommandlineparser.cpp.

QString CommandLineArg::GetKeywordString ( void   )  const [private]

Return string containing all possible keyword triggers for this argument.

Definition at line 188 of file mythcommandlineparser.cpp.

Referenced by GetHelpString(), and GetKeywordLength().

void CommandLineArg::SetParentOf ( CommandLineArg other,
bool  forward = true 
) [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 678 of file mythcommandlineparser.cpp.

void CommandLineArg::SetChildOf ( CommandLineArg other,
bool  forward = true 
) [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 707 of file mythcommandlineparser.cpp.

void CommandLineArg::SetRequires ( CommandLineArg other,
bool  forward = true 
) [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 736 of file mythcommandlineparser.cpp.

void CommandLineArg::SetBlocks ( CommandLineArg other,
bool  forward = true 
) [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 766 of file mythcommandlineparser.cpp.

void CommandLineArg::Convert ( void   )  [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 821 of file mythcommandlineparser.cpp.

Referenced by MythCommandLineParser::toMap(), MythCommandLineParser::toString(), and MythCommandLineParser::toStringList().

QString CommandLineArg::GetPreferredKeyword ( void   )  const [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 879 of file mythcommandlineparser.cpp.

bool CommandLineArg::TestLinks ( void   )  const [private]

Test all related arguments to make sure specified requirements are fulfilled.

Definition at line 901 of file mythcommandlineparser.cpp.

void CommandLineArg::CleanupLinks ( void   )  [private]

Clear out references to other arguments in preparation for deletion.

Definition at line 969 of file mythcommandlineparser.cpp.

void CommandLineArg::PrintRemovedWarning ( QString &  keyword  )  const [private]

Internal use.

Print warning for removed option.

Definition at line 1083 of file mythcommandlineparser.cpp.

Referenced by GetLongHelpString(), and MythCommandLineParser::Parse().

void CommandLineArg::PrintDeprecatedWarning ( QString &  keyword  )  const [private]

Internal use.

Print warning for deprecated option.

Definition at line 1099 of file mythcommandlineparser.cpp.

Referenced by GetLongHelpString(), and MythCommandLineParser::Parse().


Friends And Related Function Documentation

friend class MythCommandLineParser [friend]

Definition at line 69 of file mythcommandlineparser.h.


Member Data Documentation

QString CommandLineArg::m_name [private]

Definition at line 90 of file mythcommandlineparser.h.

Referenced by PrintVerbose(), SetBlocks(), SetChildOf(), SetParentOf(), and SetRequires().

QString CommandLineArg::m_group [private]

Definition at line 91 of file mythcommandlineparser.h.

Referenced by GetHelpString().

QString CommandLineArg::m_deprecated [private]
QString CommandLineArg::m_removed [private]

Definition at line 94 of file mythcommandlineparser.h.

Referenced by PrintRemovedWarning(), and SetRemoved().

QVariant::Type CommandLineArg::m_type [private]
QVariant CommandLineArg::m_default [private]
QVariant CommandLineArg::m_stored [private]
QStringList CommandLineArg::m_keywords [private]
QString CommandLineArg::m_usedKeyword [private]

Definition at line 100 of file mythcommandlineparser.h.

Referenced by Set(), and TestLinks().

Definition at line 105 of file mythcommandlineparser.h.

Referenced by CleanupLinks(), and SetRequiredChildOf().

Definition at line 106 of file mythcommandlineparser.h.

Referenced by CleanupLinks(), GetLongHelpString(), SetBlocks(), and TestLinks().

QString CommandLineArg::m_help [private]

Definition at line 108 of file mythcommandlineparser.h.

Referenced by GetHelpString(), and GetLongHelpString().

QString CommandLineArg::m_longhelp [private]

Definition at line 109 of file mythcommandlineparser.h.

Referenced by GetLongHelpString().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Mon May 28 06:41:57 2012 for MythTV by  doxygen 1.6.3