tstring.h
Go to the documentation of this file.
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_STRING_H
#define TAGLIB_STRING_H
#include <string>
#include "tbytevector.h"
#include "taglib_export.h"
#if defined(QT_VERSION) && (QT_VERSION >= 0x040000)
#define QStringToTString(s) TagLib::String(s.toUtf8().data(), TagLib::String::UTF8)
#else
#define QStringToTString(s) TagLib::String((s).utf8().data(), TagLib::String::UTF8)
#endif
#define TStringToQString(s) QString::fromUtf8((s).toCString(true))
namespace TagLib {
class StringList;
class TAGLIB_EXPORT String
{
public:
#ifndef DO_NOT_DOCUMENT
using Iterator = std::wstring::iterator;
using ConstIterator = std::wstring::const_iterator;
#endif
enum Type {
Latin1 = 0,
UTF16 = 1,
UTF16BE = 2,
UTF8 = 3,
UTF16LE = 4
};
String();
String(const String &s);
String(const std::string &s, Type t = Latin1);
String(const std::wstring &s);
String(const std::wstring &s, Type t);
String(const wchar_t *s);
String(const wchar_t *s, Type t);
String(char c, Type t = Latin1);
String(wchar_t c, Type t = Latin1);
String(const char *s, Type t = Latin1);
String(const ByteVector &v, Type t = Latin1);
~String();
std::string to8Bit(bool unicode = false) const;
std::wstring toWString() const;
const char *toCString(bool unicode = false) const;
const wchar_t *toCWString() const;
Iterator begin();
ConstIterator begin() const;
ConstIterator cbegin() const;
Iterator end();
ConstIterator end() const;
ConstIterator cend() const;
int find(const String &s, int offset = 0) const;
int rfind(const String &s, int offset = -1) const;
StringList split(const String &separator = " ") const;
bool startsWith(const String &s) const;
String substr(unsigned int position, unsigned int n = 0xffffffff) const;
String &append(const String &s);
String &clear();
String upper() const;
unsigned int size() const;
unsigned int length() const;
bool isEmpty() const;
ByteVector data(Type t) const;
int toInt(bool *ok = nullptr) const;
long long toLongLong(bool *ok = nullptr, int base = 10) const;
unsigned long long toULongLong(bool *ok = nullptr, int base = 10) const;
String stripWhiteSpace() const;
bool isLatin1() const;
bool isAscii() const;
static String number(int n);
static String fromLongLong(long long n);
static String fromULongLong(unsigned long long n);
wchar_t &operator[](int i);
const wchar_t &operator[](int i) const;
bool operator==(const String &s) const;
bool operator!=(const String &s) const;
bool operator==(const char *s) const;
bool operator!=(const char *s) const;
bool operator==(const wchar_t *s) const;
bool operator!=(const wchar_t *s) const;
String &operator+=(const String &s);
String &operator+=(const wchar_t* s);
String &operator+=(const char* s);
String &operator+=(wchar_t c);
String &operator+=(char c);
String &operator=(const String &s);
String &operator=(const std::string &s);
String &operator=(const std::wstring &s);
String &operator=(const wchar_t *s);
String &operator=(char c);
String &operator=(wchar_t c);
String &operator=(const char *s);
String &operator=(const ByteVector &v);
void swap(String &s) noexcept;
bool operator<(const String &s) const;
protected:
void detach();
private:
class StringPrivate;
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
std::shared_ptr<StringPrivate> d;
};
} // namespace TagLib
TAGLIB_EXPORT TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2);
TAGLIB_EXPORT TagLib::String operator+(const char *s1, const TagLib::String &s2);
TAGLIB_EXPORT TagLib::String operator+(const TagLib::String &s1, const char *s2);
TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::String &str);
#endif
TagLib::ByteVector
A byte vector.
Definition tbytevector.h:46
TagLib::StringList
A list of strings.
Definition tstringlist.h:44
TagLib::String
A wide string class suitable for unicode.
Definition tstring.h:83
TagLib::String::operator+
TAGLIB_EXPORT TagLib::String operator+(const TagLib::String &s1, const char *s2)
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::toLongLong
long long toLongLong(bool *ok=nullptr, int base=10) const
TagLib::String::isEmpty
bool isEmpty() const
TagLib::String::isLatin1
bool isLatin1() const
TagLib::String::toWString
std::wstring toWString() const
TagLib::String::operator+=
String & operator+=(wchar_t c)
TagLib::String::startsWith
bool startsWith(const String &s) const
TagLib::String::toInt
int toInt(bool *ok=nullptr) const
TagLib::String::operator+=
String & operator+=(char c)
TagLib::String::String
String()
TagLib::String::detach
void detach()
TagLib::String::cbegin
ConstIterator cbegin() const
TagLib::String::append
String & append(const String &s)
TagLib::String::split
StringList split(const String &separator=" ") 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)
TagLib::String::operator!=
bool operator!=(const wchar_t *s) const
TagLib::String::data
ByteVector data(Type t) const
TagLib::String::operator+
TAGLIB_EXPORT TagLib::String operator+(const TagLib::String &s1, const TagLib::String &s2)
TagLib::String::fromLongLong
static String fromLongLong(long long n)
TagLib::String::operator<<
TAGLIB_EXPORT std::ostream & operator<<(std::ostream &s, const TagLib::String &str)
TagLib::String::toULongLong
unsigned long long toULongLong(bool *ok=nullptr, int base=10) const
TagLib::String::String
String(const wchar_t *s, Type t)
TagLib::String::number
static String number(int n)
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 std::wstring &s)
TagLib::String::operator+=
String & operator+=(const String &s)
TagLib::String::fromULongLong
static String fromULongLong(unsigned long long n)
TagLib::String::String
String(const char *s, Type t=Latin1)
TagLib::String::String
String(const std::wstring &s)
TagLib::String::operator=
String & operator=(char c)
TagLib::String::stripWhiteSpace
String stripWhiteSpace() const
TagLib::String::begin
Iterator begin()
TagLib::String::String
String(const ByteVector &v, Type t=Latin1)
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::cend
ConstIterator cend() 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:96
TagLib::String::Latin1
@ Latin1
Definition tstring.h:100
TagLib::String::UTF16BE
@ UTF16BE
Definition tstring.h:109
TagLib::String::UTF16
@ UTF16
Definition tstring.h:104
TagLib::String::UTF8
@ UTF8
Definition tstring.h:113
TagLib::String::UTF16LE
@ UTF16LE
Definition tstring.h:117
TagLib::String::String
String(const std::wstring &s, Type t)
TagLib::String::operator+
TAGLIB_EXPORT TagLib::String operator+(const char *s1, const TagLib::String &s2)
TagLib::String::substr
String substr(unsigned int position, unsigned int n=0xffffffff) const
TagLib::String::end
Iterator end()
TagLib::String::~String
~String()
TagLib::String::swap
void swap(String &s) noexcept
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::String
String(wchar_t c, Type t=Latin1)
TagLib::String::size
unsigned int size() const
TagLib::String::rfind
int rfind(const String &s, int offset=-1) const
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_export.h
TAGLIB_EXPORT
#define TAGLIB_EXPORT
Definition taglib_export.h:40
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition taglib_export.h:55
tbytevector.h