Author: aschnell
Date: Wed Jan 7 12:08:51 2009
New Revision: 54410
URL: http://svn.opensuse.org/viewcvs/yast?rev=54410&view=rev
Log:
- added ycpequal functor
- make ycpless and ycpequal accept parameter to respect locale
Modified:
trunk/core/libycp/src/include/ycp/ycpless.h
Modified: trunk/core/libycp/src/include/ycp/ycpless.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/ycpless.h?rev=54410&r1=54409&r2=54410&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/ycpless.h (original)
+++ trunk/core/libycp/src/include/ycp/ycpless.h Wed Jan 7 12:08:51 2009
@@ -10,10 +10,11 @@
| (C) SuSE GmbH |
\----------------------------------------------------------------------/
- File: ycpless.h
+ File: ycpless.h
- Author: Mathias Kettner
- Maintainer: Thomas Roelz
+ Authors: Mathias Kettner
+ Arvin Schnell
+ Maintainer: Thomas Roelz
/-*/
// -*- c++ -*-
@@ -23,19 +24,56 @@
#include "YCPValue.h"
-using std::binary_function;
/*
- * global comparison function to be used with STL-Containers as generic
- * ordering operator. Compares two YCPValues and returns
- * true if the first value is less than the second one,
- * false otherwise.
+ * Global comparison functor usable as generic ordering operator for
+ * STL-containers and as predicate for STL-algorithms.
+ *
+ * Compares two YCPValues and returns true if the first value is less than the
+ * second one, false otherwise. Optionally the comparison is locale aware.
*/
+class ycpless : public std::binary_function
+{
+
+public:
+
+ ycpless(bool respect_locale = false) : respect_locale(respect_locale) {}
+
+ bool operator()(const YCPValue& x, const YCPValue& y) const
+ {
+ return x->compare(y, respect_locale) == YO_LESS;
+ }
+
+private:
+
+ const bool respect_locale;
+
+};
+
-struct ycpless : public binary_function
+/*
+ * Global comparison functor usable as predicate for STL-algorithms.
+ *
+ * Compares two YCPValues and returns true if they are equal, false otherwise.
+ * Optionally the comparison is locale aware.
+ */
+class ycpequal : public std::binary_function
{
- bool operator()(const YCPValue& x, const YCPValue& y)
- const { return x->compare(y) == YO_LESS; };
+
+public:
+
+ ycpequal(bool respect_locale = false) : respect_locale(respect_locale) {}
+
+ bool operator()(const YCPValue& x, const YCPValue& y) const
+ {
+ return x->compare(y, respect_locale) == YO_EQUAL;
+ }
+
+private:
+
+ const bool respect_locale;
+
};
+
#endif // ycpless_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org