43 return line.substr(line.find_first_not_of(
"\t "), line.find(
":"));
53 GGsize first_pos = line.find_first_of(
"0123456789", line.find(
"d="));
54 GGsize last_pos = line.find_first_not_of(
"0123456789.", first_pos);
55 std::string density_str = line.substr(first_pos, last_pos != std::string::npos ? last_pos - first_pos : last_pos);
59 std::stringstream(density_str) >> density;
63 last_pos = line.find_first_of(
";");
64 std::string unit_str = line.substr(first_pos, last_pos != std::string::npos ? last_pos - first_pos : last_pos);
66 if (unit_str ==
"g/cm3") {
69 else if (unit_str ==
"mg/cm3") {
73 GGEMSMisc::ThrowException(
"GGEMSMaterialReader",
"ReadMaterialDensity",
"Unknown density unit in material database file!!!");
86 GGsize first_pos = line.find_first_of(
"0123456789", line.find(
"n="));
87 GGsize last_pos = line.find_last_of(
";");
88 std::string element_str = line.substr(first_pos,last_pos != std::string::npos ? last_pos - first_pos : last_pos);
91 GGsize number_elements = 0;
92 std::stringstream(element_str) >> number_elements;
94 return number_elements;
103 GGsize first_pos = line.find(
"name=")+5;
104 GGsize last_pos = line.find_first_of(
";");
105 std::string element_name_str = line.substr(first_pos, last_pos != std::string::npos ? last_pos - first_pos : last_pos);
107 return element_name_str;
116 GGsize first_pos = line.find_first_of(
"0123456789", line.find(
"f="));
117 GGsize last_pos = line.find_last_of(
";");
118 std::string fraction_str = line.substr(first_pos, last_pos != std::string::npos ? last_pos - first_pos : last_pos);
122 std::stringstream(fraction_str) >> fraction;
135 if (line[line.find_first_not_of(
"\t ")] == comment) {
136 std::getline(stream, line);
148 if (line.find_first_not_of(
"\t\n ") == std::string::npos)
return true;
159 line.erase(std::remove(line.begin(), line.end(),
'\t'), line.end());
161 line.erase(std::remove(line.begin(), line.end(),
' '), line.end());
163 line.erase(std::remove(line.begin(), line.end(),
'\n'), line.end());
165 line.erase(std::remove(line.begin(), line.end(),
'\r'), line.end());
167 line.erase(std::remove(line.begin(), line.end(),
'\f'), line.end());
169 line.erase(std::remove(line.begin(), line.end(),
'\v'), line.end());
179 std::string key = line.substr(line.find_first_not_of(
"\t "), line.find(
'=')-1);
194 std::istringstream iss(line.substr(line.find(
"=")+1), std::istringstream::in);
204 std::istringstream iss(line, std::istringstream::in);