cppjieba_rb 0.4.1 → 0.4.4

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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +21 -0
  3. data/.github/workflows/linting.yml +30 -0
  4. data/.github/workflows/release.yml +42 -0
  5. data/.github/workflows/tests.yml +47 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +45 -0
  8. data/.ruby-version +1 -0
  9. data/.yamllint +35 -0
  10. data/CHANGELOG.md +17 -0
  11. data/Gemfile +11 -0
  12. data/README.md +5 -5
  13. data/Rakefile +16 -7
  14. data/cppjieba_rb.gemspec +46 -33
  15. data/ext/cppjieba/.github/workflows/cmake.yml +52 -0
  16. data/ext/cppjieba/.github/workflows/stale-issues.yml +24 -0
  17. data/ext/cppjieba/.gitmodules +3 -0
  18. data/ext/cppjieba/{ChangeLog.md → CHANGELOG.md} +50 -1
  19. data/ext/cppjieba/CMakeLists.txt +11 -14
  20. data/ext/cppjieba/LICENSE +20 -0
  21. data/ext/cppjieba/README.md +9 -18
  22. data/ext/cppjieba/deps/limonp/.github/workflows/cmake.yml +43 -0
  23. data/ext/cppjieba/deps/limonp/.gitignore +9 -0
  24. data/ext/cppjieba/deps/limonp/CHANGELOG.md +160 -0
  25. data/ext/cppjieba/deps/limonp/CMakeLists.txt +61 -0
  26. data/ext/cppjieba/deps/limonp/LICENSE +20 -0
  27. data/ext/cppjieba/deps/limonp/README.md +38 -0
  28. data/ext/cppjieba/deps/limonp/{LocalVector.hpp → include/limonp/LocalVector.hpp} +3 -3
  29. data/ext/cppjieba/deps/limonp/{Logging.hpp → include/limonp/Logging.hpp} +17 -3
  30. data/ext/cppjieba/deps/limonp/{StringUtil.hpp → include/limonp/StringUtil.hpp} +31 -10
  31. data/ext/cppjieba/deps/limonp/test/CMakeLists.txt +8 -0
  32. data/ext/cppjieba/deps/limonp/test/demo.cpp +40 -0
  33. data/ext/cppjieba/deps/limonp/test/testdata/1.conf +5 -0
  34. data/ext/cppjieba/deps/limonp/test/testdata/StdExtension.data +3 -0
  35. data/ext/cppjieba/deps/limonp/test/testdata/dict.gbk +50 -0
  36. data/ext/cppjieba/deps/limonp/test/testdata/dict.utf8 +50 -0
  37. data/ext/cppjieba/deps/limonp/test/testdata/io_testfile +2 -0
  38. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.1.utf8 +93 -0
  39. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.utf8 +93 -0
  40. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.1.utf8 +67 -0
  41. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.2.utf8 +64 -0
  42. data/ext/cppjieba/deps/limonp/test/unittest/CMakeLists.txt +30 -0
  43. data/ext/cppjieba/deps/limonp/test/unittest/TArgvContext.cpp +16 -0
  44. data/ext/cppjieba/deps/limonp/test/unittest/TCastFloat.cpp +19 -0
  45. data/ext/cppjieba/deps/limonp/test/unittest/TClosure.cpp +85 -0
  46. data/ext/cppjieba/deps/limonp/test/unittest/TColorPrint.cpp +20 -0
  47. data/ext/cppjieba/deps/limonp/test/unittest/TConfig.cpp +17 -0
  48. data/ext/cppjieba/deps/limonp/test/unittest/TLocalVector.cpp +41 -0
  49. data/ext/cppjieba/deps/limonp/test/unittest/TLogging.cpp +12 -0
  50. data/ext/cppjieba/deps/limonp/test/unittest/TStdExtension.cpp +95 -0
  51. data/ext/cppjieba/deps/limonp/test/unittest/TStringUtil.cpp +183 -0
  52. data/ext/cppjieba/include/cppjieba/DictTrie.hpp +9 -0
  53. data/ext/cppjieba/include/cppjieba/Jieba.hpp +4 -0
  54. data/ext/cppjieba/include/cppjieba/Trie.hpp +27 -1
  55. data/ext/cppjieba/test/CMakeLists.txt +4 -3
  56. data/ext/cppjieba/test/unittest/CMakeLists.txt +16 -7
  57. data/ext/cppjieba_rb/extconf.rb +11 -6
  58. data/ext/cppjieba_rb/internal.cc +1 -1
  59. data/lib/cppjieba_rb/segment.rb +4 -1
  60. data/lib/cppjieba_rb/version.rb +3 -1
  61. data/lib/cppjieba_rb.rb +12 -5
  62. data/test/test_keyword.rb +8 -8
  63. data/test/test_segment.rb +14 -10
  64. data/test/test_stop_word_filter.rb +5 -3
  65. data/test/test_tagging.rb +5 -2
  66. metadata +63 -140
  67. data/.travis.yml +0 -30
  68. data/ext/cppjieba/.travis.yml +0 -21
  69. data/ext/cppjieba/README_EN.md +0 -115
  70. data/ext/cppjieba/appveyor.yml +0 -32
  71. data/ext/cppjieba/deps/CMakeLists.txt +0 -1
  72. data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
  73. data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
  74. data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
  75. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
  76. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
  77. data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
  78. data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
  79. data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
  80. data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
  81. data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
  82. data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
  83. data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
  84. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
  85. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
  86. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
  87. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
  88. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
  89. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
  90. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
  91. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
  92. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
  93. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
  94. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
  95. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
  96. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
  97. data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
  98. data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
  99. data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
  100. data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
  101. data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
  102. data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
  103. data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
  104. data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
  105. data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
  106. data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
  107. data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
  108. data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
  109. data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
  110. data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
  111. data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
  112. data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
  113. data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
  114. data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
  115. data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
  116. data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
  117. data/ext/cppjieba/test/demo.cpp +0 -80
  118. /data/ext/cppjieba/deps/{gtest/src/.deps/.dirstamp → limonp/.gitmodules} +0 -0
  119. /data/ext/cppjieba/deps/limonp/{ArgvContext.hpp → include/limonp/ArgvContext.hpp} +0 -0
  120. /data/ext/cppjieba/deps/limonp/{Closure.hpp → include/limonp/Closure.hpp} +0 -0
  121. /data/ext/cppjieba/deps/limonp/{Colors.hpp → include/limonp/Colors.hpp} +0 -0
  122. /data/ext/cppjieba/deps/limonp/{Condition.hpp → include/limonp/Condition.hpp} +0 -0
  123. /data/ext/cppjieba/deps/limonp/{Config.hpp → include/limonp/Config.hpp} +0 -0
  124. /data/ext/cppjieba/deps/limonp/{ForcePublic.hpp → include/limonp/ForcePublic.hpp} +0 -0
  125. /data/ext/cppjieba/deps/limonp/{NonCopyable.hpp → include/limonp/NonCopyable.hpp} +0 -0
  126. /data/ext/cppjieba/deps/limonp/{StdExtension.hpp → include/limonp/StdExtension.hpp} +0 -0
  127. /data/ext/cppjieba/deps/{gtest/src/gtest_main.cc → limonp/test/unittest/gtest_main.cpp} +0 -0
@@ -1,16 +1,10 @@
1
- # CppJieba [English](README_EN.md)
1
+ # CppJieba
2
2
 
3
- [![Build Status](https://travis-ci.org/yanyiwu/cppjieba.png?branch=master)](https://travis-ci.org/yanyiwu/cppjieba)
3
+ [![CMake](https://github.com/yanyiwu/cppjieba/actions/workflows/cmake.yml/badge.svg)](https://github.com/yanyiwu/cppjieba/actions/workflows/cmake.yml)
4
4
  [![Author](https://img.shields.io/badge/author-@yanyiwu-blue.svg?style=flat)](http://yanyiwu.com/)
5
- [![Donate](https://img.shields.io/badge/donate-eos_gitdeveloper-orange.svg)](https://eosflare.io/account/gitdeveloper)
6
- [![Platform](https://img.shields.io/badge/platform-Linux,%20OS%20X,%20Windows-green.svg?style=flat)](https://github.com/yanyiwu/cppjieba)
5
+ [![Platform](https://img.shields.io/badge/platform-Linux,macOS,Windows-green.svg?style=flat)](https://github.com/yanyiwu/cppjieba)
7
6
  [![Performance](https://img.shields.io/badge/performance-excellent-brightgreen.svg?style=flat)](http://yanyiwu.com/work/2015/06/14/jieba-series-performance-test.html)
8
7
  [![Tag](https://img.shields.io/github/v/tag/yanyiwu/cppjieba.svg)](https://github.com/yanyiwu/cppjieba/releases)
9
- [![License](https://img.shields.io/badge/license-MIT-yellow.svg?style=flat)](http://yanyiwu.mit-license.org)
10
- [![Build status](https://ci.appveyor.com/api/projects/status/wl30fjnm2rhft6ta/branch/master?svg=true)](https://ci.appveyor.com/project/yanyiwu/cppjieba/branch/master)
11
-
12
-
13
- [![logo](http://images.yanyiwu.com/CppJiebaLogo-v1.png)](https://github.com/yanyiwu/cppjieba)
14
8
 
15
9
  ## 简介
16
10
 
@@ -34,8 +28,10 @@ CppJieba是"结巴(Jieba)"中文分词的C++版本
34
28
  ### 下载和编译
35
29
 
36
30
  ```sh
37
- git clone --depth=10 --branch=master git://github.com/yanyiwu/cppjieba.git
31
+ git clone https://github.com/yanyiwu/cppjieba.git
38
32
  cd cppjieba
33
+ git submodule init
34
+ git submodule update
39
35
  mkdir build
40
36
  cd build
41
37
  cmake ..
@@ -80,7 +76,7 @@ make test
80
76
  [{"word": "CEO", "offset": [93], "weight": 11.7392}, {"word": "升职", "offset": [72], "weight": 10.8562}, {"word": "加薪", "offset": [78], "weight": 10.6426}, {"word": "手扶拖拉机", "offset": [21], "weight": 10.0089}, {"word": "巅峰", "offset": [111], "weight": 9.49396}]
81
77
  ```
82
78
 
83
- 详细请看 `test/demo.cpp`.
79
+ For more details, please see [demo](https://github.com/yanyiwu/cppjieba-demo).
84
80
 
85
81
  ### 分词结果示例
86
82
 
@@ -186,7 +182,7 @@ Query方法先使用Mix方法切词,对于切出来的较长的词再使用Ful
186
182
  ["CEO:11.7392", "升职:10.8562", "加薪:10.6426", "手扶拖拉机:10.0089", "巅峰:9.49396"]
187
183
  ```
188
184
 
189
- 详细请见 `test/demo.cpp`.
185
+ For more details, please see [demo](https://github.com/yanyiwu/cppjieba-demo).
190
186
 
191
187
  ### 词性标注
192
188
 
@@ -195,7 +191,7 @@ Query方法先使用Mix方法切词,对于切出来的较长的词再使用Ful
195
191
  ["我:r", "是:v", "拖拉机:n", "学院:n", "手扶拖拉机:n", "专业:n", "的:uj", "。:x", "不用:v", "多久:m", ",:x", "我:r", "就:d", "会:v", "升职:v", "加薪:nr", ",:x", "当上:t", "CEO:eng", ",:x", "走上:v", "人生:n", "巅峰:n", "。:x"]
196
192
  ```
197
193
 
198
- 详细请看 `test/demo.cpp`.
194
+ For more details, please see [demo](https://github.com/yanyiwu/cppjieba-demo).
199
195
 
200
196
  支持自定义词性。
201
197
  比如在(`dict/user.dict.utf8`)增加一行
@@ -237,11 +233,6 @@ Query方法先使用Mix方法切词,对于切出来的较长的词再使用Ful
237
233
  + [perl5-jieba] Perl版本的结巴分词扩展。
238
234
  + [jieba-dlang] D 语言的结巴分词 Deimos Bindings。
239
235
 
240
- ## 线上演示
241
-
242
- [Web-Demo](http://cppjieba-webdemo.herokuapp.com/)
243
- (建议使用chrome打开)
244
-
245
236
  ## 性能评测
246
237
 
247
238
  [Jieba中文分词系列性能评测]
@@ -0,0 +1,43 @@
1
+ name: CMake
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ #env:
8
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
9
+ # BUILD_TYPE: Debug
10
+
11
+ jobs:
12
+ build:
13
+ # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
14
+ # You can convert this to a matrix build if you need cross-platform coverage.
15
+ # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ matrix:
19
+ os: [
20
+ ubuntu-20.04,
21
+ ubuntu-22.04,
22
+ macos-12,
23
+ macos-13,
24
+ macos-14,
25
+ windows-2019,
26
+ windows-2022,
27
+ ]
28
+ cpp_version: [11, 14, 17, 20]
29
+ build_type: [Release, Debug]
30
+
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+
34
+ - name: Configure CMake
35
+ run: cmake -B ${{github.workspace}}/build -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=${{matrix.cpp_version}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
36
+
37
+ - name: Build
38
+ run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
39
+
40
+ - name: Test
41
+ working-directory: ${{github.workspace}}/build
42
+ run: ctest -C ${{matrix.build_type}} --output-on-failure --verbose
43
+
@@ -0,0 +1,9 @@
1
+ *.o
2
+ *.ut
3
+ libcm.a
4
+ tags
5
+ *.d
6
+ build
7
+ t.cpp
8
+ a.out
9
+ *.swp
@@ -0,0 +1,160 @@
1
+ # CHANGELOG
2
+
3
+ ## v1.0.0
4
+
5
+ + rm thread pool demo
6
+ + deleted: include/limonp/BlockingQueue.hpp
7
+ + deleted: include/limonp/BoundedBlockingQueue.hpp
8
+ + deleted: include/limonp/BoundedQueue.hpp
9
+ + deleted: include/limonp/MutexLock.hpp
10
+ + deleted: include/limonp/Thread.hpp
11
+ + deleted: include/limonp/ThreadPool.hpp
12
+ + deleted: test/unittest/TBlockingQueue.cpp
13
+ + deleted: test/unittest/TBoundedQueue.cpp
14
+ + deleted: test/unittest/TMutexLock.cpp
15
+ + deleted: test/unittest/TThread.cpp
16
+ + deleted: test/unittest/TThreadPool.cpp
17
+ + rm FileLock
18
+ + rm Md5.hpp
19
+
20
+ ## v0.9.0
21
+
22
+ + [c++20] compatibility
23
+ + [c++17] compatibility
24
+
25
+ ## v0.8.1
26
+
27
+ + [CI] fix windows gtest thread link error
28
+ + [submodule] rm test/googletest
29
+ + [CMake] FetchContent googletest
30
+ + [CMake] required 3.5 -> 3.14
31
+
32
+ ## v0.8.0
33
+
34
+ + [StringUtil] Fix windows assert typo
35
+ + [CMake] find_package(Threads REQUIRED); target_link_libraries(... Threads::Threads)
36
+ + [CMAKE][CI] windows: 2019,2022
37
+ + [CMAKE][CI] matrix.build_type[Release, Debug]
38
+ + [unittest] disable #TMd5.cpp
39
+ + [unittest] disable #TFileLock.cpp
40
+ + [unittest] disable #TBoundedQueue.cpp
41
+ + [unittest] disable #TMutexLock.cpp
42
+ + [unittest] disable #TBlockingQueue.cpp
43
+ + [unittest] disable #TThread.cpp
44
+ + [unittest] disable #TThreadPool.cpp
45
+
46
+ ## v0.7.2
47
+
48
+ + [CI] ubuntu version from 20 to 22, macos version from 12 to 14
49
+ + [test/unittes] uint->size_t
50
+ + [googletest] v1.6.0->v1.10.0
51
+ + [CMake] version required 3.0 -> 3.5
52
+
53
+ ## v0.7.1
54
+
55
+ + [CMake] fix CMAKE_CXX_STANDARD passed from github/actions and [c++11, c++14] only
56
+
57
+ ## v0.7.0
58
+
59
+ + [CI] Added os.macos and cpp_version=[c++98, c++03, c++11, c++14, c++17, c++20]
60
+ + [git submodule] Added googletest-release-v1.6.0
61
+
62
+ ## v0.6.7
63
+
64
+ + Merged [pr35](https://github.com/yanyiwu/limonp/pull/35)
65
+ + Merged [pr33](https://github.com/yanyiwu/limonp/pull/33)
66
+ + Merged [pr32](https://github.com/yanyiwu/limonp/pull/32)
67
+
68
+ ## v0.6.6
69
+
70
+ + Merged [pr-31 To be compatible with cpp17 and later, use lambda instead of std::not1 & std::bind2nd #31](https://github.com/yanyiwu/limonp/pull/31)
71
+
72
+ ## v0.6.5
73
+
74
+ + Merged [pr-25 Update cmake.yml](https://github.com/yanyiwu/limonp/pull/25)
75
+ + Merged [pr-26 fix license for end of line sequence and remove useless signature](https://github.com/yanyiwu/limonp/pull/26)
76
+ + Merged [pr-27 Update cmake.yml](https://github.com/yanyiwu/limonp/pull/27)
77
+ + Merged [pr-28 add a target to be ready to support installation](https://github.com/yanyiwu/limonp/pull/28)
78
+ + Merged [pr-29 Installable by cmake](https://github.com/yanyiwu/limonp/pull/29)
79
+ + Merged [pr-30 Replace localtime with localtime_s on Windows and localtime_r on Linux](https://github.com/yanyiwu/limonp/pull/30)
80
+
81
+ ## v0.6.4
82
+
83
+ + merge [fixup gcc8 warnings](https://github.com/yanyiwu/gojieba/pull/70)
84
+
85
+ ## v0.6.3
86
+
87
+ + remove compiler conplained macro
88
+
89
+ ## v0.6.2
90
+
91
+ + merge [pr-18](https://github.com/yanyiwu/limonp/pull/18/files)
92
+
93
+ ## v0.6.1
94
+
95
+ add Specialized template for vector<string>
96
+
97
+ when it is `vector<string>`, print like this: ["hello", "world"]; (special case)
98
+ when it is `vector<int>`, print like this: [1, 10, 1000]; (common cases)
99
+
100
+ ## v0.6.0
101
+
102
+ + remove Trim out of Split.
103
+
104
+ ## v0.5.6
105
+
106
+ + fix hidden trouble.
107
+
108
+ ## v0.5.5
109
+
110
+ + macro name LOG and CHECK in Logging.hpp is so easy to confict with other lib, so I have to rename them to XLOG and XCHECK for avoiding those macro name conflicts.
111
+
112
+ ## v0.5.4
113
+
114
+ + add ForcePublic.hpp
115
+ + Add Utf8ToUnicode32 and Unicode32ToUtf8 in StringUtil.hpp
116
+
117
+ ## v0.5.3
118
+
119
+ + Fix incompatibility problem about 'time.h' in Windows.
120
+
121
+ ## v0.5.2
122
+
123
+ + Fix incompatibility problem about `enum {INFO ...}` name conflicts in Windows .
124
+ + So from this version begin: the compile flags: `-DLOGGING_LEVEL=WARNING` must be changed to `-DLOGGING_LEVEL=LL_WARNING`
125
+
126
+ ## v0.5.1
127
+
128
+ + add `ThreadPool::Stop()` to wait util all the threads finished.
129
+ If Stop() has not been called, it will be called when the ThreadPool destructing.
130
+
131
+ ## v0.5.0
132
+
133
+ + Reorganized directories: include/ -> include/limonp/ ... and so on.
134
+ + Add `NewClosure` in Closure.hpp, 0~3 arguments have been supported.
135
+ + Update ThreadPool, use `NewClosure` instead of `CreateTask`
136
+
137
+ ## v0.4.1
138
+
139
+ + `CHECK(exp) << "log message"` supported;
140
+
141
+ ## v0.4.0
142
+
143
+ + add test/demo.cc as example.
144
+ + move `print` macro to StdExtension.hpp
145
+ + BigChange: rewrite `log` module, use `LOG(INFO) << "xxx" ` instead `LogInfo` .
146
+ + remove HandyMacro.hpp, add CHECK in Logging.hpp instead.
147
+
148
+ ## v0.3.0
149
+
150
+ + remove 'MysqlClient.hpp', 'InitOnOff.hpp', 'CastFloat.hpp'
151
+ + add 'Closure.hpp'
152
+ + uniform code style
153
+
154
+ ## v0.2.0
155
+
156
+ + `namespace limonp`, not `Limonp` .
157
+
158
+ ## v0.1.0
159
+
160
+ + Basic functions
@@ -0,0 +1,61 @@
1
+ cmake_minimum_required(VERSION 3.14)
2
+
3
+ PROJECT(limonp
4
+ LANGUAGES CXX)
5
+
6
+ ################
7
+ # cmake config #
8
+ ################
9
+
10
+ if(NOT DEFINED CMAKE_CXX_STANDARD)
11
+ set(CMAKE_CXX_STANDARD 11)
12
+ endif()
13
+ message(STATUS "CMAKE_CXX_STANDARD is ${CMAKE_CXX_STANDARD}")
14
+
15
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
16
+ set(CMAKE_CXX_EXTENSIONS OFF)
17
+
18
+
19
+ ##############
20
+ # dependency #
21
+ ##############
22
+ include(GNUInstallDirs)
23
+
24
+ ##########
25
+ # target #
26
+ ##########
27
+
28
+ add_library(${PROJECT_NAME} INTERFACE)
29
+ add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
30
+
31
+ target_include_directories(${PROJECT_NAME}
32
+ INTERFACE
33
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
34
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>)
35
+
36
+ ########
37
+ # test #
38
+ ########
39
+
40
+ ENABLE_TESTING()
41
+
42
+ ADD_SUBDIRECTORY(test)
43
+ ADD_TEST(NAME ./test/demo COMMAND ./test/demo)
44
+ ADD_TEST(NAME ./test/test.run COMMAND ./test/test.run)
45
+
46
+ ###########
47
+ # install #
48
+ ###########
49
+
50
+ include(GNUInstallDirs)
51
+
52
+ install(TARGETS ${PROJECT_NAME}
53
+ EXPORT ${PROJECT_NAME})
54
+
55
+ install(EXPORT ${PROJECT_NAME}
56
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/
57
+ NAMESPACE ${PROJECT_NAME}::
58
+ FILE ${PROJECT_NAME}-config.cmake)
59
+
60
+ install(DIRECTORY include/
61
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # limonp
2
+
3
+ [![CMake](https://github.com/yanyiwu/limonp/actions/workflows/cmake.yml/badge.svg)](https://github.com/yanyiwu/limonp/actions/workflows/cmake.yml)
4
+ [![Author](https://img.shields.io/badge/author-@yanyiwu-blue.svg?style=flat)](http://yanyiwu.com/)
5
+ [![Platform](https://img.shields.io/badge/platform-Linux,macOS,Windows-green.svg?style=flat)](https://github.com/yanyiwu/limonp)
6
+ [![Tag](https://img.shields.io/github/v/tag/yanyiwu/limonp.svg)](https://github.com/yanyiwu/limonp/releases)
7
+ [![License](https://img.shields.io/badge/license-MIT-yellow.svg?style=flat)](http://yanyiwu.mit-license.org)
8
+
9
+ ## Introduction
10
+
11
+ `C++` headers(hpp) with Python style.
12
+
13
+ ## Feature
14
+
15
+ + linking is a annoying thing, so I write these source code in headers file(`*.hpp`), you can use them only with `#include "xx.hpp"`, without linking *.a or *.so .
16
+
17
+ **`no linking , no hurts`**
18
+
19
+ ## Example
20
+
21
+ See Details in `test/demo.cpp`
22
+
23
+ ## Cases
24
+
25
+ 1. [CppJieba]
26
+
27
+ ## Reference
28
+
29
+ 1. `md5.hpp` is copied from network, you can find original author in source code(in comments).
30
+ 2. `MutexLock.hpp`, `BlockingQueue.hpp`, `Condition.hpp` reference from [muduo].
31
+
32
+ ## Contact
33
+
34
+ + i@yanyiwu.com
35
+
36
+ [CppJieba]:https://github.com/yanyiwu/cppjieba.git
37
+ [muduo]:https://github.com/chenshuo/muduo.git
38
+
@@ -55,12 +55,12 @@ class LocalVector {
55
55
  size_ = vec.size();
56
56
  capacity_ = vec.capacity();
57
57
  if(vec.buffer_ == vec.ptr_) {
58
- memcpy(buffer_, vec.buffer_, sizeof(T) * size_);
58
+ memcpy(static_cast<void*>(buffer_), vec.buffer_, sizeof(T) * size_);
59
59
  ptr_ = buffer_;
60
60
  } else {
61
61
  ptr_ = (T*) malloc(vec.capacity() * sizeof(T));
62
62
  assert(ptr_);
63
- memcpy(ptr_, vec.ptr_, vec.size() * sizeof(T));
63
+ memcpy(static_cast<void*>(ptr_), vec.ptr_, vec.size() * sizeof(T));
64
64
  }
65
65
  return *this;
66
66
  }
@@ -92,7 +92,7 @@ class LocalVector {
92
92
  assert(next);
93
93
  T * old = ptr_;
94
94
  ptr_ = next;
95
- memcpy(ptr_, old, sizeof(T) * capacity_);
95
+ memcpy(static_cast<void*>(ptr_), old, sizeof(T) * capacity_);
96
96
  capacity_ = size;
97
97
  if(old != buffer_) {
98
98
  free(old);
@@ -40,10 +40,24 @@ class Logger {
40
40
  }
41
41
  #endif
42
42
  assert(level_ <= sizeof(LOG_LEVEL_ARRAY)/sizeof(*LOG_LEVEL_ARRAY));
43
+
43
44
  char buf[32];
44
- time_t now;
45
- time(&now);
46
- strftime(buf, sizeof(buf), LOG_TIME_FORMAT, localtime(&now));
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
+ #else
55
+ struct tm * tm_tmp = localtime_r(&timeNow, &tmNow);
56
+ assert(tm_tmp != nullptr);
57
+ #endif
58
+
59
+ strftime(buf, sizeof(buf), LOG_TIME_FORMAT, &tmNow);
60
+
47
61
  stream_ << buf
48
62
  << " " << filename
49
63
  << ":" << lineno
@@ -11,6 +11,8 @@
11
11
  #include <algorithm>
12
12
  #include <cctype>
13
13
  #include <map>
14
+ #include <cassert>
15
+ #include <ctime>
14
16
  #include <stdint.h>
15
17
  #include <stdio.h>
16
18
  #include <stdarg.h>
@@ -84,12 +86,16 @@ inline bool IsSpace(unsigned c) {
84
86
  }
85
87
 
86
88
  inline std::string& LTrim(std::string &s) {
87
- s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<unsigned, bool>(IsSpace))));
88
- return s;
89
+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
90
+ return !std::isspace(ch);
91
+ }));
92
+ return s;
89
93
  }
90
94
 
91
95
  inline std::string& RTrim(std::string &s) {
92
- s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<unsigned, bool>(IsSpace))).base(), s.end());
96
+ s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
97
+ return !std::isspace(ch);
98
+ }).base(), s.end());
93
99
  return s;
94
100
  }
95
101
 
@@ -97,14 +103,16 @@ inline std::string& Trim(std::string &s) {
97
103
  return LTrim(RTrim(s));
98
104
  }
99
105
 
100
- inline std::string& LTrim(std::string & s, char x) {
101
- s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::bind2nd(std::equal_to<char>(), x))));
102
- return s;
106
+ inline std::string& LTrim(std::string& s, char x) {
107
+ s.erase(s.begin(), std::find_if(s.begin(), s.end(),
108
+ [x](unsigned char c) { return !std::isspace(c) && c != x; }));
109
+ return s;
103
110
  }
104
111
 
105
- inline std::string& RTrim(std::string & s, char x) {
106
- s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::bind2nd(std::equal_to<char>(), x))).base(), s.end());
107
- return s;
112
+ inline std::string& RTrim(std::string& s, char x) {
113
+ s.erase(std::find_if(s.rbegin(), s.rend(),
114
+ [x](unsigned char c) { return !std::isspace(c) && c != x; }).base(), s.end());
115
+ return s;
108
116
  }
109
117
 
110
118
  inline std::string& Trim(std::string &s, char x) {
@@ -349,8 +357,21 @@ void GBKTrans(Uint16ContainerConIter begin, Uint16ContainerConIter end, string&
349
357
  inline void GetTime(const string& format, string& timeStr) {
350
358
  time_t timeNow;
351
359
  time(&timeNow);
360
+
361
+ struct tm tmNow;
362
+
363
+ #if defined(_WIN32) || defined(_WIN64)
364
+ errno_t e = localtime_s(&tmNow, &timeNow);
365
+ assert(e == 0);
366
+ #else
367
+ struct tm * tm_tmp = localtime_r(&timeNow, &tmNow);
368
+ assert(tm_tmp != nullptr);
369
+ #endif
370
+
352
371
  timeStr.resize(64);
353
- size_t len = strftime((char*)timeStr.c_str(), timeStr.size(), format.c_str(), localtime(&timeNow));
372
+
373
+ size_t len = strftime((char*)timeStr.c_str(), timeStr.size(), format.c_str(), &tmNow);
374
+
354
375
  timeStr.resize(len);
355
376
  }
356
377
 
@@ -0,0 +1,8 @@
1
+ SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test)
2
+ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test/lib)
3
+
4
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
5
+
6
+ ADD_EXECUTABLE(demo demo.cpp)
7
+
8
+ ADD_SUBDIRECTORY(unittest)
@@ -0,0 +1,40 @@
1
+ #include "limonp/StringUtil.hpp"
2
+ #include "limonp/Logging.hpp"
3
+
4
+ using namespace std;
5
+
6
+ #define print(x) std::cout << x << std::endl
7
+
8
+ int main(int argc, char** argv) {
9
+ string strname = "hello, world";
10
+ print(strname); //hello, world
11
+ map<string, int> mp;
12
+ mp["hello"] = 1;
13
+ mp["world"] = 2;
14
+ print(mp); // {"hello":1, "world":2}
15
+
16
+ string res;
17
+ res << mp;
18
+ print(res); // {"hello":1, "world":2}
19
+
20
+ string str;
21
+ str = limonp::StringFormat("%s, %s", "hello", "world");
22
+ print(str); //hello, world
23
+
24
+ const char * a[] = {"hello", "world"};
25
+ str = limonp::Join(a, a + sizeof(a)/sizeof(*a), ",");
26
+ print(str); //hello,world
27
+
28
+ str = "hello, world";
29
+ vector<string> buf;
30
+ limonp::Split(str, buf, ",");
31
+ print(buf); //["hello", " world"]
32
+
33
+ int arr[] = {1,10,100,1000};
34
+ vector<int> vec_i(arr, arr + sizeof(arr)/sizeof(arr[0]));
35
+ print(vec_i); //[1, 10, 100, 1000]
36
+
37
+ XLOG(INFO) << "hello, world"; //2014-04-05 20:52:37 demo.cpp:35 INFO hello, world
38
+ //In the same way, `LOG(DEBUG),LOG(WARNING),LOG(ERROR),LOG(FATAL)`.
39
+ return EXIT_SUCCESS;
40
+ }
@@ -0,0 +1,5 @@
1
+
2
+ key1 = val1
3
+ ##this is comment
4
+
5
+ key2=val2
@@ -0,0 +1,3 @@
1
+ key1 = val1
2
+ ##this is comment
3
+ key2=val2
@@ -0,0 +1,50 @@
1
+ AT&T 3 nz
2
+ B�� 3 n
3
+ c# 3 nz
4
+ C# 3 nz
5
+ c++ 3 nz
6
+ C++ 3 nz
7
+ T�� 4 n
8
+ һ 217830 m
9
+ һһ 1670 m
10
+ һһ�� 11 m
11
+ һһ�� 3 m
12
+ һһ�� 8 m
13
+ һһ�о� 34 i
14
+ һһ�� 9 m
15
+ һһ��Ӧ 43 l
16
+ һһ�� 2 m
17
+ һһ���� 4 l
18
+ һ�� 18 d
19
+ һ����ʶ 3 i
20
+ һ���� 3 m
21
+ һ����� 24 m
22
+ һ�� 22 m
23
+ һ�߰˲� 3 l
24
+ һ�� 442 m
25
+ һ��һǧ 4 m
26
+ һ��һǧ��ٶ�ʮ�� 2 m
27
+ һ��һǧ�˰ٰ�ʮ�� 2 m
28
+ һ��һǧ��� 2 m
29
+ һ��һǧ���ʮ��� 4 m
30
+ һ����ǧ 5 m
31
+ һ����ǧ�� 2 m
32
+ һ����ǧ�� 2 m
33
+ һ����ǧ�໧ 2 m
34
+ һ���� 4 m
35
+ һ������ 4 m
36
+ һ����ǧ 8 m
37
+ һ����ǧ���һʮ�� 2 m
38
+ һ����ǧ��ٽ� 4 m
39
+ һ����ǧ���� 2 m
40
+ һ����ǧ�� 2 m
41
+ һ���� 124 m
42
+ һ������ 4 m
43
+ һ����ǧ 3 m
44
+ һ��� 62 m
45
+ һ���ǧ 2 m
46
+ һ���ǧ�� 2 m
47
+ һ��� 10 m
48
+ һ���ǧ 7 m
49
+ һ���ǧ�� 2 m
50
+ һ���ǧ��� 4 m