Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
compare1.hh
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 3k
Category:
Game Server Simulator
Development Platform:
C/C++
- #ifndef __compare1_hh__
- #define __compare1_hh__
- #include <functional>
- #include "row1.hh"
- template <class BinaryPred, class CmpType>
- class MysqlCmp : public unary_function<const MysqlRow&, bool>
- {
- protected:
- unsigned int index;
- BinaryPred func;
- CmpType cmp2;
- public:
- MysqlCmp(uint i, const BinaryPred &f, const CmpType &c) : index(i),func(f),cmp2(c) {}
- bool operator () (const MysqlRow& cmp1) const {return func(cmp2,cmp1[index]);}
- };
- template <class BinaryPred>
- class MysqlCmpCStr : public MysqlCmp<BinaryPred, const char *>
- {
- public:
- MysqlCmpCStr(uint i, const BinaryPred &f, const char* c) : MysqlCmp<BinaryPred, const char *> (i,f,c) {}
- bool operator () (const MysqlRow& cmp1) const
- {return func(cmp2,cmp1[index]);}
- };
- //: A special function for using in find_if function where i is the field index number.
- // This is a more generic form of mysql_cmp_cstr will work with any
- // CmpType that MysqlString can convert to. However, this is not
- // neary as effecent. Only use when obsoletely nessary.
- template <class BinaryPred, class CmpType>
- MysqlCmp <BinaryPred, CmpType>
- mysql_cmp(uint i, const BinaryPred &func, const CmpType &cmp2)
- {
- return MysqlCmp<BinaryPred, CmpType>(i, func, cmp2);
- }
- typedef binary_function<const char*, const char*, bool> bin_char_pred;
- struct cstr_equal_to : bin_char_pred {
- bool operator () (const char *x, const char *y) const
- {return !strcmp(x,y);}
- };
- struct cstr_not_equal_to : bin_char_pred {
- bool operator () (const char *x, const char *y) const
- {return strcmp(x,y);}
- };
- struct cstr_less : bin_char_pred {
- bool operator () (const char *x, const char *y) const
- {return strcmp(x,y) > 0; }
- };
- struct cstr_less_equal : bin_char_pred {
- bool operator () (const char *x, const char *y) const
- {return strcmp(x,y) >= 0; }
- };
- struct cstr_greater : bin_char_pred {
- bool operator () (const char *x, const char *y) const
- {return strcmp(x,y) < 0; }
- };
- struct cstr_greater_equal : bin_char_pred {
- bool operator () (const char *x, const char *y) const
- {return strcmp(x,y) <= 0; }
- };
- //:A special function for using in find_if fucntion where i is the field index
- //:number.
- //
- // func should be one of cstr_equal_to(), cstr_not_equal_to(),
- // cstr_less(), cstr_less_equal(), cstr_less_equal(), cstr_less_equal().
- template <class BinaryPred>
- MysqlCmpCStr <BinaryPred>
- mysql_cmp_cstr (uint i, const BinaryPred &func, const char *cmp2) {
- return MysqlCmpCStr<BinaryPred>(i, func, cmp2);
- }
- #endif