qBittorrent
anonymous_namespace{cmdoptions.cpp}::StringOption Struct Reference
Inheritance diagram for anonymous_namespace{cmdoptions.cpp}::StringOption:
Collaboration diagram for anonymous_namespace{cmdoptions.cpp}::StringOption:

Public Member Functions

constexpr StringOption (const char *name)
 
bool operator== (const QString &arg) const
 
QString value (const QString &arg) const
 
QString value (const QProcessEnvironment &env, const QString &defaultValue={}) const
 
QString usage (const QString &valueName) const
 

Private Member Functions

QString parameterAssignment () const
 

Additional Inherited Members

- Protected Member Functions inherited from anonymous_namespace{cmdoptions.cpp}::Option
constexpr Option (const char *name, char shortcut=0)
 
QString fullParameter () const
 
QString shortcutParameter () const
 
bool hasShortcut () const
 
QString envVarName () const
 
- Static Protected Member Functions inherited from anonymous_namespace{cmdoptions.cpp}::Option
static QString padUsageText (const QString &usage)
 

Detailed Description

Definition at line 143 of file cmdoptions.cpp.

Constructor & Destructor Documentation

◆ StringOption()

constexpr anonymous_namespace{cmdoptions.cpp}::StringOption::StringOption ( const char *  name)
inlineexplicitconstexpr

Definition at line 146 of file cmdoptions.cpp.

147  : Option {name, 0}
148  {
149  }
constexpr Option(const char *name, char shortcut=0)
Definition: cmdoptions.cpp:62

Member Function Documentation

◆ operator==()

bool anonymous_namespace{cmdoptions.cpp}::StringOption::operator== ( const QString &  arg) const
inline

Definition at line 151 of file cmdoptions.cpp.

152  {
153  return arg.startsWith(parameterAssignment());
154  }

◆ parameterAssignment()

QString anonymous_namespace{cmdoptions.cpp}::StringOption::parameterAssignment ( ) const
inlineprivate

Definition at line 178 of file cmdoptions.cpp.

179  {
180  return fullParameter() + QLatin1Char('=');
181  }

◆ usage()

QString anonymous_namespace{cmdoptions.cpp}::StringOption::usage ( const QString &  valueName) const
inline

Definition at line 172 of file cmdoptions.cpp.

173  {
174  return padUsageText(parameterAssignment() + QLatin1Char('<') + valueName + QLatin1Char('>'));
175  }
static QString padUsageText(const QString &usage)
Definition: cmdoptions.cpp:90

Referenced by makeUsage().

Here is the caller graph for this function:

◆ value() [1/2]

QString anonymous_namespace{cmdoptions.cpp}::StringOption::value ( const QProcessEnvironment &  env,
const QString &  defaultValue = {} 
) const
inline

Definition at line 166 of file cmdoptions.cpp.

166  {}) const
167  {
168  QString val = env.value(envVarName());
169  return val.isEmpty() ? defaultValue : Utils::String::unquote(val, QLatin1String("'\""));
170  }
T unquote(const T &str, const QString &quotes=QChar('"'))
Definition: string.h:45

Referenced by nova3.socks.ProxyError::__str__(), nova3.socks.GeneralProxyError::__str__(), nova3.socks.Socks5AuthError::__str__(), nova3.socks.Socks5Error::__str__(), nova3.socks.Socks4Error::__str__(), and nova3.socks.HTTPError::__str__().

Here is the caller graph for this function:

◆ value() [2/2]

QString anonymous_namespace{cmdoptions.cpp}::StringOption::value ( const QString &  arg) const
inline

Definition at line 156 of file cmdoptions.cpp.

157  {
158  QStringList parts = arg.split(QLatin1Char('='));
159  if (parts.size() == 2)
160  return Utils::String::unquote(parts[1], QLatin1String("'\""));
161  throw CommandLineParameterError(QObject::tr("Parameter '%1' must follow syntax '%1=%2'",
162  "e.g. Parameter '--webui-port' must follow syntax '--webui-port=value'")
163  .arg(fullParameter(), QLatin1String("<value>")));
164  }

References Utils::String::unquote().

Referenced by nova3.socks.ProxyError::__str__(), nova3.socks.GeneralProxyError::__str__(), nova3.socks.Socks5AuthError::__str__(), nova3.socks.Socks5Error::__str__(), nova3.socks.Socks4Error::__str__(), nova3.socks.HTTPError::__str__(), and parseCommandLine().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: