Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_snpf 4 #ifndef tools_snpf 5 #define tools_snpf 5 #define tools_snpf 6 6 7 #include <cstdarg> 7 #include <cstdarg> 8 #include <cstdio> 8 #include <cstdio> 9 9 10 namespace tools { 10 namespace tools { 11 11 12 inline int vsnpf(char* a_s,size_t a_n,const ch 12 inline int vsnpf(char* a_s,size_t a_n,const char* a_fmt,va_list args){ 13 #ifdef _MSC_VER 13 #ifdef _MSC_VER 14 #if _MSC_VER < 1900 14 #if _MSC_VER < 1900 15 unsigned int old = _set_output_format(_TWO_D 15 unsigned int old = _set_output_format(_TWO_DIGIT_EXPONENT); 16 int status = _vsnprintf(a_s,a_n,a_fmt,args); 16 int status = _vsnprintf(a_s,a_n,a_fmt,args); 17 _set_output_format(old); 17 _set_output_format(old); 18 return status; 18 return status; 19 #else 19 #else 20 return _vsnprintf(a_s,a_n,a_fmt,args); 20 return _vsnprintf(a_s,a_n,a_fmt,args); 21 #endif 21 #endif 22 #else 22 #else 23 return ::vsnprintf(a_s,a_n,a_fmt,args); 23 return ::vsnprintf(a_s,a_n,a_fmt,args); 24 #endif 24 #endif 25 } 25 } 26 26 27 inline int snpf(char* a_s,size_t a_n,const cha 27 inline int snpf(char* a_s,size_t a_n,const char* a_fmt,...){ 28 va_list args; 28 va_list args; 29 va_start(args,a_fmt); 29 va_start(args,a_fmt); 30 int n = vsnpf(a_s,a_n,a_fmt,args); 30 int n = vsnpf(a_s,a_n,a_fmt,args); 31 va_end(args); 31 va_end(args); 32 return n; 32 return n; 33 } 33 } 34 34 35 35 36 } 36 } 37 37 38 #endif 38 #endif