summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-02-18 00:30:51 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-02-18 00:30:51 +0100
commitd7cf5923a093e89ab5aac0bf8cd1c3042997990c (patch)
tree7bbc2dbf1d7b5558895201e58d10a7cbe2563f2b /apt-pkg/contrib
parent319810767180e5c57c296b06c93e3ebec9f36a8e (diff)
dd support for the LANGUAGE environment variable
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/strutl.cc18
-rw-r--r--apt-pkg/contrib/strutl.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 2913fbf44..3bbaf5f30 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1000,6 +1000,24 @@ bool TokSplitString(char Tok,char *Input,char **List,
return true;
}
/*}}}*/
+// ExplodeString - Split a string up into a vector /*{{{*/
+// ---------------------------------------------------------------------
+/* This can be used to split a given string up into a vector, so the
+ propose is the same as in the method above and this one is a bit slower
+ also, but the advantage is that we an iteratable vector */
+vector<string> ExplodeString(string const &haystack, char const &split)
+{
+ string::const_iterator start = haystack.begin();
+ string::const_iterator end = start;
+ vector<string> exploded;
+ do {
+ for (; end != haystack.end() && *end != split; ++end);
+ exploded.push_back(string(start, end));
+ start = end + 1;
+ } while (end != haystack.end() && (++end) != haystack.end());
+ return exploded;
+}
+ /*}}}*/
// RegexChoice - Simple regex list/list matcher /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 2b2e147fb..d65f975d2 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -59,6 +59,7 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0)
bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,
unsigned long ListMax);
+vector<string> ExplodeString(string const &haystack, char const &split);
void ioprintf(ostream &out,const char *format,...) APT_FORMAT2;
void strprintf(string &out,const char *format,...) APT_FORMAT2;
char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3;