• R/O
  • HTTP
  • SSH
  • HTTPS

dialektos: Commit

dialektos


Commit MetaInfo

Revisiond1a77b4ddc10f5722be0d107e6eb170ed7dc7692 (tree)
Time2010-03-02 23:56:40
AuthorAiwota Programmer <aiwotaprog@tett...>
CommiterAiwota Programmer

Log Message

Support yy kakiko.

Change Summary

Incremental Difference

--- a/src/bbs_detail_judge.cxx
+++ b/src/bbs_detail_judge.cxx
@@ -22,6 +22,7 @@
2222
2323 #include "bbs_detail_base.hxx"
2424 #include "bbs_detail_2ch.hxx"
25+#include "bbs_detail_yy.hxx"
2526
2627
2728 namespace dialektos {
@@ -32,6 +33,7 @@ namespace bbs_detail {
3233 std::auto_ptr<Base> judge(const std::string& uri) {
3334
3435 if (Base* bbs = CH2::judge(uri)) return std::auto_ptr<Base>(bbs);
36+ if (Base* bbs = YY::judge(uri)) return std::auto_ptr<Base>(bbs);
3537 // if (Base* bbs = Base::judge(uri)) return bbs;
3638
3739 return std::auto_ptr<Base>();
--- /dev/null
+++ b/src/bbs_detail_yy.cxx
@@ -0,0 +1,97 @@
1+/*
2+ * Copyright (C) 2010 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+#include "bbs_detail_yy.hxx"
22+
23+#include <boost/filesystem.hpp>
24+#include <boost/xpressive/xpressive.hpp>
25+#include <string>
26+#include <iostream>
27+
28+namespace dialektos {
29+
30+namespace bbs_detail {
31+
32+
33+const std::string YY::bbs_name = "yy";
34+
35+YY* YY::judge(const std::string& uri) {
36+ if (YY* bbs = judge_thread(uri)) return bbs;
37+ if (YY* bbs = judge_board(uri)) return bbs;
38+ return 0;
39+}
40+
41+YY* YY::judge_thread(const std::string& uri) {
42+ using namespace boost::xpressive;
43+
44+ sregex regex = "http://" >> (s1=as_xpr("yy") >> repeat<2,2>(_d)
45+ >> (as_xpr(".kakiko.com")|as_xpr(".60.kg")))
46+ >> as_xpr("/test/read.cgi/")
47+ >> (s2=+_w)
48+ >> '/' >> (s3=+_d) >> '/' >> -*(_d|'-');
49+
50+ smatch what;
51+ if (!regex_match(uri, what, regex))
52+ return 0;
53+
54+ const std::string host = what[1];
55+ const std::string board = what[2];
56+ const std::string thread = what[3];
57+
58+ return new YY(uri, host, board, thread);
59+}
60+
61+YY* YY::judge_board(const std::string& uri) {
62+ using namespace boost::xpressive;
63+
64+ sregex regex = "http://" >> (s1=as_xpr("yy") >> repeat<2,2>(_d)
65+ >> (as_xpr(".kakiko.com")|as_xpr(".60.kg"))) >> as_xpr('/')
66+ >> (s2=+_w) >> '/' >> -*_w;
67+
68+ smatch what;
69+ if (!regex_match(uri, what, regex))
70+ return 0;
71+
72+ const std::string host = what[1];
73+ const std::string board = what[2];
74+
75+ return new YY(uri, host, board, "");
76+}
77+
78+
79+YY::YY(const std::string& uri, const std::string& host,
80+ const std::string& board, const std::string& thread) :
81+ Base(uri, host, board, thread) {}
82+
83+YY::YY(const YY& rhs) : Base(rhs) {}
84+
85+YY::~YY() {}
86+
87+YY* YY::do_clone() const {
88+ return new YY(*this);
89+}
90+
91+const std::string& YY::get_bbs_name() const {
92+ return bbs_name;
93+}
94+
95+} // namespace bbs_detail
96+
97+} // namespace dialektos
--- /dev/null
+++ b/src/bbs_detail_yy.hxx
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (C) 2010 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_YY_HXX
22+#define BBS_DETAIL_YY_HXX
23+
24+#include <string>
25+#include <memory>
26+#include "bbs_detail_base.hxx"
27+
28+
29+namespace dialektos {
30+
31+namespace bbs_detail {
32+
33+
34+class YY: public dialektos::bbs_detail::Base {
35+public:
36+ YY(const std::string& uri, const std::string& host,
37+ const std::string& board, const std::string& thread);
38+ virtual ~YY();
39+
40+ static YY* judge(const std::string& uri);
41+
42+protected:
43+ explicit YY(const YY& rhs);
44+
45+private:
46+ virtual YY* do_clone() const;
47+ virtual const std::string& get_bbs_name() const;
48+
49+ static YY* judge_thread(const std::string& uri);
50+ static YY* judge_board(const std::string& uri);
51+
52+
53+ static const std::string bbs_name;
54+};
55+
56+
57+} // namespace dialektos
58+
59+} // namespace dialektos
60+
61+
62+#endif
Show on old repository browser