quasardb 3.14.2.dev1__cp312-cp312-win32.whl → 3.14.2.dev4__cp312-cp312-win32.whl
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.
Potentially problematic release.
This version of quasardb might be problematic. Click here for more details.
- quasardb/INSTALL.vcxproj +10 -5
- quasardb/__init__.py +33 -4
- quasardb/cmake_install.cmake +6 -0
- quasardb/date/ALL_BUILD.vcxproj +10 -9
- quasardb/date/CMakeFiles/Export/df49adab93b9e0c10c64f72458b31971/dateTargets.cmake +13 -13
- quasardb/date/CMakeFiles/generate.stamp.depend +4 -4
- quasardb/date/INSTALL.vcxproj +10 -5
- quasardb/date/cmake_install.cmake +6 -0
- quasardb/date/dateConfigVersion.cmake +0 -5
- quasardb/date/dateTargets.cmake +4 -8
- quasardb/numpy/__init__.py +58 -10
- quasardb/pandas/__init__.py +58 -102
- quasardb/pybind11/ALL_BUILD.vcxproj +10 -9
- quasardb/pybind11/CMakeFiles/generate.stamp.depend +14 -14
- quasardb/pybind11/INSTALL.vcxproj +10 -5
- quasardb/pybind11/cmake_install.cmake +6 -0
- quasardb/qdb_api.dll +0 -0
- quasardb/quasardb.cp312-win32.pyd +0 -0
- quasardb/range-v3/ALL_BUILD.vcxproj +10 -9
- quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +13 -13
- quasardb/range-v3/CMakeFiles/generate.stamp.depend +11 -11
- quasardb/range-v3/INSTALL.vcxproj +10 -5
- quasardb/range-v3/cmake_install.cmake +42 -0
- quasardb/range-v3/range-v3-config-version.cmake +0 -5
- quasardb/range-v3/range-v3-config.cmake +4 -8
- quasardb/range-v3/range.v3.headers.vcxproj +10 -9
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/METADATA +15 -10
- quasardb-3.14.2.dev4.dist-info/RECORD +54 -0
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/WHEEL +1 -1
- quasardb/CMakeLists.txt +0 -510
- quasardb/batch_column.hpp +0 -80
- quasardb/batch_inserter.hpp +0 -248
- quasardb/blob.hpp +0 -150
- quasardb/cluster.cpp +0 -89
- quasardb/cluster.hpp +0 -551
- quasardb/concepts.hpp +0 -278
- quasardb/continuous.cpp +0 -149
- quasardb/continuous.hpp +0 -106
- quasardb/convert/array.hpp +0 -282
- quasardb/convert/point.hpp +0 -330
- quasardb/convert/range.hpp +0 -282
- quasardb/convert/unicode.hpp +0 -598
- quasardb/convert/util.hpp +0 -22
- quasardb/convert/value.hpp +0 -711
- quasardb/convert.hpp +0 -38
- quasardb/detail/qdb_resource.hpp +0 -129
- quasardb/detail/ts_column.hpp +0 -224
- quasardb/direct_blob.hpp +0 -108
- quasardb/direct_handle.hpp +0 -83
- quasardb/direct_integer.hpp +0 -94
- quasardb/dispatch.hpp +0 -157
- quasardb/double.hpp +0 -87
- quasardb/entry.hpp +0 -273
- quasardb/error.hpp +0 -318
- quasardb/handle.cpp +0 -29
- quasardb/handle.hpp +0 -98
- quasardb/integer.hpp +0 -88
- quasardb/logger.cpp +0 -106
- quasardb/logger.hpp +0 -228
- quasardb/masked_array.hpp +0 -651
- quasardb/metrics.cpp +0 -103
- quasardb/metrics.hpp +0 -112
- quasardb/module.cpp +0 -76
- quasardb/module.hpp +0 -24
- quasardb/node.hpp +0 -123
- quasardb/numpy.cpp +0 -6
- quasardb/numpy.hpp +0 -489
- quasardb/object_tracker.hpp +0 -283
- quasardb/options.hpp +0 -244
- quasardb/perf.hpp +0 -336
- quasardb/pytypes.hpp +0 -221
- quasardb/query.cpp +0 -420
- quasardb/query.hpp +0 -92
- quasardb/reader/ts_row.hpp +0 -281
- quasardb/reader/ts_value.hpp +0 -245
- quasardb/remove_cvref.hpp +0 -31
- quasardb/string.hpp +0 -160
- quasardb/table.cpp +0 -289
- quasardb/table.hpp +0 -325
- quasardb/table_reader.hpp +0 -220
- quasardb/tag.hpp +0 -77
- quasardb/timestamp.hpp +0 -97
- quasardb/traits.hpp +0 -619
- quasardb/ts_iterator.hpp +0 -193
- quasardb/utils/blob_deque.hpp +0 -96
- quasardb/utils/ostream.hpp +0 -17
- quasardb/utils/permutation.hpp +0 -50
- quasardb/utils/stable_sort.hpp +0 -25
- quasardb/utils/unzip_view.hpp +0 -89
- quasardb/utils.cpp +0 -28
- quasardb/utils.hpp +0 -174
- quasardb/writer.cpp +0 -534
- quasardb/writer.hpp +0 -396
- quasardb-3.14.2.dev1.dist-info/RECORD +0 -118
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/LICENSE.md +0 -0
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/top_level.txt +0 -0
quasardb/convert/unicode.hpp
DELETED
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "../concepts.hpp"
|
|
4
|
-
#include <range/v3/range_fwd.hpp>
|
|
5
|
-
#include <range/v3/view/adaptor.hpp>
|
|
6
|
-
#include <range/v3/view/cache1.hpp>
|
|
7
|
-
#include <range/v3/view/transform.hpp>
|
|
8
|
-
#include <iostream>
|
|
9
|
-
#include <optional>
|
|
10
|
-
|
|
11
|
-
namespace qdb::convert::unicode
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
typedef std::uint32_t u32_type;
|
|
15
|
-
typedef std::uint8_t u8_type;
|
|
16
|
-
|
|
17
|
-
namespace detail
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* General purpose buffer which holds the "next" characters. This is useful for
|
|
22
|
-
* buffering purposes, e.g. when encoding codepoints to UTF-8, where advancing the
|
|
23
|
-
* iterator forward by 1 can actually emit 4 characters.
|
|
24
|
-
*/
|
|
25
|
-
template <typename CharT, std::size_t Width = (sizeof(u32_type) / sizeof(CharT))>
|
|
26
|
-
requires(1 <= Width && Width <= 4) struct next_chars
|
|
27
|
-
{
|
|
28
|
-
public:
|
|
29
|
-
constexpr next_chars() = default;
|
|
30
|
-
|
|
31
|
-
constexpr next_chars(CharT _1)
|
|
32
|
-
: xs_{{_1}}
|
|
33
|
-
, n_{1}
|
|
34
|
-
{}
|
|
35
|
-
|
|
36
|
-
constexpr next_chars(CharT _1, CharT _2) requires(Width >= 2)
|
|
37
|
-
: xs_{{_1, _2}}
|
|
38
|
-
, n_{2}
|
|
39
|
-
{}
|
|
40
|
-
|
|
41
|
-
constexpr next_chars(CharT _1, CharT _2, CharT _3) requires(Width >= 3)
|
|
42
|
-
: xs_{{_1, _2, _3}}
|
|
43
|
-
, n_{3}
|
|
44
|
-
{}
|
|
45
|
-
|
|
46
|
-
constexpr next_chars(CharT _1, CharT _2, CharT _3, CharT _4) requires(Width == 4)
|
|
47
|
-
: xs_{{_1, _2, _3, _4}}
|
|
48
|
-
, n_{4}
|
|
49
|
-
{}
|
|
50
|
-
|
|
51
|
-
constexpr inline CharT pop() noexcept
|
|
52
|
-
{
|
|
53
|
-
assert(p_ < n_);
|
|
54
|
-
return xs_[p_++];
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
constexpr inline CharT top() const noexcept
|
|
58
|
-
{
|
|
59
|
-
assert(p_ < n_);
|
|
60
|
-
return xs_[p_];
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
constexpr inline bool empty() const noexcept
|
|
64
|
-
{
|
|
65
|
-
return p_ == n_;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
constexpr inline std::size_t size() const noexcept
|
|
69
|
-
{
|
|
70
|
-
return n_ - p_;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private:
|
|
74
|
-
std::array<CharT, Width> xs_{{}};
|
|
75
|
-
std::size_t n_ = 0;
|
|
76
|
-
std::size_t p_ = 0;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
class code_point
|
|
80
|
-
{
|
|
81
|
-
private:
|
|
82
|
-
std::uint32_t value_;
|
|
83
|
-
|
|
84
|
-
public:
|
|
85
|
-
constexpr explicit code_point(std::uint32_t value)
|
|
86
|
-
: value_{value} {};
|
|
87
|
-
|
|
88
|
-
constexpr explicit code_point(std::uint32_t && value)
|
|
89
|
-
: value_{std::move(value)} {};
|
|
90
|
-
|
|
91
|
-
constexpr inline std::uint32_t get() const noexcept
|
|
92
|
-
{
|
|
93
|
-
return value_;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
friend constexpr bool operator==(code_point const & lhs, code_point const & rhs)
|
|
97
|
-
{
|
|
98
|
-
return lhs.value_ == rhs.value_;
|
|
99
|
-
}
|
|
100
|
-
friend constexpr bool operator!=(code_point const & lhs, code_point const & rhs)
|
|
101
|
-
{
|
|
102
|
-
return !(lhs == rhs);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
static_assert(sizeof(code_point) == sizeof(std::uint32_t));
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Functor that accepts codepoints and emits encoded UTF characters.
|
|
110
|
-
*/
|
|
111
|
-
template <typename CharT>
|
|
112
|
-
struct encode_fn_;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Functor for encoding codepoints to UTF-8.
|
|
116
|
-
*/
|
|
117
|
-
template <>
|
|
118
|
-
struct encode_fn_<u8_type>
|
|
119
|
-
{
|
|
120
|
-
inline next_chars<u8_type> operator()(std::uint32_t cp) const noexcept
|
|
121
|
-
{
|
|
122
|
-
if (cp >= (1L << 16)) [[unlikely]]
|
|
123
|
-
{
|
|
124
|
-
return {static_cast<u8_type>(0xf0 | (cp >> 18)),
|
|
125
|
-
static_cast<u8_type>(0x80 | ((cp >> 12) & 0x3f)),
|
|
126
|
-
static_cast<u8_type>(0x80 | ((cp >> 6) & 0x3f)),
|
|
127
|
-
static_cast<u8_type>(0x80 | ((cp >> 0) & 0x3f))};
|
|
128
|
-
}
|
|
129
|
-
else if (cp >= (1L << 11))
|
|
130
|
-
{
|
|
131
|
-
return {static_cast<u8_type>(0xe0 | (cp >> 12)),
|
|
132
|
-
static_cast<u8_type>(0x80 | ((cp >> 6) & 0x3f)),
|
|
133
|
-
static_cast<u8_type>(0x80 | ((cp >> 0) & 0x3f))};
|
|
134
|
-
}
|
|
135
|
-
else if (cp >= (1L << 7))
|
|
136
|
-
{
|
|
137
|
-
return {static_cast<u8_type>(0xc0 | (cp >> 6)),
|
|
138
|
-
static_cast<u8_type>(0x80 | ((cp >> 0) & 0x3f))};
|
|
139
|
-
}
|
|
140
|
-
else [[likely]]
|
|
141
|
-
{
|
|
142
|
-
return {static_cast<u8_type>(cp)};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
inline next_chars<u8_type> operator()(detail::code_point cp) const noexcept
|
|
147
|
-
{
|
|
148
|
-
return operator()(cp.get());
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Functor that accepts UTF encoded characters and yields codepoints.
|
|
154
|
-
*/
|
|
155
|
-
template <typename CharT>
|
|
156
|
-
struct decode_fn_;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* UTF-8 -> CodePoint functor.
|
|
160
|
-
*/
|
|
161
|
-
template <>
|
|
162
|
-
struct decode_fn_<u8_type>
|
|
163
|
-
{
|
|
164
|
-
template <ranges::input_iterator I>
|
|
165
|
-
inline detail::code_point operator()(I it) const noexcept
|
|
166
|
-
{
|
|
167
|
-
std::uint32_t cp;
|
|
168
|
-
|
|
169
|
-
if (*it < 0x80) [[likely]]
|
|
170
|
-
{
|
|
171
|
-
cp = *it++;
|
|
172
|
-
}
|
|
173
|
-
else if ((*it & 0xe0) == 0xc0)
|
|
174
|
-
{
|
|
175
|
-
cp = ((long)(*it++ & 0x1f) << 6) | ((long)(*it++ & 0x3f) << 0);
|
|
176
|
-
}
|
|
177
|
-
else if ((*it & 0xf0) == 0xe0)
|
|
178
|
-
{
|
|
179
|
-
cp = ((long)(*it++ & 0x0f) << 12) | ((long)(*it++ & 0x3f) << 6)
|
|
180
|
-
| ((long)(*it++ & 0x3f) << 0);
|
|
181
|
-
}
|
|
182
|
-
else if ((*it & 0xf8) == 0xf0 && (*it <= 0xf4))
|
|
183
|
-
{
|
|
184
|
-
cp = ((long)(*it++ & 0x07) << 18) | ((long)(*it++ & 0x3f) << 12)
|
|
185
|
-
| ((long)(*it++ & 0x3f) << 6) | ((long)(*it++ & 0x3f) << 0);
|
|
186
|
-
}
|
|
187
|
-
else [[unlikely]]
|
|
188
|
-
{
|
|
189
|
-
cp = -1;
|
|
190
|
-
++it;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return detail::code_point{cp};
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Counts how many UTF characters are represented by a code point.
|
|
199
|
-
*/
|
|
200
|
-
template <typename CharT>
|
|
201
|
-
struct count_fn_;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Counts how many UTF-8 characters are represented by a code point.
|
|
205
|
-
*/
|
|
206
|
-
template <>
|
|
207
|
-
struct count_fn_<u8_type>
|
|
208
|
-
{
|
|
209
|
-
inline std::size_t operator()(detail::code_point cp) const noexcept
|
|
210
|
-
{
|
|
211
|
-
if (cp.get() >= (1L << 16)) [[unlikely]]
|
|
212
|
-
{
|
|
213
|
-
return 4;
|
|
214
|
-
}
|
|
215
|
-
else if (cp.get() >= (1L << 11))
|
|
216
|
-
{
|
|
217
|
-
return 3;
|
|
218
|
-
}
|
|
219
|
-
else if (cp.get() >= (1L << 7))
|
|
220
|
-
{
|
|
221
|
-
return 2;
|
|
222
|
-
}
|
|
223
|
-
else [[likely]]
|
|
224
|
-
{
|
|
225
|
-
return 1;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Skips as many UTF characters as necessary to read a single code point.
|
|
232
|
-
*/
|
|
233
|
-
template <typename CharT>
|
|
234
|
-
struct skip_fn_;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Skips as many UTF-8 characters as necessary to read a single code point.
|
|
238
|
-
*/
|
|
239
|
-
template <>
|
|
240
|
-
struct skip_fn_<u8_type>
|
|
241
|
-
{
|
|
242
|
-
template <ranges::input_iterator I>
|
|
243
|
-
constexpr inline void operator()(I & it) const noexcept
|
|
244
|
-
{
|
|
245
|
-
if (*it < 0x80) [[likely]]
|
|
246
|
-
{
|
|
247
|
-
ranges::advance(it, 1);
|
|
248
|
-
}
|
|
249
|
-
else if ((*it & 0xe0) == 0xc0)
|
|
250
|
-
{
|
|
251
|
-
ranges::advance(it, 2);
|
|
252
|
-
}
|
|
253
|
-
else if ((*it & 0xf0) == 0xe0)
|
|
254
|
-
{
|
|
255
|
-
ranges::advance(it, 3);
|
|
256
|
-
}
|
|
257
|
-
else if ((*it & 0xf8) == 0xf0 && (*it <= 0xf4))
|
|
258
|
-
{
|
|
259
|
-
ranges::advance(it, 4);
|
|
260
|
-
}
|
|
261
|
-
else [[unlikely]]
|
|
262
|
-
{
|
|
263
|
-
ranges::advance(it, 1);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
namespace utf8
|
|
269
|
-
{
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* CodePoint -> UTF8 encoding view
|
|
273
|
-
*
|
|
274
|
-
* Reads codepoints and emits UTF8. Effectively used for conversion from numpy to qdb.
|
|
275
|
-
*/
|
|
276
|
-
template <typename Rng>
|
|
277
|
-
requires(concepts::forward_range_t<Rng, detail::code_point>) class encode_view_
|
|
278
|
-
: public ranges::view_facade<encode_view_<Rng>, ranges::finite>
|
|
279
|
-
{
|
|
280
|
-
friend ranges::range_access;
|
|
281
|
-
using iterator_t = ranges::iterator_t<Rng>;
|
|
282
|
-
using value_type = u8_type;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Use a separate cursor struct, so we can implement the range as a forward range (i.e.
|
|
286
|
-
* make the iterators weakly comparable).
|
|
287
|
-
*/
|
|
288
|
-
template <typename IterT, typename SentT>
|
|
289
|
-
struct cursor
|
|
290
|
-
{
|
|
291
|
-
private:
|
|
292
|
-
IterT iter_;
|
|
293
|
-
SentT last_;
|
|
294
|
-
next_chars<value_type> next_;
|
|
295
|
-
encode_fn_<value_type> encode_;
|
|
296
|
-
count_fn_<value_type> count_;
|
|
297
|
-
|
|
298
|
-
public:
|
|
299
|
-
cursor() = default;
|
|
300
|
-
cursor(IterT iter, SentT last)
|
|
301
|
-
: iter_{iter}
|
|
302
|
-
, last_{last}
|
|
303
|
-
{
|
|
304
|
-
next();
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
inline value_type read() const noexcept
|
|
308
|
-
{
|
|
309
|
-
return next_.top();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
constexpr inline void next() noexcept
|
|
313
|
-
{
|
|
314
|
-
if (next_.empty() == false) [[likely]]
|
|
315
|
-
{
|
|
316
|
-
next_.pop();
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (iter_ != last_ && next_.empty() == true) [[likely]]
|
|
320
|
-
{
|
|
321
|
-
next_ = encode_(*(iter_++));
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
constexpr inline bool equal(cursor<IterT, SentT> const & rhs) const noexcept
|
|
326
|
-
{
|
|
327
|
-
return iter_ == rhs.iter_ && next_.empty() == rhs.next_.empty();
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
constexpr inline bool equal(ranges::default_sentinel_t) const noexcept
|
|
331
|
-
{
|
|
332
|
-
return iter_ == last_ && next_.empty();
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
inline ranges::iter_difference_t<IterT> distance_to(ranges::default_sentinel_t) const
|
|
336
|
-
{
|
|
337
|
-
// This is a hack, but we initialize the return value to `1` if we already read
|
|
338
|
-
// the next token in our constructor.
|
|
339
|
-
ranges::iter_difference_t<IterT> ret(next_.size());
|
|
340
|
-
|
|
341
|
-
// And finally, let's parse all the remaining tokens
|
|
342
|
-
for (IterT cur = iter_; cur != last_; ++cur)
|
|
343
|
-
{
|
|
344
|
-
ret += count_(*cur);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return ret;
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
public:
|
|
352
|
-
encode_view_() = default;
|
|
353
|
-
explicit encode_view_(Rng && rng) noexcept
|
|
354
|
-
: rng_{rng}
|
|
355
|
-
{}
|
|
356
|
-
|
|
357
|
-
inline decltype(auto) begin_cursor() const
|
|
358
|
-
{
|
|
359
|
-
auto beg = ranges::begin(rng_);
|
|
360
|
-
auto end = ranges::end(rng_);
|
|
361
|
-
return cursor<decltype(beg), decltype(end)>{beg, end};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
public:
|
|
365
|
-
private:
|
|
366
|
-
Rng rng_;
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* UTF8->CodePoint decoding view
|
|
371
|
-
*
|
|
372
|
-
* Reads UTF8 and decodes it into codepoints (i.e. UTF32/UCS4). Effectively
|
|
373
|
-
* used for conversion from qdb strings to numpy.
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
template <typename Rng>
|
|
377
|
-
requires(ranges::forward_range<Rng>) class decode_view_
|
|
378
|
-
: public ranges::view_facade<decode_view_<Rng>, ranges::finite>
|
|
379
|
-
{
|
|
380
|
-
friend ranges::range_access;
|
|
381
|
-
using iterator_t = ranges::iterator_t<Rng>;
|
|
382
|
-
using value_type = detail::code_point;
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Use a separate cursor struct, so we can implement the range as a forward range (i.e.
|
|
386
|
-
* make the iterators weakly comparable).
|
|
387
|
-
*/
|
|
388
|
-
template <typename IterT, typename SentT>
|
|
389
|
-
struct cursor
|
|
390
|
-
{
|
|
391
|
-
private:
|
|
392
|
-
IterT iter_;
|
|
393
|
-
SentT last_;
|
|
394
|
-
decode_fn_<u8_type> decode_{};
|
|
395
|
-
skip_fn_<u8_type> skip_{};
|
|
396
|
-
|
|
397
|
-
public:
|
|
398
|
-
cursor() = default;
|
|
399
|
-
cursor(IterT iter, SentT last)
|
|
400
|
-
: iter_{iter}
|
|
401
|
-
, last_{last} {};
|
|
402
|
-
|
|
403
|
-
inline value_type read() const noexcept
|
|
404
|
-
{
|
|
405
|
-
// XXX(leon)
|
|
406
|
-
// This is somewhat inefficient, as we're peeking ahead trying to find the "next"
|
|
407
|
-
// codepoint, which may actually iterate forward more than one step.
|
|
408
|
-
//
|
|
409
|
-
// Then, when next() is requested, we _actually_ move ahead, and have to do the same
|
|
410
|
-
// (similar) checks again.
|
|
411
|
-
//
|
|
412
|
-
// However, after too much edge cases and debugging, I conclude that in order to be
|
|
413
|
-
// "really" compatible with ranges, you *must* separate these two, there's no way around
|
|
414
|
-
// it.
|
|
415
|
-
return decode_(iter_);
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
constexpr inline void next() noexcept
|
|
419
|
-
{
|
|
420
|
-
skip_(iter_);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
constexpr inline bool equal(cursor<IterT, SentT> const & rhs) const noexcept
|
|
424
|
-
{
|
|
425
|
-
return iter_ == rhs.iter_;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
constexpr inline bool equal(ranges::default_sentinel_t) const noexcept
|
|
429
|
-
{
|
|
430
|
-
return iter_ == last_;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
inline ranges::iter_difference_t<iterator_t> distance_to(ranges::default_sentinel_t) const
|
|
434
|
-
{
|
|
435
|
-
return _distance_to(last_);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
private:
|
|
439
|
-
template <typename T>
|
|
440
|
-
inline ranges::iter_difference_t<iterator_t> _distance_to(T const & other) const
|
|
441
|
-
{
|
|
442
|
-
ranges::iter_difference_t<iterator_t> ret{0};
|
|
443
|
-
|
|
444
|
-
for (IterT cur = iter_; cur != last_; skip_(cur))
|
|
445
|
-
{
|
|
446
|
-
++ret;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return ret;
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
// Lifecycle
|
|
454
|
-
public:
|
|
455
|
-
decode_view_() = default;
|
|
456
|
-
explicit decode_view_(Rng && rng) noexcept
|
|
457
|
-
: rng_{rng} {};
|
|
458
|
-
|
|
459
|
-
inline decltype(auto) begin_cursor() const
|
|
460
|
-
{
|
|
461
|
-
auto beg = ranges::begin(rng_);
|
|
462
|
-
auto end = ranges::end(rng_);
|
|
463
|
-
|
|
464
|
-
return cursor<decltype(beg), decltype(end)>{beg, end};
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
private:
|
|
468
|
-
Rng rng_;
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
}; // namespace utf8
|
|
472
|
-
|
|
473
|
-
}; // namespace detail
|
|
474
|
-
|
|
475
|
-
namespace utf8
|
|
476
|
-
{
|
|
477
|
-
|
|
478
|
-
struct encode_view_base_fn
|
|
479
|
-
{
|
|
480
|
-
template <typename Rng>
|
|
481
|
-
constexpr detail::utf8::encode_view_<Rng> operator()(Rng && rng) const
|
|
482
|
-
{
|
|
483
|
-
return detail::utf8::encode_view_<Rng>{std::forward<Rng>(rng)};
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
struct encode_view_bind_fn
|
|
488
|
-
{
|
|
489
|
-
constexpr auto operator()() const
|
|
490
|
-
{
|
|
491
|
-
return ranges::make_view_closure(encode_view_base_fn{});
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
struct encode_view_fn
|
|
496
|
-
: encode_view_base_fn
|
|
497
|
-
, encode_view_bind_fn
|
|
498
|
-
{
|
|
499
|
-
using encode_view_base_fn::operator();
|
|
500
|
-
using encode_view_bind_fn::operator();
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
RANGES_INLINE_VARIABLE(encode_view_fn, encode_view)
|
|
504
|
-
|
|
505
|
-
struct decode_view_base_fn
|
|
506
|
-
{
|
|
507
|
-
/**
|
|
508
|
-
* Default case: our input range already has a 'perfect' u8_type (unsigned char)
|
|
509
|
-
*/
|
|
510
|
-
template <typename Rng>
|
|
511
|
-
requires(concepts::range_t<Rng, u8_type>) constexpr detail::utf8::decode_view_<Rng> operator()(
|
|
512
|
-
Rng && rng) const
|
|
513
|
-
{
|
|
514
|
-
return detail::utf8::decode_view_<Rng>{std::forward<Rng>(rng)};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Non-default case, which happens when e.g. using a std::string as a range: the underlying type is
|
|
519
|
-
* not exactly u8_type, but we can easily convert it to the appropriate type.
|
|
520
|
-
*
|
|
521
|
-
* This avoids a case where signed chars were interpreted as unsigned chars and all kinds of
|
|
522
|
-
* shenanigans, which is fixed here.
|
|
523
|
-
*/
|
|
524
|
-
template <typename Rng>
|
|
525
|
-
requires(
|
|
526
|
-
!concepts::range_t<Rng,
|
|
527
|
-
u8_type> && std::is_nothrow_convertible_v<ranges::range_value_t<Rng>, u8_type>) constexpr decltype(auto)
|
|
528
|
-
operator()(Rng && rng) const
|
|
529
|
-
{
|
|
530
|
-
auto xform_fn = [](auto x) -> u8_type { return static_cast<u8_type>(x); };
|
|
531
|
-
|
|
532
|
-
// Transform and delegate to the 'regular' operator()
|
|
533
|
-
return operator()(ranges::views::transform(rng, xform_fn));
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
struct decode_view_bind_fn
|
|
538
|
-
{
|
|
539
|
-
constexpr auto operator()() const
|
|
540
|
-
{
|
|
541
|
-
return ranges::make_view_closure(decode_view_base_fn{});
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
struct decode_view_fn
|
|
546
|
-
: decode_view_base_fn
|
|
547
|
-
, decode_view_bind_fn
|
|
548
|
-
{
|
|
549
|
-
using decode_view_base_fn::operator();
|
|
550
|
-
using decode_view_bind_fn::operator();
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
RANGES_INLINE_VARIABLE(decode_view_fn, decode_view)
|
|
554
|
-
|
|
555
|
-
}; // namespace utf8
|
|
556
|
-
|
|
557
|
-
namespace utf32
|
|
558
|
-
{
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Returns view that reads codepoints and emits UTF-32 characters.
|
|
562
|
-
*/
|
|
563
|
-
inline decltype(auto) encode_view()
|
|
564
|
-
{
|
|
565
|
-
auto xform_fn = [](detail::code_point x) -> u32_type { return static_cast<u32_type>(x.get()); };
|
|
566
|
-
return ranges::views::transform(xform_fn);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* Returns view that reads codepoints and emits UTF-32 characters.
|
|
571
|
-
*/
|
|
572
|
-
template <class Rng>
|
|
573
|
-
requires(concepts::input_range_t<Rng, detail::code_point>) inline decltype(auto) encode_view(Rng && rng)
|
|
574
|
-
{
|
|
575
|
-
return rng | encode_view();
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Returns view that reads UTF-32 characters and emits codepoints.
|
|
580
|
-
*/
|
|
581
|
-
inline decltype(auto) decode_view()
|
|
582
|
-
{
|
|
583
|
-
auto xform_fn = [](u32_type x) -> detail::code_point { return detail::code_point{x}; };
|
|
584
|
-
return ranges::views::transform(xform_fn);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Returns view that reads UTF-32 characters and emits codepoints.
|
|
589
|
-
*/
|
|
590
|
-
template <typename Rng>
|
|
591
|
-
inline decltype(auto) decode_view(Rng && rng)
|
|
592
|
-
{
|
|
593
|
-
return rng | decode_view();
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
}; // namespace utf32
|
|
597
|
-
|
|
598
|
-
}; // namespace qdb::convert::unicode
|
quasardb/convert/util.hpp
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <range/v3/algorithm/max_element.hpp>
|
|
4
|
-
#include <range/v3/view/transform.hpp>
|
|
5
|
-
|
|
6
|
-
namespace qdb::convert::detail
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
template <typename R>
|
|
10
|
-
static inline std::size_t largest_word_length(R const & xs) noexcept
|
|
11
|
-
{
|
|
12
|
-
// Transform into a range of sizes
|
|
13
|
-
auto xs_ =
|
|
14
|
-
xs | ranges::views::transform([](auto const & x) -> std::size_t { return ranges::size(x); });
|
|
15
|
-
|
|
16
|
-
// Return the element with the largest size
|
|
17
|
-
auto iter = ranges::max_element(xs_);
|
|
18
|
-
|
|
19
|
-
return std::max(*iter, std::size_t(1));
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
}; // namespace qdb::convert::detail
|