// This is the SIP interface definition for QStringList.
//
// Copyright (c) 2003
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// This file is part of PyQt.
// 
// This copy of PyQt is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2, or (at your option) any later
// version.
// 
// PyQt is supplied in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
// details.
// 
// You should have received a copy of the GNU General Public License along with
// PyQt; see the file LICENSE.  If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


%ExportedDoc
<Sect2><Title>QStringList (Qt v2+)</Title>
<Para>
The Python <Literal>len</Literal>, <Literal>[]</Literal> (for both reading and
writing slices and individual elements), <Literal>del</Literal> (for deleting
slices and indivual elements), <Literal>+</Literal>, <Literal>+=</Literal>,
<Literal>*</Literal>, <Literal>*=</Literal>, <Literal>==</Literal>,
<Literal>!=</Literal> and <Literal>in</Literal> operators are supported.
</Para>

<FuncSynopsis>
	<FuncDef>Iterator <Function>append</Function></FuncDef>
	<ParamDef>const QString &<Parameter>x</Parameter></ParamDef>
</FuncSynopsis>
<Para>
This does not return a value.
</Para>

<FuncSynopsis>
	<FuncDef>Iterator <Function>prepend</Function></FuncDef>
	<ParamDef>const QString &<Parameter>x</Parameter></ParamDef>
</FuncSynopsis>
<Para>
This does not return a value.
</Para>
</Sect2>
%End


%If (Qt_2_00 -)

class QStringList
{
%HeaderCode
#include <qstringlist.h>
%End

public:
	QStringList();
	QStringList(const QStringList &);
	QStringList(const QString &);

	void sort();
%If (Qt_2_1_0 -)
	static QStringList fromStrList(const QStrList &);
	static QStringList split(const QString &,const QString &,bool = 0);
	static QStringList split(const QChar &,const QString &,bool = 0);
	static QStringList split(const QRegExp &,const QString &,bool = 0);
	QString join(const QString &) const;
	QStringList grep(const QString &,bool = 1) const;
	QStringList grep(const QRegExp &) const;
%End

	// These are actually in QValueList, which isn't implemented so
	// pretend they are here.

	bool isEmpty() const;
	void append(const QString &);
	void prepend(const QString &);
	void remove(const QString &);
	const QString &first() const;
	const QString &last() const;
	int findIndex(const QString &) const;
	uint contains(const QString &) const;
	uint count() const;
	void clear();

	int __len__();
%MemberCode
		int len;

		len = sipCpp -> count();

		return PyInt_FromLong(len);
%End

	void __setitem__(int,const QString &);
%MemberCode
		int len;
		PyObject *res;

		len = sipCpp -> count();

		if ((a0 = sipConvertFromSequenceIndex(a0,len)) < 0)
		{
			res = NULL;
			goto tidyup;
		}

		(*sipCpp)[a0] = *a1;

		res = Py_None;
		Py_INCREF(res);

tidyup:
		if (a1IsTemp)
			delete a1;

		return res;
%End

	void __setitem__(SIP_PYSLICE,const QStringList &);
%MemberCode
		int len, start, stop, step, slicelength;

		len = sipCpp -> count();

		if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
			return NULL;

		int vlen = a1 -> count();

		if (vlen != slicelength)
		{
			sipBadLengthForSlice(vlen,slicelength);
			return NULL;
		}

		QStringList::ConstIterator it = a1 -> begin();

		for (int i = 0; i < slicelength; ++i)
		{
			(*sipCpp)[start] = *it;
			start += step;
			++it;
		}

		Py_INCREF(Py_None);
		return Py_None;
%End

	void __delitem__(int);
%MemberCode
		int len;

		len = sipCpp -> count();

		if ((a0 = sipConvertFromSequenceIndex(a0,len)) < 0)
			return NULL;

		sipCpp -> remove(sipCpp -> at(a0));

		Py_INCREF(Py_None);
		return Py_None;
%End

	void __delitem__(SIP_PYSLICE);
%MemberCode
		int len, start, stop, step, slicelength;

		len = sipCpp -> count();

		if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
			return NULL;

		for (int i = 0; i < slicelength; ++i)
		{
			sipCpp -> remove(sipCpp -> at(start));
			start += step - 1;
		}

		Py_INCREF(Py_None);
		return Py_None;
%End

	QString operator[](int);
%MemberCode
		int len;

		len = sipCpp -> count();

		if ((a0 = sipConvertFromSequenceIndex(a0,len)) < 0)
			return NULL;

		QString *qs;

		qs = &(*sipCpp)[a0];

		return sipMapCppToSelf(qs,sipClass_QString);
%End

	QStringList operator[](SIP_PYSLICE);
%MemberCode
		int len, start, stop, step, slicelength;

		len = sipCpp -> count();

		if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
			return NULL;

		QStringList *qsl = new QStringList();

		for (int i = 0; i < slicelength; ++i)
		{
			(*qsl) += (*sipCpp)[start];
			start += step;
		}

		return sipMapCppToSelf(qsl,sipClass_QStringList);
%End

	bool __contains__(const QString &);
%MemberCode
		bool res;

		res = (sipCpp -> findIndex(*a0) >= 0);

		if (a0IsTemp)
			delete a0;

		return sipConvertFromBool(res);
%End

	QStringList operator+(const QStringList &);
	QStringList &operator+=(const QStringList &);

	QStringList operator*(int);
%MemberCode
		QStringList *qsl = new QStringList();

		for (int i = 0; i < a0; ++i)
			(*qsl) += (*sipCpp);

		return sipMapCppToSelf(qsl,sipClass_QStringList);
%End

	QStringList &operator*=(int);
%MemberCode
		QStringList orig(*sipCpp);

		sipCpp -> clear();

		for (int i = 0; i < a0; ++i)
			(*sipCpp) += orig;

		Py_INCREF(sipSelf);
		return sipSelf;
%End

	bool operator==(const QStringList &);
	bool operator!=(const QStringList &);
};

%End
