From 41f3d9a1ba4120835ef986d0372a304dc6e3d16b Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 17 Nov 2005 08:30:19 +0000 Subject: [PATCH] - Provide method 'asString()' in StringVal based classes. - Provide 'operator== and != string' in StringVal based classes. --- zypp/base/StringVal.h | 25 +++++++++++++++++++++++++ zypp/detail/PatchImpl.cc | 4 ++-- zypp/detail/PatchImpl.h | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/zypp/base/StringVal.h b/zypp/base/StringVal.h index 542b8d4..5aa5ab0 100644 --- a/zypp/base/StringVal.h +++ b/zypp/base/StringVal.h @@ -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(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 /////////////////////////////////////////////////////////////////// diff --git a/zypp/detail/PatchImpl.cc b/zypp/detail/PatchImpl.cc index 69bee79..addffc7 100644 --- a/zypp/detail/PatchImpl.cc +++ b/zypp/detail/PatchImpl.cc @@ -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 diff --git a/zypp/detail/PatchImpl.h b/zypp/detail/PatchImpl.h index 9e7f7ab..4b71474 100644 --- a/zypp/detail/PatchImpl.h +++ b/zypp/detail/PatchImpl.h @@ -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 { -- 2.7.4