forked from ueno/libkkc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarisa-agent.cc
63 lines (52 loc) · 1.28 KB
/
marisa-agent.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "marisa-glib-private.h"
G_DEFINE_TYPE (MarisaAgent, marisa_agent, G_TYPE_OBJECT)
static void
marisa_agent_finalize (GObject *object)
{
MarisaAgent *agent = MARISA_AGENT (object);
delete agent->cxx;
G_OBJECT_CLASS (marisa_agent_parent_class)->finalize (object);
}
static void
marisa_agent_class_init (MarisaAgentClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = marisa_agent_finalize;
}
static void
marisa_agent_init (MarisaAgent *agent)
{
agent->cxx = new marisa::Agent ();
}
MarisaAgent *
marisa_agent_new (void)
{
return MARISA_AGENT (g_object_new (MARISA_TYPE_AGENT, NULL));
}
void
marisa_agent_set_query (MarisaAgent *agent,
const gchar *str,
gsize length)
{
agent->cxx->set_query (str, length);
}
void
marisa_agent_set_reverse_query (MarisaAgent *agent,
gsize key_id)
{
agent->cxx->set_query (key_id);
}
MarisaKey *
marisa_agent_get_key (MarisaAgent *agent)
{
const marisa::Key *cxxkey = &agent->cxx->key ();
MarisaKey *key = marisa_key_new ();
key->cxx->set_str (cxxkey->ptr (), cxxkey->length ());
key->cxx->set_id (cxxkey->id ());
return key;
}
void
marisa_agent_clear (MarisaAgent *agent)
{
agent->cxx->clear ();
}