From 18ea2c8cfff6acc93b1b98efb9dc4a930057e0ab Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 5 Apr 2012 18:56:52 +0400 Subject: [PATCH] zapit/include/zapit/channel.h: add cmpChannel.. functions --- src/zapit/include/zapit/channel.h | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index c388c751b..b46c0cd5c 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -260,4 +260,61 @@ class CZapitChannel }; }; +struct CmpChannelBySat: public std::binary_function +{ + static bool comparetolower(const char a, const char b) + { + return tolower(a) < tolower(b); + }; + + bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2) + { + if(c1->getSatellitePosition() == c2->getSatellitePosition()) + return std::lexicographical_compare(c1->getName().begin(), c1->getName().end(), c2->getName().begin(), c2->getName().end(), comparetolower); + else + return c1->getSatellitePosition() < c2->getSatellitePosition(); + ; + }; +}; + +struct CmpChannelByFreq: public std::binary_function +{ + static bool comparetolower(const char a, const char b) + { + return tolower(a) < tolower(b); + }; + + bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2) + { + if(c1->getFreqId() == c2->getFreqId()) + return std::lexicographical_compare(c1->getName().begin(), c1->getName().end(), c2->getName().begin(), c2->getName().end(), comparetolower); + else + return c1->getFreqId() < c2->getFreqId(); + ; + }; +}; + +struct CmpChannelByChName: public std::binary_function +{ + static bool comparetolower(const char a, const char b) + { + return tolower(a) < tolower(b); + }; + + bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2) + { + return std::lexicographical_compare(c1->getName().begin(), c1->getName().end(), c2->getName().begin(), c2->getName().end(), comparetolower); + }; +}; + +struct CmpChannelByChNum: public std::binary_function +{ + bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2) + { + return c1->number < c2->number; + ; + }; +}; + + #endif /* __zapit_channel_h__ */