Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/rcmp is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_rcmp
0005 #define tools_rcmp
0006 
0007 // used in safe cast.
0008 
0009 #include <string>
0010 #include <cstring>
0011 
0012 namespace tools {
0013 
0014 inline bool rcmp(const char* a_1,const char* a_2) {
0015   size_t l1 = ::strlen(a_1);
0016   size_t l2 = ::strlen(a_2);
0017   if(l1!=l2) return false;
0018   if(!l1) return true;
0019   const char* p1 = a_1+l1-1;
0020   const char* p2 = a_2+l2-1;
0021   //ab
0022   //012
0023   for(size_t index=0;index<l1;index++,p1--,p2--) {
0024     if(*p1!=*p2) return false;
0025   }
0026   return true;
0027 }
0028 
0029 inline bool rcmp(const std::string& a_1,const char* a_2) {
0030   return rcmp(a_1.c_str(), a_2);
0031 }
0032 
0033 inline bool rcmp(const char* a_1,const std::string& a_2) {
0034   return rcmp(a_1, a_2.c_str());
0035 }
0036 
0037 inline bool rcmp(const std::string& a_1,const std::string& a_2) {
0038   return rcmp(a_1.c_str(), a_2.c_str());
0039 }
0040 
0041 }
0042 
0043 #endif