TagLib  1.13.1
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
44
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
60
61#define TStringToQString(s) QString::fromUtf8((s).toCString(true))
62
63namespace TagLib {
64
65 class StringList;
66
68
83
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 {
105 UTF16 = 1,
114 UTF8 = 3,
119 };
120
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
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
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
344
356
363 // BIC: merge with the method below
364 int toInt() const;
365
373 int toInt(bool *ok) const;
374
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
445
449 String &operator+=(const wchar_t* s);
450
454 String &operator+=(const char* s);
455
459 String &operator+=(wchar_t c);
460
465
471
475 String &operator=(const std::string &s);
476
481
485 String &operator=(const wchar_t *s);
486
491
495 String &operator=(wchar_t c);
496
500 String &operator=(const char *s);
501
506
510 void swap(String &s);
511
517 bool operator<(const String &s) const;
518
527 // BIC: remove
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} // namespace TagLib
550
557
564
571
572
578TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
579
580#endif
A byte vector.
Definition tbytevector.h:46
A list of strings.
Definition tstringlist.h:46
A wide string class suitable for unicode.
Definition tstring.h:85
TAGLIB_EXPORT TagLib::String operator+(const TagLib::String &s1, const char *s2)
String & operator=(const String &s)
bool operator==(const wchar_t *s) const
String upper() const
virtual ~String()
bool isEmpty() const
bool isLatin1() const
void swap(String &s)
String & operator+=(wchar_t c)
bool startsWith(const String &s) const
String & operator+=(char c)
String & append(const String &s)
StringList split(const String &separator=" ") const
wstring toWString() const
String & operator=(const ByteVector &v)
String(char c, Type t=Latin1)
bool operator!=(const char *s) const
String(const wchar_t *s, Type t=UTF16BE)
bool operator!=(const wchar_t *s) const
ByteVector data(Type t) const
TAGLIB_EXPORT TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2)
TAGLIB_EXPORT std::ostream & operator<<(std::ostream &s, const TagLib::String &str)
static String number(int n)
String(const wstring &s, Type t=UTF16BE)
ConstIterator end() const
unsigned int length() const
bool operator==(const char *s) const
String & operator+=(const char *s)
String & operator+=(const String &s)
String(const char *s, Type t=Latin1)
String & operator=(char c)
String stripWhiteSpace() const
Iterator begin()
TAGLIB_DEPRECATED bool isNull() const
String(const ByteVector &v, Type t=Latin1)
const wchar_t * toCWString() const
String(const String &s)
bool operator<(const String &s) const
const char * toCString(bool unicode=false) const
const wchar_t & operator[](int i) const
String & clear()
std::string to8Bit(bool unicode=false) const
wchar_t & operator[](int i)
String & operator=(wchar_t c)
bool isAscii() const
String & operator=(const std::string &s)
String & operator+=(const wchar_t *s)
Type
Definition tstring.h:97
@ Latin1
Definition tstring.h:101
@ UTF16BE
Definition tstring.h:110
@ UTF16
Definition tstring.h:105
@ UTF8
Definition tstring.h:114
@ UTF16LE
Definition tstring.h:118
TAGLIB_EXPORT TagLib::String operator+(const char *s1, const TagLib::String &s2)
String substr(unsigned int position, unsigned int n=0xffffffff) const
Iterator end()
int toInt(bool *ok) const
String(const std::string &s, Type t=Latin1)
String & operator=(const wchar_t *s)
ConstIterator begin() const
bool operator==(const String &s) const
int toInt() const
String(wchar_t c, Type t=Latin1)
unsigned int size() const
static TAGLIB_DEPRECATED String null
Definition tstring.h:528
String & operator=(const wstring &s)
int rfind(const String &s, int offset=-1) const
bool operator!=(const String &s) const
String & operator=(const char *s)
int find(const String &s, int offset=0) const
A namespace for all TagLib related classes and functions.
Definition apefile.h:41
std::basic_string< wchar_t > wstring
Definition taglib.h:86
#define TAGLIB_DEPRECATED
Definition taglib.h:54
#define TAGLIB_EXPORT
Definition taglib_export.h:40