From 3b6870f1336a3a3fa531912b754316206e5530e0 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 6 Jul 2011 11:05:57 +0200 Subject: [PATCH] use more classical approach to function template instantiation --- src/utils/smallut.cpp | 38 ++++++++++---------------------------- src/utils/smallut.h | 18 +++++++----------- 2 files changed, 17 insertions(+), 39 deletions(-) diff --git a/src/utils/smallut.cpp b/src/utils/smallut.cpp index ca128037..fe7ac3d5 100644 --- a/src/utils/smallut.cpp +++ b/src/utils/smallut.cpp @@ -281,21 +281,12 @@ template bool stringToStrings(const string &s, T &tokens, return true; } -bool stringToStrings(const string &s, list &tokens, - const string& as) -{ - return stringToStrings >(s, tokens, as); -} -bool stringToStrings(const string &s, vector &tokens, - const string& as) -{ - return stringToStrings >(s, tokens, as); -} -bool stringToStrings(const string &s, set &tokens, - const string& as) -{ - return stringToStrings >(s, tokens, as); -} +template bool stringToStrings >(const string &, + list &, const string&); +template bool stringToStrings >(const string &, + vector &,const string&); +template bool stringToStrings >(const string &, + set &, const string&); template void stringsToString(const T &tokens, string &s) { @@ -321,18 +312,9 @@ template void stringsToString(const T &tokens, string &s) s.append(1, '"'); } } -void stringsToString(const list &tokens, string &s) -{ - stringsToString >(tokens, s); -} -void stringsToString(const vector &tokens, string &s) -{ - stringsToString >(tokens, s); -} -void stringsToString(const set &tokens, string &s) -{ - stringsToString >(tokens, s); -} +template void stringsToString >(const list &, string &); +template void stringsToString >(const vector &,string &); +template void stringsToString >(const set &, string &); void stringToTokens(const string& str, vector& tokens, const string& delims, bool skipinit) @@ -499,7 +481,7 @@ string escapeShell(const string &in) } -// Small utility to substitute printf-like percents cmds in a string +// Substitute printf-like percent cmds inside a string bool pcSubst(const string& in, string& out, map& subs) { string::const_iterator it; diff --git a/src/utils/smallut.h b/src/utils/smallut.h index 0f1dd508..d43933b2 100644 --- a/src/utils/smallut.h +++ b/src/utils/smallut.h @@ -47,8 +47,10 @@ struct StringIcmpPred { extern int stringlowercmp(const string& alreadylower, const string& s2); extern int stringuppercmp(const string& alreadyupper, const string& s2); + extern void stringtolower(string& io); extern string stringtolower(const string& io); + // Is one string the end part of the other ? extern int stringisuffcmp(const string& s1, const string& s2); @@ -69,8 +71,8 @@ extern bool samecharset(const string &cs1, const string &cs2); struct DateInterval { int y1;int m1;int d1; int y2;int m2;int d2; }; -bool parsedateinterval(const string&s, DateInterval *di); -int monthdays(int mon, int year); +extern bool parsedateinterval(const string&s, DateInterval *di); +extern int monthdays(int mon, int year); /** * Parse input string into list of strings. @@ -82,19 +84,13 @@ int monthdays(int mon, int year); * but so are the iso-8859-x and surely others. addseps do have to be * single-bytes */ -extern bool stringToStrings(const string& s, list &tokens, - const string& addseps = ""); -extern bool stringToStrings(const string& s, vector &tokens, - const string& addseps = ""); -extern bool stringToStrings(const string& s, set &tokens, - const string& addseps = ""); +template bool stringToStrings(const string& s, T &tokens, + const string& addseps = ""); /** * Inverse operation: */ -extern void stringsToString(const list &tokens, string &s); -extern void stringsToString(const vector &tokens, string &s); -extern void stringsToString(const set &tokens, string &s); +template void stringsToString(const T &tokens, string &s); /** * Split input string. No handling of quoting