1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 // -*- c++ -*- 19 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 20 21 // O S C L_ S T R I N G _ R E P 22 // 23 // This file contains a standardized set of string containers that 24 // can be used in place of character arrays. 25 26 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 27 28 /*! \addtogroup osclutil OSCL Util 29 * 30 * @{ 31 */ 32 33 34 /*! 35 * \file oscl_string_rep.h 36 * \brief Contains some internal implementation for string containers. 37 * 38 */ 39 40 41 #ifndef OSCL_STRING_REP_H_INCLUDED 42 #define OSCL_STRING_REP_H_INCLUDED 43 44 45 #ifndef OSCL_DEFALLOC_H_INCLUDED 46 #include "oscl_defalloc.h" 47 #endif 48 49 50 51 /** For internal use only-- heap string representation 52 */ 53 class CHeapRep 54 { 55 public: 56 CHeapRep() 57 : refcount(0) 58 , buffer(NULL) 59 , maxsize(0) 60 , size(0) 61 {} 62 63 OSCL_IMPORT_REF static void set_rep(CHeapRep*&, Oscl_DefAlloc&, const char*, uint32); 64 OSCL_IMPORT_REF static void set_rep(CHeapRep*&, Oscl_DefAlloc&, const oscl_wchar*, uint32); 65 OSCL_IMPORT_REF static void append_rep(CHeapRep*&, Oscl_DefAlloc&, const char*, uint32); 66 OSCL_IMPORT_REF static void append_rep(CHeapRep*&, Oscl_DefAlloc&, const oscl_wchar*, uint32); 67 68 uint32 refcount; 69 OsclAny* buffer; 70 uint32 maxsize; 71 uint32 size; 72 OSCL_IMPORT_REF bool set(uint32, const char*, Oscl_DefAlloc &); 73 OSCL_IMPORT_REF bool set(uint32, const oscl_wchar*, Oscl_DefAlloc &); 74 OSCL_IMPORT_REF bool append(uint32, const char*, uint32, const char*, Oscl_DefAlloc &); 75 OSCL_IMPORT_REF bool append(uint32, const oscl_wchar*, uint32, const oscl_wchar*, Oscl_DefAlloc &); 76 OSCL_IMPORT_REF void add_ref(); 77 OSCL_IMPORT_REF void remove_ref(Oscl_DefAlloc &); 78 79 OSCL_IMPORT_REF static void assign(CHeapRep*&, CHeapRep*, Oscl_DefAlloc &); 80 private: 81 static CHeapRep *New(Oscl_DefAlloc &); 82 }; 83 84 /** For internal use only-- stack string representation 85 */ 86 class CStackRep 87 { 88 public: 89 CStackRep() 90 : maxsize(0) 91 , size(0) 92 , buffer(NULL) 93 {} 94 uint32 maxsize; 95 uint32 size; 96 OsclAny* buffer; 97 OSCL_IMPORT_REF void set(const char* cp, uint32 len); 98 OSCL_IMPORT_REF void set(const oscl_wchar* cp, uint32 len); 99 OSCL_IMPORT_REF void append(const char* cp, uint32 len); 100 OSCL_IMPORT_REF void append(const oscl_wchar* cp, uint32 len); 101 }; 102 103 104 /** For internal use only-- fast string representation 105 */ 106 class CFastRep 107 { 108 public: 109 CFastRep() 110 : maxsize(0) 111 , size(0) 112 , buffer(NULL) 113 , writable(false) 114 {} 115 uint32 maxsize; 116 uint32 size; 117 OsclAny* buffer; 118 bool writable; 119 OSCL_IMPORT_REF void set_w(char* cp, uint32 len, uint32 maxlen); 120 OSCL_IMPORT_REF void set_w(oscl_wchar* cp, uint32 len, uint32 maxlen); 121 OSCL_IMPORT_REF void set_r(const char* cp, uint32 len); 122 OSCL_IMPORT_REF void set_r(const oscl_wchar* cp, uint32 len); 123 OSCL_IMPORT_REF void append(const char* cp, uint32 len); 124 OSCL_IMPORT_REF void append(const oscl_wchar* cp, uint32 len); 125 }; 126 127 128 #endif // OSCL_STRING_REP_H_INCLUDED 129 130 /*! @} */ 131