Lexically casts an argument to an int64 if it is defined. Returns true if not null.
| 741 | |
| 742 | /// Lexically casts an argument to an int64 if it is defined. Returns true if not null. |
| 743 | bool arg_as_int(int64_t &int_value, KernelArgument::Value const *value_ptr) { |
| 744 | if (value_ptr->not_null) { |
| 745 | if (value_ptr->argument->description->type == ArgumentTypeID::kInteger) { |
| 746 | int_value = static_cast<IntegerArgument::IntegerValue const *>(value_ptr)->value; |
| 747 | } |
| 748 | else if (value_ptr->argument->description->type == ArgumentTypeID::kScalar) { |
| 749 | std::stringstream ss; |
| 750 | ss << static_cast<ScalarArgument::ScalarValue const *>(value_ptr)->value; |
| 751 | ss >> int_value; |
| 752 | } |
| 753 | else { |
| 754 | throw std::runtime_error( |
| 755 | "arg_as_int64_t() - illegal cast. Problem space argument must be integer or scalar"); |
| 756 | } |
| 757 | |
| 758 | return true; |
| 759 | } |
| 760 | |
| 761 | return false; |
| 762 | } |
| 763 | |
| 764 | /// Lexically casts an argument to an int64 if it is defined. Returns true if not null. |
| 765 | bool arg_as_int(int &int_value, KernelArgument::Value const *value_ptr) { |
no test coverage detected