Import Geant4 11.0.0.beta source tree
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_pointer
|
||||
#define tools_pointer
|
||||
|
||||
//WARNING : touchy.
|
||||
//WARNING : _MSC_VER && _WIN64 : sizeof(void*) is NOT sizeof(unsigned long).
|
||||
|
||||
#include "typedefs"
|
||||
|
||||
#include "snpf"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tools {
|
||||
|
||||
inline bool to_pointer(const std::string& a_string,void*& a_value){
|
||||
upointer v = 0;
|
||||
if(::sscanf(a_string.c_str(),upointer_format_x(),&v)!=1) {
|
||||
if(::sscanf(a_string.c_str(),upointer_format(),&v)!=1) {
|
||||
a_value = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
a_value = (void*)v;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool to_pointer(const char* a_string,void*& a_value){
|
||||
upointer v = 0;
|
||||
if(::sscanf(a_string,upointer_format_x(),&v)!=1) {
|
||||
if(::sscanf(a_string,upointer_format(),&v)!=1) {
|
||||
a_value = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
a_value = (void*)v;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool p2s(const void* a_value,std::string& a_s){
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),upointer_format(),(upointer)a_value);
|
||||
a_s = s;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool p2sx(const void* a_value,std::string& a_s){
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),upointer_format_x(),(upointer)a_value);
|
||||
a_s = s;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
inline std::string p2s(const void* a_value){
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),"%lu",(unsigned long)a_value);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::string p2sx(const void* a_value){
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),"0x%lx",(unsigned long)a_value);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::string char_p2s(const char* a_value) {
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),"%lu",(unsigned long)a_value);
|
||||
return std::string(s);
|
||||
}
|
||||
|
||||
inline std::string long2s(const long a_value) {
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),"%ld",a_value);
|
||||
return std::string(s);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user