Back to index

lightning-sunbird  0.9+nobinonly
nsTDependentSubstring.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* vim:set ts=2 sw=2 sts=2 et cindent: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla.
00017  *
00018  * The Initial Developer of the Original Code is IBM Corporation.
00019  * Portions created by IBM Corporation are Copyright (C) 2003
00020  * IBM Corporation. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Scott Collins <scc@mozilla.org> (original author)
00024  *   Darin Fisher <darin@meer.net>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 
00044 class nsTDependentSubstring_CharT : public nsTSubstring_CharT
00045   {
00046     public:
00047 
00048       typedef nsTDependentSubstring_CharT    self_type;
00049 
00050     public:
00051 
00052 #ifdef MOZ_V1_STRING_ABI
00053       NS_COM void Rebind( const abstract_string_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
00054 #endif
00055       NS_COM void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
00056 
00057       NS_COM void Rebind( const char_type* start, const char_type* end );
00058 
00059 #ifdef MOZ_V1_STRING_ABI
00060       nsTDependentSubstring_CharT( const abstract_string_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
00061         : substring_type()
00062         {
00063           Rebind(str, startPos, length);
00064         }
00065 #endif
00066 
00067       nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
00068         : substring_type()
00069         {
00070           Rebind(str, startPos, length);
00071         }
00072 
00073       nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
00074         : substring_type(NS_CONST_CAST(char_type*, start), end - start, F_NONE) {}
00075 
00076       nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end )
00077         : substring_type(NS_CONST_CAST(char_type*, start.get()), end.get() - start.get(), F_NONE) {}
00078 
00079       // Create a nsTDependentSubstring to be bound later
00080       nsTDependentSubstring_CharT()
00081         : substring_type() {}
00082 
00083       // auto-generated copy-constructor OK (XXX really?? what about base class copy-ctor?)
00084 
00085     private:
00086         // NOT USED
00087       void operator=( const self_type& );        // we're immutable, you can't assign into a substring
00088   };
00089 
00090 #ifdef MOZ_V1_STRING_ABI
00091 inline
00092 const nsTDependentSubstring_CharT
00093 Substring( const nsTAString_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
00094   {
00095     return nsTDependentSubstring_CharT(str, startPos, length);
00096   }
00097 #endif
00098 
00099 inline
00100 const nsTDependentSubstring_CharT
00101 Substring( const nsTSubstring_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
00102   {
00103     return nsTDependentSubstring_CharT(str, startPos, length);
00104   }
00105 
00106 inline
00107 const nsTDependentSubstring_CharT
00108 Substring( const nsReadingIterator<CharT>& start, const nsReadingIterator<CharT>& end )
00109   {
00110     return nsTDependentSubstring_CharT(start.get(), end.get());
00111   }
00112 
00113 inline
00114 const nsTDependentSubstring_CharT
00115 Substring( const CharT* start, const CharT* end )
00116   {
00117     return nsTDependentSubstring_CharT(start, end);
00118   }
00119 
00120 #ifdef MOZ_V1_STRING_ABI
00121 inline
00122 const nsTDependentSubstring_CharT
00123 StringHead( const nsTAString_CharT& str, PRUint32 count )
00124   {
00125     return nsTDependentSubstring_CharT(str, 0, count);
00126   }
00127 #endif
00128 
00129 inline
00130 const nsTDependentSubstring_CharT
00131 StringHead( const nsTSubstring_CharT& str, PRUint32 count )
00132   {
00133     return nsTDependentSubstring_CharT(str, 0, count);
00134   }
00135 
00136 #ifdef MOZ_V1_STRING_ABI
00137 inline
00138 const nsTDependentSubstring_CharT
00139 StringTail( const nsTAString_CharT& str, PRUint32 count )
00140   {
00141     return nsTDependentSubstring_CharT(str, str.Length() - count, count);
00142   }
00143 #endif
00144 
00145 inline
00146 const nsTDependentSubstring_CharT
00147 StringTail( const nsTSubstring_CharT& str, PRUint32 count )
00148   {
00149     return nsTDependentSubstring_CharT(str, str.Length() - count, count);
00150   }