Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/path 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_path
0005 #define tools_path
0006 
0007 #include <string>
0008 #include <utility>
0009 
0010 namespace tools {
0011 
0012 inline void nosuffix(const std::string& a_string,std::string& a_value,bool a_back = true){
0013   // If a_string = dir0/dir1/dir2/dir3/name.xxx
0014   //   a_value = name
0015   // Start searching after the last / (or last \ for Windows).
0016   std::string::size_type pos = a_string.rfind('/');
0017   if(pos==std::string::npos) pos = a_string.rfind('\\');
0018   if(pos==std::string::npos) pos = 0;
0019   else pos++;
0020   std::string _s = a_string.substr(pos,a_string.size()-pos);
0021   std::string::size_type dot_pos = a_back?_s.rfind('.'):_s.find('.');
0022   if(dot_pos==std::string::npos) {
0023     a_value = std::move(_s);
0024   } else {
0025     a_value = _s.substr(0,dot_pos);
0026   }
0027 }
0028 
0029 inline std::string nosuffix(const std::string& a_string,bool a_back = true){
0030   std::string value;
0031   nosuffix(a_string,value,a_back);
0032   return value;
0033 }
0034 
0035 }
0036 
0037 #endif