mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Change String::npos from a variable to a function.
We can't export a static member function. It may lead to a linkage error.
This commit is contained in:
parent
bb49005267
commit
1d0552cab1
@ -88,7 +88,7 @@ namespace
|
||||
#endif
|
||||
|
||||
const size_t pos = s.rfind(".");
|
||||
if(pos != String::npos)
|
||||
if(pos != String::npos())
|
||||
ext = s.substr(pos + 1).upper();
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ PropertyMap TextIdentificationFrame::asProperties() const
|
||||
// ID3v2 specifies ISO8601 timestamps which contain a 'T' as separator between date and time.
|
||||
// Since this is unusual in other formats, the T is removed.
|
||||
const size_t tpos = it->find("T");
|
||||
if(tpos != String::npos)
|
||||
if(tpos != String::npos())
|
||||
(*it)[tpos] = ' ';
|
||||
}
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ void FrameFactory::updateGenre(TextIdentificationFrame *frame) const
|
||||
String s = *it;
|
||||
const size_t end = s.find(")");
|
||||
|
||||
if(s.startsWith("(") && end != String::npos) {
|
||||
if(s.startsWith("(") && end != String::npos()) {
|
||||
// "(12)Genre"
|
||||
String text = s.substr(end + 1);
|
||||
bool ok;
|
||||
|
@ -376,7 +376,7 @@ void Ogg::XiphComment::parse(const ByteVector &data)
|
||||
}
|
||||
|
||||
const size_t commentSeparatorPosition = comment.find("=");
|
||||
if(commentSeparatorPosition == String::npos) {
|
||||
if(commentSeparatorPosition == String::npos()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -139,9 +139,17 @@ public:
|
||||
|
||||
const String String::null;
|
||||
|
||||
// Actual value is -1.
|
||||
const size_t String::npos = std::wstring::npos;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// static members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t String::npos()
|
||||
{
|
||||
return std::wstring::npos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
String::String() :
|
||||
@ -303,7 +311,7 @@ StringList String::split(const String &separator) const
|
||||
StringList list;
|
||||
for(size_t index = 0;;) {
|
||||
const size_t sep = find(separator, index);
|
||||
if(sep == npos) {
|
||||
if(sep == npos()) {
|
||||
list.append(substr(index, size() - index));
|
||||
break;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ namespace TagLib {
|
||||
* either from the end of the string or starting from \a offset. If the pattern
|
||||
* is not found, \a npos is returned.
|
||||
*/
|
||||
size_t rfind(const String &s, size_t offset = npos) const;
|
||||
size_t rfind(const String &s, size_t offset = npos()) const;
|
||||
|
||||
/*!
|
||||
* Splits the string on each occurrence of \a separator.
|
||||
@ -293,7 +293,7 @@ namespace TagLib {
|
||||
* Extract a substring from this string starting at \a position and
|
||||
* continuing for \a n characters.
|
||||
*/
|
||||
String substr(size_t position, size_t n = npos) const;
|
||||
String substr(size_t position, size_t n = npos()) const;
|
||||
|
||||
/*!
|
||||
* Append \a s to the current string and return a reference to the current
|
||||
@ -515,11 +515,11 @@ namespace TagLib {
|
||||
static const String null;
|
||||
|
||||
/*!
|
||||
* When used as the value for a \a length parameter in String's member
|
||||
* Returns a special value used for \a length parameter in String's member
|
||||
* functions, means "until the end of the string".
|
||||
* As a return value, it is usually used to indicate no matches.
|
||||
*/
|
||||
static const size_t npos;
|
||||
static size_t npos();
|
||||
|
||||
protected:
|
||||
/*!
|
||||
|
@ -37,7 +37,7 @@ StringList StringList::split(const String &s, const String &pattern)
|
||||
|
||||
size_t previousOffset = 0;
|
||||
for(size_t offset = s.find(pattern);
|
||||
offset != String::npos;
|
||||
offset != String::npos();
|
||||
offset = s.find(pattern, offset + 1))
|
||||
{
|
||||
l.append(s.substr(previousOffset, offset - previousOffset));
|
||||
|
@ -218,9 +218,9 @@ public:
|
||||
|
||||
void testRfind()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(String::npos, String("foo.bar").rfind(".", 0));
|
||||
CPPUNIT_ASSERT_EQUAL(String::npos, String("foo.bar").rfind(".", 1));
|
||||
CPPUNIT_ASSERT_EQUAL(String::npos, String("foo.bar").rfind(".", 2));
|
||||
CPPUNIT_ASSERT_EQUAL(String::npos(), String("foo.bar").rfind(".", 0));
|
||||
CPPUNIT_ASSERT_EQUAL(String::npos(), String("foo.bar").rfind(".", 1));
|
||||
CPPUNIT_ASSERT_EQUAL(String::npos(), String("foo.bar").rfind(".", 2));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, String("foo.bar").rfind(".", 3));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, String("foo.bar").rfind(".", 4));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, String("foo.bar").rfind(".", 5));
|
||||
|
Loading…
x
Reference in New Issue
Block a user