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
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
00330
00331
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