|
|
@ -71,7 +71,7 @@
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
template class TQAsciiDict<TQCString>;
|
|
|
|
template class TQAsciiDict<TQCString>;
|
|
|
|
template class TQPtrList<KCmdLineArgs>;
|
|
|
|
template class TQPtrList<TDECmdLineArgs>;
|
|
|
|
|
|
|
|
|
|
|
|
class KCmdLineParsedOptions : public TQAsciiDict<TQCString>
|
|
|
|
class KCmdLineParsedOptions : public TQAsciiDict<TQCString>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -121,27 +121,27 @@ public:
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class KCmdLineArgsList: public TQPtrList<KCmdLineArgs>
|
|
|
|
class TDECmdLineArgsList: public TQPtrList<TDECmdLineArgs>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
KCmdLineArgsList() { }
|
|
|
|
TDECmdLineArgsList() { }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgsList *KCmdLineArgs::argsList = 0;
|
|
|
|
TDECmdLineArgsList *TDECmdLineArgs::argsList = 0;
|
|
|
|
int KCmdLineArgs::argc = 0;
|
|
|
|
int TDECmdLineArgs::argc = 0;
|
|
|
|
char **KCmdLineArgs::argv = 0;
|
|
|
|
char **TDECmdLineArgs::argv = 0;
|
|
|
|
char *KCmdLineArgs::mCwd = 0;
|
|
|
|
char *TDECmdLineArgs::mCwd = 0;
|
|
|
|
//static KStaticDeleter <char> mCwdd;
|
|
|
|
//static KStaticDeleter <char> mCwdd;
|
|
|
|
const KAboutData *KCmdLineArgs::about = 0;
|
|
|
|
const KAboutData *TDECmdLineArgs::about = 0;
|
|
|
|
bool KCmdLineArgs::parsed = false;
|
|
|
|
bool TDECmdLineArgs::parsed = false;
|
|
|
|
bool KCmdLineArgs::ignoreUnknown = false;
|
|
|
|
bool TDECmdLineArgs::ignoreUnknown = false;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Static functions
|
|
|
|
// Static functions
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::init(int _argc, char **_argv, const char *_appname, const char* programName,
|
|
|
|
TDECmdLineArgs::init(int _argc, char **_argv, const char *_appname, const char* programName,
|
|
|
|
const char *_description, const char *_version, bool noKApp)
|
|
|
|
const char *_description, const char *_version, bool noKApp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
init(_argc, _argv,
|
|
|
|
init(_argc, _argv,
|
|
|
@ -150,7 +150,7 @@ KCmdLineArgs::init(int _argc, char **_argv, const char *_appname, const char* pr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::init(int _argc, char **_argv, const char *_appname,
|
|
|
|
TDECmdLineArgs::init(int _argc, char **_argv, const char *_appname,
|
|
|
|
const char *_description, const char *_version, bool noKApp)
|
|
|
|
const char *_description, const char *_version, bool noKApp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
init(_argc, _argv,
|
|
|
|
init(_argc, _argv,
|
|
|
@ -159,7 +159,7 @@ KCmdLineArgs::init(int _argc, char **_argv, const char *_appname,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::initIgnore(int _argc, char **_argv, const char *_appname )
|
|
|
|
TDECmdLineArgs::initIgnore(int _argc, char **_argv, const char *_appname )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
init(_argc, _argv,
|
|
|
|
init(_argc, _argv,
|
|
|
|
new KAboutData(_appname, _appname, "unknown", "TDE Application", false));
|
|
|
|
new KAboutData(_appname, _appname, "unknown", "TDE Application", false));
|
|
|
@ -167,7 +167,7 @@ KCmdLineArgs::initIgnore(int _argc, char **_argv, const char *_appname )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::init(const KAboutData* ab)
|
|
|
|
TDECmdLineArgs::init(const KAboutData* ab)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char **_argv = (char **) malloc(sizeof(char *));
|
|
|
|
char **_argv = (char **) malloc(sizeof(char *));
|
|
|
|
_argv[0] = (char *) ab->appName();
|
|
|
|
_argv[0] = (char *) ab->appName();
|
|
|
@ -176,14 +176,14 @@ KCmdLineArgs::init(const KAboutData* ab)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::init(int _argc, char **_argv, const KAboutData *_about, bool /*noKApp*/)
|
|
|
|
TDECmdLineArgs::init(int _argc, char **_argv, const KAboutData *_about, bool /*noKApp*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
argc = _argc;
|
|
|
|
argc = _argc;
|
|
|
|
argv = _argv;
|
|
|
|
argv = _argv;
|
|
|
|
|
|
|
|
|
|
|
|
if (!argv)
|
|
|
|
if (!argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "\n\nFAILURE (TDECmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "Passing null-pointer to 'argv' is not allowed.\n\n");
|
|
|
|
fprintf(stderr, "Passing null-pointer to 'argv' is not allowed.\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
assert( 0 );
|
|
|
|
assert( 0 );
|
|
|
@ -208,30 +208,30 @@ KCmdLineArgs::init(int _argc, char **_argv, const KAboutData *_about, bool /*noK
|
|
|
|
// KApplication::addCmdLineOptions();
|
|
|
|
// KApplication::addCmdLineOptions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString KCmdLineArgs::cwd()
|
|
|
|
TQString TDECmdLineArgs::cwd()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return TQFile::decodeName(TQCString(mCwd));
|
|
|
|
return TQFile::decodeName(TQCString(mCwd));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char * KCmdLineArgs::appName()
|
|
|
|
const char * TDECmdLineArgs::appName()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!argc) return 0;
|
|
|
|
if (!argc) return 0;
|
|
|
|
return argv[0];
|
|
|
|
return argv[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::addCmdLineOptions( const KCmdLineOptions *options, const char *name,
|
|
|
|
TDECmdLineArgs::addCmdLineOptions( const KCmdLineOptions *options, const char *name,
|
|
|
|
const char *id, const char *afterId)
|
|
|
|
const char *id, const char *afterId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!argsList)
|
|
|
|
if (!argsList)
|
|
|
|
argsList = new KCmdLineArgsList();
|
|
|
|
argsList = new TDECmdLineArgsList();
|
|
|
|
|
|
|
|
|
|
|
|
int pos = argsList->count();
|
|
|
|
int pos = argsList->count();
|
|
|
|
|
|
|
|
|
|
|
|
if (pos && id && argsList->last() && !argsList->last()->name)
|
|
|
|
if (pos && id && argsList->last() && !argsList->last()->name)
|
|
|
|
pos--;
|
|
|
|
pos--;
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *args;
|
|
|
|
TDECmdLineArgs *args;
|
|
|
|
int i = 0;
|
|
|
|
int i = 0;
|
|
|
|
for(args = argsList->first(); args; args = argsList->next(), i++)
|
|
|
|
for(args = argsList->first(); args; args = argsList->next(), i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -247,12 +247,12 @@ KCmdLineArgs::addCmdLineOptions( const KCmdLineOptions *options, const char *nam
|
|
|
|
|
|
|
|
|
|
|
|
assert( parsed == false ); // You must add _ALL_ cmd line options
|
|
|
|
assert( parsed == false ); // You must add _ALL_ cmd line options
|
|
|
|
// before accessing the arguments!
|
|
|
|
// before accessing the arguments!
|
|
|
|
args = new KCmdLineArgs(options, name, id);
|
|
|
|
args = new TDECmdLineArgs(options, name, id);
|
|
|
|
argsList->insert(pos, args);
|
|
|
|
argsList->insert(pos, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::saveAppArgs( TQDataStream &ds)
|
|
|
|
TDECmdLineArgs::saveAppArgs( TQDataStream &ds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!parsed)
|
|
|
|
if (!parsed)
|
|
|
|
parseAllArgs();
|
|
|
|
parseAllArgs();
|
|
|
@ -269,7 +269,7 @@ KCmdLineArgs::saveAppArgs( TQDataStream &ds)
|
|
|
|
|
|
|
|
|
|
|
|
if (!count) return;
|
|
|
|
if (!count) return;
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *args;
|
|
|
|
TDECmdLineArgs *args;
|
|
|
|
for(args = argsList->first(); args; args = argsList->next())
|
|
|
|
for(args = argsList->first(); args; args = argsList->next())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ds << TQCString(args->id);
|
|
|
|
ds << TQCString(args->id);
|
|
|
@ -278,13 +278,13 @@ KCmdLineArgs::saveAppArgs( TQDataStream &ds)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::loadAppArgs( TQDataStream &ds)
|
|
|
|
TDECmdLineArgs::loadAppArgs( TQDataStream &ds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Remove TQt and KDE options.
|
|
|
|
// Remove TQt and KDE options.
|
|
|
|
removeArgs("qt");
|
|
|
|
removeArgs("qt");
|
|
|
|
removeArgs("kde");
|
|
|
|
removeArgs("kde");
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *args;
|
|
|
|
TDECmdLineArgs *args;
|
|
|
|
if ( argsList ) {
|
|
|
|
if ( argsList ) {
|
|
|
|
for(args = argsList->first(); args; args = argsList->next())
|
|
|
|
for(args = argsList->first(); args; args = argsList->next())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -322,9 +322,9 @@ KCmdLineArgs::loadAppArgs( TQDataStream &ds)
|
|
|
|
parsed = true;
|
|
|
|
parsed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *KCmdLineArgs::parsedArgs(const char *id)
|
|
|
|
TDECmdLineArgs *TDECmdLineArgs::parsedArgs(const char *id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KCmdLineArgs *args = argsList ? argsList->first() : 0;
|
|
|
|
TDECmdLineArgs *args = argsList ? argsList->first() : 0;
|
|
|
|
while(args)
|
|
|
|
while(args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((id && ::qstrcmp(args->id, id) == 0) || (!id && !args->id))
|
|
|
|
if ((id && ::qstrcmp(args->id, id) == 0) || (!id && !args->id))
|
|
|
@ -339,9 +339,9 @@ KCmdLineArgs *KCmdLineArgs::parsedArgs(const char *id)
|
|
|
|
return args;
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KCmdLineArgs::removeArgs(const char *id)
|
|
|
|
void TDECmdLineArgs::removeArgs(const char *id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KCmdLineArgs *args = argsList ? argsList->first() : 0;
|
|
|
|
TDECmdLineArgs *args = argsList ? argsList->first() : 0;
|
|
|
|
while(args)
|
|
|
|
while(args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (args->id && id && ::qstrcmp(args->id, id) == 0)
|
|
|
|
if (args->id && id && ::qstrcmp(args->id, id) == 0)
|
|
|
@ -443,9 +443,9 @@ findOption(const KCmdLineOptions *options, TQCString &opt,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::findOption(const char *_opt, TQCString opt, int &i, bool _enabled, bool &moreOptions)
|
|
|
|
TDECmdLineArgs::findOption(const char *_opt, TQCString opt, int &i, bool _enabled, bool &moreOptions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KCmdLineArgs *args = argsList->first();
|
|
|
|
TDECmdLineArgs *args = argsList->first();
|
|
|
|
const char *opt_name;
|
|
|
|
const char *opt_name;
|
|
|
|
const char *def;
|
|
|
|
const char *def;
|
|
|
|
TQCString argument;
|
|
|
|
TQCString argument;
|
|
|
@ -555,7 +555,7 @@ KCmdLineArgs::findOption(const char *_opt, TQCString opt, int &i, bool _enabled,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::printQ(const TQString &msg)
|
|
|
|
TDECmdLineArgs::printQ(const TQString &msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
# if [[[TQT_VERSION IS DEPRECATED]]]<0x040000
|
|
|
|
# if [[[TQT_VERSION IS DEPRECATED]]]<0x040000
|
|
|
|
TQCString localMsg = msg.local8Bit();
|
|
|
|
TQCString localMsg = msg.local8Bit();
|
|
|
@ -566,12 +566,12 @@ KCmdLineArgs::printQ(const TQString &msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::parseAllArgs()
|
|
|
|
TDECmdLineArgs::parseAllArgs()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool allowArgs = false;
|
|
|
|
bool allowArgs = false;
|
|
|
|
bool inOptions = true;
|
|
|
|
bool inOptions = true;
|
|
|
|
bool everythingAfterArgIsArgs = false;
|
|
|
|
bool everythingAfterArgIsArgs = false;
|
|
|
|
KCmdLineArgs *appOptions = argsList->last();
|
|
|
|
TDECmdLineArgs *appOptions = argsList->last();
|
|
|
|
if (!appOptions->id)
|
|
|
|
if (!appOptions->id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const KCmdLineOptions *option = appOptions->options;
|
|
|
|
const KCmdLineOptions *option = appOptions->options;
|
|
|
@ -690,7 +690,7 @@ KCmdLineArgs::parseAllArgs()
|
|
|
|
* Return argc
|
|
|
|
* Return argc
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int *
|
|
|
|
int *
|
|
|
|
KCmdLineArgs::tqt_argc()
|
|
|
|
TDECmdLineArgs::tqt_argc()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if (!argsList)
|
|
|
|
// if (!argsList)
|
|
|
|
// KApplication::addCmdLineOptions(); // Lazy bastards!
|
|
|
|
// KApplication::addCmdLineOptions(); // Lazy bastards!
|
|
|
@ -699,12 +699,12 @@ KCmdLineArgs::tqt_argc()
|
|
|
|
if( tqt_argc != -1 )
|
|
|
|
if( tqt_argc != -1 )
|
|
|
|
return &tqt_argc;
|
|
|
|
return &tqt_argc;
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *args = parsedArgs("qt");
|
|
|
|
TDECmdLineArgs *args = parsedArgs("qt");
|
|
|
|
assert(args); // No qt options have been added!
|
|
|
|
assert(args); // No qt options have been added!
|
|
|
|
if (!argv)
|
|
|
|
if (!argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "\n\nFAILURE (TDECmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "Application has not called KCmdLineArgs::init(...).\n\n");
|
|
|
|
fprintf(stderr, "Application has not called TDECmdLineArgs::init(...).\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
assert( 0 );
|
|
|
|
assert( 0 );
|
|
|
|
exit(255);
|
|
|
|
exit(255);
|
|
|
@ -721,7 +721,7 @@ KCmdLineArgs::tqt_argc()
|
|
|
|
* Return argv
|
|
|
|
* Return argv
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
char ***
|
|
|
|
char ***
|
|
|
|
KCmdLineArgs::tqt_argv()
|
|
|
|
TDECmdLineArgs::tqt_argv()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if (!argsList)
|
|
|
|
// if (!argsList)
|
|
|
|
// KApplication::addCmdLineOptions(); // Lazy bastards!
|
|
|
|
// KApplication::addCmdLineOptions(); // Lazy bastards!
|
|
|
@ -730,12 +730,12 @@ KCmdLineArgs::tqt_argv()
|
|
|
|
if( tqt_argv != NULL )
|
|
|
|
if( tqt_argv != NULL )
|
|
|
|
return &tqt_argv;
|
|
|
|
return &tqt_argv;
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *args = parsedArgs("qt");
|
|
|
|
TDECmdLineArgs *args = parsedArgs("qt");
|
|
|
|
assert(args); // No qt options have been added!
|
|
|
|
assert(args); // No qt options have been added!
|
|
|
|
if (!argv)
|
|
|
|
if (!argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "\n\nFAILURE (TDECmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "Application has not called KCmdLineArgs::init(...).\n\n");
|
|
|
|
fprintf(stderr, "Application has not called TDECmdLineArgs::init(...).\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
assert( 0 );
|
|
|
|
assert( 0 );
|
|
|
|
exit(255);
|
|
|
|
exit(255);
|
|
|
@ -754,7 +754,7 @@ KCmdLineArgs::tqt_argv()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::enable_i18n()
|
|
|
|
TDECmdLineArgs::enable_i18n()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// called twice or too late
|
|
|
|
// called twice or too late
|
|
|
|
/* if (KGlobal::_locale)
|
|
|
|
/* if (KGlobal::_locale)
|
|
|
@ -768,7 +768,7 @@ KCmdLineArgs::enable_i18n()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::usage(const TQString &error)
|
|
|
|
TDECmdLineArgs::usage(const TQString &error)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// assert(KGlobal::_locale);
|
|
|
|
// assert(KGlobal::_locale);
|
|
|
|
# if [[[TQT_VERSION IS DEPRECATED]]]<0x040000
|
|
|
|
# if [[[TQT_VERSION IS DEPRECATED]]]<0x040000
|
|
|
@ -791,7 +791,7 @@ KCmdLineArgs::usage(const TQString &error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::usage(const char *id)
|
|
|
|
TDECmdLineArgs::usage(const char *id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
enable_i18n();
|
|
|
|
enable_i18n();
|
|
|
|
assert(argsList != 0); // It's an error to call usage(...) without
|
|
|
|
assert(argsList != 0); // It's an error to call usage(...) without
|
|
|
@ -803,7 +803,7 @@ KCmdLineArgs::usage(const char *id)
|
|
|
|
TQString tmp;
|
|
|
|
TQString tmp;
|
|
|
|
TQString usage;
|
|
|
|
TQString usage;
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *args = argsList->last();
|
|
|
|
TDECmdLineArgs *args = argsList->last();
|
|
|
|
|
|
|
|
|
|
|
|
if (!(args->id) && (args->options) &&
|
|
|
|
if (!(args->id) && (args->options) &&
|
|
|
|
(args->options->name) && (args->options->name[0] != '+'))
|
|
|
|
(args->options->name) && (args->options->name[0] != '+'))
|
|
|
@ -820,7 +820,7 @@ KCmdLineArgs::usage(const char *id)
|
|
|
|
args = argsList->prev();
|
|
|
|
args = argsList->prev();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KCmdLineArgs *appOptions = argsList->last();
|
|
|
|
TDECmdLineArgs *appOptions = argsList->last();
|
|
|
|
if (!appOptions->id)
|
|
|
|
if (!appOptions->id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const KCmdLineOptions *option = appOptions->options;
|
|
|
|
const KCmdLineOptions *option = appOptions->options;
|
|
|
@ -1012,7 +1012,7 @@ KCmdLineArgs::usage(const char *id)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The given arguments are assumed to be constants.
|
|
|
|
* The given arguments are assumed to be constants.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCmdLineArgs::KCmdLineArgs( const KCmdLineOptions *_options,
|
|
|
|
TDECmdLineArgs::TDECmdLineArgs( const KCmdLineOptions *_options,
|
|
|
|
const char *_name, const char *_id)
|
|
|
|
const char *_name, const char *_id)
|
|
|
|
: options(_options), name(_name), id(_id)
|
|
|
|
: options(_options), name(_name), id(_id)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1024,7 +1024,7 @@ KCmdLineArgs::KCmdLineArgs( const KCmdLineOptions *_options,
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
* Destructor.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCmdLineArgs::~KCmdLineArgs()
|
|
|
|
TDECmdLineArgs::~TDECmdLineArgs()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete parsedOptionList;
|
|
|
|
delete parsedOptionList;
|
|
|
|
delete parsedArgList;
|
|
|
|
delete parsedArgList;
|
|
|
@ -1033,7 +1033,7 @@ KCmdLineArgs::~KCmdLineArgs()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::clear()
|
|
|
|
TDECmdLineArgs::clear()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete parsedArgList;
|
|
|
|
delete parsedArgList;
|
|
|
|
parsedArgList = 0;
|
|
|
|
parsedArgList = 0;
|
|
|
@ -1042,7 +1042,7 @@ KCmdLineArgs::clear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::reset()
|
|
|
|
TDECmdLineArgs::reset()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( argsList ) {
|
|
|
|
if ( argsList ) {
|
|
|
|
argsList->setAutoDelete( true );
|
|
|
|
argsList->setAutoDelete( true );
|
|
|
@ -1054,7 +1054,7 @@ KCmdLineArgs::reset()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::save( TQDataStream &ds) const
|
|
|
|
TDECmdLineArgs::save( TQDataStream &ds) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint count = 0;
|
|
|
|
uint count = 0;
|
|
|
|
if (parsedOptionList)
|
|
|
|
if (parsedOptionList)
|
|
|
@ -1069,7 +1069,7 @@ KCmdLineArgs::save( TQDataStream &ds) const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::load( TQDataStream &ds)
|
|
|
|
TDECmdLineArgs::load( TQDataStream &ds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!parsedOptionList) parsedOptionList = new KCmdLineParsedOptions;
|
|
|
|
if (!parsedOptionList) parsedOptionList = new KCmdLineParsedOptions;
|
|
|
|
if (!parsedArgList) parsedArgList = new KCmdLineParsedArgs;
|
|
|
|
if (!parsedArgList) parsedArgList = new KCmdLineParsedArgs;
|
|
|
@ -1090,7 +1090,7 @@ KCmdLineArgs::load( TQDataStream &ds)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::setOption(const TQCString &opt, bool enabled)
|
|
|
|
TDECmdLineArgs::setOption(const TQCString &opt, bool enabled)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isTQt)
|
|
|
|
if (isTQt)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1113,7 +1113,7 @@ KCmdLineArgs::setOption(const TQCString &opt, bool enabled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::setOption(const TQCString &opt, const char *value)
|
|
|
|
TDECmdLineArgs::setOption(const TQCString &opt, const char *value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isTQt)
|
|
|
|
if (isTQt)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1140,7 +1140,7 @@ KCmdLineArgs::setOption(const TQCString &opt, const char *value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQCString
|
|
|
|
TQCString
|
|
|
|
KCmdLineArgs::getOption(const char *_opt) const
|
|
|
|
TDECmdLineArgs::getOption(const char *_opt) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQCString *value = 0;
|
|
|
|
TQCString *value = 0;
|
|
|
|
if (parsedOptionList)
|
|
|
|
if (parsedOptionList)
|
|
|
@ -1160,7 +1160,7 @@ KCmdLineArgs::getOption(const char *_opt) const
|
|
|
|
|
|
|
|
|
|
|
|
if (result != 3)
|
|
|
|
if (result != 3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "\n\nFAILURE (TDECmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "Application requests for getOption(\"%s\") but the \"%s\" option\n",
|
|
|
|
fprintf(stderr, "Application requests for getOption(\"%s\") but the \"%s\" option\n",
|
|
|
|
_opt, _opt);
|
|
|
|
_opt, _opt);
|
|
|
|
fprintf(stderr, "has never been specified via addCmdLineOptions( ... )\n\n");
|
|
|
|
fprintf(stderr, "has never been specified via addCmdLineOptions( ... )\n\n");
|
|
|
@ -1172,7 +1172,7 @@ KCmdLineArgs::getOption(const char *_opt) const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QCStringList
|
|
|
|
QCStringList
|
|
|
|
KCmdLineArgs::getOptionList(const char *_opt) const
|
|
|
|
TDECmdLineArgs::getOptionList(const char *_opt) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QCStringList result;
|
|
|
|
QCStringList result;
|
|
|
|
if (!parsedOptionList)
|
|
|
|
if (!parsedOptionList)
|
|
|
@ -1202,7 +1202,7 @@ KCmdLineArgs::getOptionList(const char *_opt) const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
KCmdLineArgs::isSet(const char *_opt) const
|
|
|
|
TDECmdLineArgs::isSet(const char *_opt) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Look up the default.
|
|
|
|
// Look up the default.
|
|
|
|
const char *opt_name;
|
|
|
|
const char *opt_name;
|
|
|
@ -1213,7 +1213,7 @@ KCmdLineArgs::isSet(const char *_opt) const
|
|
|
|
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
if (result == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "\n\nFAILURE (TDECmdLineArgs):\n");
|
|
|
|
fprintf(stderr, "Application requests for isSet(\"%s\") but the \"%s\" option\n",
|
|
|
|
fprintf(stderr, "Application requests for isSet(\"%s\") but the \"%s\" option\n",
|
|
|
|
_opt, _opt);
|
|
|
|
_opt, _opt);
|
|
|
|
fprintf(stderr, "has never been specified via addCmdLineOptions( ... )\n\n");
|
|
|
|
fprintf(stderr, "has never been specified via addCmdLineOptions( ... )\n\n");
|
|
|
@ -1245,7 +1245,7 @@ KCmdLineArgs::isSet(const char *_opt) const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
int
|
|
|
|
KCmdLineArgs::count() const
|
|
|
|
TDECmdLineArgs::count() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!parsedArgList)
|
|
|
|
if (!parsedArgList)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -1253,11 +1253,11 @@ KCmdLineArgs::count() const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
const char *
|
|
|
|
KCmdLineArgs::arg(int n) const
|
|
|
|
TDECmdLineArgs::arg(int n) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!parsedArgList || (n >= (int) parsedArgList->count()))
|
|
|
|
if (!parsedArgList || (n >= (int) parsedArgList->count()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\nFAILURE (KCmdLineArgs): Argument out of bounds\n");
|
|
|
|
fprintf(stderr, "\n\nFAILURE (TDECmdLineArgs): Argument out of bounds\n");
|
|
|
|
fprintf(stderr, "Application requests for arg(%d) without checking count() first.\n",
|
|
|
|
fprintf(stderr, "Application requests for arg(%d) without checking count() first.\n",
|
|
|
|
n);
|
|
|
|
n);
|
|
|
|
|
|
|
|
|
|
|
@ -1269,12 +1269,12 @@ KCmdLineArgs::arg(int n) const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KURL
|
|
|
|
KURL
|
|
|
|
KCmdLineArgs::url(int n) const
|
|
|
|
TDECmdLineArgs::url(int n) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return makeURL( arg(n) );
|
|
|
|
return makeURL( arg(n) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KURL KCmdLineArgs::makeURL(const char *_urlArg)
|
|
|
|
KURL TDECmdLineArgs::makeURL(const char *_urlArg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQString urlArg = TQFile::decodeName(_urlArg);
|
|
|
|
TQString urlArg = TQFile::decodeName(_urlArg);
|
|
|
|
if (!TQDir::isRelativePath(urlArg))
|
|
|
|
if (!TQDir::isRelativePath(urlArg))
|
|
|
@ -1300,7 +1300,7 @@ KURL KCmdLineArgs::makeURL(const char *_urlArg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::addArgument(const char *argument)
|
|
|
|
TDECmdLineArgs::addArgument(const char *argument)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!parsedArgList)
|
|
|
|
if (!parsedArgList)
|
|
|
|
parsedArgList = new KCmdLineParsedArgs;
|
|
|
|
parsedArgList = new KCmdLineParsedArgs;
|
|
|
@ -1315,14 +1315,14 @@ static const KCmdLineOptions kde_tempfile_option[] =
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KCmdLineArgs::addTempFileOption()
|
|
|
|
TDECmdLineArgs::addTempFileOption()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KCmdLineArgs::addCmdLineOptions( kde_tempfile_option, "KDE-tempfile", "kde-tempfile" );
|
|
|
|
TDECmdLineArgs::addCmdLineOptions( kde_tempfile_option, "KDE-tempfile", "kde-tempfile" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KCmdLineArgs::isTempFileSet()
|
|
|
|
bool TDECmdLineArgs::isTempFileSet()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KCmdLineArgs* args = KCmdLineArgs::parsedArgs( "kde-tempfile" );
|
|
|
|
TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs( "kde-tempfile" );
|
|
|
|
if ( args )
|
|
|
|
if ( args )
|
|
|
|
return args->isSet( "tempfile" );
|
|
|
|
return args->isSet( "tempfile" );
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|