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: Decompressor.hxx,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 ************************************************************************/
30 #ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
31 #define _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
33 #ifndef INCLUDED_STL_VECTOR
35 #define INCLUDED_STL_VECTOR
37 #include <excep/XmlSearchExceptions.hxx>
38 #include <util/RandomAccessStream.hxx>
46 class CompressorIterator
;
59 virtual ~Decompressor() { }
61 virtual sal_Int32
getNextByte() = 0;
63 virtual void initReading()
70 static const sal_Int32 BitsInByte
;
71 static const sal_Int32 NBits
;
73 sal_Int32 readByte_
, toRead_
, path_
;
79 class StreamDecompressor
84 StreamDecompressor( RandomAccessStream
* in
)
89 ~StreamDecompressor() { }
92 virtual sal_Int32
getNextByte();
96 RandomAccessStream
* in_
;
102 class ByteArrayDecompressor
103 : public Decompressor
107 ByteArrayDecompressor( sal_Int32 arrayL
,sal_Int8
* array
,sal_Int32 index
)
109 initReading(array
,arrayL
,index
);
113 ~ByteArrayDecompressor() { }
115 sal_Int32
bytesRead()
117 return index_
- index0_
;
121 sal_Int32
getNextByte() throw( xmlsearch::excep::XmlSearchException
)
123 if( arrayL_
<= index_
)
124 throw xmlsearch::excep::XmlSearchException(
125 rtl::OUString::createFromAscii( "ByteArrayDecompressor->getNextByte()" ) );
126 return array_
[index_
++] & 0xFF;
135 sal_Int32 index_
,index0_
;
137 using xmlsearch::util::Decompressor::initReading
;
138 void initReading( sal_Int8
* array
,sal_Int32 arrayL
,sal_Int32 index
)
142 index_
= index0_
= index
;
143 Decompressor::initReading();