LCOV - code coverage report
Current view: top level - dom/commandhandler - nsCommandParams.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 46 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef nsCommandParams_h__
       8             : #define nsCommandParams_h__
       9             : 
      10             : #include "nsString.h"
      11             : #include "nsICommandParams.h"
      12             : #include "nsCOMPtr.h"
      13             : #include "PLDHashTable.h"
      14             : 
      15             : class nsCommandParams : public nsICommandParams
      16             : {
      17             : public:
      18             :   nsCommandParams();
      19             : 
      20             :   NS_DECL_ISUPPORTS
      21             :   NS_DECL_NSICOMMANDPARAMS
      22             : 
      23             : protected:
      24             :   virtual ~nsCommandParams();
      25             : 
      26             :   struct HashEntry : public PLDHashEntryHdr
      27             :   {
      28             :     nsCString mEntryName;
      29             : 
      30             :     uint8_t mEntryType;
      31             :     union
      32             :     {
      33             :       bool mBoolean;
      34             :       int32_t mLong;
      35             :       double mDouble;
      36             :       nsString* mString;
      37             :       nsCString* mCString;
      38             :     } mData;
      39             : 
      40             :     nsCOMPtr<nsISupports> mISupports;
      41             : 
      42           0 :     HashEntry(uint8_t aType, const char* aEntryName)
      43           0 :       : mEntryName(aEntryName)
      44           0 :       , mEntryType(aType)
      45             :     {
      46           0 :       Reset(mEntryType);
      47           0 :     }
      48             : 
      49           0 :     HashEntry(const HashEntry& aRHS)
      50           0 :       : mEntryType(aRHS.mEntryType)
      51             :     {
      52           0 :       Reset(mEntryType);
      53           0 :       switch (mEntryType) {
      54             :         case eBooleanType:
      55           0 :           mData.mBoolean = aRHS.mData.mBoolean;
      56           0 :           break;
      57             :         case eLongType:
      58           0 :           mData.mLong = aRHS.mData.mLong;
      59           0 :           break;
      60             :         case eDoubleType:
      61           0 :           mData.mDouble = aRHS.mData.mDouble;
      62           0 :           break;
      63             :         case eWStringType:
      64           0 :           NS_ASSERTION(aRHS.mData.mString, "Source entry has no string");
      65           0 :           mData.mString = new nsString(*aRHS.mData.mString);
      66           0 :           break;
      67             :         case eStringType:
      68           0 :           NS_ASSERTION(aRHS.mData.mCString, "Source entry has no string");
      69           0 :           mData.mCString = new nsCString(*aRHS.mData.mCString);
      70           0 :           break;
      71             :         case eISupportsType:
      72           0 :           mISupports = aRHS.mISupports.get();
      73           0 :           break;
      74             :         default:
      75           0 :           NS_ERROR("Unknown type");
      76             :       }
      77           0 :     }
      78             : 
      79           0 :     ~HashEntry() { Reset(eNoType); }
      80             : 
      81           0 :     void Reset(uint8_t aNewType)
      82             :     {
      83           0 :       switch (mEntryType) {
      84             :         case eNoType:
      85           0 :           break;
      86             :         case eBooleanType:
      87           0 :           mData.mBoolean = false;
      88           0 :           break;
      89             :         case eLongType:
      90           0 :           mData.mLong = 0;
      91           0 :           break;
      92             :         case eDoubleType:
      93           0 :           mData.mDouble = 0.0;
      94           0 :           break;
      95             :         case eWStringType:
      96           0 :           delete mData.mString;
      97           0 :           mData.mString = nullptr;
      98           0 :           break;
      99             :         case eISupportsType:
     100           0 :           mISupports = nullptr;
     101           0 :           break;
     102             :         case eStringType:
     103           0 :           delete mData.mCString;
     104           0 :           mData.mCString = nullptr;
     105           0 :           break;
     106             :         default:
     107           0 :           NS_ERROR("Unknown type");
     108             :       }
     109           0 :       mEntryType = aNewType;
     110           0 :     }
     111             :   };
     112             : 
     113             :   HashEntry* GetNamedEntry(const char* aName);
     114             :   HashEntry* GetOrMakeEntry(const char* aName, uint8_t aEntryType);
     115             : 
     116             : protected:
     117             :   static PLDHashNumber HashKey(const void* aKey);
     118             : 
     119             :   static bool HashMatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey);
     120             : 
     121             :   static void HashMoveEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom,
     122             :                             PLDHashEntryHdr* aTo);
     123             : 
     124             :   static void HashClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
     125             : 
     126             :   PLDHashTable mValuesHash;
     127             : 
     128             :   static const PLDHashTableOps sHashOps;
     129             : };
     130             : 
     131             : #endif // nsCommandParams_h__

Generated by: LCOV version 1.13