LCOV - code coverage report
Current view: top level - xpcom/string - nsTSubstringTuple.h (source / functions) Hit Total Coverage
Test: output.info Lines: 12 12 100.0 %
Date: 2017-07-14 16:53:18 Functions: 8 8 100.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             : // IWYU pragma: private, include "nsString.h"
       7             : 
       8             : /**
       9             :  * nsTSubstringTuple_CharT
      10             :  *
      11             :  * Represents a tuple of string fragments.  Built as a recursive binary tree.
      12             :  * It is used to implement the concatenation of two or more string objects.
      13             :  *
      14             :  * NOTE: This class is a private implementation detail and should never be
      15             :  * referenced outside the string code.
      16             :  */
      17             : class nsTSubstringTuple_CharT
      18             : {
      19             : public:
      20             : 
      21             :   typedef CharT                                 char_type;
      22             :   typedef nsCharTraits<char_type>               char_traits;
      23             : 
      24             :   typedef nsTSubstringTuple_CharT               self_type;
      25             :   typedef mozilla::detail::nsTStringRepr_CharT  base_string_type;
      26             :   typedef uint32_t                              size_type;
      27             : 
      28             : public:
      29             : 
      30        3450 :   nsTSubstringTuple_CharT(const base_string_type* aStrA,
      31             :                           const base_string_type* aStrB)
      32        3450 :     : mHead(nullptr)
      33             :     , mFragA(aStrA)
      34        3450 :     , mFragB(aStrB)
      35             :   {
      36        3450 :   }
      37             : 
      38         301 :   nsTSubstringTuple_CharT(const self_type& aHead,
      39             :                           const base_string_type* aStrB)
      40         301 :     : mHead(&aHead)
      41             :     , mFragA(nullptr) // this fragment is ignored when aHead != nullptr
      42         301 :     , mFragB(aStrB)
      43             :   {
      44         301 :   }
      45             : 
      46             :   /**
      47             :    * computes the aggregate string length
      48             :    */
      49             :   size_type Length() const;
      50             : 
      51             :   /**
      52             :    * writes the aggregate string to the given buffer.  bufLen is assumed
      53             :    * to be equal to or greater than the value returned by the Length()
      54             :    * method.  the string written to |buf| is not null-terminated.
      55             :    */
      56             :   void WriteTo(char_type* aBuf, uint32_t aBufLen) const;
      57             : 
      58             :   /**
      59             :    * returns true if this tuple is dependent on (i.e., overlapping with)
      60             :    * the given char sequence.
      61             :    */
      62             :   bool IsDependentOn(const char_type* aStart, const char_type* aEnd) const;
      63             : 
      64             : private:
      65             : 
      66             :   const self_type*        const mHead;
      67             :   const base_string_type* const mFragA;
      68             :   const base_string_type* const mFragB;
      69             : };
      70             : 
      71             : inline const nsTSubstringTuple_CharT
      72        3450 : operator+(const nsTSubstringTuple_CharT::base_string_type& aStrA,
      73             :           const nsTSubstringTuple_CharT::base_string_type& aStrB)
      74             : {
      75        3450 :   return nsTSubstringTuple_CharT(&aStrA, &aStrB);
      76             : }
      77             : 
      78             : inline const nsTSubstringTuple_CharT
      79         301 : operator+(const nsTSubstringTuple_CharT& aHead,
      80             :           const nsTSubstringTuple_CharT::base_string_type& aStrB)
      81             : {
      82         301 :   return nsTSubstringTuple_CharT(aHead, &aStrB);
      83             : }

Generated by: LCOV version 1.13