aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme/scimpl_private.h
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:44 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:44 +0300
commit59e19371de37995fcb36beb16cd6ec030af960bc (patch)
treefa68e36093ebff8b805462e9e6d331fe9d348214 /library/cpp/scheme/scimpl_private.h
parent89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff)
downloadydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/scheme/scimpl_private.h')
-rw-r--r--library/cpp/scheme/scimpl_private.h212
1 files changed, 106 insertions, 106 deletions
diff --git a/library/cpp/scheme/scimpl_private.h b/library/cpp/scheme/scimpl_private.h
index b92badabde..3527e0911c 100644
--- a/library/cpp/scheme/scimpl_private.h
+++ b/library/cpp/scheme/scimpl_private.h
@@ -1,114 +1,114 @@
-#pragma once
-
-#include "scheme.h"
-
-#include <util/thread/singleton.h>
-
-namespace NSc {
- namespace NImpl {
- template <typename TContext>
- static inline TContext& GetTlsInstance() {
- return *FastTlsSingleton<TContext>();
- }
-
- template <typename TContext>
- class TContextGuard : TNonCopyable {
- using TElement = typename TContext::TElement;
- using TTarget = typename TContext::TTarget;
+#pragma once
+
+#include "scheme.h"
+
+#include <util/thread/singleton.h>
+
+namespace NSc {
+ namespace NImpl {
+ template <typename TContext>
+ static inline TContext& GetTlsInstance() {
+ return *FastTlsSingleton<TContext>();
+ }
+
+ template <typename TContext>
+ class TContextGuard : TNonCopyable {
+ using TElement = typename TContext::TElement;
+ using TTarget = typename TContext::TTarget;
using TVectorType = TVector<TElement>;
- public:
- TContextGuard(TContext& ctx, TTarget& target)
- : Ctx(ctx)
- , Active(TContext::Needed(target))
- {
- if (Active) {
- Begin = Ctx.Vector.size();
- Ok = Ctx.Process(target);
- End = Ctx.Vector.size();
- }
- }
-
- ~TContextGuard() noexcept {
- if (Active) {
- Ctx.Vector.resize(Begin);
- }
- }
-
+ public:
+ TContextGuard(TContext& ctx, TTarget& target)
+ : Ctx(ctx)
+ , Active(TContext::Needed(target))
+ {
+ if (Active) {
+ Begin = Ctx.Vector.size();
+ Ok = Ctx.Process(target);
+ End = Ctx.Vector.size();
+ }
+ }
+
+ ~TContextGuard() noexcept {
+ if (Active) {
+ Ctx.Vector.resize(Begin);
+ }
+ }
+
const TVectorType& GetVector() const {
- return Ctx.Vector;
- }
-
- using const_iterator = size_t;
-
- size_t begin() const {
- return Begin;
- }
-
- size_t end() const {
- return End;
- }
-
- bool Ok = true;
-
- private:
- TContext& Ctx;
- size_t Begin = 0;
- size_t End = 0;
- bool Active = false;
- };
-
- template <typename TElem, typename TTgt>
- class TBasicContext {
- public:
- using TElement = TElem;
- using TTarget = TTgt;
-
+ return Ctx.Vector;
+ }
+
+ using const_iterator = size_t;
+
+ size_t begin() const {
+ return Begin;
+ }
+
+ size_t end() const {
+ return End;
+ }
+
+ bool Ok = true;
+
+ private:
+ TContext& Ctx;
+ size_t Begin = 0;
+ size_t End = 0;
+ bool Active = false;
+ };
+
+ template <typename TElem, typename TTgt>
+ class TBasicContext {
+ public:
+ using TElement = TElem;
+ using TTarget = TTgt;
+
TBasicContext() {
- Vector.reserve(64);
- }
-
+ Vector.reserve(64);
+ }
+
TVector<TElement> Vector;
- };
-
+ };
+
class TKeySortContext: public TBasicContext<TStringBuf, const TDict> {
- public:
- using TGuard = TContextGuard<TKeySortContext>;
-
- bool Process(const TDict& self);
-
- static bool Needed(const TDict& self) {
- return self.size();
- }
- };
-
+ public:
+ using TGuard = TContextGuard<TKeySortContext>;
+
+ bool Process(const TDict& self);
+
+ static bool Needed(const TDict& self) {
+ return self.size();
+ }
+ };
+
class TSelfOverrideContext: public TBasicContext<TValue, TValue::TScCore> {
- public:
- using TGuard = TContextGuard<TSelfOverrideContext>;
-
- bool Process(TValue::TScCore& self);
-
- static bool Needed(const TValue::TScCore& self) {
- return self.HasChildren();
- }
- };
-
+ public:
+ using TGuard = TContextGuard<TSelfOverrideContext>;
+
+ bool Process(TValue::TScCore& self);
+
+ static bool Needed(const TValue::TScCore& self) {
+ return self.HasChildren();
+ }
+ };
+
class TSelfLoopContext: public TBasicContext<const void*, const TValue::TScCore> {
- public:
- enum class EMode {
- Assert, Throw, Abort, Stderr
- };
-
- using TGuard = TContextGuard<TSelfLoopContext>;
-
- bool Process(const TValue::TScCore& self);
-
- static bool Needed(const TValue::TScCore& self) {
- return self.HasChildren();
- }
-
- public:
- EMode ReportingMode = EMode::Assert;
- };
- }
-}
+ public:
+ enum class EMode {
+ Assert, Throw, Abort, Stderr
+ };
+
+ using TGuard = TContextGuard<TSelfLoopContext>;
+
+ bool Process(const TValue::TScCore& self);
+
+ static bool Needed(const TValue::TScCore& self) {
+ return self.HasChildren();
+ }
+
+ public:
+ EMode ReportingMode = EMode::Assert;
+ };
+ }
+}