Helper functions

- Rescued the str_replace function from Att.
This commit is contained in:
Paul Beckingham 2011-08-27 10:22:40 -04:00
parent e5acabc452
commit 1c2a4981ac
2 changed files with 17 additions and 0 deletions

View file

@ -482,6 +482,22 @@ std::string ucFirst (const std::string& input)
return output;
}
////////////////////////////////////////////////////////////////////////////////
const std::string str_replace (
std::string &str,
const std::string& search,
const std::string& replacement)
{
std::string::size_type pos = 0;
while ((pos = str.find (search, pos)) != std::string::npos)
{
str.replace (pos, search.length (), replacement);
pos += replacement.length ();
}
return str;
}
////////////////////////////////////////////////////////////////////////////////
const char* optionalBlankLine ()
{

View file

@ -52,6 +52,7 @@ std::string commify (const std::string&);
std::string lowerCase (const std::string&);
std::string upperCase (const std::string&);
std::string ucFirst (const std::string&);
const std::string str_replace (std::string&, const std::string&, const std::string&);
const char* optionalBlankLine ();
void guess (const std::string&, std::vector<std::string>&, std::string&);
bool nontrivial (const std::string&);