react-native-jieba 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/cpp/cppjieba/CHANGELOG.md +18 -0
  2. package/cpp/cppjieba/LICENSE +20 -0
  3. package/cpp/cppjieba/README.md +288 -0
  4. package/cpp/cppjieba/deps/limonp/CHANGELOG.md +175 -0
  5. package/cpp/cppjieba/deps/limonp/LICENSE +20 -0
  6. package/cpp/cppjieba/deps/limonp/README.md +43 -0
  7. package/cpp/cppjieba/deps/limonp/include/limonp/ArgvContext.hpp +70 -0
  8. package/cpp/cppjieba/deps/limonp/include/limonp/Closure.hpp +206 -0
  9. package/cpp/cppjieba/deps/limonp/include/limonp/Colors.hpp +31 -0
  10. package/cpp/cppjieba/deps/limonp/include/limonp/Condition.hpp +38 -0
  11. package/cpp/cppjieba/deps/limonp/include/limonp/Config.hpp +103 -0
  12. package/cpp/cppjieba/deps/limonp/include/limonp/ForcePublic.hpp +7 -0
  13. package/cpp/cppjieba/deps/limonp/include/limonp/LocalVector.hpp +139 -0
  14. package/cpp/cppjieba/deps/limonp/include/limonp/Logging.hpp +92 -0
  15. package/cpp/cppjieba/deps/limonp/include/limonp/NonCopyable.hpp +21 -0
  16. package/cpp/cppjieba/deps/limonp/include/limonp/StdExtension.hpp +157 -0
  17. package/cpp/cppjieba/deps/limonp/include/limonp/StringUtil.hpp +386 -0
  18. package/cpp/cppjieba/dict/README.md +62 -0
  19. package/cpp/cppjieba/dict/hmm_model.utf8 +34 -0
  20. package/cpp/cppjieba/dict/idf.utf8 +258826 -0
  21. package/cpp/cppjieba/dict/jieba.dict.utf8 +348982 -0
  22. package/cpp/cppjieba/dict/stop_words.utf8 +1534 -0
  23. package/cpp/cppjieba/dict/user.dict.utf8 +3 -0
  24. package/cpp/cppjieba/include/cppjieba/DictTrie.hpp +322 -0
  25. package/cpp/cppjieba/include/cppjieba/FullSegment.hpp +94 -0
  26. package/cpp/cppjieba/include/cppjieba/HMMModel.hpp +131 -0
  27. package/cpp/cppjieba/include/cppjieba/HMMSegment.hpp +211 -0
  28. package/cpp/cppjieba/include/cppjieba/Jieba.hpp +169 -0
  29. package/cpp/cppjieba/include/cppjieba/KeywordExtractor.hpp +152 -0
  30. package/cpp/cppjieba/include/cppjieba/MPSegment.hpp +137 -0
  31. package/cpp/cppjieba/include/cppjieba/MixSegment.hpp +109 -0
  32. package/cpp/cppjieba/include/cppjieba/PosTagger.hpp +77 -0
  33. package/cpp/cppjieba/include/cppjieba/PreFilter.hpp +54 -0
  34. package/cpp/cppjieba/include/cppjieba/QuerySegment.hpp +89 -0
  35. package/cpp/cppjieba/include/cppjieba/SegmentBase.hpp +46 -0
  36. package/cpp/cppjieba/include/cppjieba/SegmentTagged.hpp +23 -0
  37. package/cpp/cppjieba/include/cppjieba/TextRankExtractor.hpp +192 -0
  38. package/cpp/cppjieba/include/cppjieba/Trie.hpp +200 -0
  39. package/cpp/cppjieba/include/cppjieba/Unicode.hpp +231 -0
  40. package/cpp/cppjieba/include/cppjieba/UnicodeFile.hpp +68 -0
  41. package/package.json +3 -2
@@ -0,0 +1,206 @@
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
@@ -0,0 +1,31 @@
1
+ #ifndef LIMONP_COLOR_PRINT_HPP
2
+ #define LIMONP_COLOR_PRINT_HPP
3
+
4
+ #include <string>
5
+ #include <stdarg.h>
6
+
7
+ namespace limonp {
8
+
9
+ using std::string;
10
+
11
+ enum Color {
12
+ BLACK = 30,
13
+ RED,
14
+ GREEN,
15
+ YELLOW,
16
+ BLUE,
17
+ PURPLE
18
+ }; // enum Color
19
+
20
+ static void ColorPrintln(enum Color color, const char * fmt, ...) {
21
+ va_list ap;
22
+ printf("\033[0;%dm", color);
23
+ va_start(ap, fmt);
24
+ vprintf(fmt, ap);
25
+ va_end(ap);
26
+ printf("\033[0m\n"); // if not \n , in some situation , the next lines will be set the same color unexpectedly
27
+ }
28
+
29
+ } // namespace limonp
30
+
31
+ #endif // LIMONP_COLOR_PRINT_HPP
@@ -0,0 +1,38 @@
1
+ #ifndef LIMONP_CONDITION_HPP
2
+ #define LIMONP_CONDITION_HPP
3
+
4
+ #include "MutexLock.hpp"
5
+
6
+ namespace limonp {
7
+
8
+ class Condition : NonCopyable {
9
+ public:
10
+ explicit Condition(MutexLock& mutex)
11
+ : mutex_(mutex) {
12
+ XCHECK(!pthread_cond_init(&pcond_, NULL));
13
+ }
14
+
15
+ ~Condition() {
16
+ XCHECK(!pthread_cond_destroy(&pcond_));
17
+ }
18
+
19
+ void Wait() {
20
+ XCHECK(!pthread_cond_wait(&pcond_, mutex_.GetPthreadMutex()));
21
+ }
22
+
23
+ void Notify() {
24
+ XCHECK(!pthread_cond_signal(&pcond_));
25
+ }
26
+
27
+ void NotifyAll() {
28
+ XCHECK(!pthread_cond_broadcast(&pcond_));
29
+ }
30
+
31
+ private:
32
+ MutexLock& mutex_;
33
+ pthread_cond_t pcond_;
34
+ }; // class Condition
35
+
36
+ } // namespace limonp
37
+
38
+ #endif // LIMONP_CONDITION_HPP
@@ -0,0 +1,103 @@
1
+ /************************************
2
+ * file enc : utf8
3
+ * author : wuyanyi09@gmail.com
4
+ ************************************/
5
+ #ifndef LIMONP_CONFIG_H
6
+ #define LIMONP_CONFIG_H
7
+
8
+ #include <map>
9
+ #include <fstream>
10
+ #include <iostream>
11
+ #include <assert.h>
12
+ #include "StringUtil.hpp"
13
+
14
+ namespace limonp {
15
+
16
+ using namespace std;
17
+
18
+ class Config {
19
+ public:
20
+ explicit Config(const string& filePath) {
21
+ LoadFile(filePath);
22
+ }
23
+
24
+ operator bool () {
25
+ return !map_.empty();
26
+ }
27
+
28
+ string Get(const string& key, const string& defaultvalue) const {
29
+ map<string, string>::const_iterator it = map_.find(key);
30
+ if(map_.end() != it) {
31
+ return it->second;
32
+ }
33
+ return defaultvalue;
34
+ }
35
+ int Get(const string& key, int defaultvalue) const {
36
+ string str = Get(key, "");
37
+ if("" == str) {
38
+ return defaultvalue;
39
+ }
40
+ return atoi(str.c_str());
41
+ }
42
+ const char* operator [] (const char* key) const {
43
+ if(NULL == key) {
44
+ return NULL;
45
+ }
46
+ map<string, string>::const_iterator it = map_.find(key);
47
+ if(map_.end() != it) {
48
+ return it->second.c_str();
49
+ }
50
+ return NULL;
51
+ }
52
+
53
+ string GetConfigInfo() const {
54
+ string res;
55
+ res << *this;
56
+ return res;
57
+ }
58
+
59
+ private:
60
+ void LoadFile(const string& filePath) {
61
+ ifstream ifs(filePath.c_str());
62
+ assert(ifs);
63
+ string line;
64
+ vector<string> vecBuf;
65
+ size_t lineno = 0;
66
+ while(getline(ifs, line)) {
67
+ lineno ++;
68
+ Trim(line);
69
+ if(line.empty() || StartsWith(line, "#")) {
70
+ continue;
71
+ }
72
+ vecBuf.clear();
73
+ Split(line, vecBuf, "=");
74
+ if(2 != vecBuf.size()) {
75
+ fprintf(stderr, "line[%s] illegal.\n", line.c_str());
76
+ assert(false);
77
+ continue;
78
+ }
79
+ string& key = vecBuf[0];
80
+ string& value = vecBuf[1];
81
+ Trim(key);
82
+ Trim(value);
83
+ if(!map_.insert(make_pair(key, value)).second) {
84
+ fprintf(stderr, "key[%s] already exits.\n", key.c_str());
85
+ assert(false);
86
+ continue;
87
+ }
88
+ }
89
+ ifs.close();
90
+ }
91
+
92
+ friend ostream& operator << (ostream& os, const Config& config);
93
+
94
+ map<string, string> map_;
95
+ }; // class Config
96
+
97
+ inline ostream& operator << (ostream& os, const Config& config) {
98
+ return os << config.map_;
99
+ }
100
+
101
+ } // namespace limonp
102
+
103
+ #endif // LIMONP_CONFIG_H
@@ -0,0 +1,7 @@
1
+ #ifndef LIMONP_FORCE_PUBLIC_H
2
+ #define LIMONP_FORCE_PUBLIC_H
3
+
4
+ #define private public
5
+ #define protected public
6
+
7
+ #endif // LIMONP_FORCE_PUBLIC_H
@@ -0,0 +1,139 @@
1
+ #ifndef LIMONP_LOCAL_VECTOR_HPP
2
+ #define LIMONP_LOCAL_VECTOR_HPP
3
+
4
+ #include <iostream>
5
+ #include <stdlib.h>
6
+ #include <assert.h>
7
+ #include <string.h>
8
+
9
+ namespace limonp {
10
+ using namespace std;
11
+ /*
12
+ * LocalVector<T> : T must be primitive type (char , int, size_t), if T is struct or class, LocalVector<T> may be dangerous..
13
+ * LocalVector<T> is simple and not well-tested.
14
+ */
15
+ const size_t LOCAL_VECTOR_BUFFER_SIZE = 16;
16
+ template <class T>
17
+ class LocalVector {
18
+ public:
19
+ typedef const T* const_iterator ;
20
+ typedef T value_type;
21
+ typedef size_t size_type;
22
+ private:
23
+ T buffer_[LOCAL_VECTOR_BUFFER_SIZE];
24
+ T * ptr_;
25
+ size_t size_;
26
+ size_t capacity_;
27
+ public:
28
+ LocalVector() {
29
+ init_();
30
+ };
31
+ LocalVector(const LocalVector<T>& vec) {
32
+ init_();
33
+ *this = vec;
34
+ }
35
+ LocalVector(const_iterator begin, const_iterator end) { // TODO: make it faster
36
+ init_();
37
+ while(begin != end) {
38
+ push_back(*begin++);
39
+ }
40
+ }
41
+ LocalVector(size_t size, const T& t) { // TODO: make it faster
42
+ init_();
43
+ while(size--) {
44
+ push_back(t);
45
+ }
46
+ }
47
+ ~LocalVector() {
48
+ if(ptr_ != buffer_) {
49
+ free(ptr_);
50
+ }
51
+ };
52
+ public:
53
+ LocalVector<T>& operator = (const LocalVector<T>& vec) {
54
+ clear();
55
+ size_ = vec.size();
56
+ capacity_ = vec.capacity();
57
+ if(vec.buffer_ == vec.ptr_) {
58
+ memcpy(static_cast<void*>(buffer_), vec.buffer_, sizeof(T) * size_);
59
+ ptr_ = buffer_;
60
+ } else {
61
+ ptr_ = (T*) malloc(vec.capacity() * sizeof(T));
62
+ assert(ptr_);
63
+ memcpy(static_cast<void*>(ptr_), vec.ptr_, vec.size() * sizeof(T));
64
+ }
65
+ return *this;
66
+ }
67
+ private:
68
+ void init_() {
69
+ ptr_ = buffer_;
70
+ size_ = 0;
71
+ capacity_ = LOCAL_VECTOR_BUFFER_SIZE;
72
+ }
73
+ public:
74
+ T& operator [] (size_t i) {
75
+ return ptr_[i];
76
+ }
77
+ const T& operator [] (size_t i) const {
78
+ return ptr_[i];
79
+ }
80
+ void push_back(const T& t) {
81
+ if(size_ == capacity_) {
82
+ assert(capacity_);
83
+ reserve(capacity_ * 2);
84
+ }
85
+ ptr_[size_ ++ ] = t;
86
+ }
87
+ void reserve(size_t size) {
88
+ if(size <= capacity_) {
89
+ return;
90
+ }
91
+ T * next = (T*)malloc(sizeof(T) * size);
92
+ assert(next);
93
+ T * old = ptr_;
94
+ ptr_ = next;
95
+ memcpy(static_cast<void*>(ptr_), old, sizeof(T) * capacity_);
96
+ capacity_ = size;
97
+ if(old != buffer_) {
98
+ free(old);
99
+ }
100
+ }
101
+ bool empty() const {
102
+ return 0 == size();
103
+ }
104
+ size_t size() const {
105
+ return size_;
106
+ }
107
+ size_t capacity() const {
108
+ return capacity_;
109
+ }
110
+ const_iterator begin() const {
111
+ return ptr_;
112
+ }
113
+ const_iterator end() const {
114
+ return ptr_ + size_;
115
+ }
116
+ void clear() {
117
+ if(ptr_ != buffer_) {
118
+ free(ptr_);
119
+ }
120
+ init_();
121
+ }
122
+ };
123
+
124
+ template <class T>
125
+ ostream & operator << (ostream& os, const LocalVector<T>& vec) {
126
+ if(vec.empty()) {
127
+ return os << "[]";
128
+ }
129
+ os<<"[\""<<vec[0];
130
+ for(size_t i = 1; i < vec.size(); i++) {
131
+ os<<"\", \""<<vec[i];
132
+ }
133
+ os<<"\"]";
134
+ return os;
135
+ }
136
+
137
+ }
138
+
139
+ #endif
@@ -0,0 +1,92 @@
1
+ #ifndef LIMONP_LOGGING_HPP
2
+ #define LIMONP_LOGGING_HPP
3
+
4
+ #include <sstream>
5
+ #include <iostream>
6
+ #include <cassert>
7
+ #include <cstdlib>
8
+ #include <ctime>
9
+
10
+ #ifdef XLOG
11
+ #error "XLOG has been defined already"
12
+ #endif // XLOG
13
+ #ifdef XCHECK
14
+ #error "XCHECK has been defined already"
15
+ #endif // XCHECK
16
+
17
+ #define XLOG(level) limonp::Logger(limonp::LL_##level, __FILE__, __LINE__).Stream()
18
+ #define XCHECK(exp) if(!(exp)) XLOG(FATAL) << "exp: ["#exp << "] false. "
19
+
20
+ namespace limonp {
21
+
22
+ enum {
23
+ LL_DEBUG = 0,
24
+ LL_INFO = 1,
25
+ LL_WARNING = 2,
26
+ LL_ERROR = 3,
27
+ LL_FATAL = 4,
28
+ }; // enum
29
+
30
+ static const char * LOG_LEVEL_ARRAY[] = {"DEBUG","INFO","WARN","ERROR","FATAL"};
31
+ static const char * LOG_TIME_FORMAT = "%Y-%m-%d %H:%M:%S";
32
+
33
+ class Logger {
34
+ public:
35
+ Logger(size_t level, const char* filename, int lineno)
36
+ : level_(level) {
37
+ #ifdef LOGGING_LEVEL
38
+ if (level_ < LOGGING_LEVEL) {
39
+ return;
40
+ }
41
+ #endif
42
+ assert(level_ <= sizeof(LOG_LEVEL_ARRAY)/sizeof(*LOG_LEVEL_ARRAY));
43
+
44
+ char buf[32];
45
+
46
+ time_t timeNow;
47
+ time(&timeNow);
48
+
49
+ struct tm tmNow;
50
+
51
+ #if defined(_WIN32) || defined(_WIN64)
52
+ errno_t e = localtime_s(&tmNow, &timeNow);
53
+ assert(e == 0);
54
+ (void)e;
55
+ #else
56
+ struct tm * tm_tmp = localtime_r(&timeNow, &tmNow);
57
+ assert(tm_tmp != nullptr);
58
+ (void)tm_tmp;
59
+ #endif
60
+
61
+ strftime(buf, sizeof(buf), LOG_TIME_FORMAT, &tmNow);
62
+
63
+ stream_ << buf
64
+ << " " << filename
65
+ << ":" << lineno
66
+ << " " << LOG_LEVEL_ARRAY[level_]
67
+ << " ";
68
+ }
69
+ ~Logger() {
70
+ #ifdef LOGGING_LEVEL
71
+ if (level_ < LOGGING_LEVEL) {
72
+ return;
73
+ }
74
+ #endif
75
+ std::cerr << stream_.str() << std::endl;
76
+ if (level_ == LL_FATAL) {
77
+ abort();
78
+ }
79
+ }
80
+
81
+ std::ostream& Stream() {
82
+ return stream_;
83
+ }
84
+
85
+ private:
86
+ std::ostringstream stream_;
87
+ size_t level_;
88
+ }; // class Logger
89
+
90
+ } // namespace limonp
91
+
92
+ #endif // LIMONP_LOGGING_HPP
@@ -0,0 +1,21 @@
1
+ /************************************
2
+ ************************************/
3
+ #ifndef LIMONP_NONCOPYABLE_H
4
+ #define LIMONP_NONCOPYABLE_H
5
+
6
+ namespace limonp {
7
+
8
+ class NonCopyable {
9
+ protected:
10
+ NonCopyable() {
11
+ }
12
+ ~NonCopyable() {
13
+ }
14
+ private:
15
+ NonCopyable(const NonCopyable& );
16
+ const NonCopyable& operator=(const NonCopyable& );
17
+ }; // class NonCopyable
18
+
19
+ } // namespace limonp
20
+
21
+ #endif // LIMONP_NONCOPYABLE_H