db/upnp/Util: pass char* to csvToStrings()
This commit is contained in:
parent
a5e7d0a90f
commit
02f2171010
@ -249,7 +249,7 @@ ContentDirectoryService::getSearchCapabilities(UpnpClient_Handle hdl,
|
|||||||
if (!tbuf.compare("*")) {
|
if (!tbuf.compare("*")) {
|
||||||
result.insert(result.end(), "*");
|
result.insert(result.end(), "*");
|
||||||
} else if (!tbuf.empty()) {
|
} else if (!tbuf.empty()) {
|
||||||
if (!csvToStrings(tbuf, result)) {
|
if (!csvToStrings(tbuf.c_str(), result)) {
|
||||||
error.Set(upnp_domain, "Bad response");
|
error.Set(upnp_domain, "Bad response");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,17 @@ stringToTokens(const std::string &str,
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool
|
bool
|
||||||
csvToStrings(const std::string &s, T &tokens)
|
csvToStrings(const char *s, T &tokens)
|
||||||
{
|
{
|
||||||
std::string current;
|
std::string current;
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
enum states {TOKEN, ESCAPE};
|
enum states {TOKEN, ESCAPE};
|
||||||
states state = TOKEN;
|
states state = TOKEN;
|
||||||
for (unsigned int i = 0; i < s.length(); i++) {
|
|
||||||
switch (s[i]) {
|
while (*s != 0) {
|
||||||
|
const char ch = *s++;
|
||||||
|
|
||||||
|
switch (ch) {
|
||||||
case ',':
|
case ',':
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case TOKEN:
|
case TOKEN:
|
||||||
@ -179,7 +182,7 @@ csvToStrings(const std::string &s, T &tokens)
|
|||||||
case TOKEN:
|
case TOKEN:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
current += s[i];
|
current += ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(state) {
|
switch(state) {
|
||||||
@ -193,5 +196,5 @@ csvToStrings(const std::string &s, T &tokens)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//template bool csvToStrings<list<string> >(const string &, list<string> &);
|
//template bool csvToStrings<list<string> >(const string &, list<string> &);
|
||||||
template bool csvToStrings<std::vector<std::string> >(const std::string &, std::vector<std::string> &);
|
template bool csvToStrings<std::vector<std::string> >(const char *, std::vector<std::string> &);
|
||||||
template bool csvToStrings<std::set<std::string> >(const std::string &, std::set<std::string> &);
|
template bool csvToStrings<std::set<std::string> >(const char *, std::set<std::string> &);
|
||||||
|
@ -40,6 +40,7 @@ stringToTokens(const std::string &str,
|
|||||||
const char *delims = "/", bool skipinit = true);
|
const char *delims = "/", bool skipinit = true);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool csvToStrings(const std::string& s, T &tokens);
|
bool
|
||||||
|
csvToStrings(const char *s, T &tokens);
|
||||||
|
|
||||||
#endif /* _UPNPP_H_X_INCLUDED_ */
|
#endif /* _UPNPP_H_X_INCLUDED_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user