cppjieba_rb 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -0
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/cppjieba_rb.gemspec +4 -4
- data/lib/cppjieba_rb/version.rb +1 -1
- metadata +17 -135
- data/ext/cppjieba/.gitignore +0 -17
- data/ext/cppjieba/.travis.yml +0 -21
- data/ext/cppjieba/CMakeLists.txt +0 -28
- data/ext/cppjieba/ChangeLog.md +0 -236
- data/ext/cppjieba/README.md +0 -292
- data/ext/cppjieba/README_EN.md +0 -113
- data/ext/cppjieba/appveyor.yml +0 -32
- data/ext/cppjieba/deps/CMakeLists.txt +0 -1
- data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
- data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
- data/ext/cppjieba/deps/gtest/src/.deps/.dirstamp +0 -0
- data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
- data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
- data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
- data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
- data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
- data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
- data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
- data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
- data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
- data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
- data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
- data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
- data/ext/cppjieba/deps/gtest/src/gtest_main.cc +0 -39
- data/ext/cppjieba/deps/limonp/ArgvContext.hpp +0 -70
- data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
- data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
- data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
- data/ext/cppjieba/deps/limonp/Closure.hpp +0 -206
- data/ext/cppjieba/deps/limonp/Colors.hpp +0 -31
- data/ext/cppjieba/deps/limonp/Condition.hpp +0 -38
- data/ext/cppjieba/deps/limonp/Config.hpp +0 -103
- data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
- data/ext/cppjieba/deps/limonp/ForcePublic.hpp +0 -7
- data/ext/cppjieba/deps/limonp/LocalVector.hpp +0 -139
- data/ext/cppjieba/deps/limonp/Logging.hpp +0 -76
- data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
- data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
- data/ext/cppjieba/deps/limonp/NonCopyable.hpp +0 -21
- data/ext/cppjieba/deps/limonp/StdExtension.hpp +0 -159
- data/ext/cppjieba/deps/limonp/StringUtil.hpp +0 -365
- data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
- data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
- data/ext/cppjieba/dict/README.md +0 -31
- data/ext/cppjieba/dict/hmm_model.utf8 +0 -34
- data/ext/cppjieba/dict/idf.utf8 +0 -258826
- data/ext/cppjieba/dict/jieba.dict.utf8 +0 -348982
- data/ext/cppjieba/dict/pos_dict/char_state_tab.utf8 +0 -6653
- data/ext/cppjieba/dict/pos_dict/prob_emit.utf8 +0 -166
- data/ext/cppjieba/dict/pos_dict/prob_start.utf8 +0 -259
- data/ext/cppjieba/dict/pos_dict/prob_trans.utf8 +0 -5222
- data/ext/cppjieba/dict/stop_words.utf8 +0 -1534
- data/ext/cppjieba/dict/user.dict.utf8 +0 -4
- data/ext/cppjieba/include/cppjieba/DictTrie.hpp +0 -277
- data/ext/cppjieba/include/cppjieba/FullSegment.hpp +0 -93
- data/ext/cppjieba/include/cppjieba/HMMModel.hpp +0 -129
- data/ext/cppjieba/include/cppjieba/HMMSegment.hpp +0 -190
- data/ext/cppjieba/include/cppjieba/Jieba.hpp +0 -130
- data/ext/cppjieba/include/cppjieba/KeywordExtractor.hpp +0 -153
- data/ext/cppjieba/include/cppjieba/MPSegment.hpp +0 -137
- data/ext/cppjieba/include/cppjieba/MixSegment.hpp +0 -109
- data/ext/cppjieba/include/cppjieba/PosTagger.hpp +0 -77
- data/ext/cppjieba/include/cppjieba/PreFilter.hpp +0 -54
- data/ext/cppjieba/include/cppjieba/QuerySegment.hpp +0 -90
- data/ext/cppjieba/include/cppjieba/SegmentBase.hpp +0 -46
- data/ext/cppjieba/include/cppjieba/SegmentTagged.hpp +0 -23
- data/ext/cppjieba/include/cppjieba/TextRankExtractor.hpp +0 -190
- data/ext/cppjieba/include/cppjieba/Trie.hpp +0 -174
- data/ext/cppjieba/include/cppjieba/Unicode.hpp +0 -227
- data/ext/cppjieba/test/CMakeLists.txt +0 -5
- data/ext/cppjieba/test/demo.cpp +0 -80
- data/ext/cppjieba/test/load_test.cpp +0 -54
- data/ext/cppjieba/test/testdata/curl.res +0 -1
- data/ext/cppjieba/test/testdata/extra_dict/jieba.dict.small.utf8 +0 -109750
- data/ext/cppjieba/test/testdata/gbk_dict/hmm_model.gbk +0 -34
- data/ext/cppjieba/test/testdata/gbk_dict/jieba.dict.gbk +0 -348982
- data/ext/cppjieba/test/testdata/jieba.dict.0.1.utf8 +0 -93
- data/ext/cppjieba/test/testdata/jieba.dict.0.utf8 +0 -93
- data/ext/cppjieba/test/testdata/jieba.dict.1.utf8 +0 -67
- data/ext/cppjieba/test/testdata/jieba.dict.2.utf8 +0 -64
- data/ext/cppjieba/test/testdata/load_test.urls +0 -2
- data/ext/cppjieba/test/testdata/review.100 +0 -100
- data/ext/cppjieba/test/testdata/review.100.res +0 -200
- data/ext/cppjieba/test/testdata/server.conf +0 -19
- data/ext/cppjieba/test/testdata/testlines.gbk +0 -9
- data/ext/cppjieba/test/testdata/testlines.utf8 +0 -8
- data/ext/cppjieba/test/testdata/userdict.2.utf8 +0 -1
- data/ext/cppjieba/test/testdata/userdict.english +0 -2
- data/ext/cppjieba/test/testdata/userdict.utf8 +0 -8
- data/ext/cppjieba/test/testdata/weicheng.utf8 +0 -247
- data/ext/cppjieba/test/unittest/CMakeLists.txt +0 -24
- data/ext/cppjieba/test/unittest/gtest_main.cpp +0 -39
- data/ext/cppjieba/test/unittest/jieba_test.cpp +0 -133
- data/ext/cppjieba/test/unittest/keyword_extractor_test.cpp +0 -79
- data/ext/cppjieba/test/unittest/pos_tagger_test.cpp +0 -41
- data/ext/cppjieba/test/unittest/pre_filter_test.cpp +0 -43
- data/ext/cppjieba/test/unittest/segments_test.cpp +0 -256
- data/ext/cppjieba/test/unittest/textrank_test.cpp +0 -86
- data/ext/cppjieba/test/unittest/trie_test.cpp +0 -177
- data/ext/cppjieba/test/unittest/unicode_test.cpp +0 -43
@@ -1,39 +0,0 @@
|
|
1
|
-
// Copyright 2006, Google Inc.
|
2
|
-
// All rights reserved.
|
3
|
-
//
|
4
|
-
// Redistribution and use in source and binary forms, with or without
|
5
|
-
// modification, are permitted provided that the following conditions are
|
6
|
-
// met:
|
7
|
-
//
|
8
|
-
// * Redistributions of source code must retain the above copyright
|
9
|
-
// notice, this list of conditions and the following disclaimer.
|
10
|
-
// * Redistributions in binary form must reproduce the above
|
11
|
-
// copyright notice, this list of conditions and the following disclaimer
|
12
|
-
// in the documentation and/or other materials provided with the
|
13
|
-
// distribution.
|
14
|
-
// * Neither the name of Google Inc. nor the names of its
|
15
|
-
// contributors may be used to endorse or promote products derived from
|
16
|
-
// this software without specific prior written permission.
|
17
|
-
//
|
18
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
|
30
|
-
#include <iostream>
|
31
|
-
|
32
|
-
#include "gtest/gtest.h"
|
33
|
-
|
34
|
-
GTEST_API_ int main(int argc, char **argv) {
|
35
|
-
std::cout << "Running main() from gtest_main.cc\n";
|
36
|
-
|
37
|
-
testing::InitGoogleTest(&argc, argv);
|
38
|
-
return RUN_ALL_TESTS();
|
39
|
-
}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
/************************************
|
2
|
-
* file enc : ascii
|
3
|
-
* author : wuyanyi09@gmail.com
|
4
|
-
************************************/
|
5
|
-
|
6
|
-
#ifndef LIMONP_ARGV_FUNCTS_H
|
7
|
-
#define LIMONP_ARGV_FUNCTS_H
|
8
|
-
|
9
|
-
#include <set>
|
10
|
-
#include <sstream>
|
11
|
-
#include "StringUtil.hpp"
|
12
|
-
|
13
|
-
namespace limonp {
|
14
|
-
|
15
|
-
using namespace std;
|
16
|
-
|
17
|
-
class ArgvContext {
|
18
|
-
public :
|
19
|
-
ArgvContext(int argc, const char* const * argv) {
|
20
|
-
for(int i = 0; i < argc; i++) {
|
21
|
-
if(StartsWith(argv[i], "-")) {
|
22
|
-
if(i + 1 < argc && !StartsWith(argv[i + 1], "-")) {
|
23
|
-
mpss_[argv[i]] = argv[i+1];
|
24
|
-
i++;
|
25
|
-
} else {
|
26
|
-
sset_.insert(argv[i]);
|
27
|
-
}
|
28
|
-
} else {
|
29
|
-
args_.push_back(argv[i]);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
~ArgvContext() {
|
34
|
-
}
|
35
|
-
|
36
|
-
friend ostream& operator << (ostream& os, const ArgvContext& args);
|
37
|
-
string operator [](size_t i) const {
|
38
|
-
if(i < args_.size()) {
|
39
|
-
return args_[i];
|
40
|
-
}
|
41
|
-
return "";
|
42
|
-
}
|
43
|
-
string operator [](const string& key) const {
|
44
|
-
map<string, string>::const_iterator it = mpss_.find(key);
|
45
|
-
if(it != mpss_.end()) {
|
46
|
-
return it->second;
|
47
|
-
}
|
48
|
-
return "";
|
49
|
-
}
|
50
|
-
|
51
|
-
bool HasKey(const string& key) const {
|
52
|
-
if(mpss_.find(key) != mpss_.end() || sset_.find(key) != sset_.end()) {
|
53
|
-
return true;
|
54
|
-
}
|
55
|
-
return false;
|
56
|
-
}
|
57
|
-
|
58
|
-
private:
|
59
|
-
vector<string> args_;
|
60
|
-
map<string, string> mpss_;
|
61
|
-
set<string> sset_;
|
62
|
-
}; // class ArgvContext
|
63
|
-
|
64
|
-
inline ostream& operator << (ostream& os, const ArgvContext& args) {
|
65
|
-
return os<<args.args_<<args.mpss_<<args.sset_;
|
66
|
-
}
|
67
|
-
|
68
|
-
} // namespace limonp
|
69
|
-
|
70
|
-
#endif
|
@@ -1,49 +0,0 @@
|
|
1
|
-
#ifndef LIMONP_BLOCKINGQUEUE_HPP
|
2
|
-
#define LIMONP_BLOCKINGQUEUE_HPP
|
3
|
-
|
4
|
-
#include <queue>
|
5
|
-
#include "Condition.hpp"
|
6
|
-
|
7
|
-
namespace limonp {
|
8
|
-
template<class T>
|
9
|
-
class BlockingQueue: NonCopyable {
|
10
|
-
public:
|
11
|
-
BlockingQueue()
|
12
|
-
: mutex_(), notEmpty_(mutex_), queue_() {
|
13
|
-
}
|
14
|
-
|
15
|
-
void Push(const T& x) {
|
16
|
-
MutexLockGuard lock(mutex_);
|
17
|
-
queue_.push(x);
|
18
|
-
notEmpty_.Notify(); // Wait morphing saves us
|
19
|
-
}
|
20
|
-
|
21
|
-
T Pop() {
|
22
|
-
MutexLockGuard lock(mutex_);
|
23
|
-
// always use a while-loop, due to spurious wakeup
|
24
|
-
while (queue_.empty()) {
|
25
|
-
notEmpty_.Wait();
|
26
|
-
}
|
27
|
-
assert(!queue_.empty());
|
28
|
-
T front(queue_.front());
|
29
|
-
queue_.pop();
|
30
|
-
return front;
|
31
|
-
}
|
32
|
-
|
33
|
-
size_t Size() const {
|
34
|
-
MutexLockGuard lock(mutex_);
|
35
|
-
return queue_.size();
|
36
|
-
}
|
37
|
-
bool Empty() const {
|
38
|
-
return Size() == 0;
|
39
|
-
}
|
40
|
-
|
41
|
-
private:
|
42
|
-
mutable MutexLock mutex_;
|
43
|
-
Condition notEmpty_;
|
44
|
-
std::queue<T> queue_;
|
45
|
-
}; // class BlockingQueue
|
46
|
-
|
47
|
-
} // namespace limonp
|
48
|
-
|
49
|
-
#endif // LIMONP_BLOCKINGQUEUE_HPP
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#ifndef LIMONP_BOUNDED_BLOCKING_QUEUE_HPP
|
2
|
-
#define LIMONP_BOUNDED_BLOCKING_QUEUE_HPP
|
3
|
-
|
4
|
-
#include "BoundedQueue.hpp"
|
5
|
-
|
6
|
-
namespace limonp {
|
7
|
-
|
8
|
-
template<typename T>
|
9
|
-
class BoundedBlockingQueue : NonCopyable {
|
10
|
-
public:
|
11
|
-
explicit BoundedBlockingQueue(size_t maxSize)
|
12
|
-
: mutex_(),
|
13
|
-
notEmpty_(mutex_),
|
14
|
-
notFull_(mutex_),
|
15
|
-
queue_(maxSize) {
|
16
|
-
}
|
17
|
-
|
18
|
-
void Push(const T& x) {
|
19
|
-
MutexLockGuard lock(mutex_);
|
20
|
-
while (queue_.Full()) {
|
21
|
-
notFull_.Wait();
|
22
|
-
}
|
23
|
-
assert(!queue_.Full());
|
24
|
-
queue_.Push(x);
|
25
|
-
notEmpty_.Notify();
|
26
|
-
}
|
27
|
-
|
28
|
-
T Pop() {
|
29
|
-
MutexLockGuard lock(mutex_);
|
30
|
-
while (queue_.Empty()) {
|
31
|
-
notEmpty_.Wait();
|
32
|
-
}
|
33
|
-
assert(!queue_.Empty());
|
34
|
-
T res = queue_.Pop();
|
35
|
-
notFull_.Notify();
|
36
|
-
return res;
|
37
|
-
}
|
38
|
-
|
39
|
-
bool Empty() const {
|
40
|
-
MutexLockGuard lock(mutex_);
|
41
|
-
return queue_.Empty();
|
42
|
-
}
|
43
|
-
|
44
|
-
bool Full() const {
|
45
|
-
MutexLockGuard lock(mutex_);
|
46
|
-
return queue_.Full();
|
47
|
-
}
|
48
|
-
|
49
|
-
size_t size() const {
|
50
|
-
MutexLockGuard lock(mutex_);
|
51
|
-
return queue_.size();
|
52
|
-
}
|
53
|
-
|
54
|
-
size_t capacity() const {
|
55
|
-
return queue_.capacity();
|
56
|
-
}
|
57
|
-
|
58
|
-
private:
|
59
|
-
mutable MutexLock mutex_;
|
60
|
-
Condition notEmpty_;
|
61
|
-
Condition notFull_;
|
62
|
-
BoundedQueue<T> queue_;
|
63
|
-
}; // class BoundedBlockingQueue
|
64
|
-
|
65
|
-
} // namespace limonp
|
66
|
-
|
67
|
-
#endif // LIMONP_BOUNDED_BLOCKING_QUEUE_HPP
|
@@ -1,65 +0,0 @@
|
|
1
|
-
#ifndef LIMONP_BOUNDED_QUEUE_HPP
|
2
|
-
#define LIMONP_BOUNDED_QUEUE_HPP
|
3
|
-
|
4
|
-
#include <vector>
|
5
|
-
#include <fstream>
|
6
|
-
#include <cassert>
|
7
|
-
|
8
|
-
namespace limonp {
|
9
|
-
using namespace std;
|
10
|
-
template<class T>
|
11
|
-
class BoundedQueue {
|
12
|
-
public:
|
13
|
-
explicit BoundedQueue(size_t capacity): capacity_(capacity), circular_buffer_(capacity) {
|
14
|
-
head_ = 0;
|
15
|
-
tail_ = 0;
|
16
|
-
size_ = 0;
|
17
|
-
assert(capacity_);
|
18
|
-
}
|
19
|
-
~BoundedQueue() {
|
20
|
-
}
|
21
|
-
|
22
|
-
void Clear() {
|
23
|
-
head_ = 0;
|
24
|
-
tail_ = 0;
|
25
|
-
size_ = 0;
|
26
|
-
}
|
27
|
-
bool Empty() const {
|
28
|
-
return !size_;
|
29
|
-
}
|
30
|
-
bool Full() const {
|
31
|
-
return capacity_ == size_;
|
32
|
-
}
|
33
|
-
size_t Size() const {
|
34
|
-
return size_;
|
35
|
-
}
|
36
|
-
size_t Capacity() const {
|
37
|
-
return capacity_;
|
38
|
-
}
|
39
|
-
|
40
|
-
void Push(const T& t) {
|
41
|
-
assert(!Full());
|
42
|
-
circular_buffer_[tail_] = t;
|
43
|
-
tail_ = (tail_ + 1) % capacity_;
|
44
|
-
size_ ++;
|
45
|
-
}
|
46
|
-
|
47
|
-
T Pop() {
|
48
|
-
assert(!Empty());
|
49
|
-
size_t oldPos = head_;
|
50
|
-
head_ = (head_ + 1) % capacity_;
|
51
|
-
size_ --;
|
52
|
-
return circular_buffer_[oldPos];
|
53
|
-
}
|
54
|
-
|
55
|
-
private:
|
56
|
-
size_t head_;
|
57
|
-
size_t tail_;
|
58
|
-
size_t size_;
|
59
|
-
const size_t capacity_;
|
60
|
-
vector<T> circular_buffer_;
|
61
|
-
|
62
|
-
}; // class BoundedQueue
|
63
|
-
} // namespace limonp
|
64
|
-
|
65
|
-
#endif
|
@@ -1,206 +0,0 @@
|
|
1
|
-
#ifndef LIMONP_CLOSURE_HPP
|
2
|
-
#define LIMONP_CLOSURE_HPP
|
3
|
-
|
4
|
-
namespace limonp {
|
5
|
-
|
6
|
-
class ClosureInterface {
|
7
|
-
public:
|
8
|
-
virtual ~ClosureInterface() {
|
9
|
-
}
|
10
|
-
virtual void Run() = 0;
|
11
|
-
};
|
12
|
-
|
13
|
-
template <class Funct>
|
14
|
-
class Closure0: public ClosureInterface {
|
15
|
-
public:
|
16
|
-
Closure0(Funct fun) {
|
17
|
-
fun_ = fun;
|
18
|
-
}
|
19
|
-
virtual ~Closure0() {
|
20
|
-
}
|
21
|
-
virtual void Run() {
|
22
|
-
(*fun_)();
|
23
|
-
}
|
24
|
-
private:
|
25
|
-
Funct fun_;
|
26
|
-
};
|
27
|
-
|
28
|
-
template <class Funct, class Arg1>
|
29
|
-
class Closure1: public ClosureInterface {
|
30
|
-
public:
|
31
|
-
Closure1(Funct fun, Arg1 arg1) {
|
32
|
-
fun_ = fun;
|
33
|
-
arg1_ = arg1;
|
34
|
-
}
|
35
|
-
virtual ~Closure1() {
|
36
|
-
}
|
37
|
-
virtual void Run() {
|
38
|
-
(*fun_)(arg1_);
|
39
|
-
}
|
40
|
-
private:
|
41
|
-
Funct fun_;
|
42
|
-
Arg1 arg1_;
|
43
|
-
};
|
44
|
-
|
45
|
-
template <class Funct, class Arg1, class Arg2>
|
46
|
-
class Closure2: public ClosureInterface {
|
47
|
-
public:
|
48
|
-
Closure2(Funct fun, Arg1 arg1, Arg2 arg2) {
|
49
|
-
fun_ = fun;
|
50
|
-
arg1_ = arg1;
|
51
|
-
arg2_ = arg2;
|
52
|
-
}
|
53
|
-
virtual ~Closure2() {
|
54
|
-
}
|
55
|
-
virtual void Run() {
|
56
|
-
(*fun_)(arg1_, arg2_);
|
57
|
-
}
|
58
|
-
private:
|
59
|
-
Funct fun_;
|
60
|
-
Arg1 arg1_;
|
61
|
-
Arg2 arg2_;
|
62
|
-
};
|
63
|
-
|
64
|
-
template <class Funct, class Arg1, class Arg2, class Arg3>
|
65
|
-
class Closure3: public ClosureInterface {
|
66
|
-
public:
|
67
|
-
Closure3(Funct fun, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
68
|
-
fun_ = fun;
|
69
|
-
arg1_ = arg1;
|
70
|
-
arg2_ = arg2;
|
71
|
-
arg3_ = arg3;
|
72
|
-
}
|
73
|
-
virtual ~Closure3() {
|
74
|
-
}
|
75
|
-
virtual void Run() {
|
76
|
-
(*fun_)(arg1_, arg2_, arg3_);
|
77
|
-
}
|
78
|
-
private:
|
79
|
-
Funct fun_;
|
80
|
-
Arg1 arg1_;
|
81
|
-
Arg2 arg2_;
|
82
|
-
Arg3 arg3_;
|
83
|
-
};
|
84
|
-
|
85
|
-
template <class Obj, class Funct>
|
86
|
-
class ObjClosure0: public ClosureInterface {
|
87
|
-
public:
|
88
|
-
ObjClosure0(Obj* p, Funct fun) {
|
89
|
-
p_ = p;
|
90
|
-
fun_ = fun;
|
91
|
-
}
|
92
|
-
virtual ~ObjClosure0() {
|
93
|
-
}
|
94
|
-
virtual void Run() {
|
95
|
-
(p_->*fun_)();
|
96
|
-
}
|
97
|
-
private:
|
98
|
-
Obj* p_;
|
99
|
-
Funct fun_;
|
100
|
-
};
|
101
|
-
|
102
|
-
template <class Obj, class Funct, class Arg1>
|
103
|
-
class ObjClosure1: public ClosureInterface {
|
104
|
-
public:
|
105
|
-
ObjClosure1(Obj* p, Funct fun, Arg1 arg1) {
|
106
|
-
p_ = p;
|
107
|
-
fun_ = fun;
|
108
|
-
arg1_ = arg1;
|
109
|
-
}
|
110
|
-
virtual ~ObjClosure1() {
|
111
|
-
}
|
112
|
-
virtual void Run() {
|
113
|
-
(p_->*fun_)(arg1_);
|
114
|
-
}
|
115
|
-
private:
|
116
|
-
Obj* p_;
|
117
|
-
Funct fun_;
|
118
|
-
Arg1 arg1_;
|
119
|
-
};
|
120
|
-
|
121
|
-
template <class Obj, class Funct, class Arg1, class Arg2>
|
122
|
-
class ObjClosure2: public ClosureInterface {
|
123
|
-
public:
|
124
|
-
ObjClosure2(Obj* p, Funct fun, Arg1 arg1, Arg2 arg2) {
|
125
|
-
p_ = p;
|
126
|
-
fun_ = fun;
|
127
|
-
arg1_ = arg1;
|
128
|
-
arg2_ = arg2;
|
129
|
-
}
|
130
|
-
virtual ~ObjClosure2() {
|
131
|
-
}
|
132
|
-
virtual void Run() {
|
133
|
-
(p_->*fun_)(arg1_, arg2_);
|
134
|
-
}
|
135
|
-
private:
|
136
|
-
Obj* p_;
|
137
|
-
Funct fun_;
|
138
|
-
Arg1 arg1_;
|
139
|
-
Arg2 arg2_;
|
140
|
-
};
|
141
|
-
template <class Obj, class Funct, class Arg1, class Arg2, class Arg3>
|
142
|
-
class ObjClosure3: public ClosureInterface {
|
143
|
-
public:
|
144
|
-
ObjClosure3(Obj* p, Funct fun, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
145
|
-
p_ = p;
|
146
|
-
fun_ = fun;
|
147
|
-
arg1_ = arg1;
|
148
|
-
arg2_ = arg2;
|
149
|
-
arg3_ = arg3;
|
150
|
-
}
|
151
|
-
virtual ~ObjClosure3() {
|
152
|
-
}
|
153
|
-
virtual void Run() {
|
154
|
-
(p_->*fun_)(arg1_, arg2_, arg3_);
|
155
|
-
}
|
156
|
-
private:
|
157
|
-
Obj* p_;
|
158
|
-
Funct fun_;
|
159
|
-
Arg1 arg1_;
|
160
|
-
Arg2 arg2_;
|
161
|
-
Arg3 arg3_;
|
162
|
-
};
|
163
|
-
|
164
|
-
template<class R>
|
165
|
-
ClosureInterface* NewClosure(R (*fun)()) {
|
166
|
-
return new Closure0<R (*)()>(fun);
|
167
|
-
}
|
168
|
-
|
169
|
-
template<class R, class Arg1>
|
170
|
-
ClosureInterface* NewClosure(R (*fun)(Arg1), Arg1 arg1) {
|
171
|
-
return new Closure1<R (*)(Arg1), Arg1>(fun, arg1);
|
172
|
-
}
|
173
|
-
|
174
|
-
template<class R, class Arg1, class Arg2>
|
175
|
-
ClosureInterface* NewClosure(R (*fun)(Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
|
176
|
-
return new Closure2<R (*)(Arg1, Arg2), Arg1, Arg2>(fun, arg1, arg2);
|
177
|
-
}
|
178
|
-
|
179
|
-
template<class R, class Arg1, class Arg2, class Arg3>
|
180
|
-
ClosureInterface* NewClosure(R (*fun)(Arg1, Arg2, Arg3), Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
181
|
-
return new Closure3<R (*)(Arg1, Arg2, Arg3), Arg1, Arg2, Arg3>(fun, arg1, arg2, arg3);
|
182
|
-
}
|
183
|
-
|
184
|
-
template<class R, class Obj>
|
185
|
-
ClosureInterface* NewClosure(Obj* obj, R (Obj::* fun)()) {
|
186
|
-
return new ObjClosure0<Obj, R (Obj::* )()>(obj, fun);
|
187
|
-
}
|
188
|
-
|
189
|
-
template<class R, class Obj, class Arg1>
|
190
|
-
ClosureInterface* NewClosure(Obj* obj, R (Obj::* fun)(Arg1), Arg1 arg1) {
|
191
|
-
return new ObjClosure1<Obj, R (Obj::* )(Arg1), Arg1>(obj, fun, arg1);
|
192
|
-
}
|
193
|
-
|
194
|
-
template<class R, class Obj, class Arg1, class Arg2>
|
195
|
-
ClosureInterface* NewClosure(Obj* obj, R (Obj::* fun)(Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
|
196
|
-
return new ObjClosure2<Obj, R (Obj::*)(Arg1, Arg2), Arg1, Arg2>(obj, fun, arg1, arg2);
|
197
|
-
}
|
198
|
-
|
199
|
-
template<class R, class Obj, class Arg1, class Arg2, class Arg3>
|
200
|
-
ClosureInterface* NewClosure(Obj* obj, R (Obj::* fun)(Arg1, Arg2, Arg3), Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
201
|
-
return new ObjClosure3<Obj, R (Obj::*)(Arg1, Arg2, Arg3), Arg1, Arg2, Arg3>(obj, fun, arg1, arg2, arg3);
|
202
|
-
}
|
203
|
-
|
204
|
-
} // namespace limonp
|
205
|
-
|
206
|
-
#endif // LIMONP_CLOSURE_HPP
|