本文整理汇总了C++中KCmdLineArgs::usage方法的典型用法代码示例。如果您正苦于以下问题:C++ KCmdLineArgs::usage方法的具体用法?C++ KCmdLineArgs::usage怎么用?C++ KCmdLineArgs::usage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KCmdLineArgs
的用法示例。
在下文中一共展示了KCmdLineArgs::usage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
const char *version = "0.5";
KLocalizedString description = ki18n("Unit test for .netrc and kionetrc parser.");
KCmdLineOptions options;
options.add("+command", ki18n("[url1,url2 ,...]"));
KCmdLineArgs::init( argc, argv, "kionetrctest", 0, ki18n("KIO-netrc-test"), version, description );
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int count = args->count();
KApplication app;
if ( !count )
args->usage();
else
{
KUrl u;
for( int i=0 ; i < count; i++ )
{
u = args->arg(i);
if ( !u.isValid() )
{
kDebug() << u.url() << " is invalid! Ignoring...";
continue;
}
output( u );
}
}
args->clear();
return 0;
}
示例2: main
int main(int argc, char **argv)
{
KAboutData about("khotnewstuff", 0, ki18n("KHotNewStuff"), "0.4");
about.setProgramIconName("get-hot-new-stuff");
KCmdLineArgs *args;
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions op;
op.add("+filename", ki18n("Name of .knsrc file to use"));
op.add("+filename", ki18n("Name of file to upload"));
KCmdLineArgs::addCmdLineOptions(op);
args = KCmdLineArgs::parsedArgs();
KApplication i;
if (args->count() > 0) {
KNS3::UploadDialog dialog(args->arg(0));
if (args->count() > 1) {
dialog.setUploadFile(KUrl(args->arg(1)));
}
dialog.exec();
}
else
{
args->usage();
return -1;
}
return 0;
}
示例3: inst
int
main(int argc, char *argv[])
{
KCmdLineArgs::init(argc, argv, "krootimage", "kdmgreet",
ki18n("KRootImage"), QByteArray(),
ki18n("Fancy desktop background for kdm"));
KCmdLineOptions options;
options.add("+config", ki18n("Name of the configuration file"));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (!args->count())
args->usage();
KComponentData inst(KCmdLineArgs::aboutData());
MyApplication app(args->arg(0).toLocal8Bit(),
KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv());
args->clear();
app.exec();
app.flush();
// Keep color resources after termination
XSetCloseDownMode(QX11Info::display(), RetainTemporary);
return 0;
}
示例4: main
int main(int argc, char **argv)
{
KAboutData about(QByteArray("microbe"), QByteArray("languages"), ki18n("Microbe"),
QByteArray(version), ki18n(description),
KAboutData::License_GPL, ki18n("(C) 2004-2005, The KTechLab developers"),
KLocalizedString(), QByteArray("http://ktechlab.org"),
QByteArray("[email protected]") );
about.addAuthor( ki18n("Daniel Clarke"), KLocalizedString(),
QByteArray("[email protected]") );
about.addAuthor( ki18n("David Saxton"), KLocalizedString(),
QByteArray("[email protected]") );
about.addAuthor( ki18n("Modified to add pic 16f877,16f627 and 16f628 by George John"),
KLocalizedString(), QByteArray("[email protected]") );
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions o;
o.add( QByteArray("show-source"),
ki18n( "Show source code lines in assembly output") );
o.add( QByteArray("nooptimize"),
ki18n( "Do not attempt optimization of generated instructions.") );
o.add( QByteArray("+[Input URL]"),
ki18n( "Input filename" ) );
o.add( QByteArray("+[Output URL]"),
ki18n( "Output filename" ) );
KCmdLineArgs::addCmdLineOptions(o);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() == 2 )
{
Microbe mb;
// QString s = mb.compile( args->arg(0), args->isSet("show-source"), args->isSet("optimize"));
QString s = mb.compile( args->arg(0), args->isSet("optimize"));
QString errorReport = mb.errorReport();
if ( !errorReport.isEmpty() )
{
kError() << errorReport;
return 1; // If there was an error, don't write the output to file.
}
else
{
QFile outFile(args->arg(1));
outFile.open(QIODevice::WriteOnly);
QDataStream out(&outFile);
out << s;
return 0;
}
}
else args->usage();
}
示例5: main
int main( int argc, char **argv )
{
KAboutData aboutData( "testvcalexport", 0,
ki18n( "Part of LibKCal's test suite. Checks if export "
"to vCalendar still works correctly." ), "0.1" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add( "verbose", ki18n( "Verbose output" ) );
options.add( "+input", ki18n( "Name of input file" ) );
options.add( "+output", ki18n( "Name of output file" ) );
KCmdLineArgs::addCmdLineOptions( options );
KComponentData componentData( &aboutData );
//QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() != 2 ) {
args->usage( "Wrong number of arguments." );
}
QString input = args->arg( 0 );
QString output = args->arg( 1 );
QFileInfo outputFileInfo( output );
output = outputFileInfo.absoluteFilePath();
kDebug() << "Input file:" << input;
kDebug() << "Output file:" << output;
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
FileStorage instore( cal, input );
if ( !instore.load() ) {
return 1;
}
QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
if ( !tz.isEmpty() ) {
cal->setViewTimeZoneId( tz );
}
FileStorage outstore( cal, output, new VCalFormat );
if ( !outstore.save() ) {
return 1;
}
return 0;
}
示例6: main
int main(int argc, char **argv)
{
KAboutData data("kwebdesktop", I18N_NOOP("KDE Web Desktop"), VERSION, I18N_NOOP("Displays an HTML page as the background of the desktop"),
KAboutData::License_GPL, "(c) 2000, David Faure <[email protected]>");
data.addAuthor("David Faure", I18N_NOOP("developer and maintainer"), "[email protected]");
KCmdLineArgs::init(argc, argv, &data);
KCmdLineArgs::addCmdLineOptions(options); // Add our own options.
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(args->count() != 3 && args->count() != 4)
{
args->usage();
return 1;
}
const int width = QCString(args->arg(0)).toInt();
const int height = QCString(args->arg(1)).toInt();
QCString imageFile = args->arg(2);
QString url;
if(args->count() == 4)
url = QString::fromLocal8Bit(args->arg(3));
KWebDesktop *webDesktop = new KWebDesktop(0, imageFile, width, height);
if(url.isEmpty())
url = KWebDesktopSettings::uRL();
// Apply uri filter
KURIFilterData uridata = url;
KURIFilter::self()->filterURI(uridata);
KURL u = uridata.uri();
// Now start getting, to ensure mimetype and possible connection
KWebDesktopRun *run = new KWebDesktopRun(webDesktop, u);
int ret = app.exec();
KIO::SimpleJob::removeOnHold(); // Kill any slave that was put on hold.
delete webDesktop;
delete run;
// khtml::Cache::clear();
return ret;
}
示例7: main
int main(int argc, char **argv)
{
new KInstance("makekdewidgets");
KAboutData about("makekdewidgets", I18N_NOOP("makekdewidgets"), version, description, KAboutData::License_GPL,
"(C) 2004-2005 ian reinhart geiser", 0, 0, "[email protected]");
about.addAuthor("ian reinhart geiser", 0, "[email protected]");
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(args->count() < 1)
{
args->usage();
return (1);
}
QFileInfo fi(args->arg(args->count() - 1));
QString outputFile = args->getOption("o");
QString pluginName = args->getOption("n");
QString group = args->getOption("g");
QString iconPath = "";
if(args->isSet("p"))
iconPath = args->getOption("p");
QString fileName = fi.absFilePath();
if(args->isSet("o"))
{
QFile output(outputFile);
if(output.open(IO_WriteOnly))
{
QTextStream ts(&output);
buildFile(ts, group, fileName, pluginName, iconPath);
}
output.close();
}
else
{
QTextStream ts(stdout, IO_WriteOnly);
buildFile(ts, group, fileName, pluginName, iconPath);
}
}
示例8: app
int
main( int argc, char *argv[] )
{
KApplication::disableAutoDcopRegistration();
KLocale::setMainCatalogue( "kdesktop" );
KCmdLineArgs::init( argc, argv, "krootimage", I18N_NOOP( "KRootImage" ), description, version );
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (!args->count())
args->usage();
MyApplication app( args->arg( 0 ) );
args->clear();
app.exec();
app.flushX();
// Keep color resources after termination
XSetCloseDownMode( qt_xdisplay(), RetainTemporary );
return 0;
}
示例9: main
int main( int argc, char **argv )
{
KAboutData aboutData(
"testrecurson", 0,
ki18n( "Tests all dates from 2002 to 2010 to test if the event recurs on each individual date. "
"This is meant to test the Recurrence::recursOn method for errors." ), "0.1" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add( "verbose", ki18n( "Verbose output" ) );
options.add( "+input", ki18n( "Name of input file" ) );
options.add( "[+output]", ki18n( "optional name of output file for the recurrence dates" ) );
KCmdLineArgs::addCmdLineOptions( options );
KComponentData componentData( &aboutData );
//QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() < 1 ) {
args->usage( "Wrong number of arguments." );
}
QString input = args->arg( 0 );
// kDebug() << "Input file:" << input;
QTextStream *outstream;
outstream = 0;
QString fn( "" );
if ( args->count() > 1 ) {
fn = args->arg( 1 );
// kDebug() << "We have a file name given:" << fn;
}
QFile outfile( fn );
if ( !fn.isEmpty() && outfile.open( QIODevice::WriteOnly ) ) {
// kDebug() << "Opened output file!!!";
outstream = new QTextStream( &outfile );
}
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
FileStorage store( cal, input );
if ( !store.load() ) return 1;
QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
if ( !tz.isEmpty() ) {
cal->setViewTimeZoneId( tz );
}
Incidence::List inc = cal->incidences();
for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
Incidence::Ptr incidence = *it;
// kDebug() << " ->" << incidence->summary() << "<-";
// incidence->recurrence()->dump();
QDate dt( 1996, 7, 1 );
if ( outstream ) {
// Output to file for testing purposes
int nr = 0;
while ( dt.year() <= 2020 && nr<=500 ) {
if ( incidence->recursOn( dt, cal->viewTimeSpec() ) ) {
(*outstream) << dt.toString( Qt::ISODate ) << endl;
nr++;
}
dt = dt.addDays( 1 );
}
} else {
dt = QDate( 2005, 1, 1 );
while ( dt.year() < 2007 ) {
if ( incidence->recursOn( dt, cal->viewTimeSpec() ) ) {
kDebug() << dt.toString( Qt::ISODate );
}
dt = dt.addDays( 1 );
}
}
}
delete outstream;
outfile.close();
return 0;
}
示例10: main
int main(int argc, char *argv[])
{
KCmdLineOptions options;
options.add("c <digest>", ki18n("compare <digest> with the calculated digest for a string or file."));
options.add("d", ki18n("decode the given string or file using base64"));
options.add("e", ki18n("encode the given string or file using base64"));
options.add("f", ki18n("the filename to be used as input"), "default");
options.add("p", ki18n("encode the given string or file using quoted-printable"));
options.add("q", ki18n("decode the given string or file using quoted-printable"));
options.add("r", ki18n("calculate the raw md5 for the given string or file"));
options.add("s", ki18n("the string to be used as input"));
options.add("t", ki18n("perform a timed message-digest test"));
options.add("u", ki18n("uuencode the given string or file"));
options.add("x", ki18n("uudecode the given string or file"));
options.add("z", ki18n("run a preset message-digest test"));
options.add("+command", ki18n("[input1, input2,...]"));
KCmdLineArgs::init(argc, argv, "kmdcodectest", 0,
ki18n("KMDCodecTest"), "1.0",
ki18n("Unit test for md5, base64 encode/decode "
"and uuencode/decode facilities"));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int count = args->count();
//QCoreApplication app;
if (!count) {
if (args->isSet("t")) {
MD5_timeTrial();
} else if (args->isSet("z")) {
MD5_testSuite();
} else {
args->usage();
}
} else {
bool isVerify = args->isSet("c");
bool isString = args->isSet("s");
bool isFile = args->isSet("f");
Codec type = Unspecified;
if (args->isSet("d")) {
type = Base64Decode;
} else if (args->isSet("e")) {
type = Base64Encode;
} else if (args->isSet("u")) {
type = UUEncode;
} else if (args->isSet("x")) {
type = UUDecode;
} else if (args->isSet("p")) {
type = QPEncode;
} else if (args->isSet("q")) {
type = QPDecode;
}
if (isVerify) {
const char *opt = args->getOption("c").toLocal8Bit().data();
for (int i = 0; i < count; i++) {
MD5_verify(args->arg(i).toLocal8Bit().constData(), opt, (isString || !isFile));
}
} else {
for (int i = 0; i < count; i++) {
if (type != Unspecified) {
testCodec(args->arg(i).toLocal8Bit().constData(), type, isFile);
} else {
if (isString) {
MD5_string(args->arg(i).toLocal8Bit().constData(), 0, args->isSet("r"));
} else {
MD5_file(args->arg(i).toLocal8Bit().constData(), args->isSet("r"));
}
}
}
}
}
args->clear();
return (0);
}
示例11: main
int main( int argc, char **argv )
{
KAboutData aboutData(
"testrecurrencenew", 0,
ki18n( "Load recurrence rules with the new class and print out debug messages" ), "0.1" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add( "verbose", ki18n( "Verbose output" ) );
options.add( "+input", ki18n( "Name of input file" ) );
options.add( "[+output]", ki18n( "optional name of output file for the recurrence dates" ) );
KCmdLineArgs::addCmdLineOptions( options );
KComponentData componentData( &aboutData );
//QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() < 1 ) {
args->usage( "Wrong number of arguments." );
}
QString input = args->arg( 0 );
kDebug() << "Input file:" << input;
QTextStream *outstream;
outstream = 0;
QString fn( "" );
if ( args->count() > 1 ) {
fn = args->arg( 1 );
kDebug() << "We have a file name given:" << fn;
}
QFile outfile( fn );
if ( !fn.isEmpty() && outfile.open( QIODevice::WriteOnly ) ) {
kDebug() << "Opened output file!!!";
outstream = new QTextStream( &outfile );
}
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
KDateTime::Spec viewSpec;
FileStorage store( cal, input );
if ( !store.load() ) return 1;
QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
if ( !tz.isEmpty() ) {
viewSpec = KDateTime::Spec( KSystemTimeZones::zone( tz ) );
}
Incidence::List inc = cal->incidences();
for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
Incidence::Ptr incidence = *it;
kDebug() << "*+*+*+*+*+*+*+*+*+*";
kDebug() << " ->" << incidence->summary() << "<-";
incidence->recurrence()->dump();
KDateTime dt( incidence->recurrence()->endDateTime() );
int i = 0;
if ( outstream ) {
if ( !dt.isValid() ) {
if ( viewSpec.isValid() ) {
dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ), viewSpec );
} else {
dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ) );
}
} else {
dt = dt.addYears( 2 );
}
kDebug() << "-------------------------------------------";
kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
// Output to file for testing purposes
while ( dt.isValid() && i < 500 ) {
++i;
dt = incidence->recurrence()->getPreviousDateTime( dt );
if ( dt.isValid() ) {
(*outstream) << dumpTime( dt, viewSpec ) << endl;
}
}
} else {
if ( !dt.isValid() ) {
dt = KDateTime( QDate( 2005, 7, 31 ), QTime( 23, 59, 59 ), KDateTime::Spec::UTC() );
} else {
dt = dt.addYears( 2 );
}
incidence->recurrence()->dump();
kDebug() << "-------------------------------------------";
kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
// Output to konsole
while ( dt.isValid() && i < 50 ) {
++i;
kDebug() << "-------------------------------------------";
dt = incidence->recurrence()->getPreviousDateTime( dt );
if ( dt.isValid() ) {
kDebug() << " *~*~*~*~ Previous date is:" << dumpTime( dt, viewSpec );
}
}
}
}
//.........这里部分代码省略.........
示例12: main
int main(int argc, char **argv)
{
KAboutData aboutData("testrecurrencenew", "Load recurrence rules with the new class and print out debug messages", "0.1");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addCmdLineOptions(options);
KApplication app(false, false);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(args->count() < 1)
{
args->usage("Wrong number of arguments.");
}
// use zoneinfo data from source dir
set_zone_directory(KDETOPSRCDIR "/libkcal/libical/zoneinfo");
QString input = QFile::decodeName(args->arg(0));
kdDebug(5800) << "Input file: " << input << endl;
QTextStream *outstream;
outstream = 0;
QString fn("");
if(args->count() > 1)
{
fn = args->arg(1);
kdDebug() << "We have a file name given: " << fn << endl;
}
QFile outfile(fn);
if(!fn.isEmpty() && outfile.open(IO_WriteOnly))
{
kdDebug() << "Opened output file!!!" << endl;
outstream = new QTextStream(&outfile);
}
CalendarLocal cal(QString::fromLatin1("UTC"));
if(!cal.load(input)) return 1;
QString tz = cal.nonKDECustomProperty("X-LibKCal-Testsuite-OutTZ");
if(!tz.isEmpty())
{
cal.setTimeZoneIdViewOnly(tz);
}
Incidence::List inc = cal.incidences();
for(Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it)
{
Incidence *incidence = *it;
kdDebug(5800) << "*+*+*+*+*+*+*+*+*+*" << endl;
kdDebug(5800) << " -> " << incidence->summary() << " <- " << endl;
incidence->recurrence()->dump();
QDateTime dt(incidence->recurrence()->endDateTime());
int i = 0;
if(outstream)
{
if(!dt.isValid()) dt = QDateTime(QDate(2011, 1, 1), QTime(0, 0, 1));
else dt = dt.addYears(2);
kdDebug(5800) << "-------------------------------------------" << endl;
kdDebug(5800) << " *~*~*~*~ Starting with date: " << dt << endl;
// Output to file for testing purposes
while(dt.isValid() && i < 500)
{
dt = dt.addSecs(-1);
++i;
dt = incidence->recurrence()->getPreviousDateTime(dt);
(*outstream) << dt.toString(Qt::ISODate) << endl;
}
}
else
{
if(!dt.isValid()) dt = QDateTime(QDate(2005, 7, 31), QTime(23, 59, 59));
else dt = dt.addYears(2);
incidence->recurrence()->dump();
kdDebug(5800) << "-------------------------------------------" << endl;
kdDebug(5800) << " *~*~*~*~ Starting with date: " << dt << endl;
// Output to konsole
while(dt.isValid() && i < 50)
{
dt = dt.addSecs(-1);
++i;
kdDebug(5800) << "-------------------------------------------" << endl;
dt = incidence->recurrence()->getPreviousDateTime(dt);
kdDebug(5800) << " *~*~*~*~ Previous date is: " << dt << endl;
}
}
}
delete outstream;
outfile.close();
return 0;
}