Module: sems Branch: master Commit: 5ff7b17100043fab329e73191331782caf7568c0 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=5ff7b17100043fab329e73191331782caf7568c0
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Sat Feb 4 15:09:06 2012 +0100 core: adds comparators for cstring. --- core/sip/cstring.h | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/core/sip/cstring.h b/core/sip/cstring.h index 6d849d1..581dee3 100644 --- a/core/sip/cstring.h +++ b/core/sip/cstring.h @@ -31,6 +31,7 @@ #define _CSTRING_H #include <string.h> +#include <string> struct cstring { @@ -62,7 +63,19 @@ struct cstring s = 0; len = 0; } - + + bool operator == (const cstring& rhs_str) { + return memcmp(rhs_str.s,s,len <= rhs_str.len ? len : rhs_str.len) == 0; + } + + bool operator == (const std::string& rhs_str) { + return rhs_str.compare(1,rhs_str.size(),s,len) == 0; + } + + bool operator == (const char* rhs_str) { + unsigned int rhs_len = strlen(rhs_str); + return memcmp(rhs_str,s,len <= rhs_len ? len : rhs_len) == 0; + } }; #define c2stlstr(str) \ _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
