Files
libreoffice/basic/source/inc/iosys.hxx

114 lines
3.8 KiB
C++
Raw Normal View History

2010-10-27 13:11:31 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 15:18:56 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 15:18:56 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 15:18:56 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 15:18:56 +00:00
*
* OpenOffice.org 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 Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 15:18:56 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 15:18:56 +00:00
*
************************************************************************/
#ifndef _SBIOSYS_HXX
#define _SBIOSYS_HXX
#include <tools/stream.hxx>
#include <basic/sberrors.hxx>
2000-09-18 15:18:56 +00:00
class SvStream;
// Global files (channel numbers 256 to 511) are not
// implemented at the moment.
2000-09-18 15:18:56 +00:00
#define CHANNELS 256
#define SBSTRM_INPUT 0x0001
#define SBSTRM_OUTPUT 0x0002
#define SBSTRM_RANDOM 0x0004
#define SBSTRM_APPEND 0x0008
#define SBSTRM_BINARY 0x0010
2000-09-18 15:18:56 +00:00
2012-01-27 20:27:18 +00:00
class SbiStream
{
SvStream* pStrm;
sal_uIntPtr nExpandOnWriteTo; // during writing access expand the stream to this size
2012-01-27 20:27:18 +00:00
rtl::OString aLine;
sal_uIntPtr nLine;
short nLen; // buffer length
short nMode;
short nChan;
SbError nError;
void MapError();
2000-09-18 15:18:56 +00:00
public:
SbiStream();
~SbiStream();
2012-01-27 20:27:18 +00:00
SbError Open( short, const rtl::OString&, short, short, short );
2000-09-18 15:18:56 +00:00
SbError Close();
2012-01-27 20:27:18 +00:00
SbError Read(rtl::OString&, sal_uInt16 = 0, bool bForceReadingPerByte=false);
2000-09-18 15:18:56 +00:00
SbError Read( char& );
2012-01-27 20:27:18 +00:00
SbError Write( const rtl::OString&, sal_uInt16 = 0 );
2000-09-18 15:18:56 +00:00
bool IsText() const { return (nMode & SBSTRM_BINARY) == 0; }
bool IsRandom() const { return (nMode & SBSTRM_RANDOM) != 0; }
bool IsBinary() const { return (nMode & SBSTRM_BINARY) != 0; }
bool IsSeq() const { return (nMode & SBSTRM_RANDOM) == 0; }
bool IsAppend() const { return (nMode & SBSTRM_APPEND) != 0; }
2000-09-18 15:18:56 +00:00
short GetBlockLen() const { return nLen; }
short GetMode() const { return nMode; }
sal_uIntPtr GetLine() const { return nLine; }
void SetExpandOnWriteTo( sal_uIntPtr n ) { nExpandOnWriteTo = n; }
2000-09-18 15:18:56 +00:00
void ExpandFile();
SvStream* GetStrm() { return pStrm; }
};
2012-01-27 20:27:18 +00:00
class SbiIoSystem
{
2000-09-18 15:18:56 +00:00
SbiStream* pChan[ CHANNELS ];
2012-01-27 20:27:18 +00:00
rtl::OString aPrompt;
rtl::OString aIn;
rtl::OString aOut;
short nChan;
SbError nError;
2012-01-27 20:27:18 +00:00
void ReadCon(rtl::OString&);
void WriteCon(const rtl::OString&);
2000-09-18 15:18:56 +00:00
public:
SbiIoSystem();
~SbiIoSystem();
SbError GetError();
void Shutdown();
2012-01-27 20:27:18 +00:00
void SetPrompt(const rtl::OString& r) { aPrompt = r; }
2000-09-18 15:18:56 +00:00
void SetChannel( short n ) { nChan = n; }
short GetChannel() const { return nChan;}
void ResetChannel() { nChan = 0; }
2012-01-27 20:27:18 +00:00
void Open( short, const rtl::OString&, short, short, short );
2000-09-18 15:18:56 +00:00
void Close();
2012-01-27 20:27:18 +00:00
void Read(rtl::OString&, short = 0);
2000-09-18 15:18:56 +00:00
char Read();
2012-01-27 20:27:18 +00:00
void Write(const rtl::OString&, short = 0);
2000-09-18 15:18:56 +00:00
// 0 == bad channel or no SvStream (nChannel=0..CHANNELS-1)
SbiStream* GetStream( short nChannel ) const;
void CloseAll(); // JSM
};
#endif
2010-10-27 13:11:31 +01:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */