Panda3D
 All Classes Functions Variables Enumerations
unicodeLatinMap.h
1 // Filename: unicodeLatinMap.h
2 // Created by: drose (01Feb03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef UNICODELATINMAP_H
16 #define UNICODELATINMAP_H
17 
18 #include "dtoolbase.h"
19 #include "pmap.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : UnicodeLatinMap
23 // Description : This class mainly serves as a container for a largish
24 // table of the subset of the Unicode character set that
25 // corresponds to the Latin alphabet, with its various
26 // accent marks and so on. Specifically, this table
27 // indicates how to map between the Unicode accented
28 // character and the corresponding ASCII equivalent
29 // without the accent mark; as well as how to switch
30 // case from upper to lower while retaining the Unicode
31 // accent marks.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_DTOOL UnicodeLatinMap {
34 public:
35  enum AccentType {
36  AT_none,
37  AT_acute,
38  AT_acute_and_dot_above,
39  AT_breve,
40  AT_breve_and_acute,
41  AT_breve_and_dot_below,
42  AT_breve_and_grave,
43  AT_breve_and_hook_above,
44  AT_breve_and_tilde,
45  AT_breve_below,
46  AT_caron,
47  AT_caron_and_dot_above,
48  AT_cedilla,
49  AT_cedilla_and_acute,
50  AT_cedilla_and_breve,
51  AT_circumflex,
52  AT_circumflex_and_acute,
53  AT_circumflex_and_dot_below,
54  AT_circumflex_and_grave,
55  AT_circumflex_and_hook_above,
56  AT_circumflex_and_tilde,
57  AT_circumflex_below,
58  AT_comma_below,
59  AT_curl,
60  AT_diaeresis,
61  AT_diaeresis_and_acute,
62  AT_diaeresis_and_caron,
63  AT_diaeresis_and_grave,
64  AT_diaeresis_and_macron,
65  AT_diaeresis_below,
66  AT_dot_above,
67  AT_dot_above_and_macron,
68  AT_dot_below,
69  AT_dot_below_and_dot_above,
70  AT_dot_below_and_macron,
71  AT_double_acute,
72  AT_double_grave,
73  AT_grave,
74  AT_hook,
75  AT_hook_above,
76  AT_horn,
77  AT_horn_and_acute,
78  AT_horn_and_dot_below,
79  AT_horn_and_grave,
80  AT_horn_and_hook_above,
81  AT_horn_and_tilde,
82  AT_inverted_breve,
83  AT_line_below,
84  AT_macron,
85  AT_macron_and_acute,
86  AT_macron_and_diaeresis,
87  AT_macron_and_grave,
88  AT_ogonek,
89  AT_ogonek_and_macron,
90  AT_ring_above,
91  AT_ring_above_and_acute,
92  AT_ring_below,
93  AT_stroke,
94  AT_stroke_and_acute,
95  AT_stroke_and_hook,
96  AT_tilde,
97  AT_tilde_and_acute,
98  AT_tilde_and_diaeresis,
99  AT_tilde_and_macron,
100  AT_tilde_below,
101  AT_topbar,
102  };
103 
104  enum AdditionalFlags {
105  AF_ligature = 0x0001,
106  AF_turned = 0x0002,
107  AF_reversed = 0x0004,
108  AF_smallcap = 0x0008,
109  AF_dotless = 0x0010,
110  };
111 
112  enum CharType {
113  CT_upper,
114  CT_lower,
115  CT_punct,
116  };
117 
118  class Entry {
119  public:
120  wchar_t _character;
121  CharType _char_type;
122  char _ascii_equiv;
123  char _ascii_additional;
124  wchar_t _tolower_character;
125  wchar_t _toupper_character;
126  AccentType _accent_type;
127  int _additional_flags;
128  };
129 
130  static const Entry *look_up(wchar_t character);
131 
132 private:
133  static void init();
134  static bool _initialized;
135 
136  typedef phash_map<wchar_t, const Entry *, integer_hash<wchar_t> > ByCharacter;
137  static ByCharacter *_by_character;
138  enum { max_direct_chars = 256 };
139  static const Entry *_direct_chars[max_direct_chars];
140 };
141 
142 #endif
This class mainly serves as a container for a largish table of the subset of the Unicode character se...