1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stream.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <osl/diagnose.h>
34 #include <vos/object.hxx>
35 #include <vos/stream.hxx>
39 /////////////////////////////////////////////////////////////////////////////
44 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OStream
, vos
), VOS_NAMESPACE(OStream
, vos
), VOS_NAMESPACE(OObject
, vos
), 0);
46 OStream::OStream(IPositionableStream
& rStream
)
55 sal_Int32
OStream::read(void* pbuffer
, sal_uInt32 n
) const
57 return (m_rStream
.read(pbuffer
, n
));
60 sal_Int32
OStream::read(IPositionableStream::Offset offset
,
61 void* pbuffer
, sal_uInt32 n
) const
63 return (seekTo(offset
) ? read(pbuffer
, n
) : -1);
66 sal_Int32
OStream::write(const void* pbuffer
, sal_uInt32 n
)
69 n
<= static_cast< sal_uInt32
>(std::numeric_limits
< sal_Int32
>::max())
70 && (m_rStream
.write(pbuffer
, n
) == static_cast< sal_Int32
>(n
));
73 sal_Int32
OStream::write(IPositionableStream::Offset offset
,
74 const void* pbuffer
, sal_uInt32 n
)
76 return (seekTo(offset
) && write(pbuffer
, n
));
79 sal_Bool
OStream::append(void* pbuffer
, sal_uInt32 n
)
81 return (seekToEnd() && write(pbuffer
, n
));
84 sal_Bool
OStream::seekTo(IPositionableStream::Offset pos
) const
86 return (m_rStream
.seekTo(pos
));
89 sal_Bool
OStream::seekToEnd() const
91 return (m_rStream
.seekToEnd());
94 sal_Bool
OStream::seekRelative(sal_Int32 change
) const
96 return (m_rStream
.seekRelative(change
));
99 sal_Bool
OStream::changeSize(sal_uInt32 new_size
)
101 return (m_rStream
.changeSize(new_size
));
104 sal_uInt32
OStream::getSize() const
106 return (m_rStream
.getSize());
109 sal_Bool
OStream::isEof() const
111 return (m_rStream
.isEof());
114 IPositionableStream::Offset
OStream::getOffset() const
116 return (m_rStream
.getOffset());