Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

tstring.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 copyright : (C) 2002, 2003 by Scott Wheeler 00003 email : wheeler@kde.org 00004 ***************************************************************************/ 00005 00006 /*************************************************************************** 00007 * This library is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU Lesser General Public License version * 00009 * 2.1 as published by the Free Software Foundation. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the Free Software * 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * 00019 * USA * 00020 ***************************************************************************/ 00021 00022 #ifndef TAGLIB_STRING_H 00023 #define TAGLIB_STRING_H 00024 00025 #include "taglib.h" 00026 #include "tbytevector.h" 00027 00028 #include <string> 00029 00033 #define QStringToTString(s) TagLib::String(s.utf8().data(), TagLib::String::UTF8) 00034 00038 #define TStringToQString(s) QString::fromUtf8(s.toCString(true)) 00039 00040 namespace TagLib { 00041 00043 00059 class String 00060 { 00061 public: 00066 enum Type { 00070 Latin1 = 0, 00074 UTF16 = 1, 00079 UTF16BE = 2, 00083 UTF8 = 3 00084 }; 00085 00089 String(); 00090 00096 String(const String &s); 00097 00104 String(const std::string &s, Type t = Latin1); 00105 00109 String(const wstring &s, Type t = UTF16BE); 00110 00114 String(const wchar_t *s, Type t = UTF16BE); 00115 00122 String(char c, Type t = Latin1); 00123 00127 String(wchar_t c, Type t = Latin1); 00128 00129 00136 String(const char *s, Type t = Latin1); 00137 00144 String(const ByteVector &v, Type t = Latin1); 00145 00149 virtual ~String(); 00150 00156 std::string to8Bit(bool unicode = false) const; 00157 00173 const char *toCString(bool unicode = false) const; 00174 00179 int find(const String &s, int offset = 0) const; 00180 00185 String substr(uint position, uint n = 0xffffffff) const; 00186 00191 String &append(const String &s); 00192 00198 String upper() const; 00199 00203 uint size() const; 00204 00210 bool isEmpty() const; 00211 00219 bool isNull() const; 00220 00226 ByteVector data(Type t) const; 00227 00231 int toInt() const; 00232 00236 String stripWhiteSpace() const; 00237 00241 static String number(int n); 00242 00247 bool operator==(const String &s) const; 00248 00252 String &operator+=(const String &s); 00253 00257 String &operator+=(const wchar_t* s); 00258 00262 String &operator+=(const char* s); 00263 00267 String &operator+=(wchar_t c); 00268 00272 String &operator+=(char c); 00273 00278 String &operator=(const String &s); 00279 00283 String &operator=(const std::string &s); 00284 00288 String &operator=(const wstring &s); 00289 00293 String &operator=(const wchar_t *s); 00294 00298 String &operator=(char c); 00299 00303 String &operator=(wchar_t c); 00304 00308 String &operator=(const char *s); 00309 00313 String &operator=(const ByteVector &v); 00314 00320 bool operator<(const String &s) const; 00321 00325 static String null; 00326 00327 protected: 00328 /* 00329 * If this String is being shared via implicit sharing, do a deep copy of the 00330 * data and separate from the shared members. This should be called by all 00331 * non-const subclass members. 00332 */ 00333 void detach(); 00334 00335 private: 00342 void prepare(Type t); 00343 00344 class StringPrivate; 00345 StringPrivate *d; 00346 }; 00347 00348 } 00349 00353 const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2); 00354 00358 const TagLib::String operator+(const char *s1, const TagLib::String &s2); 00359 00363 const TagLib::String operator+(const TagLib::String &s1, const char *s2); 00364 00365 00370 std::ostream &operator<<(std::ostream &s, const TagLib::String &str); 00371 00372 #endif

Generated on Wed Jul 28 16:43:07 2004 for TagLib by doxygen 1.3.7