Warning, /pim/akregator/src/storage/metakit/include/mk4str.inl is written in an unsupported language. File is not indexed.
0001 // mk4str.inl -- 0002 // This is part of Metakit, the homepage is http://www.equi4.com/metakit/ 0003 0004 /** @file 0005 * Members of the string package which are usually inlined 0006 */ 0007 0008 ///////////////////////////////////////////////////////////////////////////// 0009 // c4_String 0010 0011 #if defined(q4_MFC) // Microsoft Foundation Classes 0012 0013 #elif defined(q4_STD) // STL and standard strings 0014 0015 /// Construct empty string 0016 d4_inline c4_String::c4_String () 0017 { 0018 } 0019 0020 d4_inline c4_String::c4_String (char ch_, int nDup_) 0021 : string (nDup_, ch_) 0022 { 0023 } 0024 0025 d4_inline c4_String::c4_String (const char* str_) 0026 : string (str_) 0027 { 0028 } 0029 0030 d4_inline c4_String::c4_String (const void* ptr_, int len_) 0031 : string ((const char*) ptr_, len_) 0032 { 0033 } 0034 0035 d4_inline c4_String::c4_String (const d4_std::string& s_) 0036 : string (s_) 0037 { 0038 } 0039 0040 d4_inline c4_String::c4_String (const c4_String& s_) 0041 : string (s_) 0042 { 0043 } 0044 0045 d4_inline c4_String::~c4_String () 0046 { 0047 } 0048 0049 d4_inline const c4_String& c4_String::operator= (const c4_String& s_) 0050 { 0051 *(string*) this = s_; 0052 return *this; 0053 } 0054 0055 d4_inline c4_String::operator const char* () const 0056 { 0057 return c_str(); 0058 } 0059 0060 d4_inline char c4_String::operator[] (int i) const 0061 { 0062 return at(i); 0063 } 0064 0065 d4_inline c4_String operator+ (const c4_String& a_, const c4_String& b_) 0066 { 0067 return (d4_std::string) a_ + (d4_std::string) b_; 0068 } 0069 0070 d4_inline c4_String operator+ (const c4_String& a_, const char* b_) 0071 { 0072 return (d4_std::string) a_ + (d4_std::string) b_; 0073 } 0074 0075 d4_inline c4_String operator+ (const char* a_, const c4_String& b_) 0076 { 0077 return (d4_std::string) a_ + (d4_std::string) b_; 0078 } 0079 0080 d4_inline const c4_String& c4_String::operator+= (const c4_String& s_) 0081 { 0082 *(string*) this += s_; 0083 return *this; 0084 } 0085 0086 d4_inline const c4_String& c4_String::operator+= (const char* s_) 0087 { 0088 *(string*) this += s_; 0089 return *this; 0090 } 0091 0092 d4_inline int c4_String::GetLength() const 0093 { 0094 return length(); 0095 } 0096 0097 d4_inline bool c4_String::IsEmpty() const 0098 { 0099 return empty(); 0100 } 0101 0102 d4_inline void c4_String::Empty() 0103 { 0104 erase(); 0105 } 0106 0107 d4_inline c4_String c4_String::Left(int nCount_) const 0108 { 0109 if (nCount_ > length()) 0110 nCount_ = length(); 0111 return substr(0, nCount_); 0112 } 0113 0114 d4_inline c4_String c4_String::Right(int nCount_) const 0115 { 0116 if (nCount_ > length()) 0117 nCount_ = length(); 0118 return substr(length() - nCount_, nCount_); 0119 } 0120 0121 d4_inline int c4_String::Compare(const char* str_) const 0122 { 0123 return compare(str_); 0124 } 0125 0126 d4_inline bool c4_String::operator< (const c4_String& str_) const 0127 { 0128 return compare(str_) < 0; 0129 } 0130 0131 d4_inline int c4_String::Find(char ch_) const 0132 { 0133 return find(ch_); 0134 } 0135 0136 d4_inline int c4_String::ReverseFind(char ch_) const 0137 { 0138 return rfind(ch_); 0139 } 0140 0141 d4_inline int c4_String::FindOneOf(const char* set_) const 0142 { 0143 return find_first_of(set_); 0144 } 0145 0146 d4_inline int c4_String::Find(const char* sub_) const 0147 { 0148 return find(sub_); 0149 } 0150 0151 d4_inline c4_String c4_String::SpanIncluding(const char* set_) const 0152 { 0153 return substr(0, find_first_not_of(set_)); 0154 } 0155 0156 d4_inline c4_String c4_String::SpanExcluding(const char* set_) const 0157 { 0158 return substr(0, find_first_of(set_)); 0159 } 0160 0161 d4_inline bool operator== (const c4_String& a_, const c4_String& b_) 0162 { 0163 return (d4_std::string) a_ == (d4_std::string) b_; 0164 } 0165 0166 d4_inline bool operator!= (const c4_String& a_, const c4_String& b_) 0167 { 0168 return (d4_std::string) a_ != (d4_std::string) b_; 0169 } 0170 0171 d4_inline bool operator== (const c4_String& a_, const char* b_) 0172 { 0173 return (d4_std::string) a_ == (d4_std::string) b_; 0174 } 0175 0176 d4_inline bool operator== (const char* a_, const c4_String& b_) 0177 { 0178 return (d4_std::string) a_ == (d4_std::string) b_; 0179 } 0180 0181 d4_inline bool operator!= (const c4_String& a_, const char* b_) 0182 { 0183 return (d4_std::string) a_ != (d4_std::string) b_; 0184 } 0185 0186 d4_inline bool operator!= (const char* a_, const c4_String& b_) 0187 { 0188 return (d4_std::string) a_ != (d4_std::string) b_; 0189 } 0190 0191 #else // Universal replacement classes 0192 0193 /// Construct empty string 0194 d4_inline c4_String::c4_String () 0195 { 0196 Init(nullptr, 0); 0197 } 0198 0199 /// Construct string from Pascal-style <count,chars...> data 0200 d4_inline c4_String::c4_String (const unsigned char* ptr) 0201 { 0202 Init(ptr + 1, ptr ? *ptr : 0); 0203 } 0204 0205 /// Construct string from a specified area in memory 0206 d4_inline c4_String::c4_String (const void* ptr, int len) 0207 { 0208 Init(ptr, len); 0209 } 0210 0211 d4_inline const c4_String& c4_String::operator+= (const c4_String& s) 0212 { 0213 return *this = *this + s; 0214 } 0215 0216 d4_inline const c4_String& c4_String::operator+= (const char* s) 0217 { 0218 return *this += (c4_String) s; 0219 } 0220 0221 d4_inline const char* c4_String::Data() const 0222 { 0223 return (const char*) (_value + 2); 0224 } 0225 0226 d4_inline c4_String::operator const char* () const 0227 { 0228 return Data(); 0229 } 0230 0231 d4_inline c4_String::operator const unsigned char* () const 0232 { 0233 return (unsigned char*) Data() - 1; 0234 } 0235 0236 d4_inline char c4_String::operator[] (int i) const 0237 { 0238 return Data()[i]; 0239 } 0240 0241 d4_inline int c4_String::GetLength() const 0242 { 0243 return _value[1] != 255 ? _value[1] : FullLength(); 0244 } 0245 0246 d4_inline bool c4_String::IsEmpty() const 0247 { 0248 return GetLength() == 0; 0249 } 0250 0251 d4_inline void c4_String::Empty() 0252 { 0253 *this = ""; 0254 } 0255 0256 d4_inline bool c4_String::operator< (const c4_String& a) const 0257 { 0258 return Compare(a) < 0; 0259 } 0260 0261 d4_inline c4_String operator+ (const char* a, const c4_String& b) 0262 { 0263 return (c4_String) a + b; 0264 } 0265 0266 d4_inline c4_String operator+ (const c4_String& a, const char* b) 0267 { 0268 return a + (c4_String) b; 0269 } 0270 0271 d4_inline bool operator== (const char* a, const c4_String& b) 0272 { 0273 return b.Compare(a) == 0; 0274 } 0275 0276 d4_inline bool operator== (const c4_String& a, const char* b) 0277 { 0278 return a.Compare(b) == 0; 0279 } 0280 0281 d4_inline bool operator!= (const c4_String& a, const c4_String& b) 0282 { 0283 return !(a == b); 0284 } 0285 0286 d4_inline bool operator!= (const char* a, const c4_String& b) 0287 { 0288 return b.Compare(a) != 0; 0289 } 0290 0291 d4_inline bool operator!= (const c4_String& a, const char* b) 0292 { 0293 return a.Compare(b) != 0; 0294 } 0295 0296 #endif // q4_UNIV 0297 0298 /////////////////////////////////////////////////////////////////////////////