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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/srep (Version 11.3.0) and /externals/g4tools/include/tools/srep (Version 10.0.p2)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_srep                                
  5 #define tools_srep                                
  6                                                   
  7 #include <string>                                 
  8 #include <vector>                                 
  9 #include <utility>                                
 10                                                   
 11 #include "forit"                                  
 12                                                   
 13 namespace tools {                                 
 14                                                   
 15 inline void replace(std::string& a_string,char    
 16   tools_sforit(a_string,it) {                     
 17     if((*it)==a_old) *it = a_new;                 
 18   }                                               
 19 }                                                 
 20                                                   
 21 inline bool replace(std::string& a_string,cons    
 22   // return true : some replacement done.         
 23   // return false : nothing replaced.             
 24   if(a_old.empty()) return false;                 
 25   std::string snew;                               
 26   std::string::size_type lold = a_old.length()    
 27   bool status = false;                            
 28   std::string stmp = a_string;                    
 29   while(true) {                                   
 30     std::string::size_type pos = stmp.find(a_o    
 31     if(pos==std::string::npos){                   
 32       snew += stmp;                               
 33       break;                                      
 34     } else {                                      
 35       snew += stmp.substr(0,pos);                 
 36       snew += a_new;                              
 37       stmp = stmp.substr(pos+lold,stmp.length(    
 38       status = true;                              
 39     }                                             
 40   }                                               
 41   a_string = std::move(snew);                     
 42   return status;                                  
 43 }                                                 
 44                                                   
 45 inline bool replace_(std::string& a_string,con    
 46   return replace(a_string,a_old,a_new);           
 47 }                                                 
 48                                                   
 49 inline bool replace(std::vector<std::string>&     
 50   tools_vforit(std::string,a_strings,it) {        
 51     if(!replace(*it,a_old,a_new)) return false    
 52   }                                               
 53   return true;                                    
 54 }                                                 
 55                                                   
 56 inline void toxml(std::string& a_string){         
 57   // > : &lt;                                     
 58   // < : &gt;                                     
 59   // & : &amp;                                    
 60   // " : &quot;                                   
 61   // ' : &apos;                                   
 62   replace(a_string,"&","&amp;"); //must be fir    
 63   replace(a_string,"<","&lt;");                   
 64   replace(a_string,">","&gt;");                   
 65   replace(a_string,"\"","&quot;");                
 66   replace(a_string,"'","&apos;");                 
 67 }                                                 
 68                                                   
 69 inline std::string to_xml(const std::string& a    
 70   std::string _s = a_string;                      
 71   toxml(_s);                                      
 72   return _s;                                      
 73 }                                                 
 74                                                   
 75 inline void to_win(std::string& a_string) {       
 76   replace(a_string,"/cygdrive/c","C:");  // CY    
 77   replace(a_string,"/mnt/c","C:");       // WS    
 78   replace(a_string,'/','\\');                     
 79 }                                                 
 80                                                   
 81 inline void to_win_python(std::string& a_strin    
 82   replace(a_string,"/cygdrive/c","c:");  // CY    
 83   replace(a_string,"/mnt/c","c:");       // WS    
 84   replace(a_string,"C:","c:");                    
 85   replace(a_string,'\\','/');                     
 86 }                                                 
 87                                                   
 88 }                                                 
 89                                                   
 90 #endif