1 #ifndef _DICT_CLINET_HPP_
2 #define _DICT_CLINET_HPP_
10 #include "sigc++/sigc++.h"
17 Definition(const gchar *word): word_(word) {}
19 typedef std::vector<Definition> DefList;
27 Cmd() : state_(START) {}
29 virtual const std::string& query() { return query_; }
30 virtual bool parse(gchar *str, int code) = 0;
32 void send(GIOChannel *channel, GError *&err);
33 const DefList& result() const { return reslist_; }
42 typedef std::vector<size_t> IndexList;
43 typedef std::list<std::string> StringList;
45 static sigc::signal<void, const std::string&> on_error_;
46 static sigc::signal<void, const IndexList&> on_simple_lookup_end_;
47 static sigc::signal<void, const StringList&> on_complex_lookup_end_;
49 DictClient(const char *host, int port = 2628);
51 void lookup_simple(const gchar *word);
52 void lookup_with_rule(const gchar *word);
53 void lookup_with_fuzzy(const gchar *word);
54 const gchar *get_word(size_t index) const;
55 const gchar *get_word_data(size_t index) const;
63 std::auto_ptr<DICT::Cmd> cmd_;
64 typedef std::map<size_t, DICT::Definition> DefMap;
70 static gboolean on_io_event(GIOChannel *, GIOCondition, gpointer);
71 static int get_status_code(gchar *line);
73 static void on_resolved(gpointer data, struct hostent *ret);
74 bool parse(gchar *line, int status_code);
77 #endif//!_DICT_CLINET_HPP_