Main Page   Modules   Class Hierarchy   Data Structures   File List   Data Fields   Globals   Related Pages  

oscl_string_containers.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
00003 
00004 //               O S C L_ S T R I N G _ C O N T A I N E R S
00005 //
00006 //    This file contains a standardized set of string containers that
00007 //    can be used in place of character arrays.
00008 
00009 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
00010 
00025 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
00026 #define OSCL_STRING_CONTAINERS_H_INCLUDED
00027 
00028 
00029 #ifndef OSCL_STRING_H_INCLUDED
00030 #include "oscl_string.h"
00031 #endif
00032 
00033 #ifndef OSCL_DEFALLOC_H_INCLUDED
00034 #include "oscl_defalloc.h"
00035 #endif
00036 
00037 #ifndef OSCL_REFCOUNTER_H_INCLUDED
00038 #include "oscl_refcounter.h"
00039 #endif
00040 
00041 #ifndef OSCL_ERROR_H_INCLUDED
00042 #include "oscl_error.h"
00043 #endif
00044 
00045 #ifndef OSCL_STRING_REP_H_INCLUDED
00046 #include "oscl_string_rep.h"
00047 #endif
00048 
00049 #ifndef OSCL_STDSTRING_H_INCLUDED
00050 #include "oscl_stdstring.h"
00051 #endif
00052 
00053 #ifndef OSCL_MEM_H_INCLUDED
00054 #include "oscl_mem.h"
00055 #endif
00056 
00073 template <class Alloc>
00074 class OSCL_HeapString : public OSCL_String
00075 {
00076     public:
00077         typedef OSCL_String::chartype chartype;
00078 
00079         typedef TOSCL_StringOp optype;
00080         typedef OSCL_wString::chartype other_chartype;
00081 
00085         OSCL_HeapString();
00086 
00092         OSCL_HeapString(const OSCL_HeapString& src);
00093         OSCL_HeapString(const OSCL_String& src);
00094 
00100         OSCL_HeapString(const chartype* cstr);
00101 
00108         OSCL_HeapString(const chartype* buf, uint32 length);
00109 
00110         ~OSCL_HeapString();
00111 
00114         uint32 get_size() const;
00115         uint32 get_maxsize() const;
00116         const chartype* get_cstr() const;
00117         chartype* get_str() const;
00118 
00121         OSCL_HeapString& operator=(const OSCL_HeapString& src);
00122         OSCL_HeapString& operator=(const OSCL_String& src);
00123         OSCL_HeapString& operator=(const chartype* cstr);
00124 
00131         void set(const chartype* buf, uint32 length);
00132 
00140         void set(const other_chartype* buf, optype op);
00141 
00150         void set(const other_chartype* buf, uint32 length, optype op);
00151 
00152     private:
00153         CHeapRep *iRep;
00154         Alloc iAlloc;
00155         void create();
00156         void set_rep(const chartype*, uint32);
00157         void append_rep(const chartype*, uint32);
00158 
00161         void set_rep(const chartype* cstr);
00162         void append_rep(const chartype* cstr);
00163         void set_rep(const OSCL_String& src);
00164         void append_rep(const OSCL_String& src);
00165         void set_len(uint32 len);
00166         friend class OSCL_String;
00167 };
00168 
00174 template <class Alloc>
00175 class OSCL_wHeapString : public OSCL_wString
00176 {
00177     public:
00178         typedef OSCL_wString::chartype chartype;
00179         typedef TOSCL_wStringOp optype;
00180         typedef OSCL_String::chartype other_chartype;
00181 
00182         OSCL_wHeapString();
00183 
00184         OSCL_wHeapString(const OSCL_wHeapString& src);
00185         OSCL_wHeapString(const OSCL_wString& src);
00186 
00187         OSCL_wHeapString(const chartype* cstr);
00188         OSCL_wHeapString(const chartype* buf, uint32 length);
00189 
00190         ~OSCL_wHeapString();
00191 
00192         uint32 get_size() const;
00193         uint32 get_maxsize() const;
00194         const chartype* get_cstr() const;
00195         chartype* get_str() const;
00196 
00197         OSCL_wHeapString& operator=(const OSCL_wHeapString& src);
00198         OSCL_wHeapString& operator=(const OSCL_wString& src);
00199         OSCL_wHeapString& operator=(const chartype* cstr);
00200 
00201         void set(const chartype* buf, uint32 length);
00202 
00203         void set(const other_chartype* buf, optype op);
00204         void set(const other_chartype* buf, uint32 length, optype op);
00205 
00206     private:
00207         CHeapRep *iRep;
00208         Alloc iAlloc;
00209         void create();
00210         void set_rep(const chartype*, uint32);
00211         void append_rep(const chartype*, uint32);
00212 
00213         void set_rep(const chartype* cstr);
00214         void append_rep(const chartype* cstr);
00215         void set_rep(const OSCL_wString& src);
00216         void append_rep(const OSCL_wString& src);
00217         void set_len(uint32 len);
00218         friend class OSCL_wString;
00219 };
00220 
00244 class OSCL_HeapStringA : public OSCL_String
00245 {
00246     public:
00247         typedef OSCL_String::chartype chartype;
00248         typedef TOSCL_StringOp optype;
00249         typedef OSCL_wString::chartype other_chartype;
00250 
00258         OSCL_IMPORT_REF OSCL_HeapStringA();
00259         OSCL_IMPORT_REF OSCL_HeapStringA(Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL);
00260 
00270         OSCL_IMPORT_REF OSCL_HeapStringA(const OSCL_HeapStringA& src);
00271         OSCL_IMPORT_REF OSCL_HeapStringA(const OSCL_HeapStringA& src, Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL);
00272         OSCL_IMPORT_REF OSCL_HeapStringA(const OSCL_String& src, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL);
00273 
00283         OSCL_IMPORT_REF OSCL_HeapStringA(const chartype* cstr, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL);
00284 
00295         OSCL_IMPORT_REF OSCL_HeapStringA(const chartype* buf, uint32 length, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL);
00296 
00297         OSCL_IMPORT_REF ~OSCL_HeapStringA();
00298 
00301         OSCL_IMPORT_REF uint32 get_size() const;
00302         OSCL_IMPORT_REF uint32 get_maxsize() const;
00303         OSCL_IMPORT_REF const chartype* get_cstr() const;
00304         OSCL_IMPORT_REF chartype* get_str() const;
00305 
00308         OSCL_IMPORT_REF OSCL_HeapStringA& operator=(const OSCL_HeapStringA& src);
00309         OSCL_IMPORT_REF OSCL_HeapStringA& operator=(const OSCL_String& src);
00310         OSCL_IMPORT_REF OSCL_HeapStringA& operator=(const chartype* cstr);
00311 
00318         OSCL_IMPORT_REF void set(const chartype* buf, uint32 length);
00319 
00327         OSCL_IMPORT_REF void set(const other_chartype* buf, optype op);
00328 
00337         OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 length, optype op);
00338 
00339     private:
00340         CHeapRep *iRep;
00341         OsclRefCounter *iAllocRef;
00342         Oscl_DefAlloc *iAlloc;
00343         OsclMemAllocator iDefAlloc;
00344         void create(Oscl_DefAlloc *, OsclRefCounter*);
00345         void set_rep(const chartype*, uint32);
00346         void append_rep(const chartype*, uint32);
00347 
00350         void set_rep(const chartype* cstr);
00351         void append_rep(const chartype* cstr);
00352         void set_rep(const OSCL_String& src);
00353         void append_rep(const OSCL_String& src);
00354         void set_len(uint32 len);
00355         friend class OSCL_String;
00356 };
00357 
00363 class OSCL_wHeapStringA : public OSCL_wString
00364 {
00365     public:
00366         typedef OSCL_wString::chartype chartype;
00367         typedef TOSCL_wStringOp optype;
00368         typedef OSCL_String::chartype other_chartype;
00369 
00370         OSCL_IMPORT_REF OSCL_wHeapStringA();
00371         OSCL_IMPORT_REF OSCL_wHeapStringA(Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL);
00372 
00373         OSCL_IMPORT_REF OSCL_wHeapStringA(const OSCL_wHeapStringA& src);
00374         OSCL_IMPORT_REF OSCL_wHeapStringA(const OSCL_wHeapStringA& src, Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL);
00375         OSCL_IMPORT_REF OSCL_wHeapStringA(const OSCL_wString& src, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL);
00376 
00377         OSCL_IMPORT_REF OSCL_wHeapStringA(const chartype* cstr, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL);
00378 
00379         OSCL_IMPORT_REF OSCL_wHeapStringA(const chartype* buf, uint32 length, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL);
00380 
00381         OSCL_IMPORT_REF ~OSCL_wHeapStringA();
00382 
00383         OSCL_IMPORT_REF uint32 get_size() const;
00384         OSCL_IMPORT_REF uint32 get_maxsize() const;
00385         OSCL_IMPORT_REF const chartype* get_cstr() const;
00386         OSCL_IMPORT_REF chartype* get_str() const;
00387 
00388         OSCL_IMPORT_REF OSCL_wHeapStringA& operator=(const OSCL_wHeapStringA& src);
00389         OSCL_IMPORT_REF OSCL_wHeapStringA& operator=(const OSCL_wString& src);
00390         OSCL_IMPORT_REF OSCL_wHeapStringA& operator=(const chartype* cstr);
00391 
00392         OSCL_IMPORT_REF void set(const chartype* buf, uint32 length);
00393 
00394         OSCL_IMPORT_REF void set(const other_chartype* buf, optype op);
00395         OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 length, optype op);
00396 
00397     private:
00398         CHeapRep *iRep;
00399         OsclRefCounter *iAllocRef;
00400         Oscl_DefAlloc *iAlloc;
00401         OsclMemAllocator iDefAlloc;
00402         void create(Oscl_DefAlloc *, OsclRefCounter*);
00403         void set_rep(const chartype*, uint32);
00404         void append_rep(const chartype*, uint32);
00405 
00406         void set_rep(const chartype* cstr);
00407         void append_rep(const chartype* cstr);
00408         void set_rep(const OSCL_wString& src);
00409         void append_rep(const OSCL_wString& src);
00410         void set_len(uint32 len);
00411         friend class OSCL_wString;
00412 };
00413 
00414 
00428 template <uint32 MaxBufSize>
00429 class OSCL_StackString : public OSCL_String
00430 {
00431     public:
00432         typedef OSCL_String::chartype chartype;
00433         typedef TOSCL_StringOp optype;
00434         typedef OSCL_wString::chartype other_chartype;
00435 
00438         OSCL_StackString();
00439 
00444         OSCL_StackString(const OSCL_StackString& src);
00445         OSCL_StackString(const OSCL_String& src);
00446 
00451         OSCL_StackString(const chartype* cstr);
00452 
00458         OSCL_StackString(const chartype* buf, uint32 length);
00459 
00460         ~OSCL_StackString();
00461 
00464         uint32 get_size() const;
00465         uint32 get_maxsize() const;
00466         const chartype* get_cstr() const;
00467         chartype* get_str() const;
00468 
00471         OSCL_StackString& operator=(const OSCL_StackString& src);
00472         OSCL_StackString& operator=(const OSCL_String& src);
00473         OSCL_StackString& operator=(const chartype* cstr);
00474 
00481         void set(const chartype* buf, uint32 length);
00482 
00490         void set(const other_chartype* buf, optype op);
00491 
00500         void set(const other_chartype* buf, uint32 length, optype op);
00501 
00502     private:
00503         CStackRep rep;
00504         char buffer[MaxBufSize+1];//fixed string buffer.
00505         void create();
00506 
00509         void set_rep(const chartype* cstr);
00510         void append_rep(const chartype* cstr);
00511         void set_rep(const OSCL_String& src);
00512         void append_rep(const OSCL_String& src);
00513         void set_len(uint32 len);
00514         friend class OSCL_String;
00515 };
00516 
00522 template <uint32 MaxBufSize>
00523 class OSCL_wStackString : public OSCL_wString
00524 {
00525     public:
00526         typedef OSCL_wString::chartype chartype;
00527         typedef TOSCL_wStringOp optype;
00528         typedef OSCL_String::chartype other_chartype;
00529 
00530         OSCL_wStackString();
00531 
00532         OSCL_wStackString(const OSCL_wStackString& src);
00533         OSCL_wStackString(const OSCL_wString& src);
00534 
00535         OSCL_wStackString(const chartype* cstr);
00536         OSCL_wStackString(const chartype* buf, uint32 length);
00537 
00538         ~OSCL_wStackString();
00539 
00540         uint32 get_size() const;
00541         uint32 get_maxsize() const;
00542         const chartype* get_cstr() const;
00543         chartype* get_str() const;
00544 
00545         OSCL_wStackString& operator=(const OSCL_wStackString& src);
00546         OSCL_wStackString& operator=(const OSCL_wString& src);
00547         OSCL_wStackString& operator=(const chartype* cstr);
00548 
00549         void set(const chartype* buf, uint32 length);
00550 
00551         void set(const other_chartype* buf, optype op);
00552         void set(const other_chartype* buf, uint32 length, optype op);
00553 
00554     private:
00555         CStackRep rep;
00556         chartype buffer[MaxBufSize+1];//fixed string buffer.
00557         void create();
00558 
00559         void set_rep(const chartype* cstr);
00560         void append_rep(const chartype* cstr);
00561         void set_rep(const OSCL_wString& src);
00562         void append_rep(const OSCL_wString& src);
00563         void set_len(uint32 len);
00564         friend class OSCL_wString;
00565 };
00566 
00581 class OSCL_FastString : public OSCL_String
00582 {
00583     public:
00584         typedef OSCL_String::chartype chartype;
00585         typedef TOSCL_StringOp optype;
00586         typedef OSCL_wString::chartype other_chartype;
00587 
00591         OSCL_IMPORT_REF OSCL_FastString();
00592 
00599         OSCL_IMPORT_REF OSCL_FastString(const OSCL_FastString& src);
00600 
00606         OSCL_IMPORT_REF OSCL_FastString(const chartype* cstr);
00607 
00615         OSCL_IMPORT_REF OSCL_FastString(chartype* buf, uint32 maxlen);
00616 
00617         OSCL_IMPORT_REF ~OSCL_FastString();
00618 
00621         OSCL_IMPORT_REF uint32 get_size() const;
00622         OSCL_IMPORT_REF uint32 get_maxsize() const;
00623         OSCL_IMPORT_REF const chartype* get_cstr() const;
00624         OSCL_IMPORT_REF chartype* get_str() const;
00625 
00628         OSCL_IMPORT_REF OSCL_FastString& operator=(const OSCL_FastString& src);
00629         OSCL_IMPORT_REF OSCL_FastString& operator=(const chartype* cstr);
00630 
00636         OSCL_IMPORT_REF void set(chartype* cstr, uint32 maxlen);
00637 
00650         OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 numofbyte, optype op);
00651 
00657         OSCL_IMPORT_REF void set_length();
00658 
00659     private:
00660         CFastRep rep;
00661 
00664         void set_rep(const chartype* cstr);
00665         void append_rep(const chartype* cstr);
00666         void set_rep(const OSCL_String& src);
00667         void append_rep(const OSCL_String& src);
00668         void set_len(uint32 len);
00669         friend class OSCL_String;
00670 };
00671 
00677 class OSCL_wFastString : public OSCL_wString
00678 {
00679     public:
00680         typedef OSCL_wString::chartype chartype;
00681         typedef TOSCL_wStringOp optype;
00682         typedef OSCL_String::chartype other_chartype;
00683 
00684         OSCL_IMPORT_REF OSCL_wFastString();
00685 
00686         OSCL_IMPORT_REF OSCL_wFastString(const OSCL_wFastString& src);
00687 
00688         OSCL_IMPORT_REF OSCL_wFastString(const chartype* cstr);
00689         OSCL_IMPORT_REF OSCL_wFastString(chartype* buf, uint32 maxlen);
00690 
00691         OSCL_IMPORT_REF ~OSCL_wFastString();
00692 
00693         OSCL_IMPORT_REF uint32 get_size() const;
00694         OSCL_IMPORT_REF uint32 get_maxsize() const;
00695         OSCL_IMPORT_REF const chartype* get_cstr() const;
00696         OSCL_IMPORT_REF chartype* get_str() const;
00697 
00698         OSCL_IMPORT_REF OSCL_wFastString& operator=(const OSCL_wFastString& src);
00699         OSCL_IMPORT_REF OSCL_wFastString& operator=(const chartype* cstr);
00700 
00701         OSCL_IMPORT_REF void set(chartype* cstr, uint32 maxlen);
00702 
00703         OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 numofbyte, optype op);
00704 
00705         OSCL_IMPORT_REF void set_length();
00706 
00707     private:
00708         CFastRep rep;
00709 
00710         void set_rep(const chartype* cstr);
00711         void append_rep(const chartype* cstr);
00712         void set_rep(const OSCL_wString& src);
00713         void append_rep(const OSCL_wString& src);
00714         void set_len(uint32 len);
00715         friend class OSCL_wString;
00716 };
00717 
00718 
00719 // **************************************************************
00720 //                   OSCL_HeapString<Alloc> Implementation
00721 //                   OSCL_wHeapString<Alloc> Implementation
00722 // **************************************************************
00723 
00724 template<class Alloc>
00725 void OSCL_HeapString<Alloc>::set_rep(const chartype* cp, uint32 len)
00726 //set heap rep to new string.
00727 {
00728     CHeapRep::set_rep(iRep, iAlloc, cp, len);
00729 }
00730 
00731 template<class Alloc>
00732 void OSCL_wHeapString<Alloc>::set_rep(const chartype* cp, uint32 len)
00733 //set heap rep to new string.
00734 {
00735     CHeapRep::set_rep(iRep, iAlloc, cp, len);
00736 }
00737 
00738 // **************************************************************
00739 template<class Alloc>
00740 void OSCL_HeapString<Alloc>::append_rep(const chartype* cp, uint32 len)
00741 //set heap rep to current string plus new string.
00742 {
00743     CHeapRep::append_rep(iRep, iAlloc, cp, len);
00744 }
00745 
00746 template<class Alloc>
00747 void OSCL_wHeapString<Alloc>::append_rep(const chartype* cp, uint32 len)
00748 //set heap rep to current string plus new string.
00749 {
00750     CHeapRep::append_rep(iRep, iAlloc, cp, len);
00751 }
00752 
00753 // **************************************************************
00754 template<class Alloc>
00755 void OSCL_HeapString<Alloc>::set_rep(const chartype* cp)
00756 {
00757     set_rep(cp, (cp) ? oscl_strlen(cp) : 0);
00758 }
00759 
00760 template<class Alloc>
00761 void OSCL_wHeapString<Alloc>::set_rep(const chartype* cp)
00762 {
00763     set_rep(cp, (cp) ? oscl_strlen(cp) : 0);
00764 }
00765 
00766 
00767 // **************************************************************
00768 template<class Alloc>
00769 void OSCL_HeapString<Alloc>::append_rep(const chartype* cp)
00770 {
00771     append_rep(cp, (cp) ? oscl_strlen(cp) : 0);
00772 }
00773 
00774 template<class Alloc>
00775 void OSCL_wHeapString<Alloc>::append_rep(const chartype* cp)
00776 {
00777     append_rep(cp, (cp) ? oscl_strlen(cp) : 0);
00778 }
00779 
00780 
00781 // **************************************************************
00782 template<class Alloc>
00783 void OSCL_HeapString<Alloc>::set_rep(const OSCL_String& src)
00784 {
00785     set_rep(src.get_cstr(), src.get_size());
00786 }
00787 
00788 template<class Alloc>
00789 void OSCL_wHeapString<Alloc>::set_rep(const OSCL_wString& src)
00790 {
00791     set_rep(src.get_cstr(), src.get_size());
00792 }
00793 
00794 
00795 // **************************************************************
00796 template<class Alloc>
00797 void OSCL_HeapString<Alloc>::append_rep(const OSCL_String& src)
00798 {
00799     append_rep(src.get_cstr(), src.get_size());
00800 }
00801 
00802 template<class Alloc>
00803 void OSCL_wHeapString<Alloc>::append_rep(const OSCL_wString& src)
00804 {
00805     append_rep(src.get_cstr(), src.get_size());
00806 }
00807 
00808 
00809 // **************************************************************
00810 template<class Alloc>
00811 uint32 OSCL_HeapString<Alloc>::get_size() const
00812 {
00813     if (iRep)
00814         return iRep->size;
00815     return 0;
00816 }
00817 
00818 template<class Alloc>
00819 uint32 OSCL_wHeapString<Alloc>::get_size() const
00820 {
00821     if (iRep)
00822         return iRep->size;
00823     return 0;
00824 }
00825 
00826 // **************************************************************
00827 template<class Alloc>
00828 void OSCL_HeapString<Alloc>::set_len(uint32 len)
00829 {
00830     iRep->size = len;
00831 }
00832 
00833 template<class Alloc>
00834 void OSCL_wHeapString<Alloc>::set_len(uint32 len)
00835 {
00836     iRep->size = len;
00837 }
00838 
00839 
00840 // **************************************************************
00841 template<class Alloc>
00842 uint32 OSCL_HeapString<Alloc>::get_maxsize() const
00843 {
00844     if (iRep)
00845         return iRep->maxsize;
00846     return 0;
00847 }
00848 
00849 template<class Alloc>
00850 uint32 OSCL_wHeapString<Alloc>::get_maxsize() const
00851 {
00852     if (iRep)
00853         return iRep->maxsize;
00854     return 0;
00855 }
00856 
00857 
00858 // **************************************************************
00859 template<class Alloc>
00860 const typename OSCL_HeapString<Alloc>::chartype* OSCL_HeapString<Alloc>::get_cstr() const
00861 {
00862     if (iRep)
00863         return (chartype*)iRep->buffer;
00864     return NULL;
00865 }
00866 
00867 template<class Alloc>
00868 const typename OSCL_wHeapString<Alloc>::chartype* OSCL_wHeapString<Alloc>::get_cstr() const
00869 {
00870     if (iRep)
00871         return (chartype*)iRep->buffer;
00872     return NULL;
00873 }
00874 
00875 
00876 // **************************************************************
00877 template<class Alloc>
00878 typename OSCL_HeapString<Alloc>::chartype* OSCL_HeapString<Alloc>::get_str() const
00879 {
00880     if (iRep)
00881         return (chartype*)iRep->buffer;
00882     return NULL;
00883 }
00884 
00885 template<class Alloc>
00886 typename OSCL_wHeapString<Alloc>::chartype* OSCL_wHeapString<Alloc>::get_str() const
00887 {
00888     if (iRep)
00889         return (chartype*)iRep->buffer;
00890     return NULL;
00891 }
00892 
00893 
00894 // **************************************************************
00895 template<class Alloc>
00896 void OSCL_HeapString<Alloc>::create()
00897 {
00898     iRep = NULL;
00899 }
00900 
00901 template<class Alloc>
00902 void OSCL_wHeapString<Alloc>::create()
00903 {
00904     iRep = NULL;
00905 }
00906 
00907 
00908 // **************************************************************
00909 template<class Alloc>
00910 OSCL_HeapString<Alloc>::OSCL_HeapString()
00911 {
00912     create();
00913     set_rep(NULL);
00914 }
00915 
00916 template<class Alloc>
00917 OSCL_wHeapString<Alloc>::OSCL_wHeapString()
00918 {
00919     create();
00920     set_rep(NULL);
00921 }
00922 
00923 
00924 // **************************************************************
00925 template<class Alloc>
00926 OSCL_HeapString<Alloc>::OSCL_HeapString(const chartype* cp)
00927 {
00928     create();
00929     set_rep(cp);
00930 }
00931 
00932 template<class Alloc>
00933 OSCL_wHeapString<Alloc>::OSCL_wHeapString(const chartype* cp)
00934 {
00935     create();
00936     set_rep(cp);
00937 }
00938 
00939 
00940 // **************************************************************
00941 template<class Alloc>
00942 void OSCL_HeapString<Alloc>::set(const chartype* cp, uint32 length)
00943 {
00944     set_rep(cp, length);
00945     //just in case input string is shorter than 'length'
00946     iRep->size = oscl_strlen(get_cstr());
00947 }
00948 
00949 template<class Alloc>
00950 void OSCL_wHeapString<Alloc>::set(const chartype* cp, uint32 length)
00951 {
00952     set_rep(cp, length);
00953     //just in case input string is shorter than 'length'
00954     iRep->size = oscl_strlen(get_cstr());
00955 }
00956 
00957 
00958 // **************************************************************
00959 template<class Alloc>
00960 void OSCL_HeapString<Alloc>::set(const other_chartype* buf, optype op)
00961 {
00962     iRep->size = setrep_to_char(buf, oscl_strlen(buf), op, &iAlloc);
00963 }
00964 
00965 template<class Alloc>
00966 void OSCL_wHeapString<Alloc>::set(const other_chartype* buf, optype op)
00967 {
00968     iRep->size = setrep_to_wide_char(buf, oscl_strlen(buf), op, &iAlloc);
00969 }
00970 
00971 // **************************************************************
00972 template<class Alloc>
00973 void OSCL_HeapString<Alloc>::set(const other_chartype* buf, uint32 length, optype op)
00974 {
00975     iRep->size = setrep_to_char(buf, length, op, &iAlloc);
00976 }
00977 
00978 template<class Alloc>
00979 void OSCL_wHeapString<Alloc>::set(const other_chartype* buf, uint32 length, optype op)
00980 {
00981     iRep->size = setrep_to_wide_char(buf, length, op, &iAlloc);
00982 }
00983 
00984 // **************************************************************
00985 template<class Alloc>
00986 OSCL_HeapString<Alloc>::OSCL_HeapString(const chartype* cp, uint32 length)
00987 {
00988     create();
00989     set(cp, length);
00990 }
00991 
00992 template<class Alloc>
00993 OSCL_wHeapString<Alloc>::OSCL_wHeapString(const chartype* cp, uint32 length)
00994 {
00995     create();
00996     set(cp, length);
00997 }
00998 
00999 // **************************************************************
01000 template<class Alloc>
01001 OSCL_HeapString<Alloc>::OSCL_HeapString(const OSCL_HeapString<Alloc>& src) : OSCL_String(src)
01002 {
01003     create();
01004     if (src.iRep)
01005         CHeapRep::assign(iRep, src.iRep, iAlloc);
01006     else
01007         set_rep(src);
01008 }
01009 
01010 template<class Alloc>
01011 OSCL_wHeapString<Alloc>::OSCL_wHeapString(const OSCL_wHeapString<Alloc>& src)  : OSCL_wString(src)
01012 {
01013     create();
01014     if (src.iRep)
01015         CHeapRep::assign(iRep, src.iRep, iAlloc);
01016     else
01017         set_rep(src);
01018 }
01019 
01020 // **************************************************************
01021 template<class Alloc>
01022 OSCL_HeapString<Alloc>::OSCL_HeapString(const OSCL_String& src)
01023 {
01024     create();
01025     set_rep(src);
01026 }
01027 
01028 template<class Alloc>
01029 OSCL_wHeapString<Alloc>::OSCL_wHeapString(const OSCL_wString& src)
01030 {
01031     create();
01032     set_rep(src);
01033 }
01034 
01035 // **************************************************************
01036 template<class Alloc>
01037 OSCL_HeapString<Alloc>::~OSCL_HeapString()
01038 {
01039     if (iRep)
01040         iRep->remove_ref(iAlloc);
01041 }
01042 
01043 template<class Alloc>
01044 OSCL_wHeapString<Alloc>::~OSCL_wHeapString()
01045 {
01046     if (iRep)
01047         iRep->remove_ref(iAlloc);
01048 }
01049 
01050 
01051 // **************************************************************
01052 template<class Alloc>
01053 OSCL_HeapString<Alloc>& OSCL_HeapString<Alloc>::operator=(const OSCL_HeapString<Alloc>& src)
01054 {
01055     if (src.iRep)
01056         CHeapRep::assign(iRep, src.iRep, iAlloc);
01057     else
01058         set_rep(src);
01059     return (*this);
01060 }
01061 
01062 template<class Alloc>
01063 OSCL_wHeapString<Alloc>& OSCL_wHeapString<Alloc>::operator=(const OSCL_wHeapString<Alloc>& src)
01064 {
01065     if (src.iRep)
01066         CHeapRep::assign(iRep, src.iRep, iAlloc);
01067     else
01068         set_rep(src);
01069     return (*this);
01070 }
01071 
01072 // **************************************************************
01073 template<class Alloc>
01074 OSCL_HeapString<Alloc>& OSCL_HeapString<Alloc>::operator=(const OSCL_String & src)
01075 {
01076     set_rep(src);
01077     return (*this);
01078 }
01079 
01080 template<class Alloc>
01081 OSCL_wHeapString<Alloc>& OSCL_wHeapString<Alloc>::operator=(const OSCL_wString & src)
01082 {
01083     set_rep(src);
01084     return (*this);
01085 }
01086 
01087 // **************************************************************
01088 template<class Alloc>
01089 OSCL_HeapString<Alloc>& OSCL_HeapString<Alloc>::operator=(const chartype * cp)
01090 {
01091     set_rep(cp);
01092     return (*this);
01093 }
01094 
01095 template<class Alloc>
01096 OSCL_wHeapString<Alloc>& OSCL_wHeapString<Alloc>::operator=(const chartype * cp)
01097 {
01098     set_rep(cp);
01099     return (*this);
01100 }
01101 
01102 // **************************************************************
01103 //                 OSCL_StackString<MaxBufSize> Implementation
01104 //                 OSCL_wStackString<MaxBufSize> Implementation
01105 // **************************************************************
01106 template<uint32 MaxBufSize>
01107 void OSCL_StackString<MaxBufSize>::set_rep(const chartype* cp)
01108 {
01109     rep.set(cp, (cp) ? oscl_strlen(cp) : 0);
01110 }
01111 
01112 template<uint32 MaxBufSize>
01113 void OSCL_wStackString<MaxBufSize>::set_rep(const chartype* cp)
01114 {
01115     rep.set(cp, (cp) ? oscl_strlen(cp) : 0);
01116 }
01117 
01118 
01119 // **************************************************************
01120 template<uint32 MaxBufSize>
01121 void OSCL_StackString<MaxBufSize>::append_rep(const chartype* cp)
01122 {
01123     rep.append(cp, (cp) ? oscl_strlen(cp) : 0);
01124 }
01125 
01126 template<uint32 MaxBufSize>
01127 void OSCL_wStackString<MaxBufSize>::append_rep(const chartype* cp)
01128 {
01129     rep.append(cp, (cp) ? oscl_strlen(cp) : 0);
01130 }
01131 
01132 // **************************************************************
01133 template<uint32 MaxBufSize>
01134 void OSCL_StackString<MaxBufSize>::set_rep(const OSCL_String& src)
01135 {
01136     rep.set(src.get_cstr(), src.get_size());
01137 }
01138 
01139 template<uint32 MaxBufSize>
01140 void OSCL_wStackString<MaxBufSize>::set_rep(const OSCL_wString& src)
01141 {
01142     rep.set(src.get_cstr(), src.get_size());
01143 }
01144 
01145 // **************************************************************
01146 template<uint32 MaxBufSize>
01147 void OSCL_StackString<MaxBufSize>::append_rep(const OSCL_String& src)
01148 {
01149     rep.append(src.get_cstr(), src.get_size());
01150 }
01151 
01152 template<uint32 MaxBufSize>
01153 void OSCL_wStackString<MaxBufSize>::append_rep(const OSCL_wString& src)
01154 {
01155     rep.append(src.get_cstr(), src.get_size());
01156 }
01157 
01158 // **************************************************************
01159 template<uint32 MaxBufSize>
01160 void OSCL_StackString<MaxBufSize>::set_len(uint32 len)
01161 {
01162     rep.size = len;
01163 }
01164 
01165 template<uint32 MaxBufSize>
01166 void OSCL_wStackString<MaxBufSize>::set_len(uint32 len)
01167 {
01168     rep.size = len;
01169 }
01170 
01171 // **************************************************************
01172 template<uint32 MaxBufSize>
01173 uint32 OSCL_StackString<MaxBufSize>::get_size() const
01174 {
01175     return rep.size;
01176 }
01177 
01178 template<uint32 MaxBufSize>
01179 uint32 OSCL_wStackString<MaxBufSize>::get_size() const
01180 {
01181     return rep.size;
01182 }
01183 
01184 // **************************************************************
01185 template<uint32 MaxBufSize>
01186 uint32 OSCL_StackString<MaxBufSize>::get_maxsize() const
01187 {
01188     return rep.maxsize;
01189 }
01190 
01191 template<uint32 MaxBufSize>
01192 uint32 OSCL_wStackString<MaxBufSize>::get_maxsize() const
01193 {
01194     return rep.maxsize;
01195 }
01196 
01197 // **************************************************************
01198 template<uint32 MaxBufSize>
01199 const typename OSCL_StackString<MaxBufSize>::chartype* OSCL_StackString<MaxBufSize>::get_cstr() const
01200 {
01201     return (chartype*)rep.buffer;
01202 }
01203 
01204 template<uint32 MaxBufSize>
01205 const typename OSCL_wStackString<MaxBufSize>::chartype* OSCL_wStackString<MaxBufSize>::get_cstr() const
01206 {
01207     return (chartype*)rep.buffer;
01208 }
01209 
01210 // **************************************************************
01211 template<uint32 MaxBufSize>
01212 typename OSCL_StackString<MaxBufSize>::chartype* OSCL_StackString<MaxBufSize>::get_str() const
01213 {
01214     return (chartype*)rep.buffer;
01215 }
01216 
01217 template<uint32 MaxBufSize>
01218 typename OSCL_wStackString<MaxBufSize>::chartype* OSCL_wStackString<MaxBufSize>::get_str() const
01219 {
01220     return (chartype*)rep.buffer;
01221 }
01222 
01223 // **************************************************************
01224 template<uint32 MaxBufSize>
01225 void OSCL_StackString<MaxBufSize>::create()
01226 {
01227     rep.buffer = &buffer[0];
01228     rep.maxsize = MaxBufSize;
01229 }
01230 
01231 template<uint32 MaxBufSize>
01232 void OSCL_wStackString<MaxBufSize>::create()
01233 {
01234     rep.buffer = &buffer[0];
01235     rep.maxsize = MaxBufSize;
01236 }
01237 
01238 // **************************************************************
01239 template<uint32 MaxBufSize>
01240 OSCL_StackString<MaxBufSize>::OSCL_StackString()
01241 {
01242     create();
01243     set_rep(NULL);
01244 }
01245 
01246 template<uint32 MaxBufSize>
01247 OSCL_wStackString<MaxBufSize>::OSCL_wStackString()
01248 {
01249     create();
01250     set_rep(NULL);
01251 }
01252 
01253 // **************************************************************
01254 template<uint32 MaxBufSize>
01255 OSCL_StackString<MaxBufSize>::OSCL_StackString(const chartype* cp)
01256 {
01257     create();
01258     set_rep(cp);
01259 }
01260 
01261 template<uint32 MaxBufSize>
01262 OSCL_wStackString<MaxBufSize>::OSCL_wStackString(const chartype* cp)
01263 {
01264     create();
01265     set_rep(cp);
01266 }
01267 
01268 // **************************************************************
01269 template<uint32 MaxBufSize>
01270 void OSCL_StackString<MaxBufSize>::set(const chartype* cp, uint32 length)
01271 {
01272     rep.set(cp, length);
01273     //just in case input string is shorter than 'length';
01274     rep.size = oscl_strlen(get_cstr());
01275 }
01276 
01277 template<uint32 MaxBufSize>
01278 void OSCL_wStackString<MaxBufSize>::set(const chartype* cp, uint32 length)
01279 {
01280     rep.set(cp, length);
01281     //just in case input string is shorter than 'length';
01282     rep.size = oscl_strlen(get_cstr());
01283 }
01284 
01285 // **************************************************************
01286 template<uint32 MaxBufSize>
01287 void OSCL_StackString<MaxBufSize>::set(const other_chartype* buf, optype op)
01288 {
01289     rep.size = setrep_to_char(buf, oscl_strlen(buf), op, NULL);
01290 }
01291 
01292 template<uint32 MaxBufSize>
01293 void OSCL_wStackString<MaxBufSize>::set(const other_chartype* buf, optype op)
01294 {
01295     rep.size = setrep_to_wide_char(buf, oscl_strlen(buf), op, NULL);
01296 }
01297 
01298 // **************************************************************
01299 template<uint32 MaxBufSize>
01300 void OSCL_StackString<MaxBufSize>::set(const other_chartype* buf, uint32 length, optype op)
01301 {
01302     rep.size = setrep_to_char(buf, length, op, NULL);
01303 }
01304 
01305 template<uint32 MaxBufSize>
01306 void OSCL_wStackString<MaxBufSize>::set(const other_chartype* buf, uint32 length, optype op)
01307 {
01308     rep.size = setrep_to_wide_char(buf, length, op, NULL);
01309 }
01310 
01311 // **************************************************************
01312 template<uint32 MaxBufSize>
01313 OSCL_StackString<MaxBufSize>::OSCL_StackString(const chartype* cp, uint32 length)
01314 {
01315     create();
01316     set(cp, length);
01317 }
01318 
01319 template<uint32 MaxBufSize>
01320 OSCL_wStackString<MaxBufSize>::OSCL_wStackString(const chartype* cp, uint32 length)
01321 {
01322     create();
01323     set(cp, length);
01324 }
01325 
01326 // **************************************************************
01327 template<uint32 MaxBufSize>
01328 OSCL_StackString<MaxBufSize>::OSCL_StackString(const OSCL_StackString<MaxBufSize>& src) : OSCL_String(src)
01329 {
01330     create();
01331     set_rep(src);
01332 }
01333 
01334 template<uint32 MaxBufSize>
01335 OSCL_wStackString<MaxBufSize>::OSCL_wStackString(const OSCL_wStackString<MaxBufSize>& src)
01336 {
01337     create();
01338     set_rep(src);
01339 }
01340 
01341 // **************************************************************
01342 template<uint32 MaxBufSize>
01343 OSCL_StackString<MaxBufSize>::OSCL_StackString(const OSCL_String& src)
01344 {
01345     create();
01346     set_rep(src);
01347 }
01348 
01349 template<uint32 MaxBufSize>
01350 OSCL_wStackString<MaxBufSize>::OSCL_wStackString(const OSCL_wString& src)
01351 {
01352     create();
01353     set_rep(src);
01354 }
01355 
01356 // **************************************************************
01357 template<uint32 MaxBufSize>
01358 OSCL_StackString<MaxBufSize>::~OSCL_StackString()
01359 {}
01360 
01361 template<uint32 MaxBufSize>
01362 OSCL_wStackString<MaxBufSize>::~OSCL_wStackString()
01363 {}
01364 
01365 // **************************************************************
01366 template<uint32 MaxBufSize>
01367 OSCL_StackString<MaxBufSize>& OSCL_StackString<MaxBufSize>::operator=(const OSCL_StackString<MaxBufSize>& src)
01368 {
01369     set_rep(src);
01370     return (*this);
01371 }
01372 
01373 template<uint32 MaxBufSize>
01374 OSCL_wStackString<MaxBufSize>& OSCL_wStackString<MaxBufSize>::operator=(const OSCL_wStackString<MaxBufSize>& src)
01375 {
01376     set_rep(src);
01377     return (*this);
01378 }
01379 
01380 // **************************************************************
01381 template<uint32 MaxBufSize>
01382 OSCL_StackString<MaxBufSize>& OSCL_StackString<MaxBufSize>::operator=(const OSCL_String & src)
01383 {
01384     set_rep(src);
01385     return (*this);
01386 }
01387 
01388 template<uint32 MaxBufSize>
01389 OSCL_wStackString<MaxBufSize>& OSCL_wStackString<MaxBufSize>::operator=(const OSCL_wString & src)
01390 {
01391     set_rep(src);
01392     return (*this);
01393 }
01394 
01395 // **************************************************************
01396 template<uint32 MaxBufSize>
01397 OSCL_StackString<MaxBufSize>& OSCL_StackString<MaxBufSize>::operator=(const chartype * cp)
01398 {
01399     set_rep(cp);
01400     return (*this);
01401 }
01402 
01403 template<uint32 MaxBufSize>
01404 OSCL_wStackString<MaxBufSize>& OSCL_wStackString<MaxBufSize>::operator=(const chartype * cp)
01405 {
01406     set_rep(cp);
01407     return (*this);
01408 }
01409 
01410 #endif   // OSCL_STRING_H_INCLUDED
01411 

OSCL API
Posting Version: CORE_8.000.1.1_RC4