1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef LATINIME_CORRECTION_STATE_H
18#define LATINIME_CORRECTION_STATE_H
19
20#include <stdint.h>
21
22#include "defines.h"
23
24namespace latinime {
25
26struct CorrectionState {
27    int mParentIndex;
28    int mSiblingPos;
29    uint16_t mChildCount;
30    uint8_t mInputIndex;
31
32    uint8_t mEquivalentCharCount;
33    uint8_t mProximityCount;
34    uint8_t mTransposedCount;
35    uint8_t mExcessiveCount;
36    uint8_t mSkippedCount;
37
38    int8_t mTransposedPos;
39    int8_t mExcessivePos;
40    int8_t mSkipPos; // should be signed
41
42    // TODO: int?
43    bool mLastCharExceeded;
44
45    bool mMatching;
46    bool mTransposing;
47    bool mExceeding;
48    bool mSkipping;
49    bool mProximityMatching;
50
51    bool mNeedsToTraverseAllNodes;
52
53};
54
55inline static void initCorrectionState(CorrectionState *state, const int rootPos,
56        const uint16_t childCount, const bool traverseAll) {
57    state->mParentIndex = -1;
58    state->mChildCount = childCount;
59    state->mInputIndex = 0;
60    state->mSiblingPos = rootPos;
61    state->mNeedsToTraverseAllNodes = traverseAll;
62
63    state->mTransposedPos = -1;
64    state->mExcessivePos = -1;
65    state->mSkipPos = -1;
66
67    state->mEquivalentCharCount = 0;
68    state->mProximityCount = 0;
69    state->mTransposedCount = 0;
70    state->mExcessiveCount = 0;
71    state->mSkippedCount = 0;
72
73    state->mLastCharExceeded = false;
74
75    state->mMatching = false;
76    state->mProximityMatching = false;
77    state->mTransposing = false;
78    state->mExceeding = false;
79    state->mSkipping = false;
80
81}
82
83} // namespace latinime
84#endif // LATINIME_CORRECTION_STATE_H
85