NPOS macro

This commit is contained in:
LuckyLaszlo
2022-08-12 18:16:49 +02:00
parent b44acafefe
commit c7bbf29a1b
9 changed files with 43 additions and 43 deletions

View File

@@ -38,11 +38,11 @@ std::vector<std::string>
size_t end = 0;
size_t len = 0;
while (end != std::string::npos)
while (end != NPOS)
{
end = input.find(delim, start);
len = end - start;
if (end == std::string::npos)
if (end == NPOS)
len = end;
tmp = input.substr(start, len);
if (ctrim != '\0')
@@ -60,13 +60,13 @@ std::string trim(std::string str, char del)
// delete leadings del
pos = str.find_first_not_of(del);
if (pos == std::string::npos)
if (pos == NPOS)
pos = str.size();
str = str.substr(pos);
// delete trailing del
pos = str.find_last_not_of(del);
if (pos != std::string::npos)
if (pos != NPOS)
str = str.substr(0, pos + 1);
return str;
@@ -184,7 +184,7 @@ void
while (1)
{
pos = str.find(ori_substr, pos);
if (pos == std::string::npos)
if (pos == NPOS)
break;
str.replace(pos, ori_substr.size(), new_substr);
pos += new_substr.size();
@@ -209,14 +209,14 @@ std::string
size_t len;
begin = str.rfind(delim, pos);
if (begin == std::string::npos)
if (begin == NPOS)
begin = 0;
else
begin += delim.size();
end = str.find(delim, pos);
len = end;
if (end != std::string::npos)
if (end != NPOS)
len = end - begin;
del_str = str.substr(begin, len);
@@ -253,13 +253,13 @@ size_t
for (it = list.begin(); it != it_end; it++)
{
pos = (*it).find(':');
if (pos == std::string::npos)
if (pos == NPOS)
{
err++;
continue;
}
key = (*it).substr(0, pos);
if ( key.find(' ') != std::string::npos )
if ( key.find(' ') != NPOS )
{
err++;
continue;