| 238 | } |
| 239 | |
| 240 | EncodeNumberStatus ParseAndEncodeNumber(const char* text, |
| 241 | const NumberType& type, |
| 242 | std::function<void(uint32_t)> emit, |
| 243 | std::string* error_msg) { |
| 244 | if (!text) { |
| 245 | ErrorMsgStream(error_msg) << "The given text is a nullptr"; |
| 246 | return EncodeNumberStatus::kInvalidText; |
| 247 | } |
| 248 | |
| 249 | if (IsUnknown(type)) { |
| 250 | ErrorMsgStream(error_msg) |
| 251 | << "The expected type is not a integer or float type"; |
| 252 | return EncodeNumberStatus::kInvalidUsage; |
| 253 | } |
| 254 | |
| 255 | // If we explicitly expect a floating-point number, we should handle that |
| 256 | // first. |
| 257 | if (IsFloating(type)) { |
| 258 | return ParseAndEncodeFloatingPointNumber(text, type, emit, error_msg); |
| 259 | } |
| 260 | |
| 261 | return ParseAndEncodeIntegerNumber(text, type, emit, error_msg); |
| 262 | } |
| 263 | |
| 264 | } // namespace utils |
| 265 | } // namespace spvtools |