mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-04 03:18:33 +02:00
Helper functions
- Rescued the str_replace function from Att.
This commit is contained in:
parent
e5acabc452
commit
1c2a4981ac
2 changed files with 17 additions and 0 deletions
16
src/text.cpp
16
src/text.cpp
|
@ -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 ()
|
||||
{
|
||||
|
|
|
@ -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&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue