1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include <limits>
25
26 #include <osl/diagnose.h>
27 #include <vos/object.hxx>
28 #include <vos/stream.hxx>
29
30 using namespace vos;
31
32 /////////////////////////////////////////////////////////////////////////////
33 //
34 // Stream class
35 //
36
37 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OStream, vos), VOS_NAMESPACE(OStream, vos), VOS_NAMESPACE(OObject, vos), 0);
38
OStream(IPositionableStream & rStream)39 OStream::OStream(IPositionableStream& rStream)
40 : m_rStream(rStream)
41 {
42 }
43
~OStream()44 OStream::~OStream()
45 {
46 }
47
read(void * pbuffer,sal_uInt32 n) const48 sal_Int32 OStream::read(void* pbuffer, sal_uInt32 n) const
49 {
50 return (m_rStream.read(pbuffer, n));
51 }
52
read(IPositionableStream::Offset offset,void * pbuffer,sal_uInt32 n) const53 sal_Int32 OStream::read(IPositionableStream::Offset offset,
54 void* pbuffer, sal_uInt32 n) const
55 {
56 return (seekTo(offset) ? read(pbuffer, n) : -1);
57 }
58
write(const void * pbuffer,sal_uInt32 n)59 sal_Int32 OStream::write(const void* pbuffer, sal_uInt32 n)
60 {
61 return
62 n <= static_cast< sal_uInt32 >(std::numeric_limits< sal_Int32 >::max())
63 && (m_rStream.write(pbuffer, n) == static_cast< sal_Int32 >(n));
64 }
65
write(IPositionableStream::Offset offset,const void * pbuffer,sal_uInt32 n)66 sal_Int32 OStream::write(IPositionableStream::Offset offset,
67 const void* pbuffer, sal_uInt32 n)
68 {
69 return (seekTo(offset) && write(pbuffer, n));
70 }
71
append(void * pbuffer,sal_uInt32 n)72 sal_Bool OStream::append(void* pbuffer, sal_uInt32 n)
73 {
74 return (seekToEnd() && write(pbuffer, n));
75 }
76
seekTo(IPositionableStream::Offset pos) const77 sal_Bool OStream::seekTo(IPositionableStream::Offset pos) const
78 {
79 return (m_rStream.seekTo(pos));
80 }
81
seekToEnd() const82 sal_Bool OStream::seekToEnd() const
83 {
84 return (m_rStream.seekToEnd());
85 }
86
seekRelative(sal_Int32 change) const87 sal_Bool OStream::seekRelative(sal_Int32 change) const
88 {
89 return (m_rStream.seekRelative(change));
90 }
91
changeSize(sal_uInt32 new_size)92 sal_Bool OStream::changeSize(sal_uInt32 new_size)
93 {
94 return (m_rStream.changeSize(new_size));
95 }
96
getSize() const97 sal_uInt32 OStream::getSize() const
98 {
99 return (m_rStream.getSize());
100 }
101
isEof() const102 sal_Bool OStream::isEof() const
103 {
104 return (m_rStream.isEof());
105 }
106
getOffset() const107 IPositionableStream::Offset OStream::getOffset() const
108 {
109 return (m_rStream.getOffset());
110 }
111
112