File indexing completed on 2025-02-23 09:19:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "CCalutils.hh"
0031 #include "G4ios.hh"
0032 #include "G4UnitsTable.hh"
0033
0034 #include <sstream>
0035
0036
0037 G4String operator+(const G4String& str, const G4int i) {
0038 std::ostringstream os;
0039 os << str << i <<'\0';
0040 G4String back = os.str();
0041 return back;
0042 }
0043
0044
0045 G4String operator+(const G4String& str, const G4double i) {
0046 std::ostringstream os;
0047 os << str << i <<'\0';
0048 G4String back = os.str();
0049 return back;
0050 }
0051
0052
0053 std::ifstream& readName(std::ifstream& is, G4String& name){
0054 is >> name;
0055 if ( name != "*ENDDO" ) {
0056 while ( name.find("#.") != G4String::npos ) {
0057 is.ignore(999,'\n');
0058 is >> name;
0059 };
0060 while ( name.rfind('\"') != name.length()-1 ) {
0061 G4String other;
0062 is >> other;
0063 name += " ";
0064 name += other;
0065 };
0066 G4StrUtil::strip(name, '\"');
0067 }
0068 return is;
0069 }
0070
0071
0072 std::ifstream& findDO(std::ifstream& is, const G4String& str){
0073
0074 G4String firstwd, dowhat;
0075 dowhat = "";
0076 while (dowhat != str && is) {
0077 is >> firstwd;
0078 while (firstwd != "*DO" && is) {
0079 is.ignore(999,'\n');
0080 is >> firstwd;
0081 };
0082 is >> dowhat;
0083 };
0084 is.ignore(999,'\n');
0085 return is;
0086 }
0087
0088
0089 std::ostream& tab(std::ostream& os) {
0090 os << '\t';
0091 return os;
0092 }
0093
0094
0095 std::istream& jump(std::istream& is) {
0096 char first = ' ';
0097 char second = ' ';
0098 is.ignore(999,'\n');
0099 do {
0100 is.get(first);
0101 second = is.peek();
0102 if (first == '#' && second =='.') {
0103 is.ignore(999,'\n');
0104 }
0105 else if (first == '\n');
0106 else {
0107 is.putback(first);
0108 return is;
0109 }
0110 }
0111 while (is);
0112 return is;
0113 }
0114
0115
0116 G4bool openGeomFile(std::ifstream& is,
0117 const G4String& pathname, const G4String& filename) {
0118 G4String fullname = pathname+"/"+filename;
0119 is.open( fullname.c_str() );
0120 if (!is) {
0121 G4cerr << "ERROR: Could not open file " << filename << G4endl;
0122 return false;
0123 }
0124 return true;
0125 }