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 .
20 #ifndef INCLUDED_COMPHELPER_STREAMSECTION_HXX
21 #define INCLUDED_COMPHELPER_STREAMSECTION_HXX
23 #include <com/sun/star/io/XMarkableStream.hpp>
24 #include <com/sun/star/io/XDataInputStream.hpp>
25 #include <com/sun/star/io/XDataOutputStream.hpp>
26 #include <comphelper/comphelperdllapi.h>
31 /** implements handling for compatibly reading/writing data from/into an input/output stream.
32 data written in a block secured by this class should be readable by older versions which
33 use the same mechanism.
35 @author Frank Schoenheit
39 class COMPHELPER_DLLPUBLIC OStreamSection
41 css::uno::Reference
< css::io::XMarkableStream
> m_xMarkStream
;
42 css::uno::Reference
< css::io::XDataInputStream
> m_xInStream
;
43 css::uno::Reference
< css::io::XDataOutputStream
> m_xOutStream
;
45 sal_Int32 m_nBlockStart
;
46 sal_Int32 m_nBlockLen
;
49 /** starts reading of a "skippable" section of data within the given input stream<BR>
50 @param _rxInput the stream to read from. Must support the
51 com::sun::star::io::XMarkableStream interface
53 OStreamSection(const css::uno::Reference
< css::io::XDataInputStream
>& _rxInput
);
55 /** starts writing of a "skippable" section of data into the given output stream
56 @param _rxOutput the stream the stream to write to. Must support the
57 com::sun::star::io::XMarkableStream interface
58 @param _nPresumedLength estimation for the length of the upcoming section. If greater 0, this
59 value will be written as section length and corrected (in the dtor) only if
60 needed. If you know how much bytes you are about to write, you may
61 want to use this param, saving some stream operations this way.
63 OStreamSection(const css::uno::Reference
< css::io::XDataOutputStream
>& _rxOutput
, sal_Int32 _nPresumedLength
= 0);
65 /** dtor. <BR>If constructed for writing, the section "opened" by this object will be "closed".<BR>
66 If constructed for reading, any remaining bytes 'til the end of the section will be skipped.
71 } // namespace comphelper
73 #endif // INCLUDED_COMPHELPER_STREAMSECTION_HXX
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */