Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/package/inc/ByteGrabber.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
#ifndef INCLUDED_PACKAGE_INC_BYTEGRABBER_HXX
20
#define INCLUDED_PACKAGE_INC_BYTEGRABBER_HXX
21
22
#include <com/sun/star/uno/Sequence.h>
23
#include <com/sun/star/uno/Reference.h>
24
#include <comphelper/bytereader.hxx>
25
#include <array>
26
27
namespace com::sun::star {
28
    namespace io { class XSeekable; class XInputStream; }
29
}
30
class ByteGrabber final
31
{
32
    css::uno::Reference < css::io::XInputStream > xStream;
33
    css::uno::Reference < css::io::XSeekable > xSeek;
34
    comphelper::ByteReader* mpByteReader;
35
    std::array<sal_Int8, 8> maBuffer;
36
    css::uno::Sequence < sal_Int8 > aSequence;
37
38
public:
39
    ByteGrabber (css::uno::Reference < css::io::XInputStream > const & xIstream);
40
    ~ByteGrabber();
41
42
    void setInputStream (const css::uno::Reference < css::io::XInputStream >& xNewStream);
43
    // XInputStream
44
    /// @throws css::io::NotConnectedException
45
    /// @throws css::io::BufferSizeExceededException
46
    /// @throws css::io::IOException
47
    /// @throws css::uno::RuntimeException
48
    sal_Int32 readBytes( sal_Int8* aData, sal_Int32 nBytesToRead );
49
    // XSeekable
50
    /// @throws css::lang::IllegalArgumentException
51
    /// @throws css::io::IOException
52
    /// @throws css::uno::RuntimeException
53
    void seek( sal_Int64 location );
54
    /// @throws css::io::IOException
55
    /// @throws css::uno::RuntimeException
56
    sal_Int64 getPosition(  );
57
    /// @throws css::io::IOException
58
    /// @throws css::uno::RuntimeException
59
    sal_Int64 getLength(  );
60
61
    sal_uInt16 ReadUInt16();
62
    sal_uInt32 ReadUInt32();
63
    sal_uInt64 ReadUInt64();
64
    sal_Int16 ReadInt16()
65
0
    {
66
0
        return static_cast<sal_Int16>(ReadUInt16());
67
0
    }
68
    sal_Int32 ReadInt32()
69
0
    {
70
0
        return static_cast<sal_Int32>(ReadUInt32());
71
0
    }
72
};
73
74
#endif
75
76
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */