isotree 0.2.2 → 0.3.0

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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/LICENSE.txt +2 -2
  4. data/README.md +32 -14
  5. data/ext/isotree/ext.cpp +144 -31
  6. data/ext/isotree/extconf.rb +7 -7
  7. data/lib/isotree/isolation_forest.rb +110 -30
  8. data/lib/isotree/version.rb +1 -1
  9. data/vendor/isotree/LICENSE +1 -1
  10. data/vendor/isotree/README.md +165 -27
  11. data/vendor/isotree/include/isotree.hpp +2111 -0
  12. data/vendor/isotree/include/isotree_oop.hpp +394 -0
  13. data/vendor/isotree/inst/COPYRIGHTS +62 -0
  14. data/vendor/isotree/src/RcppExports.cpp +525 -52
  15. data/vendor/isotree/src/Rwrapper.cpp +1931 -268
  16. data/vendor/isotree/src/c_interface.cpp +953 -0
  17. data/vendor/isotree/src/crit.hpp +4232 -0
  18. data/vendor/isotree/src/dist.hpp +1886 -0
  19. data/vendor/isotree/src/exp_depth_table.hpp +134 -0
  20. data/vendor/isotree/src/extended.hpp +1444 -0
  21. data/vendor/isotree/src/external_facing_generic.hpp +399 -0
  22. data/vendor/isotree/src/fit_model.hpp +2401 -0
  23. data/vendor/isotree/src/{dealloc.cpp → headers_joined.hpp} +38 -22
  24. data/vendor/isotree/src/helpers_iforest.hpp +813 -0
  25. data/vendor/isotree/src/{impute.cpp → impute.hpp} +353 -122
  26. data/vendor/isotree/src/indexer.cpp +515 -0
  27. data/vendor/isotree/src/instantiate_template_headers.cpp +118 -0
  28. data/vendor/isotree/src/instantiate_template_headers.hpp +240 -0
  29. data/vendor/isotree/src/isoforest.hpp +1659 -0
  30. data/vendor/isotree/src/isotree.hpp +1804 -392
  31. data/vendor/isotree/src/isotree_exportable.hpp +99 -0
  32. data/vendor/isotree/src/merge_models.cpp +159 -16
  33. data/vendor/isotree/src/mult.hpp +1321 -0
  34. data/vendor/isotree/src/oop_interface.cpp +842 -0
  35. data/vendor/isotree/src/oop_interface.hpp +278 -0
  36. data/vendor/isotree/src/other_helpers.hpp +219 -0
  37. data/vendor/isotree/src/predict.hpp +1932 -0
  38. data/vendor/isotree/src/python_helpers.hpp +134 -0
  39. data/vendor/isotree/src/ref_indexer.hpp +154 -0
  40. data/vendor/isotree/src/robinmap/LICENSE +21 -0
  41. data/vendor/isotree/src/robinmap/README.md +483 -0
  42. data/vendor/isotree/src/robinmap/include/tsl/robin_growth_policy.h +406 -0
  43. data/vendor/isotree/src/robinmap/include/tsl/robin_hash.h +1620 -0
  44. data/vendor/isotree/src/robinmap/include/tsl/robin_map.h +807 -0
  45. data/vendor/isotree/src/robinmap/include/tsl/robin_set.h +660 -0
  46. data/vendor/isotree/src/serialize.cpp +4300 -139
  47. data/vendor/isotree/src/sql.cpp +141 -59
  48. data/vendor/isotree/src/subset_models.cpp +174 -0
  49. data/vendor/isotree/src/utils.hpp +3808 -0
  50. data/vendor/isotree/src/xoshiro.hpp +467 -0
  51. data/vendor/isotree/src/ziggurat.hpp +405 -0
  52. metadata +38 -104
  53. data/vendor/cereal/LICENSE +0 -24
  54. data/vendor/cereal/README.md +0 -85
  55. data/vendor/cereal/include/cereal/access.hpp +0 -351
  56. data/vendor/cereal/include/cereal/archives/adapters.hpp +0 -163
  57. data/vendor/cereal/include/cereal/archives/binary.hpp +0 -169
  58. data/vendor/cereal/include/cereal/archives/json.hpp +0 -1019
  59. data/vendor/cereal/include/cereal/archives/portable_binary.hpp +0 -334
  60. data/vendor/cereal/include/cereal/archives/xml.hpp +0 -956
  61. data/vendor/cereal/include/cereal/cereal.hpp +0 -1089
  62. data/vendor/cereal/include/cereal/details/helpers.hpp +0 -422
  63. data/vendor/cereal/include/cereal/details/polymorphic_impl.hpp +0 -796
  64. data/vendor/cereal/include/cereal/details/polymorphic_impl_fwd.hpp +0 -65
  65. data/vendor/cereal/include/cereal/details/static_object.hpp +0 -127
  66. data/vendor/cereal/include/cereal/details/traits.hpp +0 -1411
  67. data/vendor/cereal/include/cereal/details/util.hpp +0 -84
  68. data/vendor/cereal/include/cereal/external/base64.hpp +0 -134
  69. data/vendor/cereal/include/cereal/external/rapidjson/allocators.h +0 -284
  70. data/vendor/cereal/include/cereal/external/rapidjson/cursorstreamwrapper.h +0 -78
  71. data/vendor/cereal/include/cereal/external/rapidjson/document.h +0 -2652
  72. data/vendor/cereal/include/cereal/external/rapidjson/encodedstream.h +0 -299
  73. data/vendor/cereal/include/cereal/external/rapidjson/encodings.h +0 -716
  74. data/vendor/cereal/include/cereal/external/rapidjson/error/en.h +0 -74
  75. data/vendor/cereal/include/cereal/external/rapidjson/error/error.h +0 -161
  76. data/vendor/cereal/include/cereal/external/rapidjson/filereadstream.h +0 -99
  77. data/vendor/cereal/include/cereal/external/rapidjson/filewritestream.h +0 -104
  78. data/vendor/cereal/include/cereal/external/rapidjson/fwd.h +0 -151
  79. data/vendor/cereal/include/cereal/external/rapidjson/internal/biginteger.h +0 -290
  80. data/vendor/cereal/include/cereal/external/rapidjson/internal/diyfp.h +0 -271
  81. data/vendor/cereal/include/cereal/external/rapidjson/internal/dtoa.h +0 -245
  82. data/vendor/cereal/include/cereal/external/rapidjson/internal/ieee754.h +0 -78
  83. data/vendor/cereal/include/cereal/external/rapidjson/internal/itoa.h +0 -308
  84. data/vendor/cereal/include/cereal/external/rapidjson/internal/meta.h +0 -186
  85. data/vendor/cereal/include/cereal/external/rapidjson/internal/pow10.h +0 -55
  86. data/vendor/cereal/include/cereal/external/rapidjson/internal/regex.h +0 -740
  87. data/vendor/cereal/include/cereal/external/rapidjson/internal/stack.h +0 -232
  88. data/vendor/cereal/include/cereal/external/rapidjson/internal/strfunc.h +0 -69
  89. data/vendor/cereal/include/cereal/external/rapidjson/internal/strtod.h +0 -290
  90. data/vendor/cereal/include/cereal/external/rapidjson/internal/swap.h +0 -46
  91. data/vendor/cereal/include/cereal/external/rapidjson/istreamwrapper.h +0 -128
  92. data/vendor/cereal/include/cereal/external/rapidjson/memorybuffer.h +0 -70
  93. data/vendor/cereal/include/cereal/external/rapidjson/memorystream.h +0 -71
  94. data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/inttypes.h +0 -316
  95. data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/stdint.h +0 -300
  96. data/vendor/cereal/include/cereal/external/rapidjson/ostreamwrapper.h +0 -81
  97. data/vendor/cereal/include/cereal/external/rapidjson/pointer.h +0 -1414
  98. data/vendor/cereal/include/cereal/external/rapidjson/prettywriter.h +0 -277
  99. data/vendor/cereal/include/cereal/external/rapidjson/rapidjson.h +0 -656
  100. data/vendor/cereal/include/cereal/external/rapidjson/reader.h +0 -2230
  101. data/vendor/cereal/include/cereal/external/rapidjson/schema.h +0 -2497
  102. data/vendor/cereal/include/cereal/external/rapidjson/stream.h +0 -223
  103. data/vendor/cereal/include/cereal/external/rapidjson/stringbuffer.h +0 -121
  104. data/vendor/cereal/include/cereal/external/rapidjson/writer.h +0 -709
  105. data/vendor/cereal/include/cereal/external/rapidxml/license.txt +0 -52
  106. data/vendor/cereal/include/cereal/external/rapidxml/manual.html +0 -406
  107. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml.hpp +0 -2624
  108. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_iterators.hpp +0 -175
  109. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_print.hpp +0 -428
  110. data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_utils.hpp +0 -123
  111. data/vendor/cereal/include/cereal/macros.hpp +0 -154
  112. data/vendor/cereal/include/cereal/specialize.hpp +0 -139
  113. data/vendor/cereal/include/cereal/types/array.hpp +0 -79
  114. data/vendor/cereal/include/cereal/types/atomic.hpp +0 -55
  115. data/vendor/cereal/include/cereal/types/base_class.hpp +0 -203
  116. data/vendor/cereal/include/cereal/types/bitset.hpp +0 -176
  117. data/vendor/cereal/include/cereal/types/boost_variant.hpp +0 -164
  118. data/vendor/cereal/include/cereal/types/chrono.hpp +0 -72
  119. data/vendor/cereal/include/cereal/types/common.hpp +0 -129
  120. data/vendor/cereal/include/cereal/types/complex.hpp +0 -56
  121. data/vendor/cereal/include/cereal/types/concepts/pair_associative_container.hpp +0 -73
  122. data/vendor/cereal/include/cereal/types/deque.hpp +0 -62
  123. data/vendor/cereal/include/cereal/types/forward_list.hpp +0 -68
  124. data/vendor/cereal/include/cereal/types/functional.hpp +0 -43
  125. data/vendor/cereal/include/cereal/types/list.hpp +0 -62
  126. data/vendor/cereal/include/cereal/types/map.hpp +0 -36
  127. data/vendor/cereal/include/cereal/types/memory.hpp +0 -425
  128. data/vendor/cereal/include/cereal/types/optional.hpp +0 -66
  129. data/vendor/cereal/include/cereal/types/polymorphic.hpp +0 -483
  130. data/vendor/cereal/include/cereal/types/queue.hpp +0 -132
  131. data/vendor/cereal/include/cereal/types/set.hpp +0 -103
  132. data/vendor/cereal/include/cereal/types/stack.hpp +0 -76
  133. data/vendor/cereal/include/cereal/types/string.hpp +0 -61
  134. data/vendor/cereal/include/cereal/types/tuple.hpp +0 -123
  135. data/vendor/cereal/include/cereal/types/unordered_map.hpp +0 -36
  136. data/vendor/cereal/include/cereal/types/unordered_set.hpp +0 -99
  137. data/vendor/cereal/include/cereal/types/utility.hpp +0 -47
  138. data/vendor/cereal/include/cereal/types/valarray.hpp +0 -89
  139. data/vendor/cereal/include/cereal/types/variant.hpp +0 -109
  140. data/vendor/cereal/include/cereal/types/vector.hpp +0 -112
  141. data/vendor/cereal/include/cereal/version.hpp +0 -52
  142. data/vendor/isotree/src/Makevars +0 -4
  143. data/vendor/isotree/src/crit.cpp +0 -912
  144. data/vendor/isotree/src/dist.cpp +0 -749
  145. data/vendor/isotree/src/extended.cpp +0 -790
  146. data/vendor/isotree/src/fit_model.cpp +0 -1090
  147. data/vendor/isotree/src/helpers_iforest.cpp +0 -324
  148. data/vendor/isotree/src/isoforest.cpp +0 -771
  149. data/vendor/isotree/src/mult.cpp +0 -607
  150. data/vendor/isotree/src/predict.cpp +0 -853
  151. data/vendor/isotree/src/utils.cpp +0 -1566
@@ -1,223 +0,0 @@
1
- // Tencent is pleased to support the open source community by making RapidJSON available.
2
- //
3
- // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4
- //
5
- // Licensed under the MIT License (the "License"); you may not use this file except
6
- // in compliance with the License. You may obtain a copy of the License at
7
- //
8
- // http://opensource.org/licenses/MIT
9
- //
10
- // Unless required by applicable law or agreed to in writing, software distributed
11
- // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
- // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
- // specific language governing permissions and limitations under the License.
14
-
15
- #include "rapidjson.h"
16
-
17
- #ifndef CEREAL_RAPIDJSON_STREAM_H_
18
- #define CEREAL_RAPIDJSON_STREAM_H_
19
-
20
- #include "encodings.h"
21
-
22
- CEREAL_RAPIDJSON_NAMESPACE_BEGIN
23
-
24
- ///////////////////////////////////////////////////////////////////////////////
25
- // Stream
26
-
27
- /*! \class rapidjson::Stream
28
- \brief Concept for reading and writing characters.
29
-
30
- For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd().
31
-
32
- For write-only stream, only need to implement Put() and Flush().
33
-
34
- \code
35
- concept Stream {
36
- typename Ch; //!< Character type of the stream.
37
-
38
- //! Read the current character from stream without moving the read cursor.
39
- Ch Peek() const;
40
-
41
- //! Read the current character from stream and moving the read cursor to next character.
42
- Ch Take();
43
-
44
- //! Get the current read cursor.
45
- //! \return Number of characters read from start.
46
- size_t Tell();
47
-
48
- //! Begin writing operation at the current read pointer.
49
- //! \return The begin writer pointer.
50
- Ch* PutBegin();
51
-
52
- //! Write a character.
53
- void Put(Ch c);
54
-
55
- //! Flush the buffer.
56
- void Flush();
57
-
58
- //! End the writing operation.
59
- //! \param begin The begin write pointer returned by PutBegin().
60
- //! \return Number of characters written.
61
- size_t PutEnd(Ch* begin);
62
- }
63
- \endcode
64
- */
65
-
66
- //! Provides additional information for stream.
67
- /*!
68
- By using traits pattern, this type provides a default configuration for stream.
69
- For custom stream, this type can be specialized for other configuration.
70
- See TEST(Reader, CustomStringStream) in readertest.cpp for example.
71
- */
72
- template<typename Stream>
73
- struct StreamTraits {
74
- //! Whether to make local copy of stream for optimization during parsing.
75
- /*!
76
- By default, for safety, streams do not use local copy optimization.
77
- Stream that can be copied fast should specialize this, like StreamTraits<StringStream>.
78
- */
79
- enum { copyOptimization = 0 };
80
- };
81
-
82
- //! Reserve n characters for writing to a stream.
83
- template<typename Stream>
84
- inline void PutReserve(Stream& stream, size_t count) {
85
- (void)stream;
86
- (void)count;
87
- }
88
-
89
- //! Write character to a stream, presuming buffer is reserved.
90
- template<typename Stream>
91
- inline void PutUnsafe(Stream& stream, typename Stream::Ch c) {
92
- stream.Put(c);
93
- }
94
-
95
- //! Put N copies of a character to a stream.
96
- template<typename Stream, typename Ch>
97
- inline void PutN(Stream& stream, Ch c, size_t n) {
98
- PutReserve(stream, n);
99
- for (size_t i = 0; i < n; i++)
100
- PutUnsafe(stream, c);
101
- }
102
-
103
- ///////////////////////////////////////////////////////////////////////////////
104
- // GenericStreamWrapper
105
-
106
- //! A Stream Wrapper
107
- /*! \tThis string stream is a wrapper for any stream by just forwarding any
108
- \treceived message to the origin stream.
109
- \note implements Stream concept
110
- */
111
-
112
- #if defined(_MSC_VER) && _MSC_VER <= 1800
113
- CEREAL_RAPIDJSON_DIAG_PUSH
114
- CEREAL_RAPIDJSON_DIAG_OFF(4702) // unreachable code
115
- CEREAL_RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
116
- #endif
117
-
118
- template <typename InputStream, typename Encoding = UTF8<> >
119
- class GenericStreamWrapper {
120
- public:
121
- typedef typename Encoding::Ch Ch;
122
- GenericStreamWrapper(InputStream& is): is_(is) {}
123
-
124
- Ch Peek() const { return is_.Peek(); }
125
- Ch Take() { return is_.Take(); }
126
- size_t Tell() { return is_.Tell(); }
127
- Ch* PutBegin() { return is_.PutBegin(); }
128
- void Put(Ch ch) { is_.Put(ch); }
129
- void Flush() { is_.Flush(); }
130
- size_t PutEnd(Ch* ch) { return is_.PutEnd(ch); }
131
-
132
- // wrapper for MemoryStream
133
- const Ch* Peek4() const { return is_.Peek4(); }
134
-
135
- // wrapper for AutoUTFInputStream
136
- UTFType GetType() const { return is_.GetType(); }
137
- bool HasBOM() const { return is_.HasBOM(); }
138
-
139
- protected:
140
- InputStream& is_;
141
- };
142
-
143
- #if defined(_MSC_VER) && _MSC_VER <= 1800
144
- CEREAL_RAPIDJSON_DIAG_POP
145
- #endif
146
-
147
- ///////////////////////////////////////////////////////////////////////////////
148
- // StringStream
149
-
150
- //! Read-only string stream.
151
- /*! \note implements Stream concept
152
- */
153
- template <typename Encoding>
154
- struct GenericStringStream {
155
- typedef typename Encoding::Ch Ch;
156
-
157
- GenericStringStream(const Ch *src) : src_(src), head_(src) {}
158
-
159
- Ch Peek() const { return *src_; }
160
- Ch Take() { return *src_++; }
161
- size_t Tell() const { return static_cast<size_t>(src_ - head_); }
162
-
163
- Ch* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; }
164
- void Put(Ch) { CEREAL_RAPIDJSON_ASSERT(false); }
165
- void Flush() { CEREAL_RAPIDJSON_ASSERT(false); }
166
- size_t PutEnd(Ch*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; }
167
-
168
- const Ch* src_; //!< Current read position.
169
- const Ch* head_; //!< Original head of the string.
170
- };
171
-
172
- template <typename Encoding>
173
- struct StreamTraits<GenericStringStream<Encoding> > {
174
- enum { copyOptimization = 1 };
175
- };
176
-
177
- //! String stream with UTF8 encoding.
178
- typedef GenericStringStream<UTF8<> > StringStream;
179
-
180
- ///////////////////////////////////////////////////////////////////////////////
181
- // InsituStringStream
182
-
183
- //! A read-write string stream.
184
- /*! This string stream is particularly designed for in-situ parsing.
185
- \note implements Stream concept
186
- */
187
- template <typename Encoding>
188
- struct GenericInsituStringStream {
189
- typedef typename Encoding::Ch Ch;
190
-
191
- GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {}
192
-
193
- // Read
194
- Ch Peek() { return *src_; }
195
- Ch Take() { return *src_++; }
196
- size_t Tell() { return static_cast<size_t>(src_ - head_); }
197
-
198
- // Write
199
- void Put(Ch c) { CEREAL_RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; }
200
-
201
- Ch* PutBegin() { return dst_ = src_; }
202
- size_t PutEnd(Ch* begin) { return static_cast<size_t>(dst_ - begin); }
203
- void Flush() {}
204
-
205
- Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; }
206
- void Pop(size_t count) { dst_ -= count; }
207
-
208
- Ch* src_;
209
- Ch* dst_;
210
- Ch* head_;
211
- };
212
-
213
- template <typename Encoding>
214
- struct StreamTraits<GenericInsituStringStream<Encoding> > {
215
- enum { copyOptimization = 1 };
216
- };
217
-
218
- //! Insitu string stream with UTF8 encoding.
219
- typedef GenericInsituStringStream<UTF8<> > InsituStringStream;
220
-
221
- CEREAL_RAPIDJSON_NAMESPACE_END
222
-
223
- #endif // CEREAL_RAPIDJSON_STREAM_H_
@@ -1,121 +0,0 @@
1
- // Tencent is pleased to support the open source community by making RapidJSON available.
2
- //
3
- // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4
- //
5
- // Licensed under the MIT License (the "License"); you may not use this file except
6
- // in compliance with the License. You may obtain a copy of the License at
7
- //
8
- // http://opensource.org/licenses/MIT
9
- //
10
- // Unless required by applicable law or agreed to in writing, software distributed
11
- // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
- // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
- // specific language governing permissions and limitations under the License.
14
-
15
- #ifndef CEREAL_RAPIDJSON_STRINGBUFFER_H_
16
- #define CEREAL_RAPIDJSON_STRINGBUFFER_H_
17
-
18
- #include "stream.h"
19
- #include "internal/stack.h"
20
-
21
- #if CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS
22
- #include <utility> // std::move
23
- #endif
24
-
25
- #include "internal/stack.h"
26
-
27
- #if defined(__clang__)
28
- CEREAL_RAPIDJSON_DIAG_PUSH
29
- CEREAL_RAPIDJSON_DIAG_OFF(c++98-compat)
30
- #endif
31
-
32
- CEREAL_RAPIDJSON_NAMESPACE_BEGIN
33
-
34
- //! Represents an in-memory output stream.
35
- /*!
36
- \tparam Encoding Encoding of the stream.
37
- \tparam Allocator type for allocating memory buffer.
38
- \note implements Stream concept
39
- */
40
- template <typename Encoding, typename Allocator = CrtAllocator>
41
- class GenericStringBuffer {
42
- public:
43
- typedef typename Encoding::Ch Ch;
44
-
45
- GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
46
-
47
- #if CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS
48
- GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {}
49
- GenericStringBuffer& operator=(GenericStringBuffer&& rhs) {
50
- if (&rhs != this)
51
- stack_ = std::move(rhs.stack_);
52
- return *this;
53
- }
54
- #endif
55
-
56
- void Put(Ch c) { *stack_.template Push<Ch>() = c; }
57
- void PutUnsafe(Ch c) { *stack_.template PushUnsafe<Ch>() = c; }
58
- void Flush() {}
59
-
60
- void Clear() { stack_.Clear(); }
61
- void ShrinkToFit() {
62
- // Push and pop a null terminator. This is safe.
63
- *stack_.template Push<Ch>() = '\0';
64
- stack_.ShrinkToFit();
65
- stack_.template Pop<Ch>(1);
66
- }
67
-
68
- void Reserve(size_t count) { stack_.template Reserve<Ch>(count); }
69
- Ch* Push(size_t count) { return stack_.template Push<Ch>(count); }
70
- Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe<Ch>(count); }
71
- void Pop(size_t count) { stack_.template Pop<Ch>(count); }
72
-
73
- const Ch* GetString() const {
74
- // Push and pop a null terminator. This is safe.
75
- *stack_.template Push<Ch>() = '\0';
76
- stack_.template Pop<Ch>(1);
77
-
78
- return stack_.template Bottom<Ch>();
79
- }
80
-
81
- //! Get the size of string in bytes in the string buffer.
82
- size_t GetSize() const { return stack_.GetSize(); }
83
-
84
- //! Get the length of string in Ch in the string buffer.
85
- size_t GetLength() const { return stack_.GetSize() / sizeof(Ch); }
86
-
87
- static const size_t kDefaultCapacity = 256;
88
- mutable internal::Stack<Allocator> stack_;
89
-
90
- private:
91
- // Prohibit copy constructor & assignment operator.
92
- GenericStringBuffer(const GenericStringBuffer&);
93
- GenericStringBuffer& operator=(const GenericStringBuffer&);
94
- };
95
-
96
- //! String buffer with UTF8 encoding
97
- typedef GenericStringBuffer<UTF8<> > StringBuffer;
98
-
99
- template<typename Encoding, typename Allocator>
100
- inline void PutReserve(GenericStringBuffer<Encoding, Allocator>& stream, size_t count) {
101
- stream.Reserve(count);
102
- }
103
-
104
- template<typename Encoding, typename Allocator>
105
- inline void PutUnsafe(GenericStringBuffer<Encoding, Allocator>& stream, typename Encoding::Ch c) {
106
- stream.PutUnsafe(c);
107
- }
108
-
109
- //! Implement specialized version of PutN() with memset() for better performance.
110
- template<>
111
- inline void PutN(GenericStringBuffer<UTF8<> >& stream, char c, size_t n) {
112
- std::memset(stream.stack_.Push<char>(n), c, n * sizeof(c));
113
- }
114
-
115
- CEREAL_RAPIDJSON_NAMESPACE_END
116
-
117
- #if defined(__clang__)
118
- CEREAL_RAPIDJSON_DIAG_POP
119
- #endif
120
-
121
- #endif // CEREAL_RAPIDJSON_STRINGBUFFER_H_