tstring.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00035 #define QStringToTString(s) TagLib::String(s.utf8().data(), TagLib::String::UTF8)
00036
00042 #define TStringToQString(s) QString::fromUtf8(s.toCString(true))
00043
00044 namespace TagLib {
00045
00047
00063 class String
00064 {
00065 public:
00066
00067 #ifndef DO_NOT_DOCUMENT
00068 typedef std::basic_string<wchar>::iterator Iterator;
00069 typedef std::basic_string<wchar>::const_iterator ConstIterator;
00070 #endif
00071
00076 enum Type {
00080 Latin1 = 0,
00084 UTF16 = 1,
00089 UTF16BE = 2,
00093 UTF8 = 3
00094 };
00095
00099 String();
00100
00106 String(const String &s);
00107
00114 String(const std::string &s, Type t = Latin1);
00115
00119 String(const wstring &s, Type t = UTF16BE);
00120
00124 String(const wchar_t *s, Type t = UTF16BE);
00125
00132 String(char c, Type t = Latin1);
00133
00137 String(wchar_t c, Type t = Latin1);
00138
00139
00146 String(const char *s, Type t = Latin1);
00147
00154 String(const ByteVector &v, Type t = Latin1);
00155
00159 virtual ~String();
00160
00166 std::string to8Bit(bool unicode = false) const;
00167
00183 const char *toCString(bool unicode = false) const;
00184
00188 Iterator begin();
00189
00193 ConstIterator begin() const;
00194
00199 Iterator end();
00200
00205 ConstIterator end() const;
00206
00211 int find(const String &s, int offset = 0) const;
00212
00217 String substr(uint position, uint n = 0xffffffff) const;
00218
00223 String &append(const String &s);
00224
00230 String upper() const;
00231
00235 uint size() const;
00236
00242 bool isEmpty() const;
00243
00251 bool isNull() const;
00252
00258 ByteVector data(Type t) const;
00259
00263 int toInt() const;
00264
00268 String stripWhiteSpace() const;
00269
00273 static String number(int n);
00274
00278 wchar &operator[](int i);
00279
00283 const wchar &operator[](int i) const;
00284
00289 bool operator==(const String &s) const;
00290
00294 String &operator+=(const String &s);
00295
00299 String &operator+=(const wchar_t* s);
00300
00304 String &operator+=(const char* s);
00305
00309 String &operator+=(wchar_t c);
00310
00314 String &operator+=(char c);
00315
00320 String &operator=(const String &s);
00321
00325 String &operator=(const std::string &s);
00326
00330 String &operator=(const wstring &s);
00331
00335 String &operator=(const wchar_t *s);
00336
00340 String &operator=(char c);
00341
00345 String &operator=(wchar_t c);
00346
00350 String &operator=(const char *s);
00351
00355 String &operator=(const ByteVector &v);
00356
00362 bool operator<(const String &s) const;
00363
00367 static String null;
00368
00369 protected:
00375 void detach();
00376
00377 private:
00384 void prepare(Type t);
00385
00386 class StringPrivate;
00387 StringPrivate *d;
00388 };
00389
00390 }
00391
00395 const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
00396
00400 const TagLib::String operator+(const char *s1, const TagLib::String &s2);
00401
00405 const TagLib::String operator+(const TagLib::String &s1, const char *s2);
00406
00407
00412 std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
00413
00414 #endif