Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7708 - in /branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp: base/ parser/
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Tue, 30 Oct 2007 16:33:44 -0000
  • Message-id: <20071030163344.4479D37516@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Tue Oct 30 17:33:43 2007
New Revision: 7708

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7708&view=rev
Log:
backport 10.3 ini-file parser

Added:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.h
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.h
Modified:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.h
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/InputStream.h
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.h
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/Makefile.am

Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.cc?rev=7708&r1=7707&r2=7708&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.cc (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.cc Tue Oct 30
17:33:43 2007
@@ -27,7 +27,7 @@
**
** FUNCTION NAME : getline
** FUNCTION TYPE : std::string
- */
+ */
std::string getline( std::istream & str )
{
static const unsigned tmpBuffLen = 1024;
@@ -42,6 +42,55 @@
return ret;
}

+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : EachLine
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : EachLine::EachLine
+ // METHOD TYPE : Ctor
+ //
+ EachLine::EachLine( std::istream & str_r, unsigned lineNo_r )
+ : _str( str_r )
+ , _lineStart( -1 )
+ , _lineNo( lineNo_r )
+ , _valid( true )
+ {
+ next();
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : EachLine::next
+ // METHOD TYPE : bool
+ //
+ bool EachLine::next()
+ {
+ if ( ! _valid )
+ {
+ return false;
+ }
+
+ if ( ! _str ) // usg: saw EOF in previous read
+ {
+ _line.clear();
+ return(_valid = false);
+ }
+
+ _lineStart = _str.tellg();
+ _line = iostr::getline( _str );
+ ++_lineNo;
+ if ( _str.fail() || _str.bad() )
+ {
+ _line.clear();
+ return(_valid = false);
+ }
+ return(_valid = true);
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace iostr
///////////////////////////////////////////////////////////////////

Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.h?rev=7708&r1=7707&r2=7708&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.h (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/IOStream.h Tue Oct 30
17:33:43 2007
@@ -16,6 +16,8 @@
#include <boost/io/ios_state.hpp>

#include "zypp/base/PtrTypes.h"
+#include <zypp/base/SafeBool.h>
+#include <zypp/base/NonCopyable.h>

///////////////////////////////////////////////////////////////////
namespace zypp
@@ -28,7 +30,7 @@

/** Save and restore streams \c width, \c precision
* and \c fmtflags.
- */
+ */
typedef boost::io::ios_base_all_saver IosFmtFlagsSaver;


@@ -38,9 +40,77 @@
* is read but not returned.
*
* \see \ref forEachLine
- */
+ */
std::string getline( std::istream & str );

+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : EachLine
+ //
+ /** Simple lineparser: Traverse each line in a file.
+ *
+ * \code
+ * std::ifstream infile( "somefile" );
+ * for( iostr::EachLine in( infile ); in; in.next() )
+ * {
+ * DBG << *in << endl;
+ * }
+ * \endcode
+ */
+ class EachLine : private base::SafeBool<EachLine>, private
base::NonCopyable
+ {
+ typedef base::SafeBool<EachLine> SafeBool;
+
+ public:
+ /** Ctor taking a stream and reading the 1st line from it. */
+ EachLine( std::istream & str_r, unsigned lineNo_r = 0 );
+
+ /** Evaluate class in a boolean context. */
+ using SafeBool::operator bool_type;
+
+ /** Whether \c this contains a valid line to consume. */
+ bool valid() const
+ { return boolTest(); }
+
+ /** Return the current line number. */
+ unsigned lineNo() const
+ { return _lineNo; }
+
+ std::streamoff lineStart() const
+ { return _lineStart; };
+
+ /** Set current line number. */
+ void setLineNo( unsigned lineNo_r )
+ { _lineNo = lineNo_r; }
+
+ /** Access the current line. */
+ const std::string & operator*() const
+ { return _line; }
+
+ /** Advance to next line. */
+ bool next();
+
+ /** Advance \a num_r lines. */
+ bool next( unsigned num_r )
+ {
+ while ( num_r-- && next() )
+ ; /* EMPTY */
+ return valid();
+ }
+
+ private:
+ friend SafeBool::operator bool_type() const;
+ bool boolTest() const
+ { return _valid; }
+
+ private:
+ std::istream & _str;
+ std::string _line;
+ std::streamoff _lineStart;
+ unsigned _lineNo;
+ bool _valid;
+ };
+ ///////////////////////////////////////////////////////////////////

/** Simple lineparser: Call functor \a consume_r for each line.
*
@@ -62,7 +132,7 @@
*
* \todo Should be templated and specialized according to the
* functors return type, to allow \c void consumer.
- */
+ */
template<class _Function>
_Function & forEachLine( std::istream & str_r, _Function & consume_r )
{

Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/InputStream.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/InputStream.h?rev=7708&r1=7707&r2=7708&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/InputStream.h (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/InputStream.h Tue Oct 30
17:33:43 2007
@@ -93,7 +93,7 @@
{ return *_stream; }

/** Allow implicit conversion to std::istream.*/
- operator std::istream &()
+ operator std::istream &() const
{ return *_stream; }

/** Name of the std::istream.

Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.cc?rev=7708&r1=7707&r2=7708&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.cc (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.cc Tue Oct 30
17:33:43 2007
@@ -52,6 +52,36 @@

/******************************************************************
**
+ ** FUNCTION NAME : strToTrue
+ ** FUNCTION TYPE : bool
+ */
+ bool strToTrue( const std::string & str )
+ {
+ std::string t( toLower( str ) );
+ return( t == "1"
+ || t == "yes"
+ || t == "true"
+ || t == "on"
+ );
+ }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : strToFalse
+ ** FUNCTION TYPE : bool
+ */
+ bool strToFalse( const std::string & str )
+ {
+ std::string t( toLower( str ) );
+ return ! ( t == "0"
+ || t == "no"
+ || t == "false"
+ || t == "off"
+ );
+ }
+
+ /******************************************************************
+ **
** FUNCTION NAME : toLower
** FUNCTION TYPE : std::string
*/

Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.h?rev=7708&r1=7707&r2=7708&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.h (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/String.h Tue Oct 30
17:33:43 2007
@@ -206,6 +206,24 @@
//@}

///////////////////////////////////////////////////////////////////
+ /** Parsing boolean from string.
+ */
+ //@{
+ /** Return \c true if str is <tt>1, true, yes, on</tt>. */
+ bool strToTrue( const std::string & str );
+
+ /** Return \c false if str is <tt>0, false, no, off</tt>. */
+ bool strToFalse( const std::string & str );
+
+ /** Parse \c str into a bool depending on the default value.
+ * If the \c default is true, look for a legal \c false string.
+ * If the \c default is false, look for a legal \c true string.
+ */
+ inline bool strToBool( const std::string & str, bool default_r )
+ { return( default_r ? strToFalse( str ) : strToTrue( str ) ); }
+ //@}
+
+ ///////////////////////////////////////////////////////////////////
/** \name Split. */
//@{
/** Split \a line_r into words.

Added: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.cc?rev=7708&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.cc (added)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.cc Tue Oct 30
17:33:43 2007
@@ -0,0 +1,166 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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 )
+ {
+ read(is );
+ }
+
+ IniDict::IniDict()
+ {
+ }
+
+ void IniDict::read( const InputStream &is )
+ {
+ parse(is );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : IniDict::~IniDict
+ // METHOD TYPE : Dtor
+ //
+ IniDict::~IniDict()
+ {}
+
+ void IniDict::consume( const std::string &section )
+ {
+ // do nothing for now.
+ }
+
+ void IniDict::consume( const std::string &section, const std::string &key,
const std::string &value )
+ {
+ //MIL << endl;
+ _dict[section][key] = value;
+ //MIL << this->size() << endl;
+ }
+
+
+ IniDict::entry_const_iterator IniDict::entriesBegin(const std::string
&section) const
+ {
+ SectionSet::const_iterator secit = _dict.find(section);
+ if ( secit == _dict.end() )
+ {
+ return _empty_map.begin();
+ }
+
+ return (secit->second).begin();
+ }
+
+ IniDict::entry_const_iterator IniDict::entriesEnd(const std::string
&section) const
+ {
+ SectionSet::const_iterator secit = _dict.find(section);
+ if ( secit == _dict.end() )
+ {
+ return _empty_map.end();
+ }
+
+ return (secit->second).end();
+ }
+
+
+ IniDict::section_const_iterator IniDict::sectionsBegin() const
+ {
+ return make_map_key_begin( _dict );
+ }
+
+ IniDict::section_const_iterator IniDict::sectionsEnd() const
+ {
+ return make_map_key_end( _dict );
+ }
+
+ void IniDict::insertEntry( const std::string &section,
+ const std::string &key,
+ const std::string &value )
+ {
+ consume( section, key, value );
+ }
+
+ void IniDict::deleteSection( const std::string &section )
+ {
+ _dict.erase(section);
+ }
+
+ bool IniDict::hasSection( const std::string &section ) const
+ {
+ SectionSet::const_iterator secit = _dict.find(section);
+ if ( secit == _dict.end() )
+ return false;
+ return true;
+ }
+
+ bool IniDict::hasEntry( const std::string &section,
+ const std::string &entry ) const
+ {
+ SectionSet::const_iterator secit = _dict.find(section);
+ if ( secit == _dict.end() )
+ return false;
+
+ EntrySet::const_iterator entryit = (secit->second).find(entry);
+ if ( entryit == (secit->second).end() )
+ return false;
+
+ return true;
+ }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const IniDict & obj )
+ {
+ for ( IniDict::section_const_iterator si = obj.sectionsBegin();
+ si != obj.sectionsEnd();
+ ++si )
+ {
+ str << "[" << *si << "]" << endl;
+ for ( IniDict::entry_const_iterator ei = obj.entriesBegin(*si);
+ ei != obj.entriesEnd(*si);
+ ++ei )
+ {
+ str << ei->first << " = " << ei->second << endl;
+ }
+ str << endl;
+ }
+ return str;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////

Added: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.h?rev=7708&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.h (added)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniDict.h Tue Oct 30
17:33:43 2007
@@ -0,0 +1,167 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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/base/Iterator.h"
+#include "zypp/parser/IniParser.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace parser
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // 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<std::string, std::string> EntrySet;
+ typedef std::map<std::string, EntrySet> SectionSet;
+ typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator
section_const_iterator;
+ typedef EntrySet::const_iterator entry_const_iterator;
+
+ /**
+ * \name Section Iterators
+ * Iterate trough ini file sections
+ * \code
+ * for ( IniDict::section_const_iterator it = dict.sectionsBegin();
+ * it != dict.sectionsEnd();
+ * ++it )
+ * {
+ * MIL << (*it) << endl;
+ * }
+ * \endcode
+ */
+ //@{
+ section_const_iterator sectionsBegin() const;
+ section_const_iterator sectionsEnd() const;
+ //@}
+
+ /**
+ * \name Entries Iterators
+ * Iterate trough ini file entries in a section
+ * \code
+ * for ( IniDict::entry_const_iterator it = dict.entriesBegin("updates");
+ * it != dict.entriesEnd("updates");
+ * ++it )
+ * {
+ * MIL << (*it).first << endl;
+ * }
+ * \endcode
+ */
+
+ //@{
+ entry_const_iterator entriesBegin(const std::string &section) const;
+ entry_const_iterator entriesEnd(const std::string &section) const;
+ //@{
+
+ /**
+ * Creates a dictionary from a InputStream
+ * containing a ini structured file
+ */
+ IniDict( const InputStream &is );
+
+ /**
+ * Creates a mepty dictionary
+ */
+ IniDict();
+
+ /** Dtor */
+ ~IniDict();
+
+ /**
+ * Fill a dictionary from a InputStream
+ * containing a ini structured file
+ */
+ void read( const InputStream &is );
+
+ /**
+ * \short add an entry
+ * \param section
+ * \param key
+ * \param value
+ */
+ void insertEntry( const std::string &section,
+ const std::string &key,
+ const std::string &value );
+
+ /**
+ * \short add an entry
+ * \param section
+ * \param key
+ * \param value
+ */
+ void deleteSection( const std::string &section );
+
+ /**
+ * \short True if there is a section with that name
+ * \param section Section Name
+ */
+ bool hasSection( const std::string &section ) const;
+
+ /**
+ * \short True if an entry exists in the section
+ * \param section Section name
+ * \param entry entry name
+ *
+ * \note If the given section does not exist, this will
+ * of course return false.
+ */
+ bool hasEntry( const std::string &section,
+ const std::string &entry ) const;
+ public:
+
+ /** Called when a section is found. */
+ virtual void consume( const std::string &section );
+ /** Called when a key value is found. */
+ virtual void consume( const std::string &section,
+ const std::string &key,
+ const std::string &value );
+
+ private:
+ SectionSet _dict;
+ /**
+ * empty map used to simulate
+ * iteration in non existant
+ * sections
+ */
+ EntrySet _empty_map;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates IniDict Stream output */
+ std::ostream & operator<<( std::ostream & str, const IniDict & obj );
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_INIDICT_H

Added: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.cc?rev=7708&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.cc (added)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.cc Tue Oct 30
17:33:43 2007
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/IniParser.cc
+ *
+*/
+#include <iostream>
+#include <sstream>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/base/IOStream.h"
+
+#include "zypp/parser/IniParser.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace parser
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// METHOD NAME : IniParser::IniParser
+// METHOD TYPE : Ctor
+//
+IniParser::IniParser()
+ : _line_nr(0)
+{}
+
+///////////////////////////////////////////////////////////////////
+//
+// METHOD NAME : IniParser::~IniParser
+// METHOD TYPE : Dtor
+//
+IniParser::~IniParser()
+{}
+
+void IniParser::beginParse()
+{}
+
+void IniParser::consume( const std::string &section, const std::string &key,
const std::string &value )
+{}
+
+void IniParser::consume( const std::string &section )
+{}
+
+void IniParser::endParse()
+{}
+
+///////////////////////////////////////////////////////////////////
+//
+// METHOD NAME : IniParser::parse
+// METHOD TYPE : void
+//
+void IniParser::parse( const InputStream & input_r )
+{
+ MIL << "Start parsing " << input_r << endl;
+ _inputname = input_r.name();
+ beginParse();
+
+ iostr::EachLine line( input_r );
+ for ( ; line; line.next() )
+ {
+ std::string trimmed = str::trim(*line);
+
+ if (trimmed.empty() || trimmed[0] == ';' || trimmed[0] == '#')
+ continue ; /* Comment lines */
+
+ if (trimmed[0] == '[')
+ {
+ std::string section = trimmed.substr(1, trimmed.find(']')-1);
+ consume(section);
+ section.swap(_current_section);
+ continue;
+ }
+
+ std::string::size_type pos = trimmed.find('=');
+
+ if (pos != std::string::npos)
+ {
+ std::string key = str::rtrim(trimmed.substr(0, pos));
+ std::string value = str::ltrim(trimmed.substr(pos+1));
+ consume( _current_section, key, value);
+ }
+
+ }
+
+ endParse();
+ _inputname.clear();
+ MIL << "Done parsing " << input_r << endl;
+}
+
+/////////////////////////////////////////////////////////////////
+} // namespace parser
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////

Added: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.h?rev=7708&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.h (added)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/IniParser.h Tue Oct 30
17:33:43 2007
@@ -0,0 +1,79 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/IniParser.h
+ *
+*/
+#ifndef ZYPP_PARSER_INIPARSER_H
+#define ZYPP_PARSER_INIPARSER_H
+
+#include <iosfwd>
+#include <string>
+#include <list>
+
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/InputStream.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace parser
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : IniParser
+//
+/** Basic SUSEtags parser.
+ * Will replace parser/tagfile/ and parser/taggedfile/ stuff.
+*/
+class IniParser : private base::NonCopyable
+{
+public:
+ /** Default ctor */
+ IniParser();
+ /** Dtor */
+ virtual ~IniParser();
+ /** Parse the stream.
+ * \throw ParseException on errors. Invoke \ref consume
+ * for each tag. \ref consume might throw other exceptions
+ * as well.
+ */
+ void parse( const InputStream & imput_r );
+
+public:
+ /** Called when start parsing. */
+ virtual void beginParse();
+ /** Called when a section is found. */
+ virtual void consume( const std::string &section );
+ /** Called when a key value is found. */
+ virtual void consume( const std::string &section, const std::string &key,
const std::string &value );
+ /** Called when the parse is done. */
+ virtual void endParse();
+public:
+ /** Name of the current InputStream. */
+ const std::string & inputname() const
+ {
+ return _inputname;
+ }
+
+private:
+ std::string _inputname;
+ std::string _current_section;
+ int _line_nr;
+};
+
+/////////////////////////////////////////////////////////////////
+} // namespace parser
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_INIPARSER_H

Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/Makefile.am?rev=7708&r1=7707&r2=7708&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/Makefile.am (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/parser/Makefile.am Tue Oct 30
17:33:43 2007
@@ -12,10 +12,12 @@

parserinclude_HEADERS = \
XMLNodeIterator.h \
- SAXParser.h \
+ SAXParser.h \
LibXMLHelper.h \
- xml_parser_assert.h \
- ParserProgress.h
+ xml_parser_assert.h \
+ ParserProgress.h \
+ IniDict.h \
+ IniParser.h

noinst_LTLIBRARIES = lib@PACKAGE@_parser.la

@@ -24,8 +26,10 @@

lib@PACKAGE@_parser_la_SOURCES = \
XMLNodeIterator.cc \
- LibXMLHelper.cc \
- SAXParser.cc
+ LibXMLHelper.cc \
+ SAXParser.cc \
+ IniDict.cc \
+ IniParser.cc

lib@PACKAGE@_parser_la_LIBADD = xml/lib@PACKAGE@_parser_xml.la \
yum/lib@PACKAGE@_parser_yum.la \

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages