xpcom/string/public/nsTSubstringTuple.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 //* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6 // IWYU pragma: private, include "nsString.h"
michael@0 7
michael@0 8 /**
michael@0 9 * nsTSubstringTuple_CharT
michael@0 10 *
michael@0 11 * Represents a tuple of string fragments. Built as a recursive binary tree.
michael@0 12 * It is used to implement the concatenation of two or more string objects.
michael@0 13 *
michael@0 14 * NOTE: This class is a private implementation detail and should never be
michael@0 15 * referenced outside the string code.
michael@0 16 */
michael@0 17 class nsTSubstringTuple_CharT
michael@0 18 {
michael@0 19 public:
michael@0 20
michael@0 21 typedef CharT char_type;
michael@0 22 typedef nsCharTraits<char_type> char_traits;
michael@0 23
michael@0 24 typedef nsTSubstringTuple_CharT self_type;
michael@0 25 typedef nsTSubstring_CharT substring_type;
michael@0 26 typedef nsTSubstring_CharT base_string_type;
michael@0 27 typedef uint32_t size_type;
michael@0 28
michael@0 29 public:
michael@0 30
michael@0 31 nsTSubstringTuple_CharT(const base_string_type* a, const base_string_type* b)
michael@0 32 : mHead(nullptr)
michael@0 33 , mFragA(a)
michael@0 34 , mFragB(b) {}
michael@0 35
michael@0 36 nsTSubstringTuple_CharT(const self_type& head, const base_string_type* b)
michael@0 37 : mHead(&head)
michael@0 38 , mFragA(nullptr) // this fragment is ignored when head != nullptr
michael@0 39 , mFragB(b) {}
michael@0 40
michael@0 41 /**
michael@0 42 * computes the aggregate string length
michael@0 43 */
michael@0 44 size_type Length() const;
michael@0 45
michael@0 46 /**
michael@0 47 * writes the aggregate string to the given buffer. bufLen is assumed
michael@0 48 * to be equal to or greater than the value returned by the Length()
michael@0 49 * method. the string written to |buf| is not null-terminated.
michael@0 50 */
michael@0 51 void WriteTo(char_type *buf, uint32_t bufLen) const;
michael@0 52
michael@0 53 /**
michael@0 54 * returns true if this tuple is dependent on (i.e., overlapping with)
michael@0 55 * the given char sequence.
michael@0 56 */
michael@0 57 bool IsDependentOn(const char_type *start, const char_type *end) const;
michael@0 58
michael@0 59 private:
michael@0 60
michael@0 61 const self_type* mHead;
michael@0 62 const base_string_type* mFragA;
michael@0 63 const base_string_type* mFragB;
michael@0 64 };
michael@0 65
michael@0 66 inline
michael@0 67 const nsTSubstringTuple_CharT
michael@0 68 operator+(const nsTSubstringTuple_CharT::base_string_type& a, const nsTSubstringTuple_CharT::base_string_type& b)
michael@0 69 {
michael@0 70 return nsTSubstringTuple_CharT(&a, &b);
michael@0 71 }
michael@0 72
michael@0 73 inline
michael@0 74 const nsTSubstringTuple_CharT
michael@0 75 operator+(const nsTSubstringTuple_CharT& head, const nsTSubstringTuple_CharT::base_string_type& b)
michael@0 76 {
michael@0 77 return nsTSubstringTuple_CharT(head, &b);
michael@0 78 }

mercurial