Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10579 - in /trunk/libzypp/zypp/solver/detail: SystemCheck.cc SystemCheck.h
  • From: schubi2@xxxxxxxxxxxxxxxx
  • Date: Mon, 14 Jul 2008 14:52:04 -0000
  • Message-id: <20080714145204.6112734499@xxxxxxxxxxxxxxxx>
Author: schubi2
Date: Mon Jul 14 16:52:04 2008
New Revision: 10579

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10579&view=rev
Log:
Class for parsing system requirements/conflicts

Added:
trunk/libzypp/zypp/solver/detail/SystemCheck.cc
trunk/libzypp/zypp/solver/detail/SystemCheck.h

Added: trunk/libzypp/zypp/solver/detail/SystemCheck.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SystemCheck.cc?rev=10579&view=auto
==============================================================================
--- trunk/libzypp/zypp/solver/detail/SystemCheck.cc (added)
+++ trunk/libzypp/zypp/solver/detail/SystemCheck.cc Mon Jul 14 16:52:04 2008
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/solver/detail/SystemCheck.cc
+ *
+*/
+#include <iostream>
+#include <fstream>
+#include <vector>
+
+#include "zypp/base/LogTools.h"
+#include "zypp/base/IOStream.h"
+#include "zypp/base/String.h"
+
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZConfig.h"
+#include "zypp/Pathname.h"
+#include "zypp/PathInfo.h"
+#include "zypp/solver/detail/SystemCheck.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ Pathname _file;
+ CapabilitySet _require;
+ CapabilitySet _conflict;
+
+ typedef vector<string> CapList;
+
+ SystemCheck::SystemCheck() {
+ _file = ZConfig::instance().solver_checkSystemFile();
+ try
+ {
+ Target_Ptr trg( getZYpp()->target() );
+ if ( trg )
+ _file = trg->root() / _file;
+ }
+ catch ( ... )
+ {
+ // noop: Someone decided to let target() throw if the ptr is NULL ;(
+ }
+
+ PathInfo pi( _file );
+ if ( ! pi.isFile() ) {
+ WAR << "Can't read " << pi << endl;
+ return;
+ }
+ std::ifstream infile( _file.c_str() );
+ for( iostr::EachLine in( infile ); in; in.next() ) {
+ std::string l( str::trim(*in) );
+ if ( ! l.empty() && l[0] != '#' )
+ {
+ CapList capList;
+ str::split( l, back_inserter(capList), ":" );
+ if (capList.size() == 2 ) {
+ CapList::iterator it = capList.begin();
+ if (*it == "requires") {
+ _require.insert(Capability(*(it+1)));
+ } else if (*it == "conflicts") {
+ _conflict.insert(Capability(*(it+1)));
+ } else {
+ ERR << "Wrong parameter: " << l << endl;
+ }
+ } else {
+ ERR << "Wrong line: " << l << endl;
+ }
+ }
+ }
+ MIL << "Read " << pi << endl;
+ }
+
+ const Pathname & file() {
+ return _file;
+ }
+
+ const CapabilitySet & requiredSystemCap() {
+ return _require;
+ }
+
+ const CapabilitySet & conflictSystemCap() {
+ return _conflict;
+ }
+
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const SystemCheck & obj )
+ {
+ str << _file << endl;
+ str << "requires" << endl;
+ for (CapabilitySet::const_iterator it = _require.begin(); it !=
_require.end(); ++it)
+ str << " " << *it << endl;
+
+ str << "conflicts" << endl;
+ for (CapabilitySet::const_iterator it = _conflict.begin(); it !=
_conflict.end(); ++it)
+ str << " " << *it << endl;
+
+ return str;
+ }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////

Added: trunk/libzypp/zypp/solver/detail/SystemCheck.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SystemCheck.h?rev=10579&view=auto
==============================================================================
--- trunk/libzypp/zypp/solver/detail/SystemCheck.h (added)
+++ trunk/libzypp/zypp/solver/detail/SystemCheck.h Mon Jul 14 16:52:04 2008
@@ -0,0 +1,59 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/SystemCheck.h
+ *
+*/
+#ifndef ZYPP_TARGET_SYSTEMCHECK_H
+#define ZYPP_TARGET_SYSTEMCHECK_H
+
+#include <iosfwd>
+
+#include "zypp/base/NonCopyable.h"
+#include "zypp/Capability.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SystemCheck
+ //
+ /** Save and restore locale set from file.
+ */
+ class SystemCheck : private base::NonCopyable
+ {
+ friend std::ostream & operator<<( std::ostream & str, const SystemCheck
& obj );
+
+ public:
+
+ /** Return the file path. */
+ const Pathname & file() const;
+
+ /** Returns a list of required system capabilities.
+ */
+ const CapabilitySet & requiredSystemCap() const;
+
+ /** Returns a list of conflicting system capabilities.
+ */
+ const CapabilitySet & conflictSystemCap() const;
+
+ private:
+ /** Ctor taking the file to read. */
+ SystemCheck();
+
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates SystemCheck Stream output */
+ std::ostream & operator<<( std::ostream & str, const SystemCheck & obj );
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_TARGET_SYSTEMCHECK_H

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

< Previous Next >
This Thread
  • No further messages