Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54410 - /trunk/core/libycp/src/include/ycp/ycpless.h
  • From: aschnell@xxxxxxxxxxxxxxxx
  • Date: Wed, 07 Jan 2009 11:08:51 -0000
  • Message-id: <E1LKWHL-0004d5-Oy@xxxxxxxxxxxxxxxx>
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 <kettner@xxxxxxx>
- Maintainer: Thomas Roelz <tom@xxxxxxx>
+ Authors: Mathias Kettner <kettner@xxxxxxx>
+ Arvin Schnell <aschnell@xxxxxxx>
+ Maintainer: Thomas Roelz <tom@xxxxxxx>

/-*/
// -*- 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<YCPValue, YCPValue, bool>
+{
+
+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<YCPValue, YCPValue, bool>
+/*
+ * 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<YCPValue, YCPValue, bool>
{
- 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@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages