aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src/utils/char_utils.h
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-05-23 10:36:11 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-23 10:36:11 +0000
commitdd02535fb8e3994c747c9ad5c33feea808975c09 (patch)
treebdf3d36e2cbca6604065503cdf77bf6242352ea0 /native/jni/src/utils/char_utils.h
parentba7cbd60b8c53b8a95a2f7fc195427bad253e7b3 (diff)
parent75cb258ee40a97654ae364f00e1803d0bce35da8 (diff)
downloadlatinime-dd02535fb8e3994c747c9ad5c33feea808975c09.tar.gz
latinime-dd02535fb8e3994c747c9ad5c33feea808975c09.tar.xz
latinime-dd02535fb8e3994c747c9ad5c33feea808975c09.zip
am 75cb258e: Merge "Support Beginning-of-Sentence in native code"
* commit '75cb258ee40a97654ae364f00e1803d0bce35da8': Support Beginning-of-Sentence in native code
Diffstat (limited to 'native/jni/src/utils/char_utils.h')
-rw-r--r--native/jni/src/utils/char_utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/native/jni/src/utils/char_utils.h b/native/jni/src/utils/char_utils.h
index 634c45b04..f28ed5682 100644
--- a/native/jni/src/utils/char_utils.h
+++ b/native/jni/src/utils/char_utils.h
@@ -18,6 +18,7 @@
#define LATINIME_CHAR_UTILS_H
#include <cctype>
+#include <cstring>
#include <vector>
#include "defines.h"
@@ -93,6 +94,19 @@ class CharUtils {
static unsigned short latin_tolower(const unsigned short c);
static const std::vector<int> EMPTY_STRING;
+ // Returns updated code point count. Returns 0 when the code points cannot be marked as a
+ // Beginning-of-Sentence.
+ static AK_FORCE_INLINE int attachBeginningOfSentenceMarker(int *const codePoints,
+ const int codePointCount, const int maxCodePoint) {
+ if (codePointCount >= maxCodePoint) {
+ // the code points cannot be marked as a Beginning-of-Sentence.
+ return 0;
+ }
+ memmove(codePoints + 1, codePoints, sizeof(int) * codePointCount);
+ codePoints[0] = CODE_POINT_BEGINNING_OF_SENTENCE;
+ return codePointCount + 1;
+ }
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CharUtils);