OSDN Git Service

大量変更… (こういう風に書くのは好ましくない〜)
[gikomona/GikoMona.git] / core / src / model.cpp
1 #include <boost/filesystem/path.hpp>
2
3 #include "model.hpp"
4
5 namespace monazilla { namespace GikoMona { namespace core {
6
7 struct model::model_pimpl {
8     // session/tab-window
9     /* 構造
10      * bbs-name(TEXT)|board-name(TEXT)|thread-id(TEXT)|thread-name(TEXT)|is_fixed(INTEGAR)
11      */
12     database tab_db;
13     // session/history
14     /* 構造
15      * date(TEXT)|bbs-name(TEXT)|board-name(TEXT)|thread-id(TEXT)|thread-name(TEXT)
16      */
17     database history_db;
18     // application
19     config app_config;
20 };
21
22 model::model() noexcept {
23     instance = this;
24     pimpl = std::make_shared<model_pimpl>();
25     
26     auto config_path = pimpl->app_config.select<boost::filesystem::path>("config", "file-path");
27     
28     pimpl->tab_db.create(config_path);
29 }
30
31 model::~model() {}
32
33 bool model::load_file(const boost::filesystem::path& file_path,
34                       const mona_string& loaded_table_name) {
35     if(!boost::filesystem::exists(file_path)) {
36         return false;
37     }
38     
39     return true;
40 }
41
42 void model::exec_inserted_query()  {
43     inserted_value_triv_copyable_type q;
44     if(query_queue.empty()) {
45         return;
46     } else {
47         query_queue.pop(q);
48     }
49     
50     mona_string into;
51     boost::any value;
52     std::tie(*q, into, value);
53     
54     analyze_into_path_in_query(into);
55
56     if(into.find_first_of("application", 0, into.length()) != mona_string::npos) {
57         // application/*
58     } else if (into.find_first_of("session", 0, into.length()) != mona_string::npos) {
59         // session/*
60         if(into.find("history", 0, into.length()) != mona_string::npos) {
61             ;
62         } else if(into.find("tab-window") != mona_string::npos != mona_string::npos) {
63             pimpl->tab_db.insert(into, tup);
64         }
65     } else if(into.find_first_of("extension", 0, into.length()) != mona_string::npos) {
66         // extension/*
67     } else {
68         // ?
69     }
70 }
71
72 } } }