// Copyright 2013 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Author: [email protected] (Dick Sites) // #ifndef SCRIPT_SPAN_GETONESCRIPTSPAN_H_ #define SCRIPT_SPAN_GETONESCRIPTSPAN_H_ #include "generated_ulscript.h" #include "integral_types.h" #include "offsetmap.h" namespace chrome_lang_id { namespace CLD2 { static const int kMaxScriptBuffer = …; static const int kMaxScriptLowerBuffer = …; static const int kMaxScriptBytes = …; // Leave some room static const int kWithinScriptTail = …; // Stop at word space in last // N bytes of script buffer struct LangSpan { … }; static inline bool IsContinuationByte(char c) { … } // Gets lscript number for letters; always returns // 0 (common script) for non-letters int GetUTF8LetterScriptNum(const char* src); // Update src pointer to point to next quadgram, +2..+5 // Looks at src[0..4] const char* AdvanceQuad(const char* src); // Utility routine to search alphabetical tables int BinarySearch(const char* key, int lo, int hi, const CharIntPair* cipair); // Returns the length in bytes of the prefix of src that is all // interchange valid UTF-8 int SpanInterchangeValid(const char* src, int byte_length); class ScriptScanner { … }; } // namespace CLD2 } // namespace chrome_lang_id #endif // SCRIPT_SPAN_GETONESCRIPTSPAN_H_