added stream output operator
authorMichael Andres <ma@suse.de>
Tue, 7 Oct 2008 11:20:08 +0000 (11:20 +0000)
committerMichael Andres <ma@suse.de>
Tue, 7 Oct 2008 11:20:08 +0000 (11:20 +0000)
zypp/media/MediaSource.cc [new file with mode: 0644]
zypp/media/MediaSource.h
zypp/media/Mount.cc
zypp/media/Mount.h

diff --git a/zypp/media/MediaSource.cc b/zypp/media/MediaSource.cc
new file mode 100644 (file)
index 0000000..a0f31c5
--- /dev/null
@@ -0,0 +1,29 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/media/MediaSource.cc
+*/
+#include <iostream>
+
+#include "zypp/media/MediaSource.h"
+
+namespace zypp {
+  namespace media {
+
+    std::ostream & operator<<( std::ostream & str, const AttachPoint & obj )
+    {
+      return str << (obj.temp ? "*" : "") << obj.path;
+    }
+
+    std::ostream & operator<<( std::ostream & str, const AttachedMedia & obj )
+    {
+      return str << "media("  << obj.mediaSource << ")attached(" << obj.attachPoint << ")";
+    }
+
+  } // namespace media
+} // namespace zypp
index c39f0c6..45ef522 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef ZYPP_MEDIA_MEDIASOURCE_H
 #define ZYPP_MEDIA_MEDIASOURCE_H
 
+#include <iosfwd>
+
 #include "zypp/Pathname.h"
 #include "zypp/base/String.h"
 #include "zypp/base/PtrTypes.h"
@@ -92,6 +94,9 @@ namespace zypp {
       bool         iown;    //!< True, if mounted by media manager.
     };
 
+    /** \relates MediaSource Stream output */
+    inline std::ostream & operator<<( std::ostream & str, const MediaSource & obj )
+    { return str << obj.asString(); }
 
     ///////////////////////////////////////////////////////////////////
     /**
@@ -112,6 +117,8 @@ namespace zypp {
       bool     temp;    //!< If it was created temporary.
     };
 
+    /** \relates AttachPoint Stream output */
+    inline std::ostream & operator<<( std::ostream & str, const AttachPoint & obj );
 
     ///////////////////////////////////////////////////////////////////
     typedef zypp::RW_pointer<MediaSource> MediaSourceRef;
@@ -138,6 +145,8 @@ namespace zypp {
       AttachPointRef attachPoint;
     };
 
+    /** \relates AttachedMedia Stream output */
+    std::ostream & operator<<( std::ostream & str, const AttachedMedia & obj );
 
   } // namespace media
 } // namespace zypp
index 33af9bf..899adbb 100644 (file)
  *
 */
 
-#include <sys/stat.h>
-#include <stdio.h>
 #include <mntent.h>
-#include <limits.h>
-#include <unistd.h>
-#include <errno.h>
+
+#include <cstdio>
+#include <climits>
+#include <cerrno>
+
 #include <iostream>
 #include <fstream>
 #include <string>
@@ -34,6 +34,15 @@ using namespace std;
 namespace zypp {
   namespace media {
 
+    std::ostream & operator<<( std::ostream & str, const MountEntry & obj )
+    {
+      str << obj.src << " on " << obj.dir << " type " << obj.type;
+      if ( ! obj.opts.empty() )
+        str << " (" << obj.opts << ")";
+      return str;
+    }
+
+
 Mount::Mount()
 {
     process = 0;
index 5f9cda8..1c95dda 100644 (file)
 
 #ifndef ZYPP_MEDIA_MOUNT_H
 #define ZYPP_MEDIA_MOUNT_H
+
 #include <set>
 #include <map>
 #include <string>
+#include <iosfwd>
 
 #include "zypp/ExternalProgram.h"
 #include "zypp/KVMap.h"
@@ -53,11 +55,13 @@ namespace zypp {
         int         pass; //!< pass number on parallel fsck
     };
 
-    /**
+    /** \relates MountEntry
      * A vector of mount entries.
      */
     typedef std::vector<MountEntry> MountEntries;
 
+    /** \relates MountEntry Stream output */
+    std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
 
     /**
      * @short Interface to the mount program