#include <ctime>
#include <cstdio>
+#include <iostream>
+#include <fstream>
+#include <string>
#include "SpecialTable.h"
namespace PY {
SpecialTable::SpecialTable (void)
{
+#if 0
insert ("hehe", new StaticPhrase (":-)", 0));
insert ("haha", new StaticPhrase ("^_^", 0));
insert ("haha", new StaticPhrase ("o(∩∩)o...哈哈", 1));
insert ("rq", new DynamicPhrase ("%(year)-%(month)-%(day)", 1));
insert ("sj", new DynamicPhrase ("%(hour_24)时%(minute)分%(second)秒", 0));
insert ("sj", new DynamicPhrase ("%(hour_24):%(minute):%(second)", 1));
+#endif
+ load ("special_phrases");
+}
+
+gboolean
+SpecialTable::load (const gchar *file)
+{
+ try {
+ std::ifstream in (file);
+ std::string line;
+
+ while (!in.eof ()) {
+ getline (in, line);
+ size_t pos = line.find ('\t');
+ if (pos == line.npos) {
+ std::cerr << "error: " << line << std::endl;
+ continue;
+ }
+ std::string command = line.substr(0, pos);
+ std::string phrase = line.substr(pos + 1);
+ insert (command, new DynamicPhrase (phrase, 0));
+ }
+
+
+ } catch (...) {
+ std::cerr << "error" << std::endl;
+ return FALSE;
+ }
+ return TRUE;
}
static bool
}
List & list = m_map[command];
list.push_back (phrase);
+#if 0
list.sort (phraseCmp);
+#endif
}
gboolean
bchao B超
bgu B股
bichao B超
-bsn ╭∩╮(︶︿︶)╭∩╮鄙视你!
+bsn ╭∩╮(︶︿︶)╭∩╮鄙视你!
ceo 首席执行官
cpan C盘
cyuyan C语言
dna 脱氧核糖核酸
dpan D盘
gps 全球定位系统
-haha ^_^
-haha o(∩∩)o...哈哈
-hehe :-)
+haha ^_^
+haha o(∩∩)o...哈哈
+hehe :-)
hgu H股
icka IC卡
ipdianhua IP电话
pcji PC机
qiruiqq 奇瑞QQ
qqhao QQ号
-rq %(year)年%(month)月%(day)日
-rq %(year)-%(month)-%(day)
+rq %(year)年%(month)月%(day)日
+rq %(year)-%(month)-%(day)
simka SIM卡
-sj %(hour_24)时%(minute)分%(second)秒
-sj %(hour_24):%(minute):%(second)
+sj %(hour_24)时%(minute)分%(second)秒
+sj %(hour_24):%(minute):%(second)
tixu T恤
tixushan T恤衫
txingtai T型台
txu T恤
upan U盘
-xixi (*^__^*) 嘻嘻……
+xixi (*^__^*) 嘻嘻……
xshexian X射线