LCOV - code coverage report
Current view: top level - xmlhelp/source/cxxhelp/provider - db.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 16 31.2 %
Date: 2014-11-03 Functions: 2 8 25.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_PROVIDER_DB_HXX
      20             : #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_DB_HXX
      21             : 
      22             : #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
      23             : 
      24             : #include <boost/unordered_map.hpp>
      25             : #include <rtl/string.hxx>
      26             : 
      27             : namespace helpdatafileproxy {
      28             : 
      29             :     namespace hdf_internal
      30             :     {
      31             :         class Noncopyable
      32             :         {
      33             :             // not implemented
      34             :             Noncopyable(const Noncopyable&);
      35             :             void operator=(const Noncopyable&);
      36             :         protected:
      37           0 :             Noncopyable() {}
      38           0 :             ~Noncopyable() {}
      39             :         };
      40             :     }
      41             : 
      42             :     class HDFData
      43             :     {
      44             :         friend class        Hdf;
      45             : 
      46             :         int                 m_nSize;
      47             :         char*               m_pBuffer;
      48             : 
      49             :         void copyToBuffer( const char* pSrcData, int nSize );
      50             : 
      51             :     public:
      52        5122 :         HDFData( void )
      53             :             : m_nSize( 0 )
      54        5122 :             , m_pBuffer( NULL )
      55        5122 :         {}
      56        5122 :         ~HDFData()
      57        5122 :             { delete [] m_pBuffer; }
      58             : 
      59           0 :           int getSize() const
      60           0 :             { return m_nSize; }
      61           0 :           const char* getData() const
      62           0 :             { return m_pBuffer; }
      63             :     };
      64             : 
      65             :     typedef boost::unordered_map< OString,std::pair<int,int>,OStringHash >   StringToValPosMap;
      66             :     typedef boost::unordered_map< OString,OString,OStringHash >     StringToDataMap;
      67             : 
      68             :     class Hdf : hdf_internal::Noncopyable
      69             :     {
      70             :         OUString       m_aFileURL;
      71             :         StringToDataMap*    m_pStringToDataMap;
      72             :         StringToValPosMap*  m_pStringToValPosMap;
      73             :         com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 >
      74             :                             m_xSFA;
      75             : 
      76             :         com::sun::star::uno::Sequence< sal_Int8 >
      77             :                             m_aItData;
      78             :         const char*         m_pItData;
      79             :         int                 m_nItRead;
      80             :         int                 m_iItPos;
      81             : 
      82             :         bool implReadLenAndData( const char* pData, int& riPos, HDFData& rValue );
      83             : 
      84             :     public:
      85             :         //HDFHelp must get a fileURL which can then directly be used by simple file access.
      86             :         //SimpleFileAccess requires file URLs as arguments. Passing file path may work but fails
      87             :         //for example when using long file paths on Windows, which start with "\\?\"
      88           0 :         Hdf( const OUString& rFileURL,
      89             :             com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 > xSFA )
      90             :                 : m_aFileURL( rFileURL )
      91             :                 , m_pStringToDataMap( NULL )
      92             :                 , m_pStringToValPosMap( NULL )
      93             :                 , m_xSFA( xSFA )
      94             :                 , m_pItData( NULL )
      95             :                 , m_nItRead( -1 )
      96           0 :                 , m_iItPos( -1 )
      97             :         {
      98             :             OSL_ASSERT(rFileURL.startsWith("file:"));
      99           0 :         }
     100           0 :         ~Hdf()
     101           0 :             { releaseHashMap(); }
     102             : 
     103             :         void createHashMap( bool bOptimizeForPerformance = false );
     104             :         void releaseHashMap( void );
     105             : 
     106             :         bool getValueForKey( const OString& rKey, HDFData& rValue );
     107             : 
     108             :         bool startIteration( void );
     109             :         bool getNextKeyAndValue( HDFData& rKey, HDFData& rValue );
     110             :         void stopIteration( void );
     111             :     };
     112             : }
     113             : 
     114             : #endif
     115             : 
     116             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10