| TagLib 1.13 |  |

tstring.h
Go to the documentation of this file.
1/***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
5
6/***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26#ifndef TAGLIB_STRING_H
27#define TAGLIB_STRING_H
28
29#include "taglib_export.h"
30#include "taglib.h"
31#include "tbytevector.h"
32
33#include <string>
34#include <iostream>
35
45#if defined(QT_VERSION) && (QT_VERSION >= 0x040000)
46#define QStringToTString(s) TagLib::String(s.toUtf8().data(), TagLib::String::UTF8)
47#else
48#define QStringToTString(s) TagLib::String(s.utf8().data(), TagLib::String::UTF8)
49#endif
50
61#define TStringToQString(s) QString::fromUtf8(s.toCString(true))
62
63 namespace TagLib {
64
65 class StringList;
66
68
84 class TAGLIB_EXPORT String
85 {
86 public:
87
88#ifndef DO_NOT_DOCUMENT
89 typedef TagLib::wstring::iterator Iterator;
90 typedef TagLib::wstring::const_iterator ConstIterator;
91#endif
92
97 enum Type {
101 Latin1 = 0,
105 UTF16 = 1,
110 UTF16BE = 2,
114 UTF8 = 3,
118 UTF16LE = 4
119 };
120
124 String();
125
131 String(const String &s);
132
139 String(const std::string &s, Type t = Latin1);
140
148 String(const wstring &s, Type t = UTF16BE);
149
157 String(const wchar_t *s, Type t = UTF16BE);
158
165 String(char c, Type t = Latin1);
166
170 String(wchar_t c, Type t = Latin1);
171
178 String(const char *s, Type t = Latin1);
179
183 String(const ByteVector &v, Type t = Latin1);
184
188 virtual ~String();
189
196 std::string to8Bit(bool unicode = false) const;
197
205 wstring toWString() const;
206
225 const char *toCString(bool unicode = false) const;
226
243 const wchar_t *toCWString() const;
244
248 Iterator begin();
249
253 ConstIterator begin() const;
254
259 Iterator end();
260
265 ConstIterator end() const;
266
271 int find(const String &s, int offset = 0) const;
272
278 int rfind(const String &s, int offset = -1) const;
279
283 StringList split(const String &separator = " ") const;
284
288 bool startsWith(const String &s) const;
289
294 String substr(unsigned int position, unsigned int n = 0xffffffff) const;
295
300 String &append(const String &s);
301
305 String &clear();
306
312 String upper() const;
313
317 unsigned int size() const;
318
322 unsigned int length() const;
323
329 bool isEmpty() const;
330
342 // BIC: remove
343 TAGLIB_DEPRECATED bool isNull() const;
344
355 ByteVector data(Type t) const;
356
363 // BIC: merge with the method below
364 int toInt() const;
365
373 int toInt(bool *ok) const;
374
378 String stripWhiteSpace() const;
379
383 bool isLatin1() const;
384
388 bool isAscii() const;
389
393 static String number(int n);
394
398 wchar_t &operator[](int i);
399
403 const wchar_t &operator[](int i) const;
404
409 bool operator==(const String &s) const;
410
415 bool operator!=(const String &s) const;
416
421 bool operator==(const char *s) const;
422
427 bool operator!=(const char *s) const;
428
433 bool operator==(const wchar_t *s) const;
434
439 bool operator!=(const wchar_t *s) const;
440
444 String &operator+=(const String &s);
445
449 String &operator+=(const wchar_t* s);
450
454 String &operator+=(const char* s);
455
459 String &operator+=(wchar_t c);
460
464 String &operator+=(char c);
465
470 String &operator=(const String &s);
471
475 String &operator=(const std::string &s);
476
480 String &operator=(const wstring &s);
481
485 String &operator=(const wchar_t *s);
486
490 String &operator=(char c);
491
495 String &operator=(wchar_t c);
496
500 String &operator=(const char *s);
501
505 String &operator=(const ByteVector &v);
506
510 void swap(String &s);
511
517 bool operator<(const String &s) const;
518
527 // BIC: remove
528 TAGLIB_DEPRECATED static String null;
529
530 protected:
536 void detach();
537
538 private:
543 // BIC: remove
544 TAGLIB_DEPRECATED static const Type WCharByteOrder;
545
546 class StringPrivate;
547 StringPrivate *d;
548 };
549}
550
556 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
557
563 TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2);
564
570 TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2);
571
572
578 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
579
580#endif
TagLib::ByteVector
A byte vector.
Definition: tbytevector.h:46
TagLib::StringList
A list of strings.
Definition: tstringlist.h:46
TagLib::String
A wide string class suitable for unicode.
Definition: tstring.h:85
TagLib::String::operator=
String & operator=(const String &s)
TagLib::String::operator==
bool operator==(const wchar_t *s) const
TagLib::String::upper
String upper() const
TagLib::String::~String
virtual ~String()
TagLib::String::isEmpty
bool isEmpty() const
TagLib::String::isLatin1
bool isLatin1() const
TagLib::String::swap
void swap(String &s)
TagLib::String::operator+=
String & operator+=(wchar_t c)
TagLib::String::startsWith
bool startsWith(const String &s) const
TagLib::String::operator+=
String & operator+=(char c)
TagLib::String::String
String()
TagLib::String::detach
void detach()
TagLib::String::append
String & append(const String &s)
TagLib::String::split
StringList split(const String &separator=" ") const
TagLib::String::toWString
wstring toWString() const
TagLib::String::operator=
String & operator=(const ByteVector &v)
TagLib::String::String
String(char c, Type t=Latin1)
TagLib::String::operator!=
bool operator!=(const char *s) const
TagLib::String::String
String(const wchar_t *s, Type t=UTF16BE)
TagLib::String::operator!=
bool operator!=(const wchar_t *s) const
TagLib::String::operator+
TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2)
TagLib::String::data
ByteVector data(Type t) const
TagLib::String::operator<<
TAGLIB_EXPORT std::ostream & operator<<(std::ostream &s, const TagLib::String &str)
TagLib::String::number
static String number(int n)
TagLib::String::String
String(const wstring &s, Type t=UTF16BE)
TagLib::String::end
ConstIterator end() const
TagLib::String::length
unsigned int length() const
TagLib::String::operator==
bool operator==(const char *s) const
TagLib::String::operator+=
String & operator+=(const char *s)
TagLib::String::operator+=
String & operator+=(const String &s)
TagLib::String::String
String(const char *s, Type t=Latin1)
TagLib::String::operator=
String & operator=(char c)
TagLib::String::stripWhiteSpace
String stripWhiteSpace() const
TagLib::String::begin
Iterator begin()
TagLib::String::isNull
TAGLIB_DEPRECATED bool isNull() const
TagLib::String::String
String(const ByteVector &v, Type t=Latin1)
TagLib::String::operator+
TAGLIB_EXPORT const TagLib::String operator+(const char *s1, const TagLib::String &s2)
TagLib::String::toCWString
const wchar_t * toCWString() const
TagLib::String::String
String(const String &s)
TagLib::String::operator<
bool operator<(const String &s) const
TagLib::String::toCString
const char * toCString(bool unicode=false) const
TagLib::String::operator[]
const wchar_t & operator[](int i) const
TagLib::String::clear
String & clear()
TagLib::String::to8Bit
std::string to8Bit(bool unicode=false) const
TagLib::String::operator[]
wchar_t & operator[](int i)
TagLib::String::operator=
String & operator=(wchar_t c)
TagLib::String::isAscii
bool isAscii() const
TagLib::String::operator=
String & operator=(const std::string &s)
TagLib::String::operator+=
String & operator+=(const wchar_t *s)
TagLib::String::Type
Type
Definition: tstring.h:97
TagLib::String::substr
String substr(unsigned int position, unsigned int n=0xffffffff) const
TagLib::String::end
Iterator end()
TagLib::String::toInt
int toInt(bool *ok) const
TagLib::String::String
String(const std::string &s, Type t=Latin1)
TagLib::String::operator=
String & operator=(const wchar_t *s)
TagLib::String::begin
ConstIterator begin() const
TagLib::String::operator==
bool operator==(const String &s) const
TagLib::String::toInt
int toInt() const
TagLib::String::String
String(wchar_t c, Type t=Latin1)
TagLib::String::size
unsigned int size() const
TagLib::String::null
static TAGLIB_DEPRECATED String null
Definition: tstring.h:528
TagLib::String::operator=
String & operator=(const wstring &s)
TagLib::String::rfind
int rfind(const String &s, int offset=-1) const
TagLib::String::operator+
TAGLIB_EXPORT const TagLib::String operator+(const TagLib::String &s1, const char *s2)
TagLib::String::operator!=
bool operator!=(const String &s) const
TagLib::String::operator=
String & operator=(const char *s)
TagLib::String::find
int find(const String &s, int offset=0) const
TagLib
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
TagLib::wstring
std::basic_string< wchar_t > wstring
Definition: taglib.h:86
taglib.h
TAGLIB_DEPRECATED
#define TAGLIB_DEPRECATED
Definition: taglib.h:54
taglib_export.h
TAGLIB_EXPORT
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
tbytevector.h