Debian Codegraph @

xpcom/nsMigemo.cpp

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 // Copyright 2005 MURAOKA Taro(KoRoN)/KaoriYa
2
3 #include "nsMigemo.h"
4 #include "nsStringAPI.h"
5
6 #define MIGEMO_DICTPATH "C:/migemo/utf-8.d/migemo-dict"
7
8 NS_IMPL_ISUPPORTS1(nsMigemo, nsIMigemo);
9
10 migemo* nsMigemo::migemoObject = NULL;
11
12 nsMigemo::nsMigemo()
13 {
14 if (nsMigemo::migemoObject == NULL)
15 {
16 migemo* obj = migemo_open(MIGEMO_DICTPATH);
17 if (obj != NULL && migemo_is_enable(obj) != 0)
18 {
19 migemo_set_operator(obj, MIGEMO_OPINDEX_NEST_IN, (const unsigned char*)"(?:");
20 migemo_set_operator(obj, MIGEMO_OPINDEX_NEWLINE, (const unsigned char*)"\\s*");
21 nsMigemo::migemoObject = obj;
22 }
23 }
24 }
25
26 nsMigemo::~nsMigemo()
27 {
28 }
29
30 /* AUTF8String query (in AUTF8String key); */
31 NS_IMETHODIMP
32 nsMigemo::Query(const nsACString & key, nsACString & _retval)
33 {
34 if (nsMigemo::migemoObject == NULL)
35 return NS_ERROR_NOT_INITIALIZED;
36 unsigned char* answer = migemo_query(nsMigemo::migemoObject,
37 (const unsigned char*)key.BeginReading());
38 if (answer == NULL)
39 return NS_ERROR_FAILURE;
40 _retval.Assign((const nsACString::char_type*)answer);
41 migemo_release(nsMigemo::migemoObject, answer);
42 return NS_OK;
43 }