zapit/include/zapit/channel.h: add cmpChannel.. functions

This commit is contained in:
[CST] Focus
2012-04-05 18:56:52 +04:00
parent 1d9ab9929f
commit 18ea2c8cff

View File

@@ -260,4 +260,61 @@ class CZapitChannel
};
};
struct CmpChannelBySat: public std::binary_function <const CZapitChannel * const, const CZapitChannel * const, bool>
{
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 <const CZapitChannel * const, const CZapitChannel * const, bool>
{
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 <const CZapitChannel * const, const CZapitChannel * const, bool>
{
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 <const CZapitChannel * const, const CZapitChannel * const, bool>
{
bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2)
{
return c1->number < c2->number;
;
};
};
#endif /* __zapit_channel_h__ */