LCOV - code coverage report
Current view: top level - xmlhelp/source/cxxhelp/inc/util - Decompressor.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 5 0.0 %
Date: 2014-11-03 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          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             : #ifndef INCLUDED_XMLHELP_SOURCE_CXXHELP_INC_UTIL_DECOMPRESSOR_HXX
      20             : #define INCLUDED_XMLHELP_SOURCE_CXXHELP_INC_UTIL_DECOMPRESSOR_HXX
      21             : 
      22             : #include <vector>
      23             : #include <excep/XmlSearchExceptions.hxx>
      24             : #include <util/RandomAccessStream.hxx>
      25             : 
      26             : namespace xmlsearch {
      27             : 
      28             :     namespace util {
      29             : 
      30             : 
      31             :         class Decompressor
      32             :         {
      33             :         public:
      34             : 
      35             :             Decompressor()
      36             :                 : toRead_( 0 )
      37             :             {
      38             :             }
      39             : 
      40           0 :             virtual ~Decompressor() { }
      41             : 
      42             :             virtual sal_Int32 getNextByte() = 0;
      43             : 
      44           0 :             virtual void initReading()
      45             :             {
      46           0 :                 toRead_ = 0;
      47           0 :             }
      48             : 
      49             :         private:
      50             : 
      51             :             static const sal_Int32 BitsInByte;
      52             :             static const sal_Int32 NBits;
      53             : 
      54             :             sal_Int32 toRead_;
      55             :         };
      56             : 
      57             : 
      58             : 
      59             : 
      60             :         class StreamDecompressor
      61             :             : public Decompressor
      62             :         {
      63             :         public:
      64             : 
      65             :             StreamDecompressor( RandomAccessStream* in )
      66             :                 : in_( in )
      67             :             {
      68             :             }
      69             : 
      70           0 :             virtual ~StreamDecompressor() { }
      71             : 
      72             : 
      73             :             virtual sal_Int32 getNextByte() SAL_OVERRIDE;
      74             : 
      75             :         private:
      76             : 
      77             :             RandomAccessStream* in_;
      78             : 
      79             :         };
      80             : 
      81             : 
      82             : 
      83             :         class ByteArrayDecompressor
      84             :             : public Decompressor
      85             :         {
      86             :         public:
      87             : 
      88             :             ByteArrayDecompressor( sal_Int32 arrayL,sal_Int8* array,sal_Int32 index )
      89             :             {
      90             :                 initReading(array,arrayL,index);
      91             :             }
      92             : 
      93             : 
      94             :             virtual ~ByteArrayDecompressor() { }
      95             : 
      96             :             sal_Int32 bytesRead()
      97             :             {
      98             :                 return index_ - index0_;
      99             :             }
     100             : 
     101             : 
     102             :             sal_Int32 getNextByte() throw( xmlsearch::excep::XmlSearchException ) SAL_OVERRIDE
     103             :             {
     104             :                 if( arrayL_ <= index_ )
     105             :                     throw  xmlsearch::excep::XmlSearchException(
     106             :                         OUString( "ByteArrayDecompressor->getNextByte()" ) );
     107             :                 return array_[index_++] & 0xFF;
     108             :             }
     109             : 
     110             : 
     111             :         private:
     112             : 
     113             :             sal_Int32  arrayL_;
     114             :             sal_Int8   *array_;
     115             : 
     116             :             sal_Int32  index_,index0_;
     117             : 
     118             :             using xmlsearch::util::Decompressor::initReading;
     119             :             void initReading( sal_Int8* array,sal_Int32 arrayL,sal_Int32 index )
     120             :             {
     121             :                 arrayL_ = arrayL;
     122             :                 array_ = array;
     123             :                 index_ = index0_ = index;
     124             :                 Decompressor::initReading();
     125             :             }
     126             : 
     127             :         };
     128             : 
     129             : 
     130             :     }
     131             : 
     132             : }
     133             : 
     134             : 
     135             : #endif
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10