You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
4.9 KiB
200 lines
4.9 KiB
13 years ago
|
// This is the SIP interface definition for TQFile.
|
||
13 years ago
|
//
|
||
|
// Copyright (c) 2007
|
||
|
// Riverbank Computing Limited <info@riverbankcomputing.co.uk>
|
||
|
//
|
||
13 years ago
|
// This file is part of PyTQt.
|
||
13 years ago
|
//
|
||
13 years ago
|
// This copy of PyTQt is free software; you can redistribute it and/or modify it
|
||
13 years ago
|
// 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.
|
||
|
//
|
||
13 years ago
|
// PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY
|
||
13 years ago
|
// 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
|
||
13 years ago
|
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
|
||
13 years ago
|
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
|
|
||
|
|
||
|
%ExportedDoc
|
||
13 years ago
|
<Sect2><Title>TQFile</Title>
|
||
13 years ago
|
<FuncSynopsis>
|
||
|
<FuncDef>bool <Function>open</Function></FuncDef>
|
||
|
<ParamDef>int <Parameter>m</Parameter></ParamDef>
|
||
|
<ParamDef>FILE *<Parameter>f</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
Not implemented.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQ_LONG <Function>readBlock</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>char *<Parameter>data</Parameter></ParamDef>
|
||
13 years ago
|
<ParamDef>TQ_ULONG <Parameter>len</Parameter></ParamDef>
|
||
13 years ago
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
This takes a single <Literal>len</Literal> parameter. The
|
||
|
<Literal>data</Literal> is returned if there was no error, otherwise
|
||
|
<Literal>None</Literal> is returned.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQ_LONG <Function>readLine</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>char *<Parameter>data</Parameter></ParamDef>
|
||
13 years ago
|
<ParamDef>TQ_ULONG <Parameter>maxlen</Parameter></ParamDef>
|
||
13 years ago
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
This takes a single <Literal>maxlen</Literal> parameter. The
|
||
|
<Literal>data</Literal> is returned if there was no error, otherwise
|
||
|
<Literal>None</Literal> is returned.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
|
<FuncDef>static void <Function>setDecodingFunction</Function></FuncDef>
|
||
|
<ParamDef>EncoderFn <Parameter>f</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
Not yet implemented. (TQt v2+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
|
<FuncDef>static void <Function>setEncodingFunction</Function></FuncDef>
|
||
|
<ParamDef>EncoderFn <Parameter>f</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
Not yet implemented. (TQt v2+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQ_LONG <Function>writeBlock</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>const char *<Parameter>data</Parameter></ParamDef>
|
||
13 years ago
|
<ParamDef>TQ_ULONG <Parameter>len</Parameter></ParamDef>
|
||
13 years ago
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
<Literal>len</Literal> is derived from <Literal>data</Literal> and not passed
|
||
|
as a parameter.
|
||
|
</Para>
|
||
|
</Sect2>
|
||
|
%End
|
||
|
|
||
|
|
||
13 years ago
|
class TQFile : TQIODevice
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
13 years ago
|
#include <tqfile.h>
|
||
13 years ago
|
%End
|
||
|
|
||
|
public:
|
||
13 years ago
|
TQFile();
|
||
|
TQFile(const TQString &);
|
||
13 years ago
|
|
||
13 years ago
|
TQString name() const;
|
||
|
void setName(const TQString &);
|
||
13 years ago
|
|
||
13 years ago
|
static TQCString encodeName(const TQString &);
|
||
|
static TQString decodeName(const TQCString &);
|
||
13 years ago
|
// static void setEncodingFunction(EncoderFn);
|
||
|
// static void setDecodingFunction(DecoderFn);
|
||
|
|
||
|
bool exists() const;
|
||
13 years ago
|
static bool exists(const TQString &);
|
||
13 years ago
|
|
||
|
bool remove();
|
||
13 years ago
|
static bool remove(const TQString &);
|
||
13 years ago
|
|
||
|
bool open(int) /ReleaseGIL/;
|
||
|
// bool open(int,FILE *) /ReleaseGIL/;
|
||
|
bool open(int,int) /ReleaseGIL/;
|
||
|
void close();
|
||
|
void flush() /ReleaseGIL/;
|
||
|
|
||
|
Offset size() const;
|
||
|
Offset at() const;
|
||
|
bool at(Offset);
|
||
|
bool atEnd() const;
|
||
|
|
||
13 years ago
|
SIP_PYOBJECT readBlock(TQ_ULONG) /ReleaseGIL/ [TQ_LONG (char *,TQ_ULONG)];
|
||
13 years ago
|
%MethodCode
|
||
|
char *buf;
|
||
|
|
||
|
if ((buf = (char *)sipMalloc(a0)) == NULL)
|
||
|
sipIsErr = 1;
|
||
|
else
|
||
|
{
|
||
13 years ago
|
TQ_LONG actlen;
|
||
13 years ago
|
|
||
|
Py_BEGIN_ALLOW_THREADS
|
||
13 years ago
|
actlen = sipSelfWasArg ? sipCpp->TQFile::readBlock(buf,a0) : sipCpp->readBlock(buf,a0);
|
||
13 years ago
|
Py_END_ALLOW_THREADS
|
||
|
|
||
|
if (actlen < 0)
|
||
|
{
|
||
|
Py_INCREF(Py_None);
|
||
|
sipRes = Py_None;
|
||
|
}
|
||
2 years ago
|
else if ((sipRes = PyBytes_FromStringAndSize(buf,actlen)) == NULL)
|
||
13 years ago
|
sipIsErr = 1;
|
||
|
|
||
12 years ago
|
sipFree((void *)buf);
|
||
13 years ago
|
}
|
||
|
%End
|
||
|
|
||
|
|
||
13 years ago
|
TQ_LONG writeBlock(const char * /Array/,
|
||
|
TQ_ULONG /ArraySize/) /ReleaseGIL/;
|
||
|
TQ_LONG writeBlock(const TQByteArray &) /ReleaseGIL/;
|
||
13 years ago
|
|
||
13 years ago
|
SIP_PYOBJECT readLine(TQ_ULONG) /ReleaseGIL/ [TQ_LONG (char *,TQ_ULONG)];
|
||
13 years ago
|
%MethodCode
|
||
|
char *buf;
|
||
|
|
||
|
if ((buf = (char *)sipMalloc(a0)) == NULL)
|
||
|
sipIsErr = 1;
|
||
|
else
|
||
|
{
|
||
13 years ago
|
TQ_LONG actlen;
|
||
13 years ago
|
|
||
|
Py_BEGIN_ALLOW_THREADS
|
||
13 years ago
|
actlen = sipSelfWasArg ? sipCpp->TQFile::readLine(buf,a0) : sipCpp->readLine(buf,a0);
|
||
13 years ago
|
Py_END_ALLOW_THREADS
|
||
|
|
||
|
if (actlen < 0)
|
||
|
{
|
||
12 years ago
|
sipFree((void *)buf);
|
||
13 years ago
|
|
||
|
Py_INCREF(Py_None);
|
||
|
sipRes = Py_None;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
2 years ago
|
sipRes = PyBytes_FromStringAndSize(buf,actlen);
|
||
13 years ago
|
|
||
12 years ago
|
sipFree((void *)buf);
|
||
13 years ago
|
|
||
|
if (sipRes == NULL)
|
||
|
sipIsErr = 1;
|
||
|
}
|
||
|
}
|
||
|
%End
|
||
|
|
||
13 years ago
|
TQ_LONG readLine(TQString &,TQ_ULONG) /ReleaseGIL/;
|
||
13 years ago
|
|
||
|
int getch();
|
||
|
int putch(int);
|
||
|
int ungetch(int);
|
||
|
|
||
|
int handle() const;
|
||
|
|
||
13 years ago
|
TQString errorString() const;
|
||
13 years ago
|
|
||
|
protected:
|
||
13 years ago
|
void setErrorString(const TQString &);
|
||
13 years ago
|
|
||
|
private:
|
||
13 years ago
|
TQFile(const TQFile &);
|
||
13 years ago
|
};
|