mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Add iterators and operator[] to the string class.
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@319064 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
0c6be64f8a
commit
b69dd382c6
@ -252,6 +252,26 @@ const char *String::toCString(bool unicode) const
|
||||
return d->CString;
|
||||
}
|
||||
|
||||
String::Iterator String::begin()
|
||||
{
|
||||
return d->data.begin();
|
||||
}
|
||||
|
||||
String::ConstIterator String::begin() const
|
||||
{
|
||||
return d->data.begin();
|
||||
}
|
||||
|
||||
String::Iterator String::end()
|
||||
{
|
||||
return d->data.end();
|
||||
}
|
||||
|
||||
String::ConstIterator String::end() const
|
||||
{
|
||||
return d->data.end();
|
||||
}
|
||||
|
||||
int String::find(const String &s, int offset) const
|
||||
{
|
||||
wstring::size_type position = d->data.find(s.d->data, offset);
|
||||
@ -433,6 +453,16 @@ String String::number(int n) // static
|
||||
return s;
|
||||
}
|
||||
|
||||
TagLib::wchar &String::operator[](int i)
|
||||
{
|
||||
return d->data[i];
|
||||
}
|
||||
|
||||
const TagLib::wchar &String::operator[](int i) const
|
||||
{
|
||||
return d->data[i];
|
||||
}
|
||||
|
||||
bool String::operator==(const String &s) const
|
||||
{
|
||||
return d == s.d || d->data == s.d->data;
|
||||
|
@ -63,6 +63,12 @@ namespace TagLib {
|
||||
class String
|
||||
{
|
||||
public:
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT
|
||||
typedef std::basic_string<wchar>::iterator Iterator;
|
||||
typedef std::basic_string<wchar>::const_iterator ConstIterator;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The four types of string encodings supported by the ID3v2 specification.
|
||||
* ID3v1 is assumed to be Latin1 and Ogg Vorbis comments use UTF8.
|
||||
@ -176,6 +182,28 @@ namespace TagLib {
|
||||
*/
|
||||
const char *toCString(bool unicode = false) const;
|
||||
|
||||
/*!
|
||||
* Returns an iterator pointing to the beginning of the string.
|
||||
*/
|
||||
Iterator begin();
|
||||
|
||||
/*!
|
||||
* Returns a const iterator pointing to the beginning of the string.
|
||||
*/
|
||||
ConstIterator begin() const;
|
||||
|
||||
/*!
|
||||
* Returns an iterator pointing to the end of the string (the position
|
||||
* after the last character).
|
||||
*/
|
||||
Iterator end();
|
||||
|
||||
/*!
|
||||
* Returns a const iterator pointing to the end of the string (the position
|
||||
* after the last character).
|
||||
*/
|
||||
ConstIterator end() const;
|
||||
|
||||
/*!
|
||||
* Finds the first occurance of pattern \a s in this string starting from
|
||||
* \a offset. If the pattern is not found, -1 is returned.
|
||||
@ -244,6 +272,16 @@ namespace TagLib {
|
||||
*/
|
||||
static String number(int n);
|
||||
|
||||
/*!
|
||||
* Returns a reference to the character at position \a i.
|
||||
*/
|
||||
wchar &operator[](int i);
|
||||
|
||||
/*!
|
||||
* Returns a const reference to the character at position \a i.
|
||||
*/
|
||||
const wchar &operator[](int i) const;
|
||||
|
||||
/*!
|
||||
* Compares each character of the String with each character of \a s and
|
||||
* returns true if the strings match.
|
||||
|
Loading…
Reference in New Issue
Block a user