aboutsummaryrefslogtreecommitdiffstats
path: root/util/charset/unicode_table.h
diff options
context:
space:
mode:
authorsereglond <sereglond@yandex-team.ru>2022-02-10 16:47:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:47 +0300
commit73bb02f2495181e0719a800f979df508924f4b71 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /util/charset/unicode_table.h
parenteb3d925534734c808602b31b38b953677f0a279f (diff)
downloadydb-73bb02f2495181e0719a800f979df508924f4b71.tar.gz
Restoring authorship annotation for <sereglond@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/charset/unicode_table.h')
-rw-r--r--util/charset/unicode_table.h184
1 files changed, 92 insertions, 92 deletions
diff --git a/util/charset/unicode_table.h b/util/charset/unicode_table.h
index 10869256ee..9e171b2583 100644
--- a/util/charset/unicode_table.h
+++ b/util/charset/unicode_table.h
@@ -1,123 +1,123 @@
-#pragma once
-
+#pragma once
+
#include <util/system/yassert.h>
#include <util/system/defaults.h>
-#include <util/generic/typetraits.h>
-
-namespace NUnicodeTable {
+#include <util/generic/typetraits.h>
+
+namespace NUnicodeTable {
+ template <class Value>
+ struct TValueSelector;
+
template <class Value>
- struct TValueSelector;
-
- template <class Value>
- struct TValueSelector {
+ struct TValueSelector {
using TStored = const Value;
using TValueRef = const Value&;
using TValuePtr = const Value*;
-
- static inline TValueRef Get(TValuePtr val) {
- return *val;
- }
- };
-
- template <class Value>
- struct TValueSelector<const Value*> {
+
+ static inline TValueRef Get(TValuePtr val) {
+ return *val;
+ }
+ };
+
+ template <class Value>
+ struct TValueSelector<const Value*> {
using TStored = const Value[];
using TValueRef = const Value*;
using TValuePtr = const Value*;
-
- static inline TValueRef Get(TValuePtr val) {
- return val;
- }
- };
-
- template <class Value>
- struct TValues {
+
+ static inline TValueRef Get(TValuePtr val) {
+ return val;
+ }
+ };
+
+ template <class Value>
+ struct TValues {
using TSelector = TValueSelector<Value>;
-
+
using TStored = typename TSelector::TStored;
using TValueRef = typename TSelector::TValueRef;
using TValuePtr = typename TSelector::TValuePtr;
-
+
using TData = const TValuePtr*;
-
- static inline TValuePtr Get(TData table, size_t index) {
+
+ static inline TValuePtr Get(TData table, size_t index) {
static_assert(std::is_pointer<TData>::value, "expect std::is_pointer<TData>::value");
- return table[index];
- }
-
- static inline TValueRef Get(TValuePtr val) {
- return TSelector::Get(val);
- }
- };
-
- template <int Shift, class TChild>
- struct TSubtable {
+ return table[index];
+ }
+
+ static inline TValueRef Get(TValuePtr val) {
+ return TSelector::Get(val);
+ }
+ };
+
+ template <int Shift, class TChild>
+ struct TSubtable {
using TStored = typename TChild::TStored;
using TValueRef = typename TChild::TValueRef;
using TValuePtr = typename TChild::TValuePtr;
using TData = const typename TChild::TData*;
-
- static inline TValuePtr Get(TData table, size_t key) {
+
+ static inline TValuePtr Get(TData table, size_t key) {
static_assert(std::is_pointer<TData>::value, "expect std::is_pointer<TData>::value");
- return TChild::Get(table[key >> Shift], key & ((1 << Shift) - 1));
- }
-
- static inline TValueRef Get(TValuePtr val) {
- return TChild::Get(val);
- }
- };
-
- template <class T>
- class TTable {
- private:
+ return TChild::Get(table[key >> Shift], key & ((1 << Shift) - 1));
+ }
+
+ static inline TValueRef Get(TValuePtr val) {
+ return TChild::Get(val);
+ }
+ };
+
+ template <class T>
+ class TTable {
+ private:
using TImpl = T;
using TData = typename TImpl::TData;
-
- const TData Data;
- const size_t MSize;
-
- public:
+
+ const TData Data;
+ const size_t MSize;
+
+ public:
using TStored = typename TImpl::TStored;
using TValueRef = typename TImpl::TValueRef;
using TValuePtr = typename TImpl::TValuePtr;
-
- private:
- inline TValueRef GetImpl(size_t key) const {
- TValuePtr val = TImpl::Get(Data, key);
-
- return TImpl::Get(val);
- }
-
+
+ private:
+ inline TValueRef GetImpl(size_t key) const {
+ TValuePtr val = TImpl::Get(Data, key);
+
+ return TImpl::Get(val);
+ }
+
inline TValueRef Get(size_t key) const {
return GetImpl(key);
}
- public:
- TTable(TData data, size_t size)
- : Data(data)
- , MSize(size)
- {
+ public:
+ TTable(TData data, size_t size)
+ : Data(data)
+ , MSize(size)
+ {
static_assert(std::is_pointer<TData>::value, "expect std::is_pointer<TData>::value");
- }
-
- inline TValueRef Get(size_t key, TValueRef value) const {
- if (key >= Size())
- return value;
-
- return GetImpl(key);
- }
-
- inline TValueRef Get(size_t key, size_t defaultKey) const {
- if (key >= Size())
- return Get(defaultKey);
-
- return GetImpl(key);
- }
-
- inline size_t Size() const {
- return MSize;
- }
- };
-
- const size_t UNICODE_TABLE_SHIFT = 5;
+ }
+
+ inline TValueRef Get(size_t key, TValueRef value) const {
+ if (key >= Size())
+ return value;
+
+ return GetImpl(key);
+ }
+
+ inline TValueRef Get(size_t key, size_t defaultKey) const {
+ if (key >= Size())
+ return Get(defaultKey);
+
+ return GetImpl(key);
+ }
+
+ inline size_t Size() const {
+ return MSize;
+ }
+ };
+
+ const size_t UNICODE_TABLE_SHIFT = 5;
}