1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iosys.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <tools/stream.hxx>
36 #include <basic/sberrors.hxx>
41 // Zur Zeit sind globale Dateien (Kanalnummern 256 bis 511)
42 // nicht implementiert.
47 #define SBSTRM_INPUT 0x0001 // Input
48 #define SBSTRM_OUTPUT 0x0002 // Output
49 #define SBSTRM_RANDOM 0x0004 // Random
50 #define SBSTRM_APPEND 0x0008 // Append
51 #define SBSTRM_BINARY 0x0010 // Binary
54 SvStream
* pStrm
; // der Stream
55 ULONG nExpandOnWriteTo
; // bei Schreibzugriff, den Stream
56 // bis zu dieser Groesse aufblasen
57 ByteString aLine
; // aktuelle Zeile
58 ULONG nLine
; // aktuelle Zeilennummer
59 short nLen
; // Pufferlaenge
61 short nChan
; // aktueller Kanal
62 SbError nError
; // letzter Fehlercode
63 void MapError(); // Fehlercode mappen
68 SbError
Open( short, const ByteString
&, short, short, short );
70 SbError
Read( ByteString
&, USHORT
= 0, bool bForceReadingPerByte
=false );
71 SbError
Read( char& );
72 SbError
Write( const ByteString
&, USHORT
= 0 );
74 bool IsText() const { return (nMode
& SBSTRM_BINARY
) == 0; }
75 bool IsRandom() const { return (nMode
& SBSTRM_RANDOM
) != 0; }
76 bool IsBinary() const { return (nMode
& SBSTRM_BINARY
) != 0; }
77 bool IsSeq() const { return (nMode
& SBSTRM_RANDOM
) == 0; }
78 bool IsAppend() const { return (nMode
& SBSTRM_APPEND
) != 0; }
79 short GetBlockLen() const { return nLen
; }
80 short GetMode() const { return nMode
; }
81 ULONG
GetLine() const { return nLine
; }
82 void SetExpandOnWriteTo( ULONG n
) { nExpandOnWriteTo
= n
; }
84 SvStream
* GetStrm() { return pStrm
; }
88 SbiStream
* pChan
[ CHANNELS
];
89 ByteString aPrompt
; // Input-Prompt
90 ByteString aIn
, aOut
; // Console-Buffer
91 short nChan
; // aktueller Kanal
92 SbError nError
; // letzter Fehlercode
93 void ReadCon( ByteString
& );
94 void WriteCon( const ByteString
& );
100 void SetPrompt( const ByteString
& r
) { aPrompt
= r
; }
101 void SetChannel( short n
) { nChan
= n
; }
102 short GetChannel() const { return nChan
;}
103 void ResetChannel() { nChan
= 0; }
104 void Open( short, const ByteString
&, short, short, short );
106 void Read( ByteString
&, short = 0 );
108 void Write( const ByteString
&, short = 0 );
110 // 0 == bad channel or no SvStream (nChannel=0..CHANNELS-1)
111 SbiStream
* GetStream( short nChannel
) const;
112 void CloseAll(); // JSM