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: michael@0: void michael@0: nsTDependentSubstring_CharT::Rebind( const substring_type& str, uint32_t startPos, uint32_t length ) michael@0: { michael@0: // If we currently own a buffer, release it. michael@0: Finalize(); michael@0: michael@0: size_type strLength = str.Length(); michael@0: michael@0: if (startPos > strLength) michael@0: startPos = strLength; michael@0: michael@0: mData = const_cast(static_cast(str.Data())) + startPos; michael@0: mLength = XPCOM_MIN(length, strLength - startPos); michael@0: michael@0: SetDataFlags(F_NONE); michael@0: } michael@0: michael@0: void michael@0: nsTDependentSubstring_CharT::Rebind( const char_type* data, size_type length ) michael@0: { michael@0: NS_ASSERTION(data, "nsTDependentSubstring must wrap a non-NULL buffer"); michael@0: michael@0: // If we currently own a buffer, release it. michael@0: Finalize(); michael@0: michael@0: mData = const_cast(static_cast(data)); michael@0: mLength = length; michael@0: SetDataFlags(F_NONE); michael@0: }