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: michael@0: /** michael@0: * nsTDependentString_CharT michael@0: * michael@0: * Stores a null-terminated, immutable sequence of characters. michael@0: * michael@0: * Subclass of nsTString that restricts string value to an immutable michael@0: * character sequence. This class does not own its data, so the creator michael@0: * of objects of this type must take care to ensure that a michael@0: * nsTDependentString continues to reference valid memory for the michael@0: * duration of its use. michael@0: */ michael@0: class nsTDependentString_CharT : public nsTString_CharT michael@0: { michael@0: public: michael@0: michael@0: typedef nsTDependentString_CharT self_type; michael@0: michael@0: public: michael@0: michael@0: /** michael@0: * constructors michael@0: */ michael@0: michael@0: nsTDependentString_CharT( const char_type* start, const char_type* end ) michael@0: : string_type(const_cast(start), uint32_t(end - start), F_TERMINATED) michael@0: { michael@0: AssertValidDepedentString(); michael@0: } michael@0: michael@0: nsTDependentString_CharT( const char_type* data, uint32_t length ) michael@0: : string_type(const_cast(data), length, F_TERMINATED) michael@0: { michael@0: AssertValidDepedentString(); michael@0: } michael@0: michael@0: #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER) michael@0: nsTDependentString_CharT( char16ptr_t data, uint32_t length ) michael@0: : nsTDependentString_CharT(static_cast(data), length) {} michael@0: #endif michael@0: michael@0: explicit michael@0: nsTDependentString_CharT( const char_type* data ) michael@0: : string_type(const_cast(data), uint32_t(char_traits::length(data)), F_TERMINATED) michael@0: { michael@0: AssertValidDepedentString(); michael@0: } michael@0: michael@0: #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER) michael@0: explicit michael@0: nsTDependentString_CharT( char16ptr_t data ) michael@0: : nsTDependentString_CharT( static_cast(data)) {} michael@0: #endif michael@0: michael@0: nsTDependentString_CharT( const string_type& str, uint32_t startPos ) michael@0: : string_type() michael@0: { michael@0: Rebind(str, startPos); michael@0: } michael@0: michael@0: // Create a nsTDependentSubstring to be bound later michael@0: nsTDependentString_CharT() michael@0: : string_type() {} michael@0: michael@0: // XXX are you sure?? michael@0: // auto-generated copy-constructor OK michael@0: // auto-generated copy-assignment operator OK michael@0: // auto-generated destructor OK michael@0: michael@0: michael@0: /** michael@0: * allow this class to be bound to a different string... michael@0: */ michael@0: michael@0: using nsTString_CharT::Rebind; michael@0: void Rebind( const char_type* data ) michael@0: { michael@0: Rebind(data, uint32_t(char_traits::length(data))); michael@0: } michael@0: michael@0: void Rebind( const char_type* start, const char_type* end ) michael@0: { michael@0: Rebind(start, uint32_t(end - start)); michael@0: } michael@0: michael@0: void Rebind( const string_type&, uint32_t startPos ); michael@0: michael@0: private: michael@0: michael@0: // NOT USED michael@0: nsTDependentString_CharT( const substring_tuple_type& ); michael@0: };