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 Locale = -1,
00099 Latin1ID3 = 65,
00103 Latin1ID3V2 = 66,
00107 Latin1 = 0,
00111 UTF16 = 1,
00116 UTF16BE = 2,
00120 UTF8 = 3,
00124 UTF16LE = 4
00125 };
00126
00127 static Type ID3Type(int i);
00128 static Type ID3WType(Type type);
00129 static Type ID3RealType(Type type);
00130
00134 String();
00135
00141 String(const String &s);
00142
00149 String(const std::string &s, Type t = Latin1);
00150
00154 String(const wstring &s, Type t = UTF16BE);
00155
00159 String(const wchar_t *s, Type t = UTF16BE);
00160
00167 String(char c, Type t = Latin1);
00168
00172 String(wchar_t c, Type t = Latin1);
00173
00174
00181 String(const char *s, Type t = Latin1);
00182
00189 String(const ByteVector &v, Type t = Latin1);
00190
00194 virtual ~String();
00195
00201 std::string to8Bit(bool unicode = false) const;
00202
00206 wstring toWString() const;
00207
00223 const char *toCString(bool unicode = false) const;
00224
00228 Iterator begin();
00229
00233 ConstIterator begin() const;
00234
00239 Iterator end();
00240
00245 ConstIterator end() const;
00246
00251 int find(const String &s, int offset = 0) const;
00252
00258 int rfind(const String &s, int offset = -1) const;
00259
00263 StringList split(const String &separator = " ") const;
00264
00268 bool startsWith(const String &s) const;
00269
00274 String substr(uint position, uint n = 0xffffffff) const;
00275
00280 String &append(const String &s);
00281
00287 String upper() const;
00288
00292 uint size() const;
00293
00297 uint length() const;
00298
00304 bool isEmpty() const;
00305
00313 bool isNull() const;
00314
00320 ByteVector data(Type t) const;
00321
00328
00329 int toInt() const;
00330
00338 int toInt(bool *ok) const;
00339
00343 String stripWhiteSpace() const;
00344
00348 bool isLatin1() const;
00349
00353 bool isAscii() const;
00354
00358 static String number(int n);
00359
00363 wchar &operator[](int i);
00364
00368 const wchar &operator[](int i) const;
00369
00374 bool operator==(const String &s) const;
00375
00380 bool operator!=(const String &s) const;
00381
00385 String &operator+=(const String &s);
00386
00390 String &operator+=(const wchar_t* s);
00391
00395 String &operator+=(const char* s);
00396
00400 String &operator+=(wchar_t c);
00401
00405 String &operator+=(char c);
00406
00411 String &operator=(const String &s);
00412
00416 String &operator=(const std::string &s);
00417
00421 String &operator=(const wstring &s);
00422
00426 String &operator=(const wchar_t *s);
00427
00431 String &operator=(char c);
00432
00436 String &operator=(wchar_t c);
00437
00441 String &operator=(const char *s);
00442
00446 String &operator=(const ByteVector &v);
00447
00453 bool operator<(const String &s) const;
00454
00458 static String null;
00459
00460 protected:
00466 void detach();
00467
00468 private:
00475 void prepare(Type t);
00476
00477 class StringPrivate;
00478 StringPrivate *d;
00479 };
00480
00481 }
00482
00488 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
00489
00495 TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2);
00496
00502 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2);
00503
00504
00510 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
00511
00512 #endif