Lexically casts an argument to an bool if it is defined. Returns true if not null.
| 802 | |
| 803 | /// Lexically casts an argument to an bool if it is defined. Returns true if not null. |
| 804 | bool arg_as_bool(bool &bool_value, KernelArgument::Value const *value_ptr) { |
| 805 | if (value_ptr->not_null) { |
| 806 | if (value_ptr->argument->description->type == ArgumentTypeID::kInteger) { |
| 807 | int64_t value64; |
| 808 | arg_as_int(value64, value_ptr); |
| 809 | bool_value = static_cast<bool>(value64); |
| 810 | } |
| 811 | else if (value_ptr->argument->description->type == ArgumentTypeID::kEnumerated) { |
| 812 | bool_value = library::from_string<bool>( |
| 813 | static_cast<EnumeratedTypeArgument::EnumeratedTypeValue const *>(value_ptr)->element); |
| 814 | } |
| 815 | else { |
| 816 | throw std::runtime_error( |
| 817 | "arg_as_bool() - illegal cast. Problem space argument must be integer or enumerated"); |
| 818 | } |
| 819 | |
| 820 | return true; |
| 821 | } |
| 822 | |
| 823 | return false; |
| 824 | } |
| 825 | |
| 826 | /// Lexically casts an argument to a bool |
| 827 | bool arg_as_bool( |
nothing calls this directly
no test coverage detected