xpcom/string/public/nsTDependentString.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/string/public/nsTDependentString.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,98 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +
    1.11 +  /**
    1.12 +   * nsTDependentString_CharT
    1.13 +   *
    1.14 +   * Stores a null-terminated, immutable sequence of characters.
    1.15 +   *
    1.16 +   * Subclass of nsTString that restricts string value to an immutable
    1.17 +   * character sequence.  This class does not own its data, so the creator
    1.18 +   * of objects of this type must take care to ensure that a
    1.19 +   * nsTDependentString continues to reference valid memory for the
    1.20 +   * duration of its use.
    1.21 +   */
    1.22 +class nsTDependentString_CharT : public nsTString_CharT
    1.23 +  {
    1.24 +    public:
    1.25 +
    1.26 +      typedef nsTDependentString_CharT    self_type;
    1.27 +
    1.28 +    public:
    1.29 +
    1.30 +        /**
    1.31 +         * constructors
    1.32 +         */
    1.33 +
    1.34 +      nsTDependentString_CharT( const char_type* start, const char_type* end )
    1.35 +        : string_type(const_cast<char_type*>(start), uint32_t(end - start), F_TERMINATED)
    1.36 +        {
    1.37 +          AssertValidDepedentString();
    1.38 +        }
    1.39 +
    1.40 +      nsTDependentString_CharT( const char_type* data, uint32_t length )
    1.41 +        : string_type(const_cast<char_type*>(data), length, F_TERMINATED)
    1.42 +        {
    1.43 +          AssertValidDepedentString();
    1.44 +        }
    1.45 +
    1.46 +#if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
    1.47 +      nsTDependentString_CharT( char16ptr_t data, uint32_t length )
    1.48 +        : nsTDependentString_CharT(static_cast<const char16_t*>(data), length) {}
    1.49 +#endif
    1.50 +
    1.51 +      explicit
    1.52 +      nsTDependentString_CharT( const char_type* data )
    1.53 +        : string_type(const_cast<char_type*>(data), uint32_t(char_traits::length(data)), F_TERMINATED)
    1.54 +        {
    1.55 +          AssertValidDepedentString();
    1.56 +        }
    1.57 +
    1.58 +#if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
    1.59 +      explicit
    1.60 +      nsTDependentString_CharT( char16ptr_t data )
    1.61 +        : nsTDependentString_CharT( static_cast<const char16_t*>(data)) {}
    1.62 +#endif
    1.63 +
    1.64 +      nsTDependentString_CharT( const string_type& str, uint32_t startPos )
    1.65 +        : string_type()
    1.66 +        {
    1.67 +          Rebind(str, startPos);
    1.68 +        }
    1.69 +
    1.70 +      // Create a nsTDependentSubstring to be bound later
    1.71 +      nsTDependentString_CharT()
    1.72 +        : string_type() {}
    1.73 +
    1.74 +      // XXX are you sure??
    1.75 +      // auto-generated copy-constructor OK
    1.76 +      // auto-generated copy-assignment operator OK
    1.77 +      // auto-generated destructor OK
    1.78 +
    1.79 +
    1.80 +        /**
    1.81 +         * allow this class to be bound to a different string...
    1.82 +         */
    1.83 +
    1.84 +      using nsTString_CharT::Rebind;
    1.85 +      void Rebind( const char_type* data )
    1.86 +        {
    1.87 +          Rebind(data, uint32_t(char_traits::length(data)));
    1.88 +        }
    1.89 +
    1.90 +      void Rebind( const char_type* start, const char_type* end )
    1.91 +        {
    1.92 +          Rebind(start, uint32_t(end - start));
    1.93 +        }
    1.94 +
    1.95 +      void Rebind( const string_type&, uint32_t startPos );
    1.96 +
    1.97 +    private:
    1.98 +      
    1.99 +      // NOT USED
   1.100 +      nsTDependentString_CharT( const substring_tuple_type& );
   1.101 +  };

mercurial