qBittorrent
anonymous_namespace{cmdoptions.cpp}::IntOption Class Reference
Inheritance diagram for anonymous_namespace{cmdoptions.cpp}::IntOption:
Collaboration diagram for anonymous_namespace{cmdoptions.cpp}::IntOption:

Public Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from anonymous_namespace{cmdoptions.cpp}::StringOption
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
 
- 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 190 of file cmdoptions.cpp.

Constructor & Destructor Documentation

◆ IntOption()

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

Definition at line 193 of file cmdoptions.cpp.

194  : StringOption {name}
195  {
196  }

Member Function Documentation

◆ operator==()

bool anonymous_namespace{cmdoptions.cpp}::StringOption::operator==
inline

Definition at line 151 of file cmdoptions.cpp.

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

◆ usage()

QString anonymous_namespace{cmdoptions.cpp}::StringOption::usage
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]

int anonymous_namespace{cmdoptions.cpp}::IntOption::value ( const QProcessEnvironment &  env,
int  defaultValue 
) const
inline

Definition at line 213 of file cmdoptions.cpp.

214  {
215  QString val = env.value(envVarName());
216  if (val.isEmpty()) return defaultValue;
217 
218  bool ok;
219  int res = val.toInt(&ok);
220  if (!ok)
221  {
222  qDebug() << QObject::tr("Expected integer number in environment variable '%1', but got '%2'")
223  .arg(envVarName(), val);
224  return defaultValue;
225  }
226  return res;
227  }

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]

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

Definition at line 201 of file cmdoptions.cpp.

202  {
203  QString val = StringOption::value(arg);
204  bool ok = false;
205  int res = val.toInt(&ok);
206  if (!ok)
207  throw CommandLineParameterError(QObject::tr("Parameter '%1' must follow syntax '%1=%2'",
208  "e.g. Parameter '--webui-port' must follow syntax '--webui-port=<value>'")
209  .arg(fullParameter(), QLatin1String("<integer value>")));
210  return res;
211  }
QString value(const QString &arg) const
Definition: cmdoptions.cpp:156

References anonymous_namespace{preferences.cpp}::value().

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 class was generated from the following file: