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"
9 * nsTSubstringTuple_CharT
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.
14 * NOTE: This class is a private implementation detail and should never be
15 * referenced outside the string code.
17 class nsTSubstringTuple_CharT
21 typedef CharT char_type
;
22 typedef nsCharTraits
<char_type
> char_traits
;
24 typedef nsTSubstringTuple_CharT self_type
;
25 typedef nsTSubstring_CharT substring_type
;
26 typedef nsTSubstring_CharT base_string_type
;
27 typedef uint32_t size_type
;
31 nsTSubstringTuple_CharT(const base_string_type
* aStrA
,
32 const base_string_type
* aStrB
)
39 nsTSubstringTuple_CharT(const self_type
& aHead
,
40 const base_string_type
* aStrB
)
42 , mFragA(nullptr) // this fragment is ignored when aHead != nullptr
48 * computes the aggregate string length
50 size_type
Length() const;
53 * writes the aggregate string to the given buffer. bufLen is assumed
54 * to be equal to or greater than the value returned by the Length()
55 * method. the string written to |buf| is not null-terminated.
57 void WriteTo(char_type
* aBuf
, uint32_t aBufLen
) const;
60 * returns true if this tuple is dependent on (i.e., overlapping with)
61 * the given char sequence.
63 bool IsDependentOn(const char_type
* aStart
, const char_type
* aEnd
) const;
67 const self_type
* mHead
;
68 const base_string_type
* mFragA
;
69 const base_string_type
* mFragB
;
72 inline const nsTSubstringTuple_CharT
73 operator+(const nsTSubstringTuple_CharT::base_string_type
& aStrA
,
74 const nsTSubstringTuple_CharT::base_string_type
& aStrB
)
76 return nsTSubstringTuple_CharT(&aStrA
, &aStrB
);
79 inline const nsTSubstringTuple_CharT
80 operator+(const nsTSubstringTuple_CharT
& aHead
,
81 const nsTSubstringTuple_CharT::base_string_type
& aStrB
)
83 return nsTSubstringTuple_CharT(aHead
, &aStrB
);