00001 /* 00002 * $Id: String.h 562 2007-12-02 08:04:16Z mindstorm2600 $ 00003 * 00004 * X-VR2 00005 * 00006 * Copyright (C) Juan V. Guerrero 2007 00007 * 00008 * Juan V. Guerrero <mindstorm2600@users.sourceforge.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License Version 2. See the LICENSE file 00012 * at the top of the source tree. 00013 */ 00014 #ifndef __XVR2_STRING_H__ 00015 #define __XVR2_STRING_H__ 00016 #define __XVR2_ENABLE_BASIC_STRING__ 00017 #include<xvr2/BasicString.h> 00018 #include<xvr2/CoreExceptions.h> 00019 00020 namespace xvr2{ 00029 class String:public BasicString<char> { 00030 private: 00031 protected: 00032 public: 00034 String(); 00037 String(const String &s); 00041 String(const char *s); 00046 String(const Int32 n); 00051 String(const UInt32 n); 00056 String(const Int64 n); 00061 String(const UInt64 n); 00067 String(const float n); 00073 String(const double n); 00079 String(const long double n); 00082 String(const std::string &s); 00085 String(const std::string *s); 00086 String(const xvr2::Object &o); 00092 String &assign(const Int32 n); 00098 String &assign(const Int64 n); 00104 String &assign(const UInt32 n); 00110 String &assign(const UInt64 n); 00116 String &assign(const float n); 00122 String &assign(const double n); 00128 String &assign(const long double n); 00134 String &assign(const char c); 00140 String &assign(const char *sstr); 00146 String &assign(const std::string *s); 00152 String &assign(const String &sstr); 00158 String &concat(const char *s); 00164 String &concat(const char c); 00170 String &concat(const String &s); 00176 String &concat(const Int32 n); 00182 String &concat(const Int64 n); 00188 String &concat(const UInt32 n); 00194 String &concat(const UInt64 n); 00200 String &concat(const float n); 00206 String &concat(const double n); 00212 String &concat(const long double n); 00215 String& operator=(const Int32 n); 00218 String& operator=(const UInt32 n); 00221 String& operator=(const Int64 n); 00224 String& operator=(const UInt64 n); 00227 String& operator=(const float n); 00230 String& operator=(const double n); 00233 String& operator=(const long double n); 00236 String& operator=(const String &s); 00237 const String& operator+=(const String &s); 00240 const String& operator+=(const Int32 n); 00243 const String& operator+=(const UInt32 n); 00246 const String& operator+=(const Int64 n); 00249 const String& operator+=(const UInt64 n); 00252 const String& operator+=(const float n); 00255 const String& operator+=(const double n); 00258 const String& operator+=(const long double n); 00269 friend std::ostream& operator<<(std::ostream& stream, 00270 const String &s); 00274 const String& toUpperCase(); 00278 const String& toLowerCase(); 00283 const int toInt(); 00289 const unsigned int toUInt(); 00293 const float toFloat(); 00297 const double toDouble(); 00301 const long double toLongDouble(); 00305 const Int64 toInt64(); 00307 const bool operator==(const Int32 n); 00309 const bool operator==(const UInt32 n); 00311 const bool operator==(const Int64 n); 00313 const bool operator==(const UInt64 n); 00315 const bool operator==(const float n); 00317 const bool operator==(const double n); 00319 const bool operator==(const long double n); 00325 const bool operator!=(const Int32 n); 00331 const bool operator!=(const UInt32 n); 00337 const bool operator!=(const Int64 n); 00343 const bool operator!=(const UInt64 n); 00349 const bool operator!=(const float n); 00355 const bool operator!=(const double n); 00361 const bool operator!=(const long double n); 00367 int compare(const String &s) const; 00372 bool equals(const char c) const; 00376 bool equals(const String &s) const; 00380 bool equals(const String &s); 00385 const bool equals(const Int32 n); 00390 const bool equals(const UInt32 n); 00395 const bool equals(const Int64 n); 00400 const bool equals(const UInt64 n); 00405 const bool equals(const float n); 00410 const bool equals(const double n); 00415 const bool equals(const long double n); 00421 bool startsIWith(const char *s) const; 00427 bool startsWith(const String &s) const; 00433 bool endsIWith(const char *s) const; 00439 bool endsWith(const String &s) const; 00446 String getSubstr(int start, int end); 00449 virtual std::string toString(); 00454 void eat(const char *data, int len); 00459 virtual String &trimLeft(const char c = ' '); 00464 virtual String &trimRight(const char c = ' '); 00465 }; 00466 extern const String NL; 00467 } 00468 #endif