static
| 285 | |
| 286 | // static |
| 287 | util::Status Builder::GetPrecompiledCharsMap(absl::string_view name, |
| 288 | std::string *output) { |
| 289 | CHECK_OR_RETURN(output); |
| 290 | |
| 291 | if (name == "identity") { |
| 292 | output->clear(); |
| 293 | return util::OkStatus(); |
| 294 | } |
| 295 | |
| 296 | std::string result; |
| 297 | |
| 298 | #ifndef DISABLE_EMBEDDED_DATA |
| 299 | for (size_t i = 0; i < kNormalizationRules_size; ++i) { |
| 300 | const auto *blob = &kNormalizationRules_blob[i]; |
| 301 | if (blob->name == name) { |
| 302 | output->assign(blob->data, blob->size); |
| 303 | CHECK_OR_RETURN(IsValidNormalizerData(*output)); |
| 304 | return util::OkStatus(); |
| 305 | } |
| 306 | } |
| 307 | #else // DISABLE_EMBEDDED_DATA |
| 308 | { |
| 309 | const std::string filename = |
| 310 | absl::StrCat(util::JoinPath(GetDataDir(), name), ".bin"); |
| 311 | auto input = filesystem::NewReadableFile(filename, true /* is binary */); |
| 312 | if (input->status().ok()) { |
| 313 | input->ReadAll(output); |
| 314 | CHECK_OR_RETURN(IsValidNormalizerData(*output)); |
| 315 | return util::OkStatus(); |
| 316 | } |
| 317 | } |
| 318 | #endif // DISABLE_EMBEDDED_DATA |
| 319 | |
| 320 | return util::StatusBuilder(util::StatusCode::kNotFound, GTL_LOC) |
| 321 | << "No precompiled charsmap is found: " << name << " in " |
| 322 | << GetDataDir(); |
| 323 | } |
| 324 | |
| 325 | #ifdef ENABLE_NFKC_COMPILE |
| 326 | namespace { |
nothing calls this directly
no test coverage detected