Branch data Line data Source code
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 : :
20 : : #include <ByteChucker.hxx>
21 : : #include <PackageConstants.hxx>
22 : : #include <com/sun/star/io/XSeekable.hpp>
23 : : #include <com/sun/star/io/XOutputStream.hpp>
24 : :
25 : : using namespace ::com::sun::star::io;
26 : : using namespace ::com::sun::star::uno;
27 : : using namespace ::com::sun::star::lang;
28 : :
29 : 482 : ByteChucker::ByteChucker(Reference<XOutputStream> xOstream)
30 : : : xStream(xOstream)
31 : : , xSeek (xOstream, UNO_QUERY )
32 : : , a1Sequence ( 1 )
33 : : , a2Sequence ( 2 )
34 : : , a4Sequence ( 4 )
35 [ + - ]: 482 : , p1Sequence ( a1Sequence.getArray() )
36 [ + - ]: 482 : , p2Sequence ( a2Sequence.getArray() )
37 [ + - ][ + - ]: 964 : , p4Sequence ( a4Sequence.getArray() )
[ + - ][ + - ]
[ + - ]
38 : : {
39 : 482 : }
40 : :
41 [ + - ][ + - ]: 482 : ByteChucker::~ByteChucker()
[ + - ]
42 : : {
43 : 482 : }
44 : :
45 : 81272 : void ByteChucker::WriteBytes( const Sequence< sal_Int8 >& aData )
46 : : throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
47 : : {
48 : 81272 : xStream->writeBytes(aData);
49 : 81272 : }
50 : :
51 : 3429 : sal_Int64 ByteChucker::GetPosition( )
52 : : throw(IOException, RuntimeException)
53 : : {
54 : 3429 : return xSeek->getPosition();
55 : : }
56 : :
57 : 0 : ByteChucker& ByteChucker::operator << (sal_Int8 nInt8)
58 : : {
59 : 0 : p1Sequence[0] = nInt8 & 0xFF;
60 : 0 : WriteBytes( a1Sequence );
61 : 0 : return *this;
62 : : }
63 : :
64 : 36920 : ByteChucker& ByteChucker::operator << (sal_Int16 nInt16)
65 : : {
66 : 36920 : p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >> 0 ) & 0xFF);
67 : 36920 : p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >> 8 ) & 0xFF);
68 : 36920 : WriteBytes( a2Sequence );
69 : 36920 : return *this;
70 : : }
71 : 26490 : ByteChucker& ByteChucker::operator << (sal_Int32 nInt32)
72 : : {
73 : 26490 : p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >> 0 ) & 0xFF);
74 : 26490 : p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >> 8 ) & 0xFF);
75 : 26490 : p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF);
76 : 26490 : p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF);
77 : 26490 : WriteBytes( a4Sequence );
78 : 26490 : return *this;
79 : : }
80 : :
81 : 0 : ByteChucker& ByteChucker::operator << (sal_uInt8 nuInt8)
82 : : {
83 : 0 : p1Sequence[0] = nuInt8 & 0xFF;
84 : 0 : WriteBytes( a1Sequence );
85 : 0 : return *this;
86 : : }
87 : 0 : ByteChucker& ByteChucker::operator << (sal_uInt16 nuInt16)
88 : : {
89 : 0 : p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >> 0 ) & 0xFF);
90 : 0 : p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >> 8 ) & 0xFF);
91 : 0 : WriteBytes( a2Sequence );
92 : 0 : return *this;
93 : : }
94 : 10824 : ByteChucker& ByteChucker::operator << (sal_uInt32 nuInt32)
95 : : {
96 : 10824 : p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >> 0 ) & 0xFF);
97 : 10824 : p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF);
98 : 10824 : p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF);
99 : 10824 : p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF);
100 : 10824 : WriteBytes( a4Sequence );
101 : 10824 : return *this;
102 : : }
103 : :
104 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|