inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/rcmp
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_rcmp
00005 #define inlib_rcmp
00006 
00007 // used in safe cast.
00008 
00009 #include <string>
00010 
00011 namespace inlib {
00012 
00013 inline bool rcmp(const std::string& a_1,const std::string& a_2) {
00014   std::string::size_type l1 = a_1.size();
00015   std::string::size_type l2 = a_2.size();
00016   if(l1!=l2) return false;
00017   if(!l1) return true;
00018   const char* p1 = a_1.c_str()+l1-1;
00019   const char* p2 = a_2.c_str()+l2-1;
00020   //ab
00021   //012
00022   for(std::string::size_type index=0;index<l1;index++,p1--,p2--) {
00023     if(*p1!=*p2) return false;
00024   }
00025   return true;
00026 }
00027 
00028 }
00029 
00030 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines