Get digit (masked_number) from StringVal. Only accept digits or -1.
| 430 | |
| 431 | /// Get digit (masked_number) from StringVal. Only accept digits or -1. |
| 432 | static inline bool GetDigitFromString(FunctionContext* ctx, const StringVal& str, |
| 433 | int* res) { |
| 434 | if (str.len != 1 || str.ptr[0] < '0' || str.ptr[0] > '9') { |
| 435 | ctx->SetError(Substitute( |
| 436 | "Can't convert '$0' to a valid masked_number. Valid values: 0-9.", |
| 437 | AnyValUtil::ToString(str)).c_str()); |
| 438 | return false; |
| 439 | } |
| 440 | *res = str.ptr[0] - '0'; |
| 441 | return true; |
| 442 | } |
| 443 | |
| 444 | /// MaskShowFirstN overloads for string value |
| 445 | StringVal MaskFunctions::MaskShowFirstN(FunctionContext* ctx, const StringVal& val) { |
no test coverage detected