use common method when concatenating multiple values for a metadata element. Use a comma as separator

This commit is contained in:
Jean-Francois Dockes
2020-08-11 11:39:22 +02:00
parent fd0cf698a1
commit 13333e6512
6 changed files with 40 additions and 37 deletions
+18
View File
@@ -66,6 +66,24 @@ template void map_ss_cp_noshr<map<string, string> >(
template void map_ss_cp_noshr<unordered_map<string, string> >(
unordered_map<string,string> s, unordered_map<string,string>*d);
// Add data to metadata field, store multiple values as CSV, avoid
// appending multiple identical instances.
template <class T> void addmeta(
T& store, const string& nm, const string& value)
{
auto it = store.find(nm);
if (it == store.end() || it->second.empty()) {
store[nm] = value;
} else if (it->second.find(value) == string::npos) {
store[nm] += ',';
store[nm] += value;
}
}
template void addmeta<map<string, string>>(
map<string, string>&, const string&, const string&);
template void addmeta<unordered_map<string, string>>(
unordered_map<string, string>&, const string&, const string&);
#ifdef _WIN32
static bool path_hasdrive(const string& s)
{
+3
View File
@@ -115,5 +115,8 @@ extern bool thumbPathForUrl(const std::string& url, int size,
// string data (to pass to other thread):
template <class T> void map_ss_cp_noshr(T s, T *d);
// Set or extend metadata field. We store the data as CSV
template <class T> void addmeta(T& store, const std::string& nm,
const std::string& value);
#endif /* _RCLUTIL_H_INCLUDED_ */