Bump version to 6.4-15
[LibreOffice.git] / io / source / stm / streamhelper.hxx
blobc1bb1b7db748965f12909b896b23e8c1d8e4d2f8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_IO_SOURCE_STM_STREAMHELPER_HXX
21 #define INCLUDED_IO_SOURCE_STM_STREAMHELPER_HXX
23 #include <com/sun/star/uno/Sequence.hxx>
25 #include <assert.h>
27 using namespace com::sun::star::uno;
29 namespace io_stm
32 class MemRingBuffer
34 public:
35 MemRingBuffer();
36 virtual ~MemRingBuffer();
38 /***
39 * overwrites data at given position. Size is automatically extended, when
40 * data is written beyond end.
41 ***/
42 /// @throws css::io::BufferSizeExceededException
43 void writeAt( sal_Int32 nPos, const Sequence<sal_Int8> &);
44 /// @throws css::io::BufferSizeExceededException
45 void readAt( sal_Int32 nPos, Sequence<sal_Int8> & , sal_Int32 nBytesToRead ) const;
46 sal_Int32 getSize() const throw();
47 /// @throws css::io::BufferSizeExceededException
48 void forgetFromStart(sal_Int32 nBytesToForget);
50 private:
51 /// @throws css::io::BufferSizeExceededException
52 void resizeBuffer(sal_Int32 nMinSize);
53 void checkInvariants() const {
54 assert( m_nBufferLen >= 0 );
55 assert( m_nOccupiedBuffer >= 0 );
56 assert( m_nOccupiedBuffer <= m_nBufferLen );
57 assert( m_nStart >= 0 );
58 assert( 0 == m_nStart || m_nStart < m_nBufferLen );
59 (void) this; // avoid loplugin:staticmethods
62 sal_Int8 *m_p;
63 sal_Int32 m_nBufferLen;
64 sal_Int32 m_nStart;
65 sal_Int32 m_nOccupiedBuffer;
69 class MemFIFO :
70 private MemRingBuffer
72 public:
73 /// @throws css::io::BufferSizeExceededException
74 void write( const Sequence<sal_Int8> &);
75 /// @throws css::io::BufferSizeExceededException
76 void read( Sequence<sal_Int8> & , sal_Int32 nBytesToRead );
77 /// @throws css::io::BufferSizeExceededException
78 void skip( sal_Int32 nBytesToSkip );
79 sal_Int32 getSize() const throw()
80 { return MemRingBuffer::getSize(); }
86 #endif // INCLUDED_IO_SOURCE_STM_STREAMHELPER_HXX
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */