merge the formfield patch from ooo-build
[ooovba.git] / basic / source / inc / iosys.hxx
blob791439771fe8e5b4dcb29a14071ffb8eb89d80a1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iosys.hxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 #ifndef _SBIOSYS_HXX
32 #define _SBIOSYS_HXX
34 #include <tools/stream.hxx>
35 #ifndef _SBERRORS_HXX
36 #include <basic/sberrors.hxx>
37 #endif
39 class SvStream;
41 // Zur Zeit sind globale Dateien (Kanalnummern 256 bis 511)
42 // nicht implementiert.
44 #define CHANNELS 256
45 #define CONSOLE 0
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
53 class SbiStream {
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
60 short nMode; // Bits:
61 short nChan; // aktueller Kanal
62 SbError nError; // letzter Fehlercode
63 void MapError(); // Fehlercode mappen
65 public:
66 SbiStream();
67 ~SbiStream();
68 SbError Open( short, const ByteString&, short, short, short );
69 SbError Close();
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; }
83 void ExpandFile();
84 SvStream* GetStrm() { return pStrm; }
87 class SbiIoSystem {
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& );
95 public:
96 SbiIoSystem();
97 ~SbiIoSystem();
98 SbError GetError();
99 void Shutdown();
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 );
105 void Close();
106 void Read( ByteString&, short = 0 );
107 char Read();
108 void Write( const ByteString&, short = 0 );
109 short NextChannel();
110 // 0 == bad channel or no SvStream (nChannel=0..CHANNELS-1)
111 SbiStream* GetStream( short nChannel ) const;
112 void CloseAll(); // JSM
115 #endif