Back to index

lightning-sunbird  0.9+nobinonly
nsTObsoleteAStringThunk.cpp
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 
00040 class nsTObsoleteAStringThunk_CharT : public nsTObsoleteAString_CharT
00041   {
00042     public:
00043       typedef nsTObsoleteAStringThunk_CharT    self_type; 
00044       typedef nsTSubstring_CharT               substring_type;
00045 
00046     public:
00047 
00048       nsTObsoleteAStringThunk_CharT() {}
00049 
00050 
00051       static const void* get_vptr()
00052         {
00053           const void* result;
00054           new (&result) self_type();
00055           return result;
00056         }
00057 
00058 
00063             substring_type* concrete_self()       { return NS_REINTERPRET_CAST(      substring_type*, this); }
00064       const substring_type* concrete_self() const { return NS_REINTERPRET_CAST(const substring_type*, this); }
00065 
00066 
00071       virtual ~nsTObsoleteAStringThunk_CharT()
00072         {
00073           concrete_self()->Finalize();
00074         }
00075 
00076       virtual PRUint32 GetImplementationFlags() const
00077         {
00078           return 0;
00079         }
00080 
00081       virtual const buffer_handle_type* GetFlatBufferHandle() const
00082         {
00083           return (const buffer_handle_type*) (concrete_self()->IsTerminated() != PR_FALSE);
00084         }
00085 
00086       virtual const buffer_handle_type*  GetBufferHandle() const
00087         {
00088           return 0;
00089         }
00090 
00091       virtual const shared_buffer_handle_type* GetSharedBufferHandle() const
00092         {
00093           return 0;
00094         }
00095 
00096       virtual size_type Length() const
00097         {
00098           return concrete_self()->Length();
00099         }
00100 
00101       virtual PRBool IsVoid() const
00102         {
00103           return concrete_self()->IsVoid();
00104         }
00105 
00106       virtual void SetIsVoid(PRBool val)
00107         {
00108           concrete_self()->SetIsVoid(val);
00109         }
00110 
00111       virtual void SetCapacity(size_type size)
00112         {
00113           concrete_self()->SetCapacity(size);
00114         }
00115 
00116       virtual void SetLength(size_type size)
00117         {
00118           concrete_self()->SetLength(size);
00119         }
00120 
00121       virtual void Cut(index_type cutStart, size_type cutLength)
00122         {
00123           concrete_self()->Cut(cutStart, cutLength);
00124         }
00125 
00126       virtual void do_AssignFromReadable(const abstract_string_type &s)
00127         {
00128           concrete_self()->Assign(s);
00129         }
00130 
00131       virtual void do_AssignFromElementPtr(const char_type *data)
00132         {
00133           concrete_self()->Assign(data);
00134         }
00135 
00136       virtual void do_AssignFromElementPtrLength(const char_type *data, size_type length)
00137         {
00138           concrete_self()->Assign(data, length);
00139         }
00140 
00141       virtual void do_AssignFromElement(char_type c)
00142         {
00143           concrete_self()->Assign(c);
00144         }
00145 
00146       virtual void do_AppendFromReadable(const abstract_string_type &s)
00147         {
00148           concrete_self()->Append(s);
00149         }
00150 
00151       virtual void do_AppendFromElementPtr(const char_type *data)
00152         {
00153           concrete_self()->Append(data);
00154         }
00155 
00156       virtual void do_AppendFromElementPtrLength(const char_type *data, size_type length)
00157         {
00158           concrete_self()->Append(data, length);
00159         }
00160 
00161       virtual void do_AppendFromElement(char_type c)
00162         {
00163           concrete_self()->Append(c);
00164         }
00165 
00166       virtual void do_InsertFromReadable(const abstract_string_type &s, index_type pos)
00167         {
00168           concrete_self()->Insert(s, pos);
00169         }
00170 
00171       virtual void do_InsertFromElementPtr(const char_type *data, index_type pos)
00172         {
00173           concrete_self()->Insert(data, pos);
00174         }
00175 
00176       virtual void do_InsertFromElementPtrLength(const char_type *data, index_type pos, size_type length)
00177         {
00178           concrete_self()->Insert(data, pos, length);
00179         }
00180 
00181       virtual void do_InsertFromElement(char_type c, index_type pos)
00182         {
00183           concrete_self()->Insert(c, pos);
00184         }
00185 
00186       virtual void do_ReplaceFromReadable(index_type cutStart, size_type cutLength, const abstract_string_type &s)
00187         {
00188           concrete_self()->Replace(cutStart, cutLength, s);
00189         }
00190 
00191       virtual const char_type *GetReadableFragment(const_fragment_type& frag, nsFragmentRequest which, PRUint32 offset) const
00192         {
00193           const substring_type* s = concrete_self();
00194           switch (which)
00195             {
00196               case kFirstFragment:
00197               case kLastFragment:
00198               case kFragmentAt:
00199                 frag.mStart = s->Data();
00200                 frag.mEnd = frag.mStart + s->Length();
00201                 return frag.mStart + offset;
00202               case kPrevFragment:
00203               case kNextFragment:
00204               default:
00205                 return 0;
00206             }
00207         }
00208 
00209       virtual char_type *GetWritableFragment(fragment_type& frag, nsFragmentRequest which, PRUint32 offset)
00210         {
00211           substring_type* s = concrete_self();
00212           switch (which)
00213             {
00214               case kFirstFragment:
00215               case kLastFragment:
00216               case kFragmentAt:
00217                 char_type* start;
00218                 s->BeginWriting(start);
00219                 frag.mStart = start;
00220                 frag.mEnd = start + s->Length();
00221                 return frag.mStart + offset;
00222               case kPrevFragment:
00223               case kNextFragment:
00224               default:
00225                 return 0;
00226             }
00227         }
00228   };
00229 
00230 
00235 const void *nsTObsoleteAString_CharT::sCanonicalVTable = nsTObsoleteAStringThunk_CharT::get_vptr();