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
00023
00024
00025
00026 #ifndef TAGLIB_STRING_H
00027 #define TAGLIB_STRING_H
00028
00029 #include "taglib_export.h"
00030 #include "taglib.h"
00031 #include "tbytevector.h"
00032
00033 #include <string>
00034 #include <iostream>
00035
00044 #define QStringToTString(s) TagLib::String(s.utf8().data(), TagLib::String::UTF8)
00045
00055 #define TStringToQString(s) QString::fromUtf8(s.toCString(true))
00056
00057 namespace TagLib {
00058
00059 class StringList;
00060
00062
00078 class TAGLIB_EXPORT String
00079 {
00080 public:
00081
00082 #ifndef DO_NOT_DOCUMENT
00083 typedef std::basic_string<wchar>::iterator Iterator;
00084 typedef std::basic_string<wchar>::const_iterator ConstIterator;
00085 #endif
00086
00091 enum Type {
00095 Latin1 = 0,
00099 UTF16 = 1,
00104 UTF16BE = 2,
00108 UTF8 = 3,
00112 UTF16LE = 4
00113 };
00114
00118 String();
00119
00125 String(const String &s);
00126
00133 String(const std::string &s, Type t = Latin1);
00134
00138 String(const wstring &s, Type t = UTF16BE);
00139
00143 String(const wchar_t *s, Type t = UTF16BE);
00144
00151 String(char c, Type t = Latin1);
00152
00156 String(wchar_t c, Type t = Latin1);
00157
00158
00165 String(const char *s, Type t = Latin1);
00166
00173 String(const ByteVector &v, Type t = Latin1);
00174
00178 virtual ~String();
00179
00185 std::string to8Bit(bool unicode = false) const;
00186
00190 wstring toWString() const;
00191
00207 const char *toCString(bool unicode = false) const;
00208
00212 Iterator begin();
00213
00217 ConstIterator begin() const;
00218
00223 Iterator end();
00224
00229 ConstIterator end() const;
00230
00235 int find(const String &s, int offset = 0) const;
00236
00242 int rfind(const String &s, int offset = -1) const;
00243
00247 StringList split(const String &separator = " ") const;
00248
00252 bool startsWith(const String &s) const;
00253
00258 String substr(uint position, uint n = 0xffffffff) const;
00259
00264 String &append(const String &s);
00265
00271 String upper() const;
00272
00276 uint size() const;
00277
00281 uint length() const;
00282
00288 bool isEmpty() const;
00289
00297 bool isNull() const;
00298
00304 ByteVector data(Type t) const;
00305
00312
00313 int toInt() const;
00314
00322 int toInt(bool *ok) const;
00323
00327 String stripWhiteSpace() const;
00328
00332 bool isLatin1() const;
00333
00337 bool isAscii() const;
00338
00342 static String number(int n);
00343
00347 wchar &operator[](int i);
00348
00352 const wchar &operator[](int i) const;
00353
00358 bool operator==(const String &s) const;
00359
00364 bool operator!=(const String &s) const;
00365
00369 String &operator+=(const String &s);
00370
00374 String &operator+=(const wchar_t* s);
00375
00379 String &operator+=(const char* s);
00380
00384 String &operator+=(wchar_t c);
00385
00389 String &operator+=(char c);
00390
00395 String &operator=(const String &s);
00396
00400 String &operator=(const std::string &s);
00401
00405 String &operator=(const wstring &s);
00406
00410 String &operator=(const wchar_t *s);
00411
00415 String &operator=(char c);
00416
00420 String &operator=(wchar_t c);
00421
00425 String &operator=(const char *s);
00426
00430 String &operator=(const ByteVector &v);
00431
00437 bool operator<(const String &s) const;
00438
00442 static String null;
00443
00444 protected:
00450 void detach();
00451
00452 private:
00459 void prepare(Type t);
00460
00461 class StringPrivate;
00462 StringPrivate *d;
00463 };
00464
00465 }
00466
00472 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
00473
00479 TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2);
00480
00486 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2);
00487
00488
00494 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
00495
00496 #endif