LCOV - code coverage report
Current view: top level - registry/source - regimpl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 12 83.3 %
Date: 2015-06-13 12:38:46 Functions: 5 6 83.3 %
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             : 
      20             : #ifndef INCLUDED_REGISTRY_SOURCE_REGIMPL_HXX
      21             : #define INCLUDED_REGISTRY_SOURCE_REGIMPL_HXX
      22             : 
      23             : #include <set>
      24             : #include <unordered_map>
      25             : 
      26             : #include <registry/registry.h>
      27             : #include <rtl/ustring.hxx>
      28             : #include <osl/mutex.hxx>
      29             : #include <store/store.hxx>
      30             : 
      31             : #define REG_PAGESIZE 512
      32             : 
      33             : #define REG_MODE_CREATE     store_AccessCreate
      34             : #define REG_MODE_OPEN       store_AccessReadWrite
      35             : #define REG_MODE_OPENREAD   store_AccessReadOnly
      36             : 
      37             : #define KEY_MODE_CREATE     store_AccessCreate
      38             : #define KEY_MODE_OPEN       store_AccessReadWrite
      39             : #define KEY_MODE_OPENREAD   store_AccessReadOnly
      40             : 
      41             : 
      42             : #define VALUE_MODE_CREATE   store_AccessCreate
      43             : #define VALUE_MODE_OPEN     store_AccessReadWrite
      44             : #define VALUE_MODE_OPENREAD store_AccessReadOnly
      45             : 
      46             : // 5 bytes = 1 (byte for the type) + 4 (bytes for the size of the data)
      47             : #define VALUE_HEADERSIZE    5
      48             : #define VALUE_TYPEOFFSET    1
      49             : #define VALUE_HEADEROFFSET  5
      50             : 
      51             : #define REG_GUARD(mutex) \
      52             :     osl::Guard< osl::Mutex > aGuard( mutex );
      53             : 
      54             : class ORegKey;
      55             : class RegistryTypeReader;
      56             : 
      57             : class ORegistry
      58             : {
      59             : public:
      60             :     ORegistry();
      61             : 
      62         788 :     sal_uInt32  acquire()
      63         788 :         { return ++m_refCount; }
      64             : 
      65         928 :     sal_uInt32  release()
      66         928 :         { return --m_refCount; }
      67             : 
      68             :     RegError    initRegistry(const OUString& name,
      69             :                              RegAccessMode accessMode,
      70             :                              bool bCreate = false);
      71             : 
      72             :     RegError    closeRegistry();
      73             : 
      74             :     RegError    destroyRegistry(const OUString& name);
      75             : 
      76             :     RegError    acquireKey(RegKeyHandle hKey);
      77             :     RegError    releaseKey(RegKeyHandle hKey);
      78             : 
      79             :     RegError    createKey(RegKeyHandle hKey,
      80             :                           const OUString& keyName,
      81             :                           RegKeyHandle* phNewKey);
      82             : 
      83             :     RegError    openKey(RegKeyHandle hKey,
      84             :                         const OUString& keyName,
      85             :                         RegKeyHandle* phOpenKey);
      86             : 
      87             :     RegError    closeKey(RegKeyHandle hKey);
      88             : 
      89             :     RegError    deleteKey(RegKeyHandle hKey, const OUString& keyName);
      90             : 
      91             :     RegError    loadKey(RegKeyHandle hKey,
      92             :                         const OUString& regFileName,
      93             :                         bool bWarings=false,
      94             :                         bool bReport=false);
      95             : 
      96             :     RegError    saveKey(RegKeyHandle hKey,
      97             :                         const OUString& regFileName,
      98             :                         bool bWarings=false,
      99             :                         bool bReport=false);
     100             : 
     101             :     RegError    dumpRegistry(RegKeyHandle hKey) const;
     102             : 
     103             :     ~ORegistry();
     104             : 
     105        1288 :     bool            isReadOnly() const
     106        1288 :         { return m_readOnly; }
     107             : 
     108         300 :     bool            isOpen() const
     109         300 :         { return m_isOpen; }
     110             : 
     111             :     ORegKey*    getRootKey();
     112             : 
     113        1191 :     const store::OStoreFile& getStoreFile() const
     114        1191 :         { return m_file; }
     115             : 
     116           0 :     const OUString&    getName() const
     117           0 :         { return m_name; }
     118             : 
     119             :     friend class ORegKey;
     120             : 
     121             : private:
     122             :     RegError    eraseKey(ORegKey* pKey, const OUString& keyName);
     123             : 
     124             :     RegError    deleteSubkeysAndValues(ORegKey* pKey);
     125             : 
     126             :     RegError    loadAndSaveValue(ORegKey* pTargetKey,
     127             :                                  ORegKey* pSourceKey,
     128             :                                  const OUString& valueName,
     129             :                                  sal_uInt32 nCut,
     130             :                                  bool bWarnings=false,
     131             :                                  bool bReport=false);
     132             : 
     133             :     static RegError checkBlop(store::OStoreStream& rValue,
     134             :                           const OUString& sTargetPath,
     135             :                           sal_uInt32 srcValueSize,
     136             :                           sal_uInt8* pSrcBuffer,
     137             :                           bool bReport=false);
     138             : 
     139             :     static RegError mergeModuleValue(store::OStoreStream& rTargetValue,
     140             :                                  RegistryTypeReader& reader,
     141             :                                  RegistryTypeReader& reader2);
     142             : 
     143             :     RegError    loadAndSaveKeys(ORegKey* pTargetKey,
     144             :                                 ORegKey* pSourceKey,
     145             :                                 const OUString& keyName,
     146             :                                 sal_uInt32 nCut,
     147             :                                 bool bWarnings=false,
     148             :                                 bool bReport=false);
     149             : 
     150             :     RegError    dumpValue(const OUString& sPath,
     151             :                           const OUString& sName,
     152             :                           sal_Int16 nSpace) const;
     153             : 
     154             :     RegError    dumpKey(const OUString& sPath,
     155             :                         const OUString& sName,
     156             :                         sal_Int16 nSpace) const;
     157             : 
     158             :     typedef std::unordered_map< OUString, ORegKey*, OUStringHash > KeyMap;
     159             : 
     160             :     sal_uInt32      m_refCount;
     161             :     osl::Mutex          m_mutex;
     162             :     bool            m_readOnly;
     163             :     bool            m_isOpen;
     164             :     OUString       m_name;
     165             :     store::OStoreFile   m_file;
     166             :     KeyMap          m_openKeyTable;
     167             : 
     168             :     const OUString ROOT;
     169             : };
     170             : 
     171             : #endif
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11