• R/O
  • HTTP
  • SSH
  • HTTPS

libcore: Commit

GikoMonaのソフトウェアの基幹部分を集めて1つのライブラリに集約したものです。gikomona/pnutsのコンパイルにはこのライブラリが必須です。


Commit MetaInfo

Revision78a6170fed2827a4a0d3d118d59969a29b3dd426 (tree)
Time2014-08-10 01:39:16
Authorcaprice <caprice@user...>
Commitercaprice

Log Message

名前とdatabaseがばらけていたのをまとめた、が今ひとつすっきりしない
そもそもmodelをもう少し練り直す必要があるのではないか…

Change Summary

Incremental Difference

--- a/src/model.cpp
+++ b/src/model.cpp
@@ -6,27 +6,29 @@
66 namespace monazilla { namespace GikoMona { namespace core {
77
88 struct model::model_pimpl {
9+
10+ struct resource_pair {
11+ database database;
12+ mona_string file_name;
13+ };
14+
15+ // gikomona/config
16+ resource_pair config;
17+
18+ // ict/board
19+ resource_pair board;
20+
921 // session/tab-window
1022 /* 構造
1123 * bbs-name(TEXT)|board-name(TEXT)|thread-id(TEXT)|thread-name(TEXT)|is_fixed(INTEGAR)
1224 */
13- database tab_db;
25+ resource_pair tab;
1426
1527 // session/history
1628 /* 構造
1729 * date(TEXT)|bbs-name(TEXT)|board-name(TEXT)|thread-id(TEXT)|thread-name(TEXT)
1830 */
19- database history_db;
20-
21- // application
22- config app_config;
23-
24- struct {
25- const mona_string tab_db = "session.tab-window.db";
26- const mona_string history_db = "session.history.db";
27- const mona_string linkref_db = "session.linkrefs.db";
28- const mona_string app_config = "application-config.xml";
29- } file_name;
31+ resource_pair history;
3032 };
3133
3234 model::model() noexcept {
@@ -44,17 +46,11 @@ bool model::load_file(const boost::filesystem::path& file_path) {
4446 auto ext = file_path.extension();
4547 auto file_name = file_path.filename();
4648
47- /* 依存型が欲しいなぁって */
48- if(ext == "db") {
49- // sqlite -> class `database'
50- if(file_name == pimpl->file_name.tab_db) {
51- pimpl->tab_db.get_connection().open(file_path.c_str());
52- } else if(file_name == pimpl->file_name.history_db) {
53- pimpl->history_db.get_connection().open(file_path.c_str());
54- }
55- } else if(ext == "xml") {
56- // xml -> class `config'
57- pimpl->app_config;
49+ /* TODO: BOOST_FUSION_ADAPT_STRUCTの利用を検討 */
50+ if(file_name == pimpl->file_name.tab_db) {
51+ pimpl->tab.database.get_connection().open(file_path.c_str());
52+ } else if(file_name == pimpl->file_name.history_db) {
53+ pimpl->history.database.get_connection().open(file_path.c_str());
5854 }
5955
6056 return true;
@@ -63,15 +59,6 @@ bool model::load_file(const boost::filesystem::path& file_path) {
6359 bool model::save_to_file(const boost::filesystem::path& path) {
6460 if(!boost::filesystem::exists(path)) { return false; }
6561
66- auto ext = path.extension();
67-
68- if(ext == "db") {
69- // caprice::sqlitexx::connection は open の時点でファイルの作成を完了している。
70- // さらに、connection に対する動作は全て db に書き込まれているので、単に true を返すに留める。
71- return true;
72- }
73-
74- pimpl->app_config;
7562 return true;
7663 }
7764
@@ -128,8 +115,7 @@ std::vector<mona_string> model::analyze_query(const mona_string& src) const {
128115 boost::algorithm::split(result,
129116 src,
130117 [](char c) -> bool {
131- if(c == '/') return true;
132- return false;
118+ return (c == '/');
133119 });
134120
135121 return std::move(result); // RVO を期待した方が良いか…?
Show on old repository browser