本文整理汇总了C++中QApplicationArgument类的典型用法代码示例。如果您正苦于以下问题:C++ QApplicationArgument类的具体用法?C++ QApplicationArgument怎么用?C++ QApplicationArgument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QApplicationArgument类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: main
int main(int argc, char **argv)
{
enum ExitCode
{
/**
* We start from 2, because QApplicationArgumentParser
* uses 1.
*/
QueryFailure = 2,
StdOutFailure
};
const QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName(QLatin1String("xmlpatterns"));
QXmlNamePool namePool;
PatternistApplicationParser parser(argc, argv, namePool);
parser.setApplicationDescription(QLatin1String("A tool for running XQuery queries."));
parser.setApplicationVersion(QLatin1String("0.1"));
QApplicationArgument param(QLatin1String("param"),
QXmlPatternistCLI::tr("Binds an external variable. The value is directly available using the variable reference: $name."),
qMetaTypeId<Parameter>());
param.setMaximumOccurrence(-1);
parser.addArgument(param);
const QApplicationArgument noformat(QLatin1String("no-format"),
QXmlPatternistCLI::tr("By default output is formatted for readability. When specified, strict serialization is performed."));
parser.addArgument(noformat);
const QApplicationArgument isURI(QLatin1String("is-uri"),
QXmlPatternistCLI::tr("If specified, all filenames on the command line are interpreted as URIs instead of a local filenames."));
parser.addArgument(isURI);
const QApplicationArgument initialTemplateName(QLatin1String("initial-template"),
QXmlPatternistCLI::tr("The name of the initial template to call as a Clark Name."),
QVariant::String);
parser.addArgument(initialTemplateName);
/* The temporary object is required to compile with g++ 3.3. */
QApplicationArgument queryURI = QApplicationArgument(QLatin1String("query/stylesheet"),
QXmlPatternistCLI::tr("A local filename pointing to the query to run. If the name ends with .xsl it's assumed "
"to be an XSL-T stylesheet. If it ends with .xq, it's assumed to be an XQuery query. (In "
"other cases it's also assumed to be an XQuery query, but that interpretation may "
"change in a future release of Qt.)"),
QVariant::String);
queryURI.setMinimumOccurrence(1);
queryURI.setNameless(true);
parser.addArgument(queryURI);
QApplicationArgument focus = QApplicationArgument(QLatin1String("focus"),
QXmlPatternistCLI::tr("The document to use as focus. Mandatory "
"in case a stylesheet is used. This option is "
"also affected by the is-uris option."),
QVariant::String);
focus.setMinimumOccurrence(0);
focus.setNameless(true);
parser.addArgument(focus);
QApplicationArgument output(QLatin1String("output"),
QXmlPatternistCLI::tr("A local file to which the output should be written. "
"The file is overwritten, or if not exist, created. "
"If absent, stdout is used."),
qMetaTypeId<QIODevice *>());
parser.addArgument(output);
if(!parser.parse())
return parser.exitCode();
/* Get the query URI. */
const QUrl effectiveURI(finalizeURI(parser, isURI, queryURI));
QXmlQuery::QueryLanguage lang;
if(effectiveURI.toString().endsWith(QLatin1String(".xsl")))
lang = QXmlQuery::XSLT20;
else
lang = QXmlQuery::XQuery10;
if(lang == QXmlQuery::XQuery10 && parser.has(initialTemplateName))
{
parser.message(QXmlPatternistCLI::tr("An initial template name cannot be specified when running an XQuery."));
return QApplicationArgumentParser::ParseError;
}
QXmlQuery query(lang, namePool);
query.setInitialTemplateName(qVariantValue<QXmlName>(parser.value(initialTemplateName)));
/* Bind external variables. */
{
const QVariantList parameters(parser.values(param));
const int len = parameters.count();
/* For tracking duplicates. */
QSet<QString> usedParameters;
for(int i = 0; i < len; ++i)
{
const Parameter p(qVariantValue<Parameter>(parameters.at(i)));
//.........这里部分代码省略.........
示例3: 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();
}