| 101 | const int IsoSqlFormatTokenizer::FRACTIONAL_MAX_LEN = 9; |
| 102 | |
| 103 | FormatTokenizationResult IsoSqlFormatTokenizer::Tokenize() { |
| 104 | DCHECK(dt_ctx_ != nullptr); |
| 105 | DCHECK(dt_ctx_->fmt != nullptr); |
| 106 | DCHECK(dt_ctx_->fmt_len > 0); |
| 107 | DCHECK(dt_ctx_->toks.size() == 0); |
| 108 | DCHECK(used_tokens_.empty()); |
| 109 | if (dt_ctx_->fmt_len > MAX_FORMAT_LENGTH) return TOO_LONG_FORMAT_ERROR; |
| 110 | const char* str_end = dt_ctx_->fmt + dt_ctx_->fmt_len; |
| 111 | const char* current_pos = dt_ctx_->fmt; |
| 112 | ProcessFXModifier(¤t_pos); |
| 113 | while (current_pos < str_end) { |
| 114 | ProcessSeparators(¤t_pos); |
| 115 | if (current_pos == str_end) break; |
| 116 | FormatTokenizationResult parse_result = ProcessNextToken(¤t_pos); |
| 117 | if (parse_result != SUCCESS) return parse_result; |
| 118 | } |
| 119 | if (dt_ctx_->toks.empty()) return GENERAL_ERROR; |
| 120 | return CheckIncompatibilities(); |
| 121 | } |
| 122 | |
| 123 | void IsoSqlFormatTokenizer::ProcessSeparators(const char** current_pos) { |
| 124 | DCHECK(current_pos != nullptr && *current_pos != nullptr); |
no test coverage detected