1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     ngc_ProfanityFilterBase.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 47308 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_NGC_CTR_NGC_PROFANITY_FILTER_BASE_H_
17 #define NN_NGC_CTR_NGC_PROFANITY_FILTER_BASE_H_
18 
19 #include <nn/types.h>
20 #include <nn/Result.h>
21 #include <nn/WithInitialize.h>
22 #include <nn/cfg/CTR/cfg_RegionCode.h>
23 
24 namespace nn
25 {
26 namespace ngc
27 {
28 namespace CTR
29 {
30 
31 /* Please see man pages for details
32 
33 
34 
35 
36  */
37 class ProfanityFilterBase
38 {
39 public:
40     /* Please see man pages for details
41 
42      */
~ProfanityFilterBase()43     virtual ~ProfanityFilterBase(){}
44 
45     /* Please see man pages for details
46 
47 
48      */
49     virtual u32 GetContentVersion() = 0;
50 
51     /* Please see man pages for details
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80      */
81     virtual nn::Result CheckProfanityWords( bit32* pCheckResults, const wchar_t** ppWords, size_t nWordCount ) = 0;
82 
83     /* Please see man pages for details
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112      */
113     virtual nn::Result CheckProfanityWords( bit32* pCheckResults, ProfanityFilterPatternList nPatternCode, const wchar_t** ppWords, size_t nWordCount ) = 0;
114 
115     /* Please see man pages for details
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147      */
148     virtual nn::Result CheckProfanityWords( bit32* pCheckResults, bool bCommunicateWithOtherRegions, const wchar_t** ppWords, size_t nWordCount ) = 0;
149 
150     /* Please see man pages for details
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173      */
174     virtual nn::Result MaskProfanityWordsInText( int* pProfanityWordCount, wchar_t* pText ) = 0;
175 
176     /* Please see man pages for details
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200      */
201     virtual nn::Result MaskProfanityWordsInText( int* pProfanityWordCount, ProfanityFilterPatternList nPatternCode, wchar_t* pText ) = 0;
202 
203     /* Please see man pages for details
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224      */
225     virtual nn::Result MaskProfanityWordsInText( int* pProfanityWordCount, bool bCommunicateWithOtherRegions, wchar_t* pText ) = 0;
226 
227 protected:
228     void GetPatternListsFromRegion( ProfanityFilterPatternList* pPatternLists, int *pListNum, bool bCommunicateWithOtherRegions );
229     static void ConvertUserInputForWord( wchar_t* pConvertedWord, int nLength, const wchar_t* pWord );
230     static void ConvertUserInputForText( wchar_t* pConvertedWord, u8* pSourceLengthMapping, int nLength, const wchar_t* pWord );
231     bool IsIncludesAtSign( const wchar_t* pWord, int nLength );
232     static bool ConvertRegexPatternForText( wchar_t* pConvertedPattern, const wchar_t* pPattern, size_t nLength );
233 
234 private:
235     /* Please see man pages for details
236 
237      */
238     typedef struct SmallMap
239     {
240         //
241         wchar_t small;
242 
243         //
244         wchar_t big;
245     } SmallMap;
246 
247     /* Please see man pages for details
248 
249      */
250     typedef struct HalfwidthMap
251     {
252         //
253         wchar_t half;
254 
255         //
256         wchar_t full;
257     } HalfwidthMap;
258 
259     static void ConvertKatakanaToBig( wchar_t *pKana );
260     static bool ConvertHalfwidthKatakanaToFullwidth( wchar_t *pBuffer, wchar_t half, const HalfwidthMap* pMapping, int mapNum );
261 
262 private:
263     static const SmallMap s_SmallMapping[];
264     static const HalfwidthMap s_HalfMapping[];
265     static const HalfwidthMap s_VoicedMapping[];
266     static const HalfwidthMap s_SemiVoicedMapping[];
267 };
268 
269 }   // namespace CTR
270 }   // namespaec ngc
271 }   // namespace nn
272 
273 #endif // NN_NGC_CTR_NGC_PROFANITY_FILTER_BASE_H_
274