/***************************************************************************
                            KStringHandler.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_KStringHandler.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KStringHandler.h>
#include <qtobjc/QRegExp.h>


@implementation  KStringHandler

- (void *) qt
{
	return _qt;
}

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

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

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


+ (NSString *) word: (NSString *)text pos: (unsigned int)pos
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_word((qt_QString *) [text toQString: &_qstring_text], (unsigned int)pos);
	return [NSString fromQString: _qstring];
}

+ (NSString *) word: (NSString *)text range: (NSString *)range
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_word1((qt_QString *) [text toQString: &_qstring_text], (char*) [range cString]);
	return [NSString fromQString: _qstring];
}

+ (NSString *) insword: (NSString *)text word: (NSString *)word pos: (unsigned int)pos
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_word = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_insword((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [word toQString: &_qstring_word], (unsigned int)pos);
	return [NSString fromQString: _qstring];
}

+ (NSString *) setword: (NSString *)text word: (NSString *)word pos: (unsigned int)pos
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_word = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_setword((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [word toQString: &_qstring_word], (unsigned int)pos);
	return [NSString fromQString: _qstring];
}

+ (NSString *) remrange: (NSString *)text range: (NSString *)range
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_remrange((qt_QString *) [text toQString: &_qstring_text], (char*) [range cString]);
	return [NSString fromQString: _qstring];
}

+ (NSString *) remword: (NSString *)text pos: (unsigned int)pos
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_remword((qt_QString *) [text toQString: &_qstring_text], (unsigned int)pos);
	return [NSString fromQString: _qstring];
}

+ (NSString *) remword: (NSString *)text word: (NSString *)word
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_word = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_remword1((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [word toQString: &_qstring_word]);
	return [NSString fromQString: _qstring];
}

+ (NSString *) capwords: (NSString *)text
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_capwords((qt_QString *) [text toQString: &_qstring_text]);
	return [NSString fromQString: _qstring];
}

+ (NSArray *) capwordsFromList: (NSArray *)list
{
static qt_QStringList * _qlist = 0L;
static qt_QStringList * _qlist_list = 0L;
	_qlist = kde_KStringHandler_capwords1((qt_QStringList*) [list toQStringList: (void *)&_qlist_list]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (NSString *) reverse: (NSString *)text
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_reverse((qt_QString *) [text toQString: &_qstring_text]);
	return [NSString fromQString: _qstring];
}

+ (NSArray *) reverseList: (NSArray *)list
{
static qt_QStringList * _qlist = 0L;
static qt_QStringList * _qlist_list = 0L;
	_qlist = kde_KStringHandler_reverse1((qt_QStringList*) [list toQStringList: (void *)&_qlist_list]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (NSString *) ljust: (NSString *)text width: (unsigned int)width
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_ljust((qt_QString *) [text toQString: &_qstring_text], (unsigned int)width);
	return [NSString fromQString: _qstring];
}

+ (NSString *) rjust: (NSString *)text width: (unsigned int)width
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_rjust((qt_QString *) [text toQString: &_qstring_text], (unsigned int)width);
	return [NSString fromQString: _qstring];
}

+ (NSString *) center: (NSString *)text width: (unsigned int)width
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_text = 0L;
	_qstring = kde_KStringHandler_center((qt_QString *) [text toQString: &_qstring_text], (unsigned int)width);
	return [NSString fromQString: _qstring];
}

+ (NSString *) lsqueeze: (NSString *)str maxlen: (unsigned int)maxlen
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_str = 0L;
	_qstring = kde_KStringHandler_lsqueeze((qt_QString *) [str toQString: &_qstring_str], (unsigned int)maxlen);
	return [NSString fromQString: _qstring];
}

+ (NSString *) csqueeze: (NSString *)str maxlen: (unsigned int)maxlen
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_str = 0L;
	_qstring = kde_KStringHandler_csqueeze((qt_QString *) [str toQString: &_qstring_str], (unsigned int)maxlen);
	return [NSString fromQString: _qstring];
}

+ (NSString *) rsqueeze: (NSString *)str maxlen: (unsigned int)maxlen
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_str = 0L;
	_qstring = kde_KStringHandler_rsqueeze((qt_QString *) [str toQString: &_qstring_str], (unsigned int)maxlen);
	return [NSString fromQString: _qstring];
}

+ (BOOL) matchFileName: (NSString *)filename pattern: (NSString *)pattern
{
static qt_QString * _qstring_pattern = 0L;
static qt_QString * _qstring_filename = 0L;
	return (BOOL) kde_KStringHandler_matchFileName((qt_QString *) [filename toQString: &_qstring_filename], (qt_QString *) [pattern toQString: &_qstring_pattern]);
}

+ (NSArray *) perlSplit: (NSString *)sep string: (NSString *)s maxlen: (unsigned int)max
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_s = 0L;
static qt_QString * _qstring_sep = 0L;
	_qlist = kde_KStringHandler_perlSplit((qt_QString *) [sep toQString: &_qstring_sep], (qt_QString *) [s toQString: &_qstring_s], (unsigned int)max);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (NSArray *) perlSplitWithUnichar: (unichar *)sep string: (NSString *)s maxlen: (unsigned int)max
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_s = 0L;
	_qlist = kde_KStringHandler_perlSplit1((qt_QChar*)sep, (qt_QString *) [s toQString: &_qstring_s], (unsigned int)max);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (NSArray *) perlSplitWithRegExp: (QRegExp*)sep string: (NSString *)s maxlen: (unsigned int)max
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_s = 0L;
	_qlist = kde_KStringHandler_perlSplit2((qt_QRegExp*) [sep qt], (qt_QString *) [s toQString: &_qstring_s], (unsigned int)max);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

@end
