cppjieba_rb 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.travis.yml +26 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +81 -0
- data/Rakefile +20 -0
- data/cppjieba_rb.gemspec +50 -0
- data/ext/cppjieba/.gitignore +17 -0
- data/ext/cppjieba/.travis.yml +22 -0
- data/ext/cppjieba/CMakeLists.txt +28 -0
- data/ext/cppjieba/ChangeLog.md +236 -0
- data/ext/cppjieba/README.md +285 -0
- data/ext/cppjieba/README_EN.md +111 -0
- data/ext/cppjieba/appveyor.yml +32 -0
- data/ext/cppjieba/deps/CMakeLists.txt +1 -0
- data/ext/cppjieba/deps/gtest/CMakeLists.txt +5 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +283 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +230 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +1421 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +796 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +232 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +176 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +259 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +2155 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +58 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +308 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +210 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +1226 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +4822 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +1788 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +350 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +968 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +336 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +3330 -0
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +296 -0
- data/ext/cppjieba/deps/gtest/src/.deps/.dirstamp +0 -0
- data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +681 -0
- data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +509 -0
- data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
- data/ext/cppjieba/deps/gtest/src/gtest-all.cc +48 -0
- data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +1234 -0
- data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +380 -0
- data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +1038 -0
- data/ext/cppjieba/deps/gtest/src/gtest-port.cc +746 -0
- data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +356 -0
- data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +110 -0
- data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +110 -0
- data/ext/cppjieba/deps/gtest/src/gtest.cc +4898 -0
- data/ext/cppjieba/deps/gtest/src/gtest_main.cc +39 -0
- data/ext/cppjieba/deps/limonp/ArgvContext.hpp +70 -0
- data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +49 -0
- data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +67 -0
- data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +65 -0
- data/ext/cppjieba/deps/limonp/Closure.hpp +206 -0
- data/ext/cppjieba/deps/limonp/Colors.hpp +31 -0
- data/ext/cppjieba/deps/limonp/Condition.hpp +38 -0
- data/ext/cppjieba/deps/limonp/Config.hpp +103 -0
- data/ext/cppjieba/deps/limonp/FileLock.hpp +74 -0
- data/ext/cppjieba/deps/limonp/ForcePublic.hpp +7 -0
- data/ext/cppjieba/deps/limonp/LocalVector.hpp +139 -0
- data/ext/cppjieba/deps/limonp/Logging.hpp +76 -0
- data/ext/cppjieba/deps/limonp/Md5.hpp +411 -0
- data/ext/cppjieba/deps/limonp/MutexLock.hpp +51 -0
- data/ext/cppjieba/deps/limonp/NonCopyable.hpp +21 -0
- data/ext/cppjieba/deps/limonp/StdExtension.hpp +159 -0
- data/ext/cppjieba/deps/limonp/StringUtil.hpp +365 -0
- data/ext/cppjieba/deps/limonp/Thread.hpp +44 -0
- data/ext/cppjieba/deps/limonp/ThreadPool.hpp +86 -0
- data/ext/cppjieba/dict/README.md +31 -0
- data/ext/cppjieba/dict/hmm_model.utf8 +34 -0
- data/ext/cppjieba/dict/idf.utf8 +258826 -0
- data/ext/cppjieba/dict/jieba.dict.utf8 +348982 -0
- data/ext/cppjieba/dict/pos_dict/char_state_tab.utf8 +6653 -0
- data/ext/cppjieba/dict/pos_dict/prob_emit.utf8 +166 -0
- data/ext/cppjieba/dict/pos_dict/prob_start.utf8 +259 -0
- data/ext/cppjieba/dict/pos_dict/prob_trans.utf8 +5222 -0
- data/ext/cppjieba/dict/stop_words.utf8 +1534 -0
- data/ext/cppjieba/dict/user.dict.utf8 +4 -0
- data/ext/cppjieba/include/cppjieba/DictTrie.hpp +227 -0
- data/ext/cppjieba/include/cppjieba/FullSegment.hpp +93 -0
- data/ext/cppjieba/include/cppjieba/HMMModel.hpp +129 -0
- data/ext/cppjieba/include/cppjieba/HMMSegment.hpp +190 -0
- data/ext/cppjieba/include/cppjieba/Jieba.hpp +108 -0
- data/ext/cppjieba/include/cppjieba/KeywordExtractor.hpp +153 -0
- data/ext/cppjieba/include/cppjieba/MPSegment.hpp +137 -0
- data/ext/cppjieba/include/cppjieba/MixSegment.hpp +109 -0
- data/ext/cppjieba/include/cppjieba/PosTagger.hpp +77 -0
- data/ext/cppjieba/include/cppjieba/PreFilter.hpp +54 -0
- data/ext/cppjieba/include/cppjieba/QuerySegment.hpp +90 -0
- data/ext/cppjieba/include/cppjieba/SegmentBase.hpp +46 -0
- data/ext/cppjieba/include/cppjieba/SegmentTagged.hpp +23 -0
- data/ext/cppjieba/include/cppjieba/TextRankExtractor.hpp +190 -0
- data/ext/cppjieba/include/cppjieba/Trie.hpp +174 -0
- data/ext/cppjieba/include/cppjieba/Unicode.hpp +215 -0
- data/ext/cppjieba/test/CMakeLists.txt +5 -0
- data/ext/cppjieba/test/demo.cpp +80 -0
- data/ext/cppjieba/test/load_test.cpp +54 -0
- data/ext/cppjieba/test/testdata/curl.res +1 -0
- data/ext/cppjieba/test/testdata/extra_dict/jieba.dict.small.utf8 +109750 -0
- data/ext/cppjieba/test/testdata/gbk_dict/hmm_model.gbk +34 -0
- data/ext/cppjieba/test/testdata/gbk_dict/jieba.dict.gbk +348982 -0
- data/ext/cppjieba/test/testdata/jieba.dict.0.1.utf8 +93 -0
- data/ext/cppjieba/test/testdata/jieba.dict.0.utf8 +93 -0
- data/ext/cppjieba/test/testdata/jieba.dict.1.utf8 +67 -0
- data/ext/cppjieba/test/testdata/jieba.dict.2.utf8 +64 -0
- data/ext/cppjieba/test/testdata/load_test.urls +2 -0
- data/ext/cppjieba/test/testdata/review.100 +100 -0
- data/ext/cppjieba/test/testdata/review.100.res +200 -0
- data/ext/cppjieba/test/testdata/server.conf +19 -0
- data/ext/cppjieba/test/testdata/testlines.gbk +9 -0
- data/ext/cppjieba/test/testdata/testlines.utf8 +8 -0
- data/ext/cppjieba/test/testdata/userdict.2.utf8 +1 -0
- data/ext/cppjieba/test/testdata/userdict.english +2 -0
- data/ext/cppjieba/test/testdata/userdict.utf8 +8 -0
- data/ext/cppjieba/test/testdata/weicheng.utf8 +247 -0
- data/ext/cppjieba/test/unittest/CMakeLists.txt +24 -0
- data/ext/cppjieba/test/unittest/gtest_main.cpp +39 -0
- data/ext/cppjieba/test/unittest/jieba_test.cpp +133 -0
- data/ext/cppjieba/test/unittest/keyword_extractor_test.cpp +79 -0
- data/ext/cppjieba/test/unittest/pos_tagger_test.cpp +41 -0
- data/ext/cppjieba/test/unittest/pre_filter_test.cpp +43 -0
- data/ext/cppjieba/test/unittest/segments_test.cpp +256 -0
- data/ext/cppjieba/test/unittest/textrank_test.cpp +86 -0
- data/ext/cppjieba/test/unittest/trie_test.cpp +177 -0
- data/ext/cppjieba/test/unittest/unicode_test.cpp +43 -0
- data/ext/cppjieba_rb/cppjieba_rb.c +10 -0
- data/ext/cppjieba_rb/extconf.rb +26 -0
- data/ext/cppjieba_rb/internal.cc +148 -0
- data/lib/cppjieba_rb/segment.rb +20 -0
- data/lib/cppjieba_rb/version.rb +3 -0
- data/lib/cppjieba_rb.rb +34 -0
- data/test/test_keyword.rb +17 -0
- data/test/test_segment.rb +24 -0
- data/test/test_tagging.rb +19 -0
- metadata +244 -0
@@ -0,0 +1,336 @@
|
|
1
|
+
$$ -*- mode: c++; -*-
|
2
|
+
$var n = 10 $$ Maximum number of tuple fields we want to support.
|
3
|
+
$$ This meta comment fixes auto-indentation in Emacs. }}
|
4
|
+
// Copyright 2009 Google Inc.
|
5
|
+
// All Rights Reserved.
|
6
|
+
//
|
7
|
+
// Redistribution and use in source and binary forms, with or without
|
8
|
+
// modification, are permitted provided that the following conditions are
|
9
|
+
// met:
|
10
|
+
//
|
11
|
+
// * Redistributions of source code must retain the above copyright
|
12
|
+
// notice, this list of conditions and the following disclaimer.
|
13
|
+
// * Redistributions in binary form must reproduce the above
|
14
|
+
// copyright notice, this list of conditions and the following disclaimer
|
15
|
+
// in the documentation and/or other materials provided with the
|
16
|
+
// distribution.
|
17
|
+
// * Neither the name of Google Inc. nor the names of its
|
18
|
+
// contributors may be used to endorse or promote products derived from
|
19
|
+
// this software without specific prior written permission.
|
20
|
+
//
|
21
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
28
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
29
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
30
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
31
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
//
|
33
|
+
// Author: wan@google.com (Zhanyong Wan)
|
34
|
+
|
35
|
+
// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
|
36
|
+
|
37
|
+
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|
38
|
+
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|
39
|
+
|
40
|
+
#include <utility> // For ::std::pair.
|
41
|
+
|
42
|
+
// The compiler used in Symbian has a bug that prevents us from declaring the
|
43
|
+
// tuple template as a friend (it complains that tuple is redefined). This
|
44
|
+
// hack bypasses the bug by declaring the members that should otherwise be
|
45
|
+
// private as public.
|
46
|
+
// Sun Studio versions < 12 also have the above bug.
|
47
|
+
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
|
48
|
+
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
|
49
|
+
#else
|
50
|
+
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
|
51
|
+
template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \
|
52
|
+
private:
|
53
|
+
#endif
|
54
|
+
|
55
|
+
|
56
|
+
$range i 0..n-1
|
57
|
+
$range j 0..n
|
58
|
+
$range k 1..n
|
59
|
+
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
|
60
|
+
#define GTEST_0_TUPLE_(T) tuple<>
|
61
|
+
|
62
|
+
$for k [[
|
63
|
+
$range m 0..k-1
|
64
|
+
$range m2 k..n-1
|
65
|
+
#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]>
|
66
|
+
|
67
|
+
]]
|
68
|
+
|
69
|
+
// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
|
70
|
+
|
71
|
+
$for j [[
|
72
|
+
$range m 0..j-1
|
73
|
+
#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]]
|
74
|
+
|
75
|
+
|
76
|
+
]]
|
77
|
+
|
78
|
+
// In theory, defining stuff in the ::std namespace is undefined
|
79
|
+
// behavior. We can do this as we are playing the role of a standard
|
80
|
+
// library vendor.
|
81
|
+
namespace std {
|
82
|
+
namespace tr1 {
|
83
|
+
|
84
|
+
template <$for i, [[typename T$i = void]]>
|
85
|
+
class tuple;
|
86
|
+
|
87
|
+
// Anything in namespace gtest_internal is Google Test's INTERNAL
|
88
|
+
// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
|
89
|
+
namespace gtest_internal {
|
90
|
+
|
91
|
+
// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
|
92
|
+
template <typename T>
|
93
|
+
struct ByRef { typedef const T& type; }; // NOLINT
|
94
|
+
template <typename T>
|
95
|
+
struct ByRef<T&> { typedef T& type; }; // NOLINT
|
96
|
+
|
97
|
+
// A handy wrapper for ByRef.
|
98
|
+
#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
|
99
|
+
|
100
|
+
// AddRef<T>::type is T if T is a reference; otherwise it's T&. This
|
101
|
+
// is the same as tr1::add_reference<T>::type.
|
102
|
+
template <typename T>
|
103
|
+
struct AddRef { typedef T& type; }; // NOLINT
|
104
|
+
template <typename T>
|
105
|
+
struct AddRef<T&> { typedef T& type; }; // NOLINT
|
106
|
+
|
107
|
+
// A handy wrapper for AddRef.
|
108
|
+
#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
|
109
|
+
|
110
|
+
// A helper for implementing get<k>().
|
111
|
+
template <int k> class Get;
|
112
|
+
|
113
|
+
// A helper for implementing tuple_element<k, T>. kIndexValid is true
|
114
|
+
// iff k < the number of fields in tuple type T.
|
115
|
+
template <bool kIndexValid, int kIndex, class Tuple>
|
116
|
+
struct TupleElement;
|
117
|
+
|
118
|
+
|
119
|
+
$for i [[
|
120
|
+
template <GTEST_$(n)_TYPENAMES_(T)>
|
121
|
+
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T)> [[]]
|
122
|
+
{ typedef T$i type; };
|
123
|
+
|
124
|
+
|
125
|
+
]]
|
126
|
+
} // namespace gtest_internal
|
127
|
+
|
128
|
+
template <>
|
129
|
+
class tuple<> {
|
130
|
+
public:
|
131
|
+
tuple() {}
|
132
|
+
tuple(const tuple& /* t */) {}
|
133
|
+
tuple& operator=(const tuple& /* t */) { return *this; }
|
134
|
+
};
|
135
|
+
|
136
|
+
|
137
|
+
$for k [[
|
138
|
+
$range m 0..k-1
|
139
|
+
template <GTEST_$(k)_TYPENAMES_(T)>
|
140
|
+
class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] {
|
141
|
+
public:
|
142
|
+
template <int k> friend class gtest_internal::Get;
|
143
|
+
|
144
|
+
tuple() : $for m, [[f$(m)_()]] {}
|
145
|
+
|
146
|
+
explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]]
|
147
|
+
$for m, [[f$(m)_(f$m)]] {}
|
148
|
+
|
149
|
+
tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
|
150
|
+
|
151
|
+
template <GTEST_$(k)_TYPENAMES_(U)>
|
152
|
+
tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
|
153
|
+
|
154
|
+
$if k == 2 [[
|
155
|
+
template <typename U0, typename U1>
|
156
|
+
tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
|
157
|
+
|
158
|
+
]]
|
159
|
+
|
160
|
+
tuple& operator=(const tuple& t) { return CopyFrom(t); }
|
161
|
+
|
162
|
+
template <GTEST_$(k)_TYPENAMES_(U)>
|
163
|
+
tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) {
|
164
|
+
return CopyFrom(t);
|
165
|
+
}
|
166
|
+
|
167
|
+
$if k == 2 [[
|
168
|
+
template <typename U0, typename U1>
|
169
|
+
tuple& operator=(const ::std::pair<U0, U1>& p) {
|
170
|
+
f0_ = p.first;
|
171
|
+
f1_ = p.second;
|
172
|
+
return *this;
|
173
|
+
}
|
174
|
+
|
175
|
+
]]
|
176
|
+
|
177
|
+
GTEST_DECLARE_TUPLE_AS_FRIEND_
|
178
|
+
|
179
|
+
template <GTEST_$(k)_TYPENAMES_(U)>
|
180
|
+
tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) {
|
181
|
+
|
182
|
+
$for m [[
|
183
|
+
f$(m)_ = t.f$(m)_;
|
184
|
+
|
185
|
+
]]
|
186
|
+
return *this;
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
$for m [[
|
191
|
+
T$m f$(m)_;
|
192
|
+
|
193
|
+
]]
|
194
|
+
};
|
195
|
+
|
196
|
+
|
197
|
+
]]
|
198
|
+
// 6.1.3.2 Tuple creation functions.
|
199
|
+
|
200
|
+
// Known limitations: we don't support passing an
|
201
|
+
// std::tr1::reference_wrapper<T> to make_tuple(). And we don't
|
202
|
+
// implement tie().
|
203
|
+
|
204
|
+
inline tuple<> make_tuple() { return tuple<>(); }
|
205
|
+
|
206
|
+
$for k [[
|
207
|
+
$range m 0..k-1
|
208
|
+
|
209
|
+
template <GTEST_$(k)_TYPENAMES_(T)>
|
210
|
+
inline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) {
|
211
|
+
return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]);
|
212
|
+
}
|
213
|
+
|
214
|
+
]]
|
215
|
+
|
216
|
+
// 6.1.3.3 Tuple helper classes.
|
217
|
+
|
218
|
+
template <typename Tuple> struct tuple_size;
|
219
|
+
|
220
|
+
|
221
|
+
$for j [[
|
222
|
+
template <GTEST_$(j)_TYPENAMES_(T)>
|
223
|
+
struct tuple_size<GTEST_$(j)_TUPLE_(T)> { static const int value = $j; };
|
224
|
+
|
225
|
+
|
226
|
+
]]
|
227
|
+
template <int k, class Tuple>
|
228
|
+
struct tuple_element {
|
229
|
+
typedef typename gtest_internal::TupleElement<
|
230
|
+
k < (tuple_size<Tuple>::value), k, Tuple>::type type;
|
231
|
+
};
|
232
|
+
|
233
|
+
#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
|
234
|
+
|
235
|
+
// 6.1.3.4 Element access.
|
236
|
+
|
237
|
+
namespace gtest_internal {
|
238
|
+
|
239
|
+
|
240
|
+
$for i [[
|
241
|
+
template <>
|
242
|
+
class Get<$i> {
|
243
|
+
public:
|
244
|
+
template <class Tuple>
|
245
|
+
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
|
246
|
+
Field(Tuple& t) { return t.f$(i)_; } // NOLINT
|
247
|
+
|
248
|
+
template <class Tuple>
|
249
|
+
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
|
250
|
+
ConstField(const Tuple& t) { return t.f$(i)_; }
|
251
|
+
};
|
252
|
+
|
253
|
+
|
254
|
+
]]
|
255
|
+
} // namespace gtest_internal
|
256
|
+
|
257
|
+
template <int k, GTEST_$(n)_TYPENAMES_(T)>
|
258
|
+
GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
|
259
|
+
get(GTEST_$(n)_TUPLE_(T)& t) {
|
260
|
+
return gtest_internal::Get<k>::Field(t);
|
261
|
+
}
|
262
|
+
|
263
|
+
template <int k, GTEST_$(n)_TYPENAMES_(T)>
|
264
|
+
GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
|
265
|
+
get(const GTEST_$(n)_TUPLE_(T)& t) {
|
266
|
+
return gtest_internal::Get<k>::ConstField(t);
|
267
|
+
}
|
268
|
+
|
269
|
+
// 6.1.3.5 Relational operators
|
270
|
+
|
271
|
+
// We only implement == and !=, as we don't have a need for the rest yet.
|
272
|
+
|
273
|
+
namespace gtest_internal {
|
274
|
+
|
275
|
+
// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
|
276
|
+
// first k fields of t1 equals the first k fields of t2.
|
277
|
+
// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
|
278
|
+
// k1 != k2.
|
279
|
+
template <int kSize1, int kSize2>
|
280
|
+
struct SameSizeTuplePrefixComparator;
|
281
|
+
|
282
|
+
template <>
|
283
|
+
struct SameSizeTuplePrefixComparator<0, 0> {
|
284
|
+
template <class Tuple1, class Tuple2>
|
285
|
+
static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
|
286
|
+
return true;
|
287
|
+
}
|
288
|
+
};
|
289
|
+
|
290
|
+
template <int k>
|
291
|
+
struct SameSizeTuplePrefixComparator<k, k> {
|
292
|
+
template <class Tuple1, class Tuple2>
|
293
|
+
static bool Eq(const Tuple1& t1, const Tuple2& t2) {
|
294
|
+
return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
|
295
|
+
::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
|
296
|
+
}
|
297
|
+
};
|
298
|
+
|
299
|
+
} // namespace gtest_internal
|
300
|
+
|
301
|
+
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
|
302
|
+
inline bool operator==(const GTEST_$(n)_TUPLE_(T)& t,
|
303
|
+
const GTEST_$(n)_TUPLE_(U)& u) {
|
304
|
+
return gtest_internal::SameSizeTuplePrefixComparator<
|
305
|
+
tuple_size<GTEST_$(n)_TUPLE_(T)>::value,
|
306
|
+
tuple_size<GTEST_$(n)_TUPLE_(U)>::value>::Eq(t, u);
|
307
|
+
}
|
308
|
+
|
309
|
+
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
|
310
|
+
inline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t,
|
311
|
+
const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); }
|
312
|
+
|
313
|
+
// 6.1.4 Pairs.
|
314
|
+
// Unimplemented.
|
315
|
+
|
316
|
+
} // namespace tr1
|
317
|
+
} // namespace std
|
318
|
+
|
319
|
+
|
320
|
+
$for j [[
|
321
|
+
#undef GTEST_$(j)_TUPLE_
|
322
|
+
|
323
|
+
]]
|
324
|
+
|
325
|
+
|
326
|
+
$for j [[
|
327
|
+
#undef GTEST_$(j)_TYPENAMES_
|
328
|
+
|
329
|
+
]]
|
330
|
+
|
331
|
+
#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
|
332
|
+
#undef GTEST_BY_REF_
|
333
|
+
#undef GTEST_ADD_REF_
|
334
|
+
#undef GTEST_TUPLE_ELEMENT_
|
335
|
+
|
336
|
+
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|