| 255 | |
| 256 | template <class TChar> |
| 257 | [[noreturn]] static Y_NO_INLINE void ThrowParseError(EParseStatus status, const TChar* data, size_t len, const TChar* pos) { |
| 258 | Y_ASSERT(status != PS_OK); |
| 259 | |
| 260 | typedef TBasicString<TChar> TStringType; |
| 261 | |
| 262 | switch (status) { |
| 263 | case PS_EMPTY_STRING: |
| 264 | ythrow TFromStringException() << TStringBuf("Cannot parse empty string as number. "); |
| 265 | case PS_PLUS_STRING: |
| 266 | ythrow TFromStringException() << TStringBuf("Cannot parse string \"+\" as number. "); |
| 267 | case PS_MINUS_STRING: |
| 268 | ythrow TFromStringException() << TStringBuf("Cannot parse string \"-\" as number. "); |
| 269 | case PS_BAD_SYMBOL: |
| 270 | ythrow TFromStringException() << TStringBuf("Unexpected symbol \"") << EscapeC(*pos) << TStringBuf("\" at pos ") << (pos - data) << TStringBuf(" in string ") << TStringType(data, len).Quote() << TStringBuf(". "); |
| 271 | case PS_OVERFLOW: |
| 272 | ythrow TFromStringException() << TStringBuf("Integer overflow in string ") << TStringType(data, len).Quote() << TStringBuf(". "); |
| 273 | default: |
| 274 | ythrow yexception() << TStringBuf("Unknown error code in string converter. "); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | template <typename T, typename TUnsigned, int base, typename TChar> |
| 279 | Y_NO_INLINE T ParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds) { |