ENH: rationalize some string methods.

- silently deprecate 'startsWith', 'endsWith' methods
  (added in 2016: 2b14360662), in favour of
  'starts_with', 'ends_with' methods, corresponding to C++20 and
  allowing us to cull then in a few years.

- handle single character versions of starts_with, ends_with.

- add single character version of removeEnd and silently deprecate
  removeTrailing which did the same thing.

- drop the const versions of removeRepeated, removeTrailing.
  Unused and with potential confusion.

STYLE: use shrink_to_fit(), erase()
This commit is contained in:
Mark Olesen
2019-11-11 18:50:00 +01:00
committed by Andrew Heather
parent ea214727a5
commit 7c1190f0b1
28 changed files with 185 additions and 206 deletions

View File

@ -68,7 +68,7 @@ inline bool Foam::string::removePath()
return false;
}
this->erase(0, i+1);
erase(0, i+1);
return true;
}
@ -82,7 +82,7 @@ inline bool Foam::string::removeExt()
return false;
}
this->resize(i);
erase(i);
return true;
}
@ -163,7 +163,7 @@ inline bool Foam::string::stripInvalid(std::string& str)
}
}
str.resize(nChar);
str.erase(nChar);
return true;
}
@ -228,7 +228,7 @@ Foam::string::quotemeta(const std::string& str, const char quote)
sQuoted += c;
}
sQuoted.resize(sQuoted.size());
sQuoted.shrink_to_fit();
return sQuoted;
}
@ -251,7 +251,7 @@ inline String Foam::string::validate(const std::string& str)
}
}
out.resize(len);
out.erase(len);
return out;
}