Author: dmacvicar
Date: Sun May 6 18:05:19 2007
New Revision: 5499
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5499&view=rev
Log:
r5240@piscolita: duncan | 2007-05-02 19:08:37 +0200
Dictionary wrapper over ini parser, and test
Added:
trunk/libzypp/zypp/parser/IniDict.cc
trunk/libzypp/zypp/parser/IniDict.h
Modified:
trunk/ (props changed)
Added: trunk/libzypp/zypp/parser/IniDict.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/IniDict.cc?rev=5499&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/IniDict.cc (added)
+++ trunk/libzypp/zypp/parser/IniDict.cc Sun May 6 18:05:19 2007
@@ -0,0 +1,75 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/IniDict.cc
+ *
+*/
+#include <iostream>
+//#include "zypp/base/Logger.h"
+#include <map>
+#include <string>
+#include "zypp/parser/IniDict.h"
+
+using namespace std;
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace parser
+ { /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : IniDict
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : IniDict::IniDict
+ // METHOD TYPE : Ctor
+ //
+ IniDict::IniDict( const InputStream &is )
+ {
+ parse(is);
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : IniDict::~IniDict
+ // METHOD TYPE : Dtor
+ //
+ IniDict::~IniDict()
+ {}
+
+ void IniDict::consume( const std::string §ion )
+ {
+ // do nothing for now.
+ }
+
+ void IniDict::consume( const std::string §ion, const std::string &key, const std::string &value )
+ {
+ _dict[section][key] = value;
+ }
+
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const IniDict & obj )
+ {
+ return str;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/parser/IniDict.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/IniDict.h?rev=5499&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/IniDict.h (added)
+++ trunk/libzypp/zypp/parser/IniDict.h Sun May 6 18:05:19 2007
@@ -0,0 +1,67 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/IniDict.h
+ *
+*/
+#ifndef ZYPP_PARSER_INIDICT_H
+#define ZYPP_PARSER_INIDICT_H
+
+#include <iosfwd>
+#include <map>
+#include <string>
+
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/InputStream.h"
+#include "zypp/parser/IniParser.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace parser
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : IniDict
+ //
+ /**
+ *
+ */
+ class IniDict : public IniParser
+ {
+ friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
+ public:
+ /** Default ctor */
+ IniDict( const InputStream &is );
+ /** Dtor */
+ ~IniDict();
+
+ public:
+
+ /** Called when a section is found. */
+ virtual void consume( const std::string §ion );
+ /** Called when a key value is found. */
+ virtual void consume( const std::string §ion, const std::string &key, const std::string &value );
+
+ private:
+ std::map