Mailinglist Archive: zypp-commit (168 mails)
| < Previous | Next > |
[zypp-commit] r8126 - /branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h
- From: mlandres@xxxxxxxxxxxxxxxx
- Date: Tue, 18 Dec 2007 20:39:50 -0000
- Message-id: <20071218203950.C7B3327968@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Tue Dec 18 21:39:50 2007
New Revision: 8126
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8126&view=rev
Log:
added compareCI: case insensitive string compare
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h?rev=8126&r1=8125&r2=8126&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h Tue Dec 18 21:39:50 2007
@@ -302,11 +302,36 @@
* \todo improve
*/
std::string toLower( const std::string & s );
+ /** \overload */
+ inline std::string toLower( const char * s )
+ { return( s ? toLower( std::string(s) ) : std::string() ); }
/** Return uppercase version of \a s
* \todo improve
*/
std::string toUpper( const std::string & s );
+ /** \overload */
+ inline std::string toUpper( const char * s )
+ { return( s ? toUpper( std::string(s) ) : std::string() ); }
+ //@}
+
+
+ /** \name Case insensitive comparison. */
+ //@{
+ inline int compareCI( const char * lhs, const char * rhs )
+ {
+ if ( lhs == rhs )
+ return 0;
+ if ( ! ( lhs && rhs ) )
+ return( lhs ? 1 : -1 );
+ return ::strcasecmp( lhs, rhs );
+ }
+ inline int compareCI( const std::string & lhs, const std::string & rhs )
+ { return compareCI( lhs.c_str(), rhs.c_str() ); }
+ inline int compareCI( const char * lhs, const std::string & rhs )
+ { return compareCI( lhs, rhs.c_str() ); }
+ inline int compareCI( const std::string & lhs, const char * rhs )
+ { return compareCI( lhs.c_str(), rhs ); }
//@}
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx
Date: Tue Dec 18 21:39:50 2007
New Revision: 8126
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8126&view=rev
Log:
added compareCI: case insensitive string compare
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h?rev=8126&r1=8125&r2=8126&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/base/String.h Tue Dec 18 21:39:50 2007
@@ -302,11 +302,36 @@
* \todo improve
*/
std::string toLower( const std::string & s );
+ /** \overload */
+ inline std::string toLower( const char * s )
+ { return( s ? toLower( std::string(s) ) : std::string() ); }
/** Return uppercase version of \a s
* \todo improve
*/
std::string toUpper( const std::string & s );
+ /** \overload */
+ inline std::string toUpper( const char * s )
+ { return( s ? toUpper( std::string(s) ) : std::string() ); }
+ //@}
+
+
+ /** \name Case insensitive comparison. */
+ //@{
+ inline int compareCI( const char * lhs, const char * rhs )
+ {
+ if ( lhs == rhs )
+ return 0;
+ if ( ! ( lhs && rhs ) )
+ return( lhs ? 1 : -1 );
+ return ::strcasecmp( lhs, rhs );
+ }
+ inline int compareCI( const std::string & lhs, const std::string & rhs )
+ { return compareCI( lhs.c_str(), rhs.c_str() ); }
+ inline int compareCI( const char * lhs, const std::string & rhs )
+ { return compareCI( lhs, rhs.c_str() ); }
+ inline int compareCI( const std::string & lhs, const char * rhs )
+ { return compareCI( lhs.c_str(), rhs ); }
//@}
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx
| < Previous | Next > |