Geant4-11
Functions
anonymous_namespace{G4AnalysisMessengerHelper.cc} Namespace Reference

Functions

G4String ObjectType (const G4String &hnType)
 
void Replace (std::string &str, const std::string &from, const std::string &to)
 

Function Documentation

◆ ObjectType()

G4String anonymous_namespace{G4AnalysisMessengerHelper.cc}::ObjectType ( const G4String hnType)

Definition at line 51 of file G4AnalysisMessengerHelper.cc.

52{
53 G4String first = hnType.substr(0,1);
54 if (first == "h") {
55 return "Histogram";
56 } else if (first == "p") {
57 return "Profile";
58 } else {
59 // other possibilitied not handled
60 return "";
61 }
62}

Referenced by G4AnalysisMessengerHelper::Update().

◆ Replace()

void anonymous_namespace{G4AnalysisMessengerHelper.cc}::Replace ( std::string &  str,
const std::string &  from,
const std::string &  to 
)

Definition at line 65 of file G4AnalysisMessengerHelper.cc.

65 {
66 // Replace all occurrences of from string
67 if (from.empty()) return;
68 size_t start_pos = 0;
69 while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
70 str.replace(start_pos, from.length(), to);
71 start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
72 }
73}

Referenced by G4AnalysisMessengerHelper::Update().