- Provide method 'asString()' in StringVal based classes.
authorMichael Andres <ma@suse.de>
Thu, 17 Nov 2005 08:30:19 +0000 (08:30 +0000)
committerMichael Andres <ma@suse.de>
Thu, 17 Nov 2005 08:30:19 +0000 (08:30 +0000)
- Provide 'operator== and != string' in StringVal based classes.

zypp/base/StringVal.h
zypp/detail/PatchImpl.cc
zypp/detail/PatchImpl.h

index 542b8d4..5aa5ab0 100644 (file)
@@ -30,8 +30,12 @@ namespace zypp
     class StringVal
     {
     public:
+      /** */
       operator const std::string &() const
       { return _value; }
+      /** */
+      const std::string & asString() const
+      { return _value; }
     protected:
       /** */
       StringVal();
@@ -54,6 +58,27 @@ namespace zypp
     inline std::ostream & operator<<( std::ostream & str, const StringVal & obj )
     { return str << static_cast<const std::string &>(obj); }
 
+    ///////////////////////////////////////////////////////////////////
+
+    inline bool operator==( const StringVal & lhs, const StringVal & rhs )
+    { return lhs.asString() == rhs.asString(); }
+
+    inline bool operator==( const StringVal & lhs, const std::string & rhs )
+    { return lhs.asString() == rhs; }
+
+    inline bool operator==( const std::string & lhs, const StringVal & rhs )
+    { return lhs == rhs.asString(); }
+
+
+    inline bool operator!=( const StringVal & lhs, const StringVal & rhs )
+    { return !( lhs == rhs ); }
+
+    inline bool operator!=( const StringVal & lhs, const std::string & rhs )
+    { return !( lhs == rhs ); }
+
+    inline bool operator!=( const std::string & lhs, const StringVal & rhs )
+    { return !( lhs == rhs ); }
+
     /////////////////////////////////////////////////////////////////
   } // namespace base
   ///////////////////////////////////////////////////////////////////
index 69bee79..addffc7 100644 (file)
@@ -83,12 +83,12 @@ namespace zypp
        it != not_installed.end();
        it++)
       {
-       if ((std::string)((*it)->kind()) == "message")
+       if ((*it)->kind() == "message")
        {
 //       DBG << "Patch contains a message" << endl;
          return true;
        }
-       if ((std::string)((*it)->kind()) == "package")
+       if ((*it)->kind() == "package")
        {
                                 // Resolvable*
                                  // Resolvable
index 9e7f7ab..4b71474 100644 (file)
@@ -27,7 +27,7 @@ namespace zypp
     //
     /** Class representing a patch
      * \todo Get rid of string based ResKind detection in e.g.
-     * PatchImpl::interactive. Esp. DO NOT CAST ResKind to std::string.
+     * PatchImpl::interactive.
     */
     class PatchImpl : public PatchImplIf
     {