LibreOffice Module package (master) 1
ByteGrabber.hxx
Go to the documentation of this file.
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
25#include <mutex>
26
27namespace com::sun::star {
28 namespace io { class XSeekable; class XInputStream; }
29}
30class ByteGrabber final
31{
32 std::mutex m_aMutex;
33
34 css::uno::Reference < css::io::XInputStream > xStream;
35 css::uno::Reference < css::io::XSeekable > xSeek;
36 css::uno::Sequence < sal_Int8 > aSequence;
38
39public:
40 ByteGrabber (css::uno::Reference < css::io::XInputStream > const & xIstream);
42
43 void setInputStream (const css::uno::Reference < css::io::XInputStream >& xNewStream);
44 // XInputStream
49 sal_Int32 readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead );
50 // XSeekable
54 void seek( sal_Int64 location );
57 sal_Int64 getPosition( );
60 sal_Int64 getLength( );
61
62 sal_uInt16 ReadUInt16();
63 sal_uInt32 ReadUInt32();
64 sal_Int16 ReadInt16()
65 {
66 return static_cast<sal_Int16>(ReadUInt16());
67 }
68 sal_Int32 ReadInt32()
69 {
70 return static_cast<sal_Int32>(ReadUInt32());
71 }
72};
73
74#endif
75
76/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int64 getLength()
Definition: ByteGrabber.cxx:85
const sal_Int8 * pSequence
Definition: ByteGrabber.hxx:37
std::mutex m_aMutex
Definition: ByteGrabber.hxx:32
void seek(sal_Int64 location)
Definition: ByteGrabber.cxx:67
sal_Int16 ReadInt16()
Definition: ByteGrabber.hxx:64
void setInputStream(const css::uno::Reference< css::io::XInputStream > &xNewStream)
Definition: ByteGrabber.cxx:51
css::uno::Reference< css::io::XInputStream > xStream
Definition: ByteGrabber.hxx:34
ByteGrabber(css::uno::Reference< css::io::XInputStream > const &xIstream)
ByteGrabber implements the >> operators on an XOutputStream.
Definition: ByteGrabber.cxx:39
sal_Int32 ReadInt32()
Definition: ByteGrabber.hxx:68
sal_Int64 getPosition()
Definition: ByteGrabber.cxx:76
sal_Int32 readBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nBytesToRead)
Definition: ByteGrabber.cxx:59
css::uno::Reference< css::io::XSeekable > xSeek
Definition: ByteGrabber.hxx:35
css::uno::Sequence< sal_Int8 > aSequence
Definition: ByteGrabber.hxx:36
sal_uInt32 ReadUInt32()
sal_uInt16 ReadUInt16()
Definition: ByteGrabber.cxx:94
signed char sal_Int8