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 <ostream>
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
00060
00076 class TAGLIB_EXPORT String
00077 {
00078 public:
00079
00080 #ifndef DO_NOT_DOCUMENT
00081 typedef std::basic_string<wchar>::iterator Iterator;
00082 typedef std::basic_string<wchar>::const_iterator ConstIterator;
00083 #endif
00084
00089 enum Type {
00093 Latin1 = 0,
00097 UTF16 = 1,
00102 UTF16BE = 2,
00106 UTF8 = 3,
00110 UTF16LE = 4
00111 };
00112
00116 String();
00117
00123 String(const String &s);
00124
00131 String(const std::string &s, Type t = Latin1);
00132
00136 String(const wstring &s, Type t = UTF16BE);
00137
00141 String(const wchar_t *s, Type t = UTF16BE);
00142
00149 String(char c, Type t = Latin1);
00150
00154 String(wchar_t c, Type t = Latin1);
00155
00156
00163 String(const char *s, Type t = Latin1);
00164
00171 String(const ByteVector &v, Type t = Latin1);
00172
00176 virtual ~String();
00177
00183 std::string to8Bit(bool unicode = false) const;
00184
00188 wstring toWString() const;
00189
00205 const char *toCString(bool unicode = false) const;
00206
00210 Iterator begin();
00211
00215 ConstIterator begin() const;
00216
00221 Iterator end();
00222
00227 ConstIterator end() const;
00228
00233 int find(const String &s, int offset = 0) const;
00234
00240 int rfind(const String &s, int offset = -1) const;
00241
00245 bool startsWith(const String &s) const;
00246
00251 String substr(uint position, uint n = 0xffffffff) const;
00252
00257 String &append(const String &s);
00258
00264 String upper() const;
00265
00269 uint size() const;
00270
00274 uint length() const;
00275
00281 bool isEmpty() const;
00282
00290 bool isNull() const;
00291
00297 ByteVector data(Type t) const;
00298
00305
00306 int toInt() const;
00307
00315 int toInt(bool *ok) const;
00316
00320 String stripWhiteSpace() const;
00321
00325 bool isLatin1() const;
00326
00330 bool isAscii() const;
00331
00335 static String number(int n);
00336
00340 wchar &operator[](int i);
00341
00345 const wchar &operator[](int i) const;
00346
00351 bool operator==(const String &s) const;
00352
00356 String &operator+=(const String &s);
00357
00361 String &operator+=(const wchar_t* s);
00362
00366 String &operator+=(const char* s);
00367
00371 String &operator+=(wchar_t c);
00372
00376 String &operator+=(char c);
00377
00382 String &operator=(const String &s);
00383
00387 String &operator=(const std::string &s);
00388
00392 String &operator=(const wstring &s);
00393
00397 String &operator=(const wchar_t *s);
00398
00402 String &operator=(char c);
00403
00407 String &operator=(wchar_t c);
00408
00412 String &operator=(const char *s);
00413
00417 String &operator=(const ByteVector &v);
00418
00424 bool operator<(const String &s) const;
00425
00429 static String null;
00430
00431 protected:
00437 void detach();
00438
00439 private:
00446 void prepare(Type t);
00447
00448 class StringPrivate;
00449 StringPrivate *d;
00450 };
00451
00452 }
00453
00459 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
00460
00466 TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2);
00467
00473 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2);
00474
00475
00481 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
00482
00483 #endif