xpcom/string/public/nsTDependentString.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
     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/. */
     8   /**
     9    * nsTDependentString_CharT
    10    *
    11    * Stores a null-terminated, immutable sequence of characters.
    12    *
    13    * Subclass of nsTString that restricts string value to an immutable
    14    * character sequence.  This class does not own its data, so the creator
    15    * of objects of this type must take care to ensure that a
    16    * nsTDependentString continues to reference valid memory for the
    17    * duration of its use.
    18    */
    19 class nsTDependentString_CharT : public nsTString_CharT
    20   {
    21     public:
    23       typedef nsTDependentString_CharT    self_type;
    25     public:
    27         /**
    28          * constructors
    29          */
    31       nsTDependentString_CharT( const char_type* start, const char_type* end )
    32         : string_type(const_cast<char_type*>(start), uint32_t(end - start), F_TERMINATED)
    33         {
    34           AssertValidDepedentString();
    35         }
    37       nsTDependentString_CharT( const char_type* data, uint32_t length )
    38         : string_type(const_cast<char_type*>(data), length, F_TERMINATED)
    39         {
    40           AssertValidDepedentString();
    41         }
    43 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
    44       nsTDependentString_CharT( char16ptr_t data, uint32_t length )
    45         : nsTDependentString_CharT(static_cast<const char16_t*>(data), length) {}
    46 #endif
    48       explicit
    49       nsTDependentString_CharT( const char_type* data )
    50         : string_type(const_cast<char_type*>(data), uint32_t(char_traits::length(data)), F_TERMINATED)
    51         {
    52           AssertValidDepedentString();
    53         }
    55 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
    56       explicit
    57       nsTDependentString_CharT( char16ptr_t data )
    58         : nsTDependentString_CharT( static_cast<const char16_t*>(data)) {}
    59 #endif
    61       nsTDependentString_CharT( const string_type& str, uint32_t startPos )
    62         : string_type()
    63         {
    64           Rebind(str, startPos);
    65         }
    67       // Create a nsTDependentSubstring to be bound later
    68       nsTDependentString_CharT()
    69         : string_type() {}
    71       // XXX are you sure??
    72       // auto-generated copy-constructor OK
    73       // auto-generated copy-assignment operator OK
    74       // auto-generated destructor OK
    77         /**
    78          * allow this class to be bound to a different string...
    79          */
    81       using nsTString_CharT::Rebind;
    82       void Rebind( const char_type* data )
    83         {
    84           Rebind(data, uint32_t(char_traits::length(data)));
    85         }
    87       void Rebind( const char_type* start, const char_type* end )
    88         {
    89           Rebind(start, uint32_t(end - start));
    90         }
    92       void Rebind( const string_type&, uint32_t startPos );
    94     private:
    96       // NOT USED
    97       nsTDependentString_CharT( const substring_tuple_type& );
    98   };

mercurial