1 // OVPhoneticLib.h: BPMF syllable toolkit
2 //
3 //
4 // Copyright (c) 2004-2006 The OpenVanilla Project (http://openvanilla.org)
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 // 1. Redistributions of source code must retain the above copyright
12 //    notice, this list of conditions and the following disclaimer.
13 // 2. Redistributions in binary form must reproduce the above copyright
14 //    notice, this list of conditions and the following disclaimer in the
15 //    documentation and/or other materials provided with the distribution.
16 // 3. Neither the name of OpenVanilla nor the names of its contributors
17 //    may be used to endorse or promote products derived from this software
18 //    without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 // POSSIBILITY OF SUCH DAMAGE.
31 
32 #ifndef __OVPhoneticLib_h
33 #define __OVPhoneticLib_h
34 
35 enum {
36     OVPStandardLayout=0,
37     OVPEtenLayout=1
38 };
39 
40 class OVPCandidate;
41 
42 class OVPhoneticSyllable
43 {
44 public:
45     OVPhoneticSyllable(int layout=OVPStandardLayout);
46 
47     int layout();
48     void setLayout(int layout);
49 
50     int empty();
51     int isComposeKey(char c);
52     int addKey(char c);
53     int isValidKey(char c);
54     int removeLast();
55     void clear();
56 
57     const char *compose();
58     const char *standardLayoutCode();
59 
60 protected:
61     unsigned short syllable;
62     int keylayout;
63     friend OVPCandidate* OVPFindCandidate(unsigned short *data, OVPhoneticSyllable *s);
64 };
65 
66 struct OVPCandidate
67 {
68     OVPCandidate();
69     ~OVPCandidate();
70     int count;
71     char **candidates;
72 };
73 
74 // you're responsible to delete the object returned
75 OVPCandidate *OVPFindCandidate(unsigned short *data, OVPhoneticSyllable *syl);
76 
77 enum {
78     OVP_PUNCTUATION_MASK = 0xff00,
79     OVP_CTRL_OPT_MASK = 0xfe00,
80     OVP_PUNCTUATION_LIST = 0xff80
81 };
82 OVPCandidate *OVPFindCandidateWithCode(unsigned short *data, unsigned short k);
83 
84 #endif
85 
86