| 253 | |
| 254 | struct IsTitleUnicode { |
| 255 | static bool Call(KernelContext*, const uint8_t* input, size_t input_string_ncodeunits, |
| 256 | Status* st) { |
| 257 | // rules: |
| 258 | // 1. lower case follows cased |
| 259 | // 2. upper case follows uncased |
| 260 | // 3. at least 1 cased character (which logically should be upper/title) |
| 261 | bool rules_1_and_2; |
| 262 | bool previous_cased = false; // in LL, LU or LT |
| 263 | bool rule_3 = false; |
| 264 | bool status = |
| 265 | arrow::util::UTF8AllOf(input, input + input_string_ncodeunits, &rules_1_and_2, |
| 266 | [&previous_cased, &rule_3](uint32_t codepoint) { |
| 267 | if (IsLowerCaseCharacterUnicode(codepoint)) { |
| 268 | if (!previous_cased) return false; // rule 1 broken |
| 269 | // next should be more lower case or uncased |
| 270 | previous_cased = true; |
| 271 | } else if (IsCasedCharacterUnicode(codepoint)) { |
| 272 | if (previous_cased) return false; // rule 2 broken |
| 273 | // next should be a lower case or uncased |
| 274 | previous_cased = true; |
| 275 | rule_3 = true; // rule 3 obeyed |
| 276 | } else { |
| 277 | // an uncased char, like _ or 1 |
| 278 | // next should be upper case or more uncased |
| 279 | previous_cased = false; |
| 280 | } |
| 281 | return true; |
| 282 | }); |
| 283 | if (!ARROW_PREDICT_TRUE(status)) { |
| 284 | *st = Status::Invalid("Invalid UTF8 sequence in input"); |
| 285 | return false; |
| 286 | } |
| 287 | return rules_1_and_2 & rule_3; |
| 288 | } |
| 289 | }; |
| 290 | |
| 291 | struct IsUpperUnicode : CharacterPredicateUnicode<IsUpperUnicode> { |
nothing calls this directly
no test coverage detected