FileReaderBaseImpl.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_PARSER_YUM_FILEREADERBASEIMPL_H_
00013 #define ZYPP_PARSER_YUM_FILEREADERBASEIMPL_H_
00014 
00015 #include "zypp/data/ResolvableData.h"
00016 #include "zypp/parser/xml/Reader.h"
00017 
00018 #include "zypp/parser/yum/FileReaderBase.h"
00019 
00020 namespace zypp
00021 {
00022   namespace parser
00023   {
00024     namespace yum
00025     {
00026 
00027 
00028   class FileReaderBase::BaseImpl : private base::NonCopyable
00029   {
00030   public:
00031 
00035     enum Tag
00036     {
00037       tag_NONE,
00038       tag_package,
00039       tag_format,
00040       tag_patch,
00041       tag_atoms,
00042       tag_script,
00043       tag_message,
00044       tag_pkgfiles,
00045       tag_deltarpm,
00046       tag_patchrpm,
00047       tag_pattern,
00048       tag_product
00049     };
00050 
00067     struct TagPath
00068     {
00069       typedef std::list<Tag> TagList;
00070       
00071       void append(const Tag tag) { path.push_back(tag); }
00072       void remove() { if (!path.empty()) path.pop_back(); }
00073       unsigned depth() const { return path.size(); }
00074       Tag currentTag() const
00075       {
00076         if (!path.empty()) return path.back();
00077         return tag_NONE;
00078       }
00079       bool contains(const Tag tag) const
00080       {
00081         TagList::const_iterator result = find(path.begin(), path.end(), tag);
00082         return result != path.end();
00083       }
00084       std::string asString();
00085 
00086       TagList path;
00087     };
00088 
00089 
00090   public:
00092     BaseImpl();
00093 
00104     bool consumePackageNode(xml::Reader & reader_r, data::Packagebase_Ptr & package_ptr);
00105 
00112     bool consumeFormatNode(xml::Reader & reader_r, data::Packagebase_Ptr & package_ptr);
00113 
00120     bool consumeDependency(xml::Reader & reader_r, data::Dependencies & deps_r);
00121 
00122 
00123   public:
00125     void tag(const Tag tag) { _tagpath.append(tag); }
00126 
00128     bool isBeingProcessed(Tag tag) const { return _tagpath.contains(tag); }
00129 
00131     void toParentTag() { _tagpath.remove(); }
00132 
00134     const TagPath & tagPath() const { return _tagpath; }
00135 
00136 
00137   private:
00139     TagPath _tagpath;
00140 
00145     bool _expect_rpm_entry;
00146 
00150     Dep _dtype;
00151   };
00152 
00153 
00154     } // ns yum
00155   } // ns parser
00156 } // ns zypp
00157 
00158 #endif /*ZYPP_PARSER_YUM_FILEREADERBASEIMPL_H_*/
00159 
00160 // vim: set ts=2 sts=2 sw=2 et ai:

Generated on Tue Sep 25 19:23:03 2007 for libzypp by  doxygen 1.5.3