From cc3cdee24a3158e59e4b4c66d56a06c065dce20c Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Sun, 6 May 2007 16:06:01 +0000 Subject: [PATCH] r5245@piscolita: duncan | 2007-05-06 17:48:39 +0200 more improvements --- devel/devel.dmacvicar/testbed.cc | 11 +++-------- tests/parser/inifile/inidict_test.cc | 7 +++++++ zypp/parser/IniDict.cc | 8 ++++++-- zypp/parser/IniDict.h | 11 ++++++++++- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/devel/devel.dmacvicar/testbed.cc b/devel/devel.dmacvicar/testbed.cc index 8f16e2faf..dae3e72f8 100644 --- a/devel/devel.dmacvicar/testbed.cc +++ b/devel/devel.dmacvicar/testbed.cc @@ -26,14 +26,9 @@ int main(int argc, char **argv) { ZYpp::Ptr z = getZYpp(); - Pathname dbpath = Pathname(getenv("PWD")); - - //RepositoryImpl_Ptr repositoryImpl(new CachedRepositoryImpl(dbpath)); - //RepositoryFactory factory; - //Repository_Ref repository = factory.createFrom(repositoryImpl); - //ResStore dbres = repository.resolvables(); - - //MIL << dbres.size() << " resolvables" << endl; + z->initializeTarget("/"); + ResStore res = z->target()->resolvables(); + MIL << res.size() << " resolvables" << endl; } catch ( const Exception &e ) diff --git a/tests/parser/inifile/inidict_test.cc b/tests/parser/inifile/inidict_test.cc index fc2b3317f..eb623d002 100644 --- a/tests/parser/inifile/inidict_test.cc +++ b/tests/parser/inifile/inidict_test.cc @@ -25,6 +25,13 @@ void ini_read_test(const string &dir) { InputStream is((Pathname(dir)+"/1.ini")); IniDict dict(is); + + //MIL << dict["homedmacvicar"]["type"] << endl; + + for ( IniDict::const_iterator it = dict.begin(); it != dict.end(); ++it ) + { + MIL << (*it).first << endl; + } } test_suite* diff --git a/zypp/parser/IniDict.cc b/zypp/parser/IniDict.cc index b3ac33623..250df464d 100644 --- a/zypp/parser/IniDict.cc +++ b/zypp/parser/IniDict.cc @@ -10,7 +10,7 @@ * */ #include -//#include "zypp/base/Logger.h" +#include "zypp/base/Logger.h" #include #include #include "zypp/parser/IniDict.h" @@ -53,7 +53,11 @@ namespace zypp void IniDict::consume( const std::string §ion, const std::string &key, const std::string &value ) { - _dict[section][key] = value; + //MIL << endl; + PropertySet keys = _dict[section]; + keys[key] = value; + _dict[section] = keys; + //MIL << this->size() << endl; } diff --git a/zypp/parser/IniDict.h b/zypp/parser/IniDict.h index 2274f2085..345569471 100644 --- a/zypp/parser/IniDict.h +++ b/zypp/parser/IniDict.h @@ -32,17 +32,26 @@ namespace zypp // CLASS NAME : IniDict // /** + * Parses a INI file and offers its structure as a + * dictionary. * */ class IniDict : public IniParser { friend std::ostream & operator<<( std::ostream & str, const IniDict & obj ); public: + typedef std::map PropertySet; + typedef std::map ConfigSet; + typedef ConfigSet::const_iterator const_iterator; + + const_iterator begin() const { return _dict.begin(); } + const_iterator end() const { return _dict.end(); } /** Default ctor */ IniDict( const InputStream &is ); /** Dtor */ ~IniDict(); + public: /** Called when a section is found. */ @@ -51,7 +60,7 @@ namespace zypp virtual void consume( const std::string §ion, const std::string &key, const std::string &value ); private: - std::map > _dict; + ConfigSet _dict; }; /////////////////////////////////////////////////////////////////// -- 2.34.1