| 156 | } |
| 157 | |
| 158 | long ArgumentValue::getNumber() const { |
| 159 | switch(type) { |
| 160 | case ArgumentSpec::TYPE_ADDRESS: |
| 161 | case ArgumentSpec::TYPE_HEX: { |
| 162 | STR_TO_INT(data, std::strtol, 16); |
| 163 | throw std::string("Invalid argument, ") + ArgumentSpec::getExpectedMessage(type); |
| 164 | } |
| 165 | case ArgumentSpec::TYPE_DECIMAL: { |
| 166 | STR_TO_INT(data, std::strtol, 10); |
| 167 | throw std::string("Invalid argument, ") + ArgumentSpec::getExpectedMessage(type); |
| 168 | } |
| 169 | case ArgumentSpec::TYPE_NUMBER: { |
| 170 | STR_TO_INT(data, std::strtol, 0); |
| 171 | throw std::string("Invalid argument, ") + ArgumentSpec::getExpectedMessage(type); |
| 172 | } |
| 173 | default: |
| 174 | throw "Calling ArgumentValue::getNumber() on unexpected argument type"; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | unsigned long ArgumentValue::getUnsignedNumber() const { |
| 179 | switch(type) { |
no test coverage detected