Mailinglist Archive: zypp-commit (38 mails)

< Previous Next >
[zypp-commit] <libzypp> master : Provide non-throwing Rel::parseFrom(std::string)
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Fri, 28 Aug 2009 16:36:06 +0200
  • Message-id: <E1Mh2Yu-0000LY-67@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 2688551762d93de3cb352ddd4169d0c9d08ad266
Author: Michael Andres <ma@xxxxxxx>
Date: Fri Aug 28 16:36:06 2009 +0200

Provide non-throwing Rel::parseFrom(std::string)
---
zypp/Rel.cc | 11 +++++++++++
zypp/Rel.h | 9 +++++++--
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/zypp/Rel.cc b/zypp/Rel.cc
index 089ca7c..1839c63 100644
--- a/zypp/Rel.cc
+++ b/zypp/Rel.cc
@@ -86,6 +86,17 @@ namespace zypp
: _op( parse( strval_r, default_r ) )
{}

+ bool Rel::parseFrom( const std::string & strval_r )
+ {
+ std::map<std::string,Rel::for_use_in_switch>::const_iterator it = findStr(
strval_r );
+ if ( it == _table.end() )
+ {
+ return false;
+ }
+ _op = it->second;
+ return true;
+ }
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Rel::asString
diff --git a/zypp/Rel.h b/zypp/Rel.h
index a5ca5f8..1162abe 100644
--- a/zypp/Rel.h
+++ b/zypp/Rel.h
@@ -87,15 +87,20 @@ namespace zypp
*
* \throw PARSE if \a strval_r is not legal.
* \todo refine exceptions and check throw.
- */
+ */
explicit
Rel( const std::string & strval_r );

/** Ctor from string (non-throwing).
* Illegal string values resolve to \c default_r
- */
+ */
Rel( const std::string & strval_r, const Rel & default_r );

+ /** Assign from string IFF it contains a legal value.
+ * \return Whether \a strval_r contained a legal value.
+ */
+ bool parseFrom( const std::string & strval_r );
+
/** Ctor from bits. */
explicit
Rel( unsigned bits_r )
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages