1 /** 2 * Yudit Unicode Editor Source File 3 * 4 * GNU Copyright (C) 1997-2006 Gaspar Sinai <gaspar@yudit.org> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License, version 2, 8 * dated June 1991. See file COPYYING for details. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 #ifndef SString_h 21 #define SString_h 22 23 #include "SBinVector.h" 24 25 #include <string.h> 26 27 // This is for %*.*s printf 28 #define SSARGS(_s) (int)_s.size(), (int)_s.size(), _s.array() 29 /** 30 * @author: Gaspar Sinai <gaspar@yudit.org> 31 * @version: 2000-04-23 32 */ 33 class SString : public SBinVector<char> 34 { 35 public: 36 SString(void); 37 SString (long l); 38 SString (double d); 39 SString (void* p); 40 SString (const char* s); 41 SString (const char* s, unsigned int len); 42 SString (const char* s, unsigned int from, unsigned int len); 43 virtual SObject* clone() const; 44 SString& operator=(const SString& v); 45 void print (int in); 46 void print (unsigned int in); 47 void print (long in); 48 void print (unsigned long in); 49 void print (double in); 50 virtual ~SString (); 51 52 int find (const SString& v, unsigned int from =0) const; 53 int find (char v, unsigned int from =0) const; 54 55 int replace (const SString& e, const SString& with, unsigned int from =0); 56 int replaceAll (const SString& e, const SString& with, unsigned int from=0); 57 void insert (unsigned int ind, const SString& v); 58 void append (const SString& v); 59 void append (long l); 60 void append (const char *, unsigned int len); 61 void append (char); 62 bool match (const SString& pattern) const; 63 64 SString& operator << (const SString& e2); 65 //friend SString& operator << (SString& e1, const SString& e2); 66 67 unsigned int hashCode () const; 68 long longValue() const; 69 double doubleValue() const; 70 inline bool operator == (const SString& e) const; 71 bool operator != (const SString& e) const; 72 bool operator < (const SString& e) const; 73 bool operator > (const SString& e) const; 74 bool operator <= (const SString& e) const; 75 bool operator >= (const SString& e) const; 76 77 int compare (const SString& s) const; 78 void truncate (unsigned int size); 79 void lower (); 80 void upper (); 81 82 char* cString() const; 83 84 protected: 85 void refer (const SString& v); 86 }; 87 88 extern SString SStringNull; 89 90 //PUBLIC/INLINE 91 /** 92 * Is it equal 93 */ 94 bool 95 SString::operator==(const SString& e) const 96 { 97 return equals(e); 98 } 99 100 101 #endif /* SString _h*/ 102