1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <string_view>
25 #include <tools/stream.hxx>
26 #include <o3tl/typed_flags_set.hxx>
30 // Global files (channel numbers 256 to 511) are not
31 // implemented at the moment.
35 enum class SbiStreamFlags
46 template<> struct typed_flags
<SbiStreamFlags
> : is_typed_flags
<SbiStreamFlags
, 0x1f> {};
51 std::unique_ptr
<SvStream
> pStrm
;
52 sal_uInt64 nExpandOnWriteTo
; // during writing access expand the stream to this size
55 short nLen
; // buffer length
63 ErrCode
const & Open( std::string_view
, StreamMode
, SbiStreamFlags
, short );
64 ErrCode
const & Close();
65 ErrCode
Read(OString
&, sal_uInt16
= 0, bool bForceReadingPerByte
=false);
66 ErrCode
const & Read( char& );
67 ErrCode
Write( const OString
& );
69 bool IsText() const { return !bool(nMode
& SbiStreamFlags::Binary
); }
70 bool IsRandom() const { return bool(nMode
& SbiStreamFlags::Random
); }
71 bool IsBinary() const { return bool(nMode
& SbiStreamFlags::Binary
); }
72 bool IsSeq() const { return !bool(nMode
& SbiStreamFlags::Random
); }
73 bool IsAppend() const { return bool(nMode
& SbiStreamFlags::Append
); }
74 short GetBlockLen() const { return nLen
; }
75 SbiStreamFlags
GetMode() const { return nMode
; }
76 sal_uInt64
GetLine() const { return nLine
; }
77 void SetExpandOnWriteTo( sal_uInt64 n
) { nExpandOnWriteTo
= n
; }
79 SvStream
* GetStrm() { return pStrm
.get(); }
84 SbiStream
* pChan
[ CHANNELS
];
90 void ReadCon(OString
&);
91 void WriteCon(std::u16string_view
);
94 ~SbiIoSystem() COVERITY_NOEXCEPT_FALSE
;
97 void SetPrompt(const OString
& r
) { aPrompt
= r
; }
98 void SetChannel( short n
) { nChan
= n
; }
99 short GetChannel() const { return nChan
;}
100 void ResetChannel() { nChan
= 0; }
101 void Open( short, std::string_view
, StreamMode
, SbiStreamFlags
, short );
105 void Write(std::u16string_view
);
106 // 0 == bad channel or no SvStream (nChannel=0..CHANNELS-1)
107 SbiStream
* GetStream( short nChannel
) const;
108 void CloseAll(); // JSM
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */