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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/tos (Version 11.3.0) and /externals/g4tools/include/tools/tos (Version 8.3)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_tos                                 
  5 #define tools_tos                                 
  6                                                   
  7 // Used in BatchLab/MemoryTuple and Rio_Tuple.    
  8 // We need something different than the to<T>     
  9 // to handle std::vector<> and bool.              
 10                                                   
 11 #include "sprintf"                                
 12 #include "charmanip"                              
 13 #include "typedefs"                               
 14                                                   
 15 #include <vector>                                 
 16                                                   
 17 namespace tools {                                 
 18                                                   
 19 inline std::string tos(unsigned char a_value){    
 20   std::string _s;                                 
 21   if(is_printable(a_value))                       
 22     sprintf(_s,32,"%c",a_value);                  
 23   else                                            
 24     sprintf(_s,32,"%d",a_value);                  
 25   return _s;                                      
 26 }                                                 
 27                                                   
 28 inline std::string tos(char a_value){             
 29   std::string _s;                                 
 30   if(is_printable(a_value))                       
 31     sprintf(_s,32,"%c",a_value);                  
 32   else                                            
 33     sprintf(_s,32,"%d",a_value);                  
 34   return _s;                                      
 35 }                                                 
 36                                                   
 37 inline std::string tos(unsigned short a_value)    
 38   std::string _s;                                 
 39   sprintf(_s,32,"%d",a_value);                    
 40   return _s;                                      
 41 }                                                 
 42                                                   
 43 inline std::string tos(short a_value){            
 44   std::string _s;                                 
 45   sprintf(_s,32,"%d",a_value);                    
 46   return _s;                                      
 47 }                                                 
 48                                                   
 49 inline std::string tos(unsigned int a_value) {    
 50   std::string _s;                                 
 51   sprintf(_s,32,"%u",a_value);                    
 52   return _s;                                      
 53 }                                                 
 54                                                   
 55 inline std::string tosx(unsigned int a_value)     
 56   std::string _s;                                 
 57   sprintf(_s,32,"%x",a_value);                    
 58   return _s;                                      
 59 }                                                 
 60                                                   
 61 inline std::string tos(int a_value){              
 62   std::string _s;                                 
 63   sprintf(_s,32,"%d",a_value);                    
 64   return _s;                                      
 65 }                                                 
 66                                                   
 67 inline std::string tos(uint64 a_value) {          
 68   std::string _s;                                 
 69   sprintf(_s,32,uint64_format(),a_value);         
 70   return _s;                                      
 71 }                                                 
 72                                                   
 73 inline std::string tos(int64 a_value){            
 74   std::string _s;                                 
 75   sprintf(_s,32,int64_format(),a_value);          
 76   return _s;                                      
 77 }                                                 
 78                                                   
 79 inline std::string tos(float a_value){            
 80   std::string _s;                                 
 81   sprintf(_s,32,"%g",a_value);                    
 82   return _s;                                      
 83 }                                                 
 84                                                   
 85 inline std::string tos(double a_value){           
 86   std::string _s;                                 
 87   sprintf(_s,32,"%g",a_value);                    
 88   return _s;                                      
 89 }                                                 
 90                                                   
 91 inline std::string tos(bool a_value){             
 92   return std::string(a_value?"true":"false");     
 93 }                                                 
 94                                                   
 95 inline std::string tos(const std::string& a_va    
 96                                                   
 97 template <class T>                                
 98 inline std::string tos(const std::vector<T>& a    
 99                        const std::string& a_se    
100                        bool a_sep_at_end = fal    
101   size_t number = a_vals.size();                  
102   if(number<=0) return "";                        
103   std::string result;                             
104   number--;                                       
105   for(size_t index=0;index<number;index++) {      
106     result += tos(a_vals[index]);                 
107     result += a_sep;                              
108   }                                               
109   result += tos(a_vals[number]);                  
110   if(a_sep_at_end) result += a_sep;               
111   return result;                                  
112 }                                                 
113                                                   
114 inline std::string tos(unsigned int a_linen,co    
115   std::string _s;                                 
116   for(unsigned int index=0;index<a_linen;index    
117     _s += std::string(a_lines[index]);            
118     _s += "\n";                                   
119   }                                               
120   return _s;                                      
121 }                                                 
122                                                   
123 }                                                 
124                                                   
125 #endif