1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/**
* Yudit Unicode Editor Source File
*
* GNU Copyright (C) 2002 Gaspar Sinai <gsinai@yudit.org>
* GNU Copyright (C) 2001 Gaspar Sinai <gsinai@yudit.org>
* GNU Copyright (C) 2000 Gaspar Sinai <gsinai@yudit.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* dated June 1991. See file COPYYING for details.
*
* This program is distributed 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef SIOStream_h
#define SIOStream_h
#include "SEvent.h"
#include "SIO.h"
#include "SStringVector.h"
#include "SString.h"
class SReader : public SJob, public SEventTarget
{
public:
// If target is zero this will be a blocking function.
SReader (const SInputStream& i, SEventTarget* t=0);
SReader (const SInputStream& i, const SStringVector& sep, SEventTarget* t=0);
~SReader ();
// These are for public use
bool read (SString* s);
virtual int run ();
virtual bool read (const SEventSource* s, const SString& m);
virtual void error (const SEventSource* s);
bool isOK();
bool close();
protected:
bool finishFlag;
bool errFlag;
bool more;
SString buffer;
SStringVector line;
SStringVector sepVector;
SEventTarget* trg;
SInputStream in;
};
class SWriter : public SJob, public SEventTarget
{
public:
SWriter (const SOutputStream& i, SEventTarget* t=0);
~SWriter ();
// This is for public use
bool write (const SString& s);
bool isErrror() { return errFlag; }
bool isFinished() { return writeCount==0; }
virtual int run ();
virtual bool write (const SEventSource* s);
virtual void error (const SEventSource* s);
bool isOK();
bool close();
protected:
int writeCount;
bool finishFlag;
bool errFlag;
SOutputStream out;
SEventTarget* trg;
};
#endif /* SIOStream_h */
|