mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 09:12:28 +02:00
Add missing functions
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "Poco/StringTokenizer.h"
|
||||
#include "Poco/Ascii.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace Poco {
|
||||
|
||||
@@ -77,6 +78,47 @@ StringTokenizer::StringTokenizer(const std::string& str, const std::string& sepa
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t StringTokenizer::count(const std::string& token) const
|
||||
{
|
||||
std::size_t result = 0;
|
||||
TokenVec::const_iterator it = std::find(_tokens.begin(), _tokens.end(), token);
|
||||
while(it != _tokens.end())
|
||||
{
|
||||
result++;
|
||||
it = std::find(++it, _tokens.end(), token);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::size_t StringTokenizer::find(const std::string& token, std::size_t pos) const
|
||||
{
|
||||
TokenVec::const_iterator it = std::find(_tokens.begin() + pos, _tokens.end(), token);
|
||||
if ( it != _tokens.end() )
|
||||
{
|
||||
return it - _tokens.begin();
|
||||
}
|
||||
throw NotFoundException(token);
|
||||
}
|
||||
|
||||
bool StringTokenizer::has(const std::string& token) const
|
||||
{
|
||||
TokenVec::const_iterator it = std::find(_tokens.begin(), _tokens.end(), token);
|
||||
return it != _tokens.end();
|
||||
}
|
||||
|
||||
std::size_t StringTokenizer::replace(const std::string& oldToken, const std::string& newToken, std::size_t pos)
|
||||
{
|
||||
std::size_t result = 0;
|
||||
TokenVec::iterator it = std::find(_tokens.begin() + pos, _tokens.end(), oldToken);
|
||||
while(it != _tokens.end())
|
||||
{
|
||||
result++;
|
||||
*it = newToken;
|
||||
it = std::find(++it, _tokens.end(), oldToken);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
StringTokenizer::~StringTokenizer()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user