OSDN Git Service

Async HTTP GET is implemented. HTTP Header class is implemented.
[fukui-no-namari/dialektos.git] / src / bbs_detail_base.hxx
1 /*
2  * Copyright (C) 2009 by Aiwota Programmer
3  * aiwotaprog@tetteke.tk
4  *
5  * This file is part of Dialektos.
6  *
7  * Dialektos is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Dialektos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Dialektos.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef BBS_DETAIL_BASE_HXX
22 #define BBS_DETAIL_BASE_HXX
23
24 #include <string>
25 #include <vector>
26 #include "board_subject_item.hxx"
27 #include "http_header.hxx"
28
29
30 namespace dialektos {
31
32 namespace text_view {
33   class Layoutable;
34 }
35
36 namespace bbs_detail {
37
38
39 class Base {
40 public:
41   Base(const std::string& uri, const std::string& host,
42       const std::string& board, const std::string& thread);
43   Base* clone() const;
44   virtual ~Base();
45   virtual std::string get_board_dir_path() const;
46   virtual std::string get_thread_file_path() const;
47   virtual std::string get_thread_idx_path() const;
48   virtual std::string get_thread_dat_uri() const;
49   virtual std::string get_another_thread_uri(const std::string& thread) const;
50   virtual std::string get_board_subject_path() const;
51   virtual std::string get_board_subject_uri() const;
52   virtual std::string get_board_subject_idx_path() const;
53   virtual std::string get_board_idx_dir_path() const;
54   virtual http::Header get_board_subject_request_header() const;
55   virtual http::Header get_thread_dat_request_header() const;
56   virtual std::string get_title_from_string(const std::string& dat) const;
57
58   virtual const std::string& get_encoding() const;
59
60   virtual void load_thread(text_view::Layoutable& output) const;
61   virtual void load_thread_from_string(
62       const std::string& dat, text_view::Layoutable& output) const;
63   virtual void load_subject(std::vector<SubjectItem>& output) const;
64   virtual void load_subject_from_string(
65       const std::string&, std::vector<SubjectItem>& output) const;
66
67   bool is_board() const;
68   bool is_thread() const;
69 //  static Base* judge(const std::string& uri);
70
71   bool operator==(const bbs_detail::Base& rhs) const;
72
73 protected:
74   explicit Base(const Base& rhs);
75 private:
76   virtual Base* do_clone() const;
77
78 protected:
79   virtual const std::string& get_bbs_name() const;
80
81   const std::string uri_;
82   const std::string host_;
83   const std::string board_;
84   const std::string thread_;
85
86   static const std::string bbs_name;
87   static const std::string encoding;
88 };
89
90
91 } // namespace bbs_detail
92
93 } // namespace dialektos
94
95 #endif