Back to index

lightning-sunbird  0.9+nobinonly
nsTObsoleteAString.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  *   Darin Fisher <darin@meer.net>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 
00045 class nsTObsoleteAString_CharT
00046   {
00047     public:
00052       NS_COM static const void *sCanonicalVTable;
00053 
00060       enum nsFragmentRequest { kPrevFragment, kFirstFragment, kLastFragment, kNextFragment, kFragmentAt };
00061 
00074       struct nsReadableFragment
00075         {
00076           const CharT*  mStart;
00077           const CharT*  mEnd;
00078           const void*   mFragmentIdentifier;
00079 
00080           nsReadableFragment() : mStart(0), mEnd(0), mFragmentIdentifier(0) {}
00081         };
00082 
00083 
00096       struct nsWritableFragment
00097         {
00098           CharT*    mStart;
00099           CharT*    mEnd;
00100           void*     mFragmentIdentifier;
00101 
00102           nsWritableFragment() : mStart(0), mEnd(0), mFragmentIdentifier(0) {}
00103         };
00104 
00105     protected:
00106 
00107       typedef CharT                                char_type;
00108 
00109       typedef void                                 buffer_handle_type;
00110       typedef void                                 shared_buffer_handle_type;
00111       typedef nsReadableFragment                   const_fragment_type;
00112       typedef nsWritableFragment                   fragment_type;
00113 
00114       typedef nsTAString_CharT                     abstract_string_type;
00115 
00116       typedef PRUint32                             size_type;
00117       typedef PRUint32                             index_type;
00118 
00119     protected:
00120 
00121       friend class nsTAString_CharT;
00122       friend class nsTSubstring_CharT;
00123 
00126       virtual ~nsTObsoleteAString_CharT() { }
00127 
00128       virtual PRUint32                          GetImplementationFlags() const = 0;
00129       virtual const        buffer_handle_type*  GetFlatBufferHandle()    const = 0;
00130       virtual const        buffer_handle_type*  GetBufferHandle()        const = 0;
00131       virtual const shared_buffer_handle_type*  GetSharedBufferHandle()  const = 0;
00132 
00133       virtual size_type Length() const = 0;
00134 
00135       virtual PRBool IsVoid() const = 0;
00136       virtual void SetIsVoid( PRBool ) = 0;
00137 
00138       virtual void SetCapacity( size_type ) = 0;
00139       virtual void SetLength( size_type ) = 0;
00140 
00141       virtual void Cut( index_type cutStart, size_type cutLength ) = 0;
00142 
00143       virtual void do_AssignFromReadable( const abstract_string_type& ) = 0;
00144       virtual void do_AssignFromElementPtr( const char_type* ) = 0;
00145       virtual void do_AssignFromElementPtrLength( const char_type*, size_type ) = 0;
00146       virtual void do_AssignFromElement( char_type ) = 0;
00147 
00148       virtual void do_AppendFromReadable( const abstract_string_type& ) = 0;
00149       virtual void do_AppendFromElementPtr( const char_type* ) = 0;
00150       virtual void do_AppendFromElementPtrLength( const char_type*, size_type ) = 0;
00151       virtual void do_AppendFromElement( char_type ) = 0;
00152 
00153       virtual void do_InsertFromReadable( const abstract_string_type&, index_type ) = 0;
00154       virtual void do_InsertFromElementPtr( const char_type*, index_type ) = 0;
00155       virtual void do_InsertFromElementPtrLength( const char_type*, index_type, size_type ) = 0;
00156       virtual void do_InsertFromElement( char_type, index_type ) = 0;
00157 
00158       virtual void do_ReplaceFromReadable( index_type, size_type, const abstract_string_type& ) = 0;
00159 
00160       virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 = 0 ) const = 0;
00161       virtual       char_type* GetWritableFragment(       fragment_type&, nsFragmentRequest, PRUint32 = 0 ) = 0;
00162   };
00163 
00164   // forward declare implementation
00165 class nsTObsoleteAStringThunk_CharT;