From: David Kalnischkies Date: Fri, 4 Sep 2009 17:32:45 +0000 (+0200) Subject: add a helper to easily get a vector of strings from the configuration X-Git-Tag: 0.7.24~4^2~18 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/50c409c42a971c6e8a25cb32a87992474247834b add a helper to easily get a vector of strings from the configuration --- diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 48a5f0bff..b83ece3e4 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -223,6 +223,25 @@ string Configuration::FindDir(const char *Name,const char *Default) const return Res; } /*}}}*/ +// Configuration::FindVector - Find a vector of values /*{{{*/ +// --------------------------------------------------------------------- +/* Returns a vector of config values under the given item */ +vector Configuration::FindVector(const char *Name) const +{ + vector Vec; + const Item *Top = Lookup(Name); + if (Top == NULL) + return Vec; + + Item *I = Top->Child; + while(I != NULL) + { + Vec.push_back(I->Value); + I = I->Next; + } + return Vec; +} + /*}}}*/ // Configuration::FindI - Find an integer value /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 2534692a3..e2da83f5b 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -31,6 +31,7 @@ #include +#include #include using std::string; @@ -70,6 +71,8 @@ class Configuration string Find(const string Name,const char *Default = 0) const {return Find(Name.c_str(),Default);}; string FindFile(const char *Name,const char *Default = 0) const; string FindDir(const char *Name,const char *Default = 0) const; + std::vector FindVector(const string &Name) const; + std::vector FindVector(const char *Name) const; int FindI(const char *Name,int Default = 0) const; int FindI(const string Name,int Default = 0) const {return FindI(Name.c_str(),Default);}; bool FindB(const char *Name,bool Default = false) const; diff --git a/debian/changelog b/debian/changelog index 550addc92..349c95038 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ apt (0.7.24) UNRELEASED; urgency=low - activate DOT_MULTI_TARGETS, it is default on since doxygen 1.5.9 * buildlib/po4a_manpage.mak, doc/makefile, configure: - simplify the makefiles needed for po4a manpages + * apt-pkg/contrib/configuration.cc: + - add a helper to easily get a vector of strings from the config -- David Kalnischkies Fri, 28 Aug 2009 09:40:08 +0200