Fawkes API  Fawkes Development Version
string_compare.cpp
1 
2 /***************************************************************************
3  * string_compare.cpp - Fawkes string compare utils
4  *
5  * Created: Fri May 11 23:40:28 2007
6  * Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <utils/misc/string_compare.h>
25 
26 #include <cstring>
27 
28 namespace fawkes {
29 
30 /** @class StringEquality <utils/misc/string_compare.h>
31  * String equality checker.
32  * This is a valid binary predicate that can be used for instance hash maps
33  * as the equality predicate.
34  *
35  * The only method is used to check whether two supplied strings are equal.
36  * Uses strcmp for char arrays.
37  *
38  * @author Tim Niemueller
39  */
40 
41 /** Check equality of two strings.
42  * @param s1_ first string
43  * @param s2_ second string
44  * @return true, if the strings are equal, false otherwise
45  */
46 bool
47 StringEquality::operator()(const char *s1_, const char *s2_) const
48 {
49  return (strcmp(s1_, s2_) == 0);
50 }
51 
52 /** @class StringLess <utils/misc/string_compare.h>
53  * String less than test.
54  * This is a valid binary predicate that can be used for instance for maps
55  * as the less predicate.
56  *
57  * The only method is used to check whether one supplied strings is less
58  * then the other. Uses strcmp for char arrays.
59  *
60  * @author Tim Niemueller
61  */
62 
63 /** Check equality of two strings.
64  * @param s1_ first string
65  * @param s2_ second string
66  * @return true, if the s1_ < s2_
67  */
68 bool
69 StringLess::operator()(const char *s1_, const char *s2_) const
70 {
71  return (strcmp(s1_, s2_) < 0);
72 }
73 
74 } // end namespace fawkes
bool operator()(const char *s1_, const char *s2_) const
Check equality of two strings.
bool operator()(const char *s1_, const char *s2_) const
Check equality of two strings.
Fawkes library namespace.