use insert function instead of for loop
[LibreOffice.git] / include / oox / ole / vbainputstream.hxx
blob4f2f78d8155926f03ec6ffc65d962dcab1e9569d
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_OOX_OLE_VBAINPUTSTREAM_HXX
21 #define INCLUDED_OOX_OLE_VBAINPUTSTREAM_HXX
23 #include <cstddef>
24 #include <vector>
26 #include <oox/helper/binaryinputstream.hxx>
27 #include <oox/helper/binarystreambase.hxx>
28 #include <sal/types.h>
30 namespace oox::ole {
33 /** A non-seekable input stream that implements run-length decompression. */
34 class VbaInputStream final : public BinaryInputStream
36 public:
37 explicit VbaInputStream( BinaryInputStream& rInStrm );
39 /** Returns -1, stream size is not determinable. */
40 virtual sal_Int64 size() const override;
41 /** Returns -1, stream position is not tracked. */
42 virtual sal_Int64 tell() const override;
43 /** Does nothing, stream is not seekable. */
44 virtual void seek( sal_Int64 nPos ) override;
45 /** Closes the input stream but not the wrapped stream. */
46 virtual void close() override;
48 /** Reads nBytes bytes to the passed sequence.
49 @return Number of bytes really read. */
50 virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
51 /** Reads nBytes bytes to the (existing) buffer opMem.
52 @return Number of bytes really read. */
53 virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
54 /** Seeks the stream forward by the passed number of bytes. */
55 virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
57 private:
58 /** If no data left in chunk buffer, reads the next chunk from stream. */
59 bool updateChunk();
61 private:
62 typedef ::std::vector< sal_uInt8 > ChunkBuffer;
64 BinaryInputStream* mpInStrm;
65 ChunkBuffer maChunk;
66 size_t mnChunkPos;
70 } // namespace oox::ole
72 #endif
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */