/***************************************************************************
                            KCmdLineArgs.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_KCmdLineArgs.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KCmdLineArgs.h>
#include <kdeobjc/KAboutData.h>


@implementation  KCmdLineArgs

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


- (NSString *) getOption: (NSString *)option
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_KCmdLineArgs_getOption((kde_KCmdLineArgs *)[self qt], (char*) [option cString]);
	return [NSString fromQCString: _qcstring];
}

- (NSArray *) getOptionList: (NSString *)option
{
static kde_QCStringList * _qlist = 0L;
	_qlist = kde_KCmdLineArgs_getOptionList((kde_KCmdLineArgs *)[self qt], (char*) [option cString]);
	return (NSArray *) [NSMutableArray arrayWithQCStringList: _qlist];
}

- (BOOL) isSet: (NSString *)option
{
	return (BOOL) kde_KCmdLineArgs_isSet((kde_KCmdLineArgs *)[self qt], (char*) [option cString]);
}

- (int) count
{
	return (int) kde_KCmdLineArgs_count((kde_KCmdLineArgs *)[self qt]);
}

- (NSString *) arg: (int)n
{
	return (NSString *) [NSString stringWithCString: kde_KCmdLineArgs_arg((kde_KCmdLineArgs *)[self qt], (int)n)];
}

- (KURL*) url: (int)n
{
	return (KURL*) [QtSupport objectForQtKey: kde_KCmdLineArgs_url((kde_KCmdLineArgs *)[self qt], (int)n) withClass: [KURL class] allocatedInObjcWorld: YES];
}

- clear
{
	kde_KCmdLineArgs_clear((kde_KCmdLineArgs *)[self qt]);
	return self;
}

+ init: (int)_argc _argv: (NSString *)_argv _appname: (NSString *)_appname _description: (NSString *)_description _version: (NSString *)_version noKApp: (BOOL)noKApp
{
	kde_KCmdLineArgs_init((int)_argc, (char**) [_argv cString], (char*) [_appname cString], (char*) [_description cString], (char*) [_version cString], (int)noKApp);
	return self;
}

+ init: (int)_argc _argv: (NSString *)_argv _appname: (NSString *)_appname _description: (NSString *)_description _version: (NSString *)_version 
{
	kde_KCmdLineArgs_init((int)_argc, (char**) [_argv cString], (char*) [_appname cString], (char*) [_description cString], (char*) [_version cString], 0);
	return self;
}

+ init: (int)_argc _argv: (NSString *)_argv about: (KAboutData*)about noKApp: (BOOL)noKApp
{
	kde_KCmdLineArgs_init1((int)_argc, (char**) [_argv cString], (kde_KAboutData*) [about qt], (int)noKApp);
	return self;
}

+ init: (int)_argc _argv: (NSString *)_argv about: (KAboutData*)about 
{
	kde_KCmdLineArgs_init1((int)_argc, (char**) [_argv cString], (kde_KAboutData*) [about qt], 0);
	return self;
}

+ init: (KAboutData*)about
{
	kde_KCmdLineArgs_init2((kde_KAboutData*) [about qt]);
	return self;
}

//+ addCmdLineOptions: (KCmdLineOptions*)options name: (NSString *)name identifier: (NSString *)identifier afterId: (NSString *)afterId
//{
//	kde_KCmdLineArgs_addCmdLineOptions((kde_KCmdLineOptions*) [options qt], (char*) [name cString], (char*) [identifier cString], (char*) [afterId cString]);
//	return self;
//}

//+ addCmdLineOptions: (KCmdLineOptions*)options
//{
//	kde_KCmdLineArgs_addCmdLineOptions((kde_KCmdLineOptions*) [options qt], 0, 0, 0);
//	return self;
//}

+ (KCmdLineArgs*) parsedArgs: (NSString *)identifier
{
	return (KCmdLineArgs*) [QtSupport objectForQtKey: kde_KCmdLineArgs_parsedArgs((char*) [identifier cString]) withClass: [KCmdLineArgs class] allocatedInObjcWorld: YES];
}

+ (KCmdLineArgs*) parsedArgs
{
	return (KCmdLineArgs*) [QtSupport objectForQtKey: kde_KCmdLineArgs_parsedArgs(0) withClass: [KCmdLineArgs class] allocatedInObjcWorld: YES];
}

+ (NSString *) cwd
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KCmdLineArgs_cwd();
	return [NSString fromQString: _qstring];
}

+ (NSString *) appName
{
	return (NSString *) [NSString stringWithCString: kde_KCmdLineArgs_appName()];
}

+ usage: (NSString *)identifier
{
	kde_KCmdLineArgs_usage((char*) [identifier cString]);
	return self;
}

+ usage
{
	kde_KCmdLineArgs_usage(0);
	return self;
}

+ usageForError: (NSString *)error
{
static qt_QString * _qstring_error = 0L;
	kde_KCmdLineArgs_usage1((qt_QString *) [error toQString: &_qstring_error]);
	return self;
}

+ enable_i18n
{
	kde_KCmdLineArgs_enable_i18n();
	return self;
}

+ (KURL*) makeURL: (NSString *)urlArg
{
	return (KURL*) [QtSupport objectForQtKey: kde_KCmdLineArgs_makeURL((char*) [urlArg cString]) withClass: [KURL class] allocatedInObjcWorld: YES];
}

+ setCwd: (NSString *)cwd
{
	kde_KCmdLineArgs_setCwd((char*) [cwd cString]);
	return self;
}

//- initWithCmdLineOptions: (KCmdLineOptions*)_options _id: (NSString *)_id _name: (NSString *)_name
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_KCmdLineArgs((kde_KCmdLineOptions*) [_options qt], (char*) [_id cString], (char*) [_name cString])];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			kde_del_KCmdLineArgs((kde_KCmdLineArgs *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

@end
