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
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
00041 #define QStringToTString(s) TagLib::String(s.utf8().data(), TagLib::String::UTF8)
00042
00048 #define TStringToQString(s) QString::fromUtf8(s.toCString(true))
00049
00050 namespace TagLib {
00051
00053
00069 class TAGLIB_EXPORT String
00070 {
00071 public:
00072
00073 #ifndef DO_NOT_DOCUMENT
00074 typedef std::basic_string<wchar>::iterator Iterator;
00075 typedef std::basic_string<wchar>::const_iterator ConstIterator;
00076 #endif
00077
00082 enum Type {
00086 Locale = -1,
00090 Latin1ID3 = 65,
00094 Latin1ID3V2 = 66,
00098 Latin1 = 0,
00102 UTF16 = 1,
00107 UTF16BE = 2,
00111 UTF8 = 3,
00115 UTF16LE = 4
00116 };
00117
00118 static Type ID3Type(int i);
00119 static Type ID3WType(Type type);
00120 static Type ID3RealType(Type type);
00121
00125 String();
00126
00132 String(const String &s);
00133
00140 String(const std::string &s, Type t = Latin1);
00141
00145 String(const wstring &s, Type t = UTF16BE);
00146
00150 String(const wchar_t *s, Type t = UTF16BE);
00151
00158 String(char c, Type t = Latin1);
00159
00163 String(wchar_t c, Type t = Latin1);
00164
00165
00172 String(const char *s, Type t = Latin1);
00173
00180 String(const ByteVector &v, Type t = Latin1);
00181
00185 virtual ~String();
00186
00192 std::string to8Bit(bool unicode = false) const;
00193
00197 wstring toWString() const;
00198
00214 const char *toCString(bool unicode = false) const;
00215
00219 Iterator begin();
00220
00224 ConstIterator begin() const;
00225
00230 Iterator end();
00231
00236 ConstIterator end() const;
00237
00242 int find(const String &s, int offset = 0) const;
00243
00249 int rfind(const String &s, int offset = -1) const;
00250
00254 bool startsWith(const String &s) const;
00255
00260 String substr(uint position, uint n = 0xffffffff) const;
00261
00266 String &append(const String &s);
00267
00273 String upper() const;
00274
00278 uint size() const;
00279
00283 uint length() const;
00284
00290 bool isEmpty() const;
00291
00299 bool isNull() const;
00300
00306 ByteVector data(Type t) const;
00307
00311 int toInt() const;
00312
00316 String stripWhiteSpace() const;
00317
00321 bool isLatin1() const;
00322
00326 bool isAscii() const;
00327
00331 static String number(int n);
00332
00336 wchar &operator[](int i);
00337
00341 const wchar &operator[](int i) const;
00342
00347 bool operator==(const String &s) const;
00348
00352 String &operator+=(const String &s);
00353
00357 String &operator+=(const wchar_t* s);
00358
00362 String &operator+=(const char* s);
00363
00367 String &operator+=(wchar_t c);
00368
00372 String &operator+=(char c);
00373
00378 String &operator=(const String &s);
00379
00383 String &operator=(const std::string &s);
00384
00388 String &operator=(const wstring &s);
00389
00393 String &operator=(const wchar_t *s);
00394
00398 String &operator=(char c);
00399
00403 String &operator=(wchar_t c);
00404
00408 String &operator=(const char *s);
00409
00413 String &operator=(const ByteVector &v);
00414
00420 bool operator<(const String &s) const;
00421
00425 static String null;
00426
00427 protected:
00433 void detach();
00434
00435 private:
00442 void prepare(Type t);
00443
00444 class StringPrivate;
00445 StringPrivate *d;
00446 };
00447
00448 }
00449
00455 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
00456
00462 TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2);
00463
00469 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2);
00470
00471
00477 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
00478
00479 #endif