1 // Copyright 2010-2018, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef MOZC_DICTIONARY_DICTIONARY_TOKEN_H_
31 #define MOZC_DICTIONARY_DICTIONARY_TOKEN_H_
32 
33 #include <string>
34 
35 #include "base/port.h"
36 
37 namespace mozc {
38 namespace dictionary {
39 
40 struct Token {
41   typedef uint8 AttributesBitfield;
42 
43   enum Attribute {
44     NONE = 0,
45     SPELLING_CORRECTION = 1,
46     LABEL_SIZE = 2,
47     // * CAUTION *
48     // If you are going to add new attributes, make sure that they have larger
49     // values than LABEL_SIZE!! The attributes having less values than it are
50     // tightly integrated with the system dictionary codec.
51 
52     // The following attribute is not stored in the system dictionary but is
53     // added by dictionary modules when looking up from user dictionary.
54     USER_DICTIONARY = 1 << 7,
55   };
56 
TokenToken57   Token() : cost(0), lid(0), rid(0), attributes(NONE) {}
TokenToken58   Token(const string &k, const string &v, int c, int l, int r,
59         AttributesBitfield a) : key(k), value(v), cost(c), lid(l), rid(r),
60                                 attributes(a) {}
61 
62   string key;
63   string value;
64   int    cost;
65   int    lid;
66   int    rid;
67   AttributesBitfield attributes;
68 };
69 
70 }  // namespace dictionary
71 }  // namespace mozc
72 
73 #endif  // MOZC_DICTIONARY_DICTIONARY_TOKEN_H_
74