- Adapt to virtual ostream operator<< provided by ReferenceCounted.
authorMichael Andres <ma@suse.de>
Mon, 12 Dec 2005 15:02:14 +0000 (15:02 +0000)
committerMichael Andres <ma@suse.de>
Mon, 12 Dec 2005 15:02:14 +0000 (15:02 +0000)
- fixed Exception to compile

devel/Example.createCapabilities.cc
devel/devel.ma/Main.cc
zypp/Resolvable.h
zypp/base/Exception.cc
zypp/base/Exception.h
zypp/capability/CapabilityImpl.cc
zypp/capability/CapabilityImpl.h

index 75a0e5c..efa8bb5 100644 (file)
@@ -5,6 +5,7 @@
 #include <list>
 #include <string>
 #include <zypp/base/Logger.h>
+#include <zypp/base/Exception.h>
 #include <zypp/base/String.h>
 #include <zypp/base/IOStream.h>
 #include <zypp/base/PtrTypes.h>
index 15f8dc1..a0a399b 100644 (file)
@@ -1,31 +1,38 @@
 #include <iostream>
-#include "zypp/base/Logger.h"
-#include "zypp/base/PtrTypes.h"
-#include "zypp/base/Exception.h"
-#include "zypp/base/Fd.h"
-#include "zypp/Pathname.h"
+#include <ctime>
+
+#include <fstream>
+#include <list>
+#include <string>
+#include <zypp/base/Logger.h>
+#include <zypp/base/String.h>
+#include <zypp/base/IOStream.h>
+#include <zypp/base/PtrTypes.h>
+
+#include <zypp/CapFactory.h>
+#include <zypp/CapSet.h>
 
 using namespace std;
 using namespace zypp;
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
+namespace zypp
+{
+  struct foo : public base::ReferenceCounted
+  {
+  };
+}
 
 /******************************************************************
 **
-**
 **      FUNCTION NAME : main
 **      FUNCTION TYPE : int
-**
-**      DESCRIPTION :
 */
 int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  base::Fd( "packages", O_RDONLY );
+  foo f;
+  SEC << f << endl;
 
   INT << "===[END]============================================" << endl;
   return 0;
index 884ec5b..369c4ef 100644 (file)
@@ -42,7 +42,6 @@ namespace zypp
     typedef TraitsType::KindType     Kind;
     typedef TraitsType::PtrType      Ptr;
     typedef TraitsType::constPtrType constPtr;
-    friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
 
   public:
     /**  */
@@ -116,12 +115,6 @@ namespace zypp
     inline typename ResTraits<_Res>::constPtrType asKind( const Resolvable::constPtr & p )
     { return dynamic_pointer_cast<const _Res>(p); }
 
-  ///////////////////////////////////////////////////////////////////
-
-  /** \relates Resolvable Stream output via Resolvable::dumpOn */
-  inline std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
-  { return obj.dumpOn( str ); }
-
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index fa1c2d2..d98d266 100644 (file)
@@ -10,6 +10,7 @@
  *
 */
 #include <iostream>
+#include <sstream>
 
 #include "zypp/base/Logger.h"
 #include "zypp/base/String.h"
@@ -49,14 +50,12 @@ namespace zypp
   Exception::~Exception() throw()
   {}
 
-#if 0
   std::string Exception::asString() const
   {
-    std::string ret( _where.asString() );
-    ret += ": ";
-    return ret += _msg;
+    std::ostringstream str;
+    dumpOn( str );
+    return str.str();
   }
-#endif
 
   std::ostream & Exception::dumpOn( std::ostream & str ) const
   {
index 29f7eb9..9666f6f 100644 (file)
@@ -73,7 +73,7 @@ namespace zypp
    *  44     {
    *  45       try
    *  46         {
-   *  47           ZYPP_THROW( Exception, "Something bad happened." );
+   *  47           ZYPP_THROW_MSG( Exception, "Something bad happened." );
    *  48         }
    *  49       catch ( Exception & excpt )
    *  50         {
@@ -128,15 +128,11 @@ namespace zypp
     void relocate( const CodeLocation & where_r ) const
     { _where = where_r; }
 
-    /** Return the provided message string. */
+    /** Return the message string provided to the ctor. */
     const std::string & msg() const
     { return _msg; }
 
-    /** Return message string. */
-    virtual const char * what() const throw()
-    { return _msg.c_str(); }
-
-    /** Exception as string */
+    /** A proper error message. */
     std::string asString() const;
 
   protected:
@@ -153,7 +149,9 @@ namespace zypp
     static std::string strErrno( int errno_r, const std::string & msg_r );
 
   public:
-    /** Drop a logline. */
+    /** Drop a logline on throw, catch or rethrow.
+     * Used by \ref ZYPP_THROW macros.
+    */
     static void log( const Exception & excpt_r, const CodeLocation & where_r,
                      const char *const prefix_r );
 
@@ -161,6 +159,10 @@ namespace zypp
     mutable CodeLocation _where;
     std::string _msg;
 
+    /** Return message string. */
+    virtual const char * what() const throw()
+    { return _msg.c_str(); }
+
     /** Called by <tt>std::ostream & operator\<\<</tt> */
     std::ostream & dumpError( std::ostream & str ) const;
   };
index 42b0ace..80fc00a 100644 (file)
@@ -42,16 +42,16 @@ namespace zypp
       return asString() < rhs->asString();
     }
 
-    /******************************************************************
-     **
-     **        FUNCTION NAME : operator<<
-     **        FUNCTION TYPE : std::ostream &
-    */
-    std::ostream & operator<<( std::ostream & str, const CapabilityImpl & obj )
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : CapabilityImpl::capImplOrderLess
+    // METHOD TYPE : bool
+    //
+    std::ostream & CapabilityImpl::dumpOn( std::ostream & str ) const
     {
-      return str << '[' << obj.refers() << "] "
-      << '(' << obj.kind() << ") "
-      << obj.asString();
+      return str << '[' << refers() << "] "
+                 << '(' << kind() << ") "
+                 << asString();
     }
 
     /////////////////////////////////////////////////////////////////
index 892b52d..a7c0e0e 100644 (file)
@@ -60,6 +60,10 @@ namespace zypp
       virtual bool matches( Resolvable::constPtr resolvable_r,
                             solver::Context_constPtr solverContext_r ) const = 0;
 
+    protected:
+      /** Helper for stream output. */
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+
     private:
       /** Kind of Resolvable \c this refers to. */
       Resolvable::Kind _refers;
@@ -92,11 +96,6 @@ namespace zypp
       }
     };
 
-    ///////////////////////////////////////////////////////////////////
-
-    /** \relates CapabilityImpl Stream output */
-    extern std::ostream & operator<<( std::ostream & str, const CapabilityImpl & obj );
-
     /////////////////////////////////////////////////////////////////
   } // namespace capability
   ///////////////////////////////////////////////////////////////////