projects
/
platform
/
upstream
/
libzypp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ed06406
)
Provide non-throwing Rel::parseFrom(std::string)
author
Michael Andres
<ma@suse.de>
Fri, 28 Aug 2009 14:36:06 +0000
(16:36 +0200)
committer
Michael Andres
<ma@suse.de>
Fri, 28 Aug 2009 14:36:06 +0000
(16:36 +0200)
zypp/Rel.cc
patch
|
blob
|
history
zypp/Rel.h
patch
|
blob
|
history
diff --git
a/zypp/Rel.cc
b/zypp/Rel.cc
index
089ca7c
..
1839c63
100644
(file)
--- a/
zypp/Rel.cc
+++ b/
zypp/Rel.cc
@@
-86,6
+86,17
@@
namespace zypp
: _op( parse( strval_r, default_r ) )
{}
: _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
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Rel::asString
diff --git
a/zypp/Rel.h
b/zypp/Rel.h
index
a5ca5f8
..
1162abe
100644
(file)
--- 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.
*
* \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
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 );
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 )
/** Ctor from bits. */
explicit
Rel( unsigned bits_r )