yast2-core

ycpless.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:        ycpless.h
00014 
00015    Authors:     Mathias Kettner <kettner@suse.de>
00016                 Arvin Schnell <aschnell@suse.de>
00017    Maintainer:  Thomas Roelz <tom@suse.de>
00018 
00019 /-*/
00020 // -*- c++ -*-
00021 
00022 #ifndef ycpless_h
00023 #define ycpless_h
00024 
00025 #include "YCPValue.h"
00026 
00027 
00028 /*
00029  * Global comparison functor usable as generic ordering operator for
00030  * STL-containers and as predicate for STL-algorithms.
00031  *
00032  * Compares two YCPValues and returns true if the first value is less than the
00033  * second one, false otherwise. Optionally the comparison is locale aware.
00034  */
00035 class ycp_less : public std::binary_function<YCPValue, YCPValue, bool>
00036 {
00037 
00038 public:
00039 
00040     ycp_less(bool respect_locale = false) : respect_locale(respect_locale) {}
00041 
00042     bool operator()(const YCPValue& x, const YCPValue& y) const
00043     {
00044         return x->compare(y, respect_locale) == YO_LESS;
00045     }
00046 
00047 private:
00048 
00049     const bool respect_locale;
00050 
00051 };
00052 
00053 
00054 /*
00055  * Global comparison functor usable as predicate for STL-algorithms.
00056  *
00057  * Compares two YCPValues and returns true if they are equal, false otherwise.
00058  * Optionally the comparison is locale aware.
00059  */
00060 class ycp_equal_to : public std::binary_function<YCPValue, YCPValue, bool>
00061 {
00062 
00063 public:
00064 
00065     ycp_equal_to(bool respect_locale = false) : respect_locale(respect_locale) {}
00066 
00067     bool operator()(const YCPValue& x, const YCPValue& y) const
00068     {
00069         return x->compare(y, respect_locale) == YO_EQUAL;
00070     }
00071 
00072 private:
00073 
00074     const bool respect_locale;
00075 
00076 };
00077 
00078 
00079 /*
00080  * Global comparison functor usable as predicate for STL-algorithms.
00081  *
00082  * Compares two YCPValues and returns true if they are not equal, false
00083  * otherwise.  Optionally the comparison is locale aware.
00084  */
00085 class ycp_not_equal_to : public std::binary_function<YCPValue, YCPValue, bool>
00086 {
00087 
00088 public:
00089 
00090     ycp_not_equal_to(bool respect_locale = false) : respect_locale(respect_locale) {}
00091 
00092     bool operator()(const YCPValue& x, const YCPValue& y) const
00093     {
00094         return x->compare(y, respect_locale) != YO_EQUAL;
00095     }
00096 
00097 private:
00098 
00099     const bool respect_locale;
00100 
00101 };
00102 
00103 
00104 #endif   // ycpless_h

Generated on a sunny day for yast2-core by doxygen 1.7.3