[DEV] update some API

This commit is contained in:
Edouard DUPIN 2017-02-03 21:00:43 +01:00
parent 15295165a3
commit f3d93713c0
2 changed files with 14 additions and 6 deletions

View File

@ -804,12 +804,18 @@ bool etk::start_with(const std::string& _obj, const std::string& _val, bool _cas
std::string etk::replace(const std::string& _obj, char _val, char _replace) { std::string etk::replace(const std::string& _obj, char _val, char _replace) {
std::string copy(_obj); std::string copy(_obj);
for( size_t iii = 0; std::replace(copy.begin(), copy.end(), _val, _replace);
iii < copy.size(); return copy;
iii++) {
if (copy[iii] == _val) { }
copy[iii] = _replace;
} //! @not_in_doc
std::string etk::replace(const std::string& _obj, const std::string& _val, const std::string& _replace) {
std::string copy(_obj);
size_t pos = 0;
while ((pos = copy.find(_val, pos)) != std::string::npos) {
copy.replace(pos, _val.length(), _replace);
pos += _replace.length();
} }
return copy; return copy;
} }

View File

@ -617,6 +617,8 @@ namespace etk {
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace); std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace);
#endif #endif
//! @not_in_doc //! @not_in_doc
std::string replace(const std::string& _obj, const std::string& _val, const std::string& _replace);
//! @not_in_doc
std::string extract_line(const std::string& _obj, int32_t _pos); std::string extract_line(const std::string& _obj, int32_t _pos);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous