michael@0: //* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: // IWYU pragma: private, include "nsString.h" michael@0: michael@0: /** michael@0: * nsTSubstringTuple_CharT michael@0: * michael@0: * Represents a tuple of string fragments. Built as a recursive binary tree. michael@0: * It is used to implement the concatenation of two or more string objects. michael@0: * michael@0: * NOTE: This class is a private implementation detail and should never be michael@0: * referenced outside the string code. michael@0: */ michael@0: class nsTSubstringTuple_CharT michael@0: { michael@0: public: michael@0: michael@0: typedef CharT char_type; michael@0: typedef nsCharTraits char_traits; michael@0: michael@0: typedef nsTSubstringTuple_CharT self_type; michael@0: typedef nsTSubstring_CharT substring_type; michael@0: typedef nsTSubstring_CharT base_string_type; michael@0: typedef uint32_t size_type; michael@0: michael@0: public: michael@0: michael@0: nsTSubstringTuple_CharT(const base_string_type* a, const base_string_type* b) michael@0: : mHead(nullptr) michael@0: , mFragA(a) michael@0: , mFragB(b) {} michael@0: michael@0: nsTSubstringTuple_CharT(const self_type& head, const base_string_type* b) michael@0: : mHead(&head) michael@0: , mFragA(nullptr) // this fragment is ignored when head != nullptr michael@0: , mFragB(b) {} michael@0: michael@0: /** michael@0: * computes the aggregate string length michael@0: */ michael@0: size_type Length() const; michael@0: michael@0: /** michael@0: * writes the aggregate string to the given buffer. bufLen is assumed michael@0: * to be equal to or greater than the value returned by the Length() michael@0: * method. the string written to |buf| is not null-terminated. michael@0: */ michael@0: void WriteTo(char_type *buf, uint32_t bufLen) const; michael@0: michael@0: /** michael@0: * returns true if this tuple is dependent on (i.e., overlapping with) michael@0: * the given char sequence. michael@0: */ michael@0: bool IsDependentOn(const char_type *start, const char_type *end) const; michael@0: michael@0: private: michael@0: michael@0: const self_type* mHead; michael@0: const base_string_type* mFragA; michael@0: const base_string_type* mFragB; michael@0: }; michael@0: michael@0: inline michael@0: const nsTSubstringTuple_CharT michael@0: operator+(const nsTSubstringTuple_CharT::base_string_type& a, const nsTSubstringTuple_CharT::base_string_type& b) michael@0: { michael@0: return nsTSubstringTuple_CharT(&a, &b); michael@0: } michael@0: michael@0: inline michael@0: const nsTSubstringTuple_CharT michael@0: operator+(const nsTSubstringTuple_CharT& head, const nsTSubstringTuple_CharT::base_string_type& b) michael@0: { michael@0: return nsTSubstringTuple_CharT(head, &b); michael@0: }