Returns a copy of the string passed to the argument. (kScalar arguments are stored as strings).
| 1206 | /// Returns a copy of the string passed to the argument. |
| 1207 | /// (kScalar arguments are stored as strings). |
| 1208 | bool arg_as_string( |
| 1209 | std::string& arg, |
| 1210 | char const* name, |
| 1211 | ProblemSpace const& problem_space, |
| 1212 | ProblemSpace::Problem const& problem) { |
| 1213 | |
| 1214 | size_t idx = problem_space.argument_index(name); |
| 1215 | KernelArgument::Value const* value_ptr = problem.at(idx).get(); |
| 1216 | |
| 1217 | if (value_ptr->not_null) { |
| 1218 | if (value_ptr->argument->description->type == ArgumentTypeID::kScalar) { |
| 1219 | std::string const& str_value = |
| 1220 | static_cast<ScalarArgument::ScalarValue const*>(value_ptr)->value; |
| 1221 | arg = std::string(str_value); |
| 1222 | } |
| 1223 | else { |
| 1224 | throw std::runtime_error( |
| 1225 | "arg_as_string() - illegal cast. Problem space argument must be scalar"); |
| 1226 | } |
| 1227 | |
| 1228 | return true; |
| 1229 | } |
| 1230 | |
| 1231 | return false; |
| 1232 | } |
| 1233 | |
| 1234 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
| 1235 |
nothing calls this directly
no test coverage detected