Fawkes API  Fawkes Development Version
string_compare.cpp
00001 
00002 /***************************************************************************
00003  *  string_compare.cpp - Fawkes string compare utils
00004  *
00005  *  Created: Fri May 11 23:40:28 2007
00006  *  Copyright  2006-2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #include <utils/misc/string_compare.h>
00025 #include <cstring>
00026 
00027 namespace fawkes {
00028 
00029 /** @class StringEquality <utils/misc/string_compare.h>
00030  * String equality checker.
00031  * This is a valid binary predicate that can be used for instance hash maps
00032  * as the equality predicate.
00033  *
00034  * The only method is used to check whether two supplied strings are equal.
00035  * Uses strcmp for char arrays.
00036  *
00037  * @author Tim Niemueller
00038  */
00039 
00040 /** Check equality of two strings.
00041  * @param __s1 first string
00042  * @param __s2 second string
00043  * @return true, if the strings are equal, false otherwise
00044  */
00045 bool
00046 StringEquality::operator()(const char *__s1, const char *__s2) const
00047 {
00048   return ( strcmp(__s1, __s2) == 0 );
00049 }
00050 
00051 
00052 /** @class StringLess <utils/misc/string_compare.h>
00053  * String less than test.
00054  * This is a valid binary predicate that can be used for instance for maps
00055  * as the less predicate.
00056  *
00057  * The only method is used to check whether one supplied strings is less
00058  * then the other. Uses strcmp for char arrays.
00059  *
00060  * @author Tim Niemueller
00061  */
00062 
00063 /** Check equality of two strings.
00064  * @param __s1 first string
00065  * @param __s2 second string
00066  * @return true, if the __s1 < __s2
00067  */
00068 bool
00069 StringLess::operator()(const char *__s1, const char *__s2) const
00070 {
00071   return ( strcmp(__s1, __s2) < 0 );
00072 }
00073 
00074 
00075 } // end namespace fawkes