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

oscl_string.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
00003 
00004 //               O S C L_ S T R I N G   C L A S 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_H_INCLUDED
00026 #define OSCL_STRING_H_INCLUDED
00027 
00028 
00029 #ifndef OSCL_BASE_H_INCLUDED
00030 #include "oscl_base.h"
00031 #endif
00032 
00033 #ifndef OSCL_MEM_H_INCLUDED
00034 #include "oscl_mem.h"
00035 #endif
00036 
00039 enum TOSCL_StringOp
00040 {
00041     //Compress from wide-character to single-wide without any conversion.
00042     //This operation is only appropriate for ASCII strings.
00043     EOSCL_StringOp_CompressASCII
00044     //Compress from wide-character to single-side with UTF-16 to UTF-8 conversion
00045     , EOSCL_StringOp_UTF16ToUTF8
00046 };
00047 
00050 enum TOSCL_wStringOp
00051 {
00052     //Expand from single-wide to wide-character without any conversion.
00053     //This operation is only appropriate for ASCII strings.
00054     EOSCL_wStringOp_ExpandASCII
00055     //Expand from single-wide to wide-character with UTF-8 to UTF-16 conversion.
00056     , EOSCL_wStringOp_UTF8ToUTF16
00057 };
00058 
00063 class OSCL_IMPORT_REF OSCL_String : public HeapBase
00064 
00065 {
00066     public:
00067         typedef char chartype;
00068 
00073         virtual uint32 get_size() const = 0;
00074 
00080         virtual uint32 get_maxsize() const = 0;
00081 
00085         virtual const chartype* get_cstr() const = 0;
00086 
00090         virtual bool is_writable() const;
00091 
00096         virtual chartype* get_str() const = 0;
00097 
00100         OSCL_String& operator=(const OSCL_String& src);
00101 
00105         OSCL_String& operator=(const chartype* cstr);
00106 
00111         OSCL_String& operator+=(const OSCL_String& src);
00112 
00118         OSCL_String& operator+=(const chartype* cstr);
00119 
00124         OSCL_String& operator+=(const chartype c);
00125 
00128         bool operator== (const OSCL_String& src) const;
00129         bool operator!= (const OSCL_String& src) const;
00130         bool operator< (const OSCL_String& src) const;
00131         bool operator<= (const OSCL_String& src) const;
00132         bool operator> (const OSCL_String& src) const;
00133         bool operator>= (const OSCL_String& src) const;
00134 
00138         bool operator== (const chartype* cstr) const;
00139 
00146         chartype operator[](uint32 index) const;
00147 
00153         virtual chartype read(uint32 index)const;
00154 
00167         virtual uint32 setrep_to_char(const oscl_wchar* src, uint32 len,
00168                                       TOSCL_StringOp op, Oscl_DefAlloc* aAlloc);
00173         virtual int8 hash() const;
00174 
00181         virtual void write(uint32 index, chartype c);
00182 
00192         virtual void write(uint32 offset, uint32 length, const chartype* buf);
00193 
00194 #ifdef T_ARM
00195 //ADS 1.2 compiler doesn't interpret "protected" correctly for templates.
00196 //so the constructor/destructor need to be public.
00197     public:
00198 #else
00199     protected:
00200 #endif
00201         OSCL_String();
00202         virtual ~OSCL_String();
00203 
00204     protected:
00211         virtual void set_rep(const chartype* cstr) = 0;
00212 
00217         virtual void append_rep(const chartype* cstr) = 0;
00218 
00221         virtual void set_rep(const OSCL_String& src) = 0;
00222 
00226         virtual void append_rep(const OSCL_String& src) = 0;
00227 
00231         virtual void set_len(uint32 len) = 0;
00232 };
00233 
00241 class OSCL_IMPORT_REF OSCL_wString
00242 {
00243     public:
00244         typedef oscl_wchar chartype;
00245 
00246         virtual uint32 get_size() const = 0;
00247 
00248         virtual uint32 get_maxsize() const = 0;
00249 
00250         virtual const chartype* get_cstr() const = 0;
00251 
00252         virtual bool is_writable() const;
00253 
00254         virtual chartype* get_str() const = 0;
00255 
00256         OSCL_wString& operator=(const OSCL_wString& src);
00257         OSCL_wString& operator=(const chartype* cstr);
00258 
00259         OSCL_wString& operator+=(const OSCL_wString& src);
00260         OSCL_wString& operator+=(const chartype* cstr);
00261         OSCL_wString& operator+=(const chartype c);
00262 
00263         bool operator== (const OSCL_wString& src) const;
00264         bool operator!= (const OSCL_wString& src) const;
00265         bool operator< (const OSCL_wString& src) const;
00266         bool operator<= (const OSCL_wString& src) const;
00267         bool operator> (const OSCL_wString& src) const;
00268         bool operator>= (const OSCL_wString& src) const;
00269         bool operator== (const chartype* cstr) const;
00270 
00271         chartype operator[](uint32 index) const;
00272 
00273         virtual chartype read(uint32 index)const;
00274 
00275         virtual uint32 setrep_to_wide_char(const char* src, uint32 len,
00276                                            TOSCL_wStringOp op, Oscl_DefAlloc* aAlloc);
00277 
00278         virtual int8 hash() const;
00279 
00280         virtual void write(uint32 index, chartype c);
00281         virtual void write(uint32 offset, uint32 length, const chartype* buf);
00282 
00283 #ifdef T_ARM
00284 //ADS 1.2 compiler doesn't interpret "protected" correctly for templates.
00285 //so the constructor/destructor need to be public.
00286     public:
00287 #else
00288     protected:
00289 #endif
00290         OSCL_wString();
00291         virtual ~OSCL_wString();
00292 
00293     protected:
00294         virtual void set_rep(const chartype* cstr) = 0;
00295         virtual void append_rep(const chartype* cstr) = 0;
00296 
00297         virtual void set_rep(const OSCL_wString& src) = 0;
00298         virtual void append_rep(const OSCL_wString& src) = 0;
00299 
00300         virtual void set_len(uint32 len) = 0;
00301 };
00302 
00303 #endif   // OSCL_STRING_H_INCLUDED
00304 

OSCL API
Posting Version: CORE_8.000.1.1_RC4