a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* vim:set ts=2 sw=2 sts=2 et cindent: */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* ***** BEGIN LICENSE BLOCK *****
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Version: MPL 1.1/GPL 2.0/LGPL 2.1
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * The contents of this file are subject to the Mozilla Public License Version
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * 1.1 (the "License"); you may not use this file except in compliance with
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the License. You may obtain a copy of the License at
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * http://www.mozilla.org/MPL/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Software distributed under the License is distributed on an "AS IS" basis,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * for the specific language governing rights and limitations under the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * License.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * The Original Code is Mozilla.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * The Initial Developer of the Original Code is IBM Corporation.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Portions created by IBM Corporation are Copyright (C) 2003
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * IBM Corporation. All Rights Reserved.
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync *
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Contributor(s):
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Scott Collins <scc@mozilla.org> (original author)
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Darin Fisher <darin@meer.net>
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync *
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Alternatively, the contents of this file may be used under the terms of
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * either the GNU General Public License Version 2 or later (the "GPL"), or
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * in which case the provisions of the GPL or the LGPL are applicable instead
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * of those above. If you wish to allow use of your version of this file only
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * under the terms of either the GPL or the LGPL, and not to allow others to
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * use your version of this file under the terms of the MPL, indicate your
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * decision by deleting the provisions above and replace them with the notice
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * and other provisions required by the GPL or the LGPL. If you do not delete
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the provisions above, a recipient may use your version of this file under
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the terms of any one of the MPL, the GPL or the LGPL.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * ***** END LICENSE BLOCK ***** */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /**
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncclass nsTDependentSubstring_CharT : public nsTSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync public:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync typedef nsTDependentSubstring_CharT self_type;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync public:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NS_COM void Rebind( const abstract_string_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NS_COM void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync void Rebind( const char_type* start, const char_type* end )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NS_ASSERTION(start && end, "nsTDependentSubstring must wrap a non-NULL buffer");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync mData = NS_CONST_CAST(char_type*, start);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync mLength = end - start;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync SetDataFlags(F_NONE);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync nsTDependentSubstring_CharT( const abstract_string_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync : substring_type(F_NONE)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Rebind(str, startPos, length);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync : substring_type(F_NONE)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Rebind(str, startPos, length);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync : substring_type(NS_CONST_CAST(char_type*, start), end - start, F_NONE) {}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync : substring_type(NS_CONST_CAST(char_type*, start.get()), end.get() - start.get(), F_NONE) {}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync // auto-generated copy-constructor OK (XXX really?? what about base class copy-ctor?)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync private:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync // NOT USED
a180a41bba1d50822df23fff0099e90b86638b89vboxsync void operator=( const self_type& ); // we're immutable, you can't assign into a substring
a180a41bba1d50822df23fff0099e90b86638b89vboxsync };
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncSubstring( const nsTAString_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(str, startPos, length);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncSubstring( const nsTSubstring_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(str, startPos, length);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncSubstring( const nsReadingIterator<CharT>& start, const nsReadingIterator<CharT>& end )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(start.get(), end.get());
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncSubstring( const CharT* start, const CharT* end )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(start, end);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncStringHead( const nsTAString_CharT& str, PRUint32 count )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(str, 0, count);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncStringHead( const nsTSubstring_CharT& str, PRUint32 count )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(str, 0, count);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncStringTail( const nsTAString_CharT& str, PRUint32 count )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(str, str.Length() - count, count);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncinline
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncconst nsTDependentSubstring_CharT
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncStringTail( const nsTSubstring_CharT& str, PRUint32 count )
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return nsTDependentSubstring_CharT(str, str.Length() - count, count);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync