本文整理汇总了C++中QApplicationArgument::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QApplicationArgument::name方法的具体用法?C++ QApplicationArgument::name怎么用?C++ QApplicationArgument::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QApplicationArgument
的用法示例。
在下文中一共展示了QApplicationArgument::name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typeToName
virtual QString typeToName(const QApplicationArgument &argument) const
{
if(argument.name() == QLatin1String("param"))
return QLatin1String("name=value");
else if(argument.name() == QLatin1String("output"))
return QLatin1String("local file");
else
return QApplicationArgumentParser::typeToName(argument);
}
示例2: convertToValue
virtual QVariant convertToValue(const QApplicationArgument &arg,
const QString &input) const
{
if(arg.name() == QLatin1String("param"))
{
const int assign = input.indexOf(QLatin1Char('='));
if(assign == -1)
{
message(QXmlPatternistCLI::tr("Each binding must contain an equal sign."));
return QVariant();
}
const QString name(input.left(assign));
const QString value(input.mid(assign + 1));
if(!QXmlName::isNCName(name))
{
message(QXmlPatternistCLI::tr("The variable name must be a valid NCName, which %1 isn't.").arg(name));
return QVariant();
}
/* The value.isNull() check ensures we can bind variables whose value is an empty string. */
return QVariant::fromValue(Parameter(name, value.isNull() ? QString(QLatin1String("")) : value ));
}
else if(arg.name() == QLatin1String("output"))
{
QFile *const f = new QFile(input);
if(f->open(QIODevice::WriteOnly))
return QVariant::fromValue(static_cast<QIODevice *>(f));
else
{
message(QXmlPatternistCLI::tr("Failed to open file %1 for writing: %2").arg(f->fileName(), f->errorString()));
return QVariant();
}
}
else if(arg.name() == QLatin1String("initial-template"))
{
const QXmlName name(QXmlName::fromClarkName(input, m_namePool));
if(name.isNull())
{
message(QXmlPatternistCLI::tr("%1 is an invalid Clark Name").arg(input));
return QVariant();
}
else
return QVariant::fromValue(name);
}
else
return QApplicationArgumentParser::convertToValue(arg, input);
}
示例3: defaultValue
virtual QVariant defaultValue(const QApplicationArgument &argument) const
{
if(argument.name() == QLatin1String("output"))
{
QFile *const out = new QFile();
#ifdef Q_OS_WIN
/* If we don't open stdout in "binary" mode on Windows, it will translate
* 0xA into 0xD 0xA. */
_setmode(_fileno(stdout), _O_BINARY);
m_stdout = _wfdopen(_fileno(stdout), L"wb");
out->open(m_stdout, QIODevice::WriteOnly);
#else
out->open(stdout, QIODevice::WriteOnly);
#endif
return QVariant::fromValue(static_cast<QIODevice *>(out));
}
else
return QApplicationArgumentParser::defaultValue(argument);
}
示例4: qHash
/*!
\internal
\relates QApplicationArgument
Computes a hash key on \a argument's name and returns it.
*/
uint qHash(const QApplicationArgument &argument)
{
return qHash(argument.name());
}
示例5: name
/*!
Returns true if this QApplicationArgument instance is equal to \a other.
Equalness is defined to only consider name(). If for instance the type() differs
but the names are equal, this operator will return \c true.
*/
bool QApplicationArgument::operator==(const QApplicationArgument &other) const
{
return name() == other.name();
}