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 Latin1 = 0,
00090 UTF16 = 1,
00095 UTF16BE = 2,
00099 UTF8 = 3,
00103 UTF16LE = 4
00104 };
00105
00109 String();
00110
00116 String(const String &s);
00117
00124 String(const std::string &s, Type t = Latin1);
00125
00129 String(const wstring &s, Type t = UTF16BE);
00130
00134 String(const wchar_t *s, Type t = UTF16BE);
00135
00142 String(char c, Type t = Latin1);
00143
00147 String(wchar_t c, Type t = Latin1);
00148
00149
00156 String(const char *s, Type t = Latin1);
00157
00164 String(const ByteVector &v, Type t = Latin1);
00165
00169 virtual ~String();
00170
00176 std::string to8Bit(bool unicode = false) const;
00177
00181 wstring toWString() const;
00182
00198 const char *toCString(bool unicode = false) const;
00199
00203 Iterator begin();
00204
00208 ConstIterator begin() const;
00209
00214 Iterator end();
00215
00220 ConstIterator end() const;
00221
00226 int find(const String &s, int offset = 0) const;
00227
00233 int rfind(const String &s, int offset = -1) const;
00234
00238 bool startsWith(const String &s) const;
00239
00244 String substr(uint position, uint n = 0xffffffff) const;
00245
00250 String &append(const String &s);
00251
00257 String upper() const;
00258
00262 uint size() const;
00263
00267 uint length() const;
00268
00274 bool isEmpty() const;
00275
00283 bool isNull() const;
00284
00290 ByteVector data(Type t) const;
00291
00295 int toInt() const;
00296
00300 String stripWhiteSpace() const;
00301
00305 bool isLatin1() const;
00306
00310 bool isAscii() const;
00311
00315 static String number(int n);
00316
00320 wchar &operator[](int i);
00321
00325 const wchar &operator[](int i) const;
00326
00331 bool operator==(const String &s) const;
00332
00336 String &operator+=(const String &s);
00337
00341 String &operator+=(const wchar_t* s);
00342
00346 String &operator+=(const char* s);
00347
00351 String &operator+=(wchar_t c);
00352
00356 String &operator+=(char c);
00357
00362 String &operator=(const String &s);
00363
00367 String &operator=(const std::string &s);
00368
00372 String &operator=(const wstring &s);
00373
00377 String &operator=(const wchar_t *s);
00378
00382 String &operator=(char c);
00383
00387 String &operator=(wchar_t c);
00388
00392 String &operator=(const char *s);
00393
00397 String &operator=(const ByteVector &v);
00398
00404 bool operator<(const String &s) const;
00405
00409 static String null;
00410
00411 protected:
00417 void detach();
00418
00419 private:
00426 void prepare(Type t);
00427
00428 class StringPrivate;
00429 StringPrivate *d;
00430 };
00431
00432 }
00433
00439 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
00440
00446 TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2);
00447
00453 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2);
00454
00455
00461 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
00462
00463 #endif