system/helpers.cpp: add split_config_string helper

Origin commit data
------------------
Branch: ni/coolstream
Commit: bef1b79bed
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2014-04-23 (Wed, 23 Apr 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2014-04-23 17:21:50 +04:00
parent 00ac5c6c0c
commit fee715d7d9
2 changed files with 19 additions and 0 deletions

View File

@@ -740,3 +740,20 @@ void hdd_flush(const char * fname)
close(fd);
}
}
/* split string like PARAM1=value1 PARAM2=value2 into map */
bool split_config_string(const std::string &str, std::map<std::string,std::string> &smap)
{
smap.clear();
std::string::size_type start = 0;
std::string::size_type end = 0;
while ((end = str.find(" ", start)) != std::string::npos) {
std::string param = str.substr(start, end - start);
std::string::size_type i = param.find("=");
if (i != std::string::npos) {
smap[param.substr(0,i).c_str()] = param.substr(i+1).c_str();
}
start = end + 1;
}
return !smap.empty();
}