diff options
author | Ruslan Kovalev <ruslan.a.kovalev@gmail.com> | 2022-02-10 16:46:44 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:44 +0300 |
commit | 59e19371de37995fcb36beb16cd6ec030af960bc (patch) | |
tree | fa68e36093ebff8b805462e9e6d331fe9d348214 /library/cpp/scheme/scimpl_defs.h | |
parent | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff) | |
download | ydb-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_defs.h')
-rw-r--r-- | library/cpp/scheme/scimpl_defs.h | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/library/cpp/scheme/scimpl_defs.h b/library/cpp/scheme/scimpl_defs.h index f3dd66b437..4720cd35cd 100644 --- a/library/cpp/scheme/scimpl_defs.h +++ b/library/cpp/scheme/scimpl_defs.h @@ -1,122 +1,122 @@ -#pragma once - +#pragma once + #include <library/cpp/json/json_reader.h> #include <library/cpp/json/json_value.h> - -#include <util/system/types.h> -#include <util/memory/pool.h> - -#include <util/generic/deque.h> -#include <util/generic/hash.h> -#include <util/generic/ptr.h> -#include <util/generic/strbuf.h> + +#include <util/system/types.h> +#include <util/memory/pool.h> + +#include <util/generic/deque.h> +#include <util/generic/hash.h> +#include <util/generic/ptr.h> +#include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <functional> #include <util/string/vector.h> -#include <util/string/type.h> - -namespace NSc { - namespace NDefinitions { - const size_t POOL_BLOCK_SIZE = 4000; // leave 96 bytes for overhead - +#include <util/string/type.h> + +namespace NSc { + namespace NDefinitions { + const size_t POOL_BLOCK_SIZE = 4000; // leave 96 bytes for overhead + struct TPool: public TAtomicRefCount<TPool> { - TMemoryPool Pool; - - TPool(size_t blsz = POOL_BLOCK_SIZE, TMemoryPool::IGrowPolicy* grow = TMemoryPool::TExpGrow::Instance()) - : Pool(blsz, grow) + TMemoryPool Pool; + + TPool(size_t blsz = POOL_BLOCK_SIZE, TMemoryPool::IGrowPolicy* grow = TMemoryPool::TExpGrow::Instance()) + : Pool(blsz, grow) { } - + TMemoryPool* Get() { return &Pool; } - - TStringBuf AppendBuf(const TStringBuf& strb) { - return Pool.AppendCString(strb); - } - - template <typename T> - T* NewWithPool() { - return new (Pool.Allocate<T>()) T(&Pool); - } - }; - } - + + TStringBuf AppendBuf(const TStringBuf& strb) { + return Pool.AppendCString(strb); + } + + template <typename T> + T* NewWithPool() { + return new (Pool.Allocate<T>()) T(&Pool); + } + }; + } + using TStringBufs = TVector<TStringBuf>; - - class TSchemeException : public yexception { - }; - - class TSchemeParseException : public TSchemeException { - public: - size_t Offset = 0; + + class TSchemeException : public yexception { + }; + + class TSchemeParseException : public TSchemeException { + public: + size_t Offset = 0; TString Reason; - - public: - TSchemeParseException() = default; - + + public: + TSchemeParseException() = default; + TSchemeParseException(size_t off, const TString& reason) - : Offset(off) - , Reason(reason) + : Offset(off) + , Reason(reason) { } - }; - + }; + struct TJsonOpts: public NJson::TJsonReaderConfig { - enum EJsonOpts { - JO_DEFAULT = 0, // just dump json, used to be default, actually - JO_SORT_KEYS = 1, // sort dict keys to make output more predictable - JO_SKIP_UNSAFE = 2, // skip nonunicode data to make external json parsers happy - // will skip nonunicode dict keys and replace nonunicode values with nulls - JO_FORMAT = 8, // format json - + enum EJsonOpts { + JO_DEFAULT = 0, // just dump json, used to be default, actually + JO_SORT_KEYS = 1, // sort dict keys to make output more predictable + JO_SKIP_UNSAFE = 2, // skip nonunicode data to make external json parsers happy + // will skip nonunicode dict keys and replace nonunicode values with nulls + JO_FORMAT = 8, // format json + JO_PARSER_STRICT_JSON = 16, // strict standard json JO_PARSER_STRICT_UTF8 = 32, // strict utf8 - JO_PARSER_DISALLOW_COMMENTS = 64, + JO_PARSER_DISALLOW_COMMENTS = 64, JO_PARSER_DISALLOW_DUPLICATE_KEYS = 128, - - JO_PRETTY = JO_FORMAT | JO_SORT_KEYS, // pretty print json - JO_SAFE = JO_SKIP_UNSAFE | JO_SORT_KEYS, // ensure standard parser-safe json - - JO_PARSER_STRICT_WITH_COMMENTS = JO_PARSER_STRICT_JSON | JO_PARSER_STRICT_UTF8, - JO_PARSER_STRICT = JO_PARSER_STRICT_JSON | JO_PARSER_STRICT_UTF8 | JO_PARSER_DISALLOW_COMMENTS, - }; - - public: - TJsonOpts(int opts = JO_SORT_KEYS) + + JO_PRETTY = JO_FORMAT | JO_SORT_KEYS, // pretty print json + JO_SAFE = JO_SKIP_UNSAFE | JO_SORT_KEYS, // ensure standard parser-safe json + + JO_PARSER_STRICT_WITH_COMMENTS = JO_PARSER_STRICT_JSON | JO_PARSER_STRICT_UTF8, + JO_PARSER_STRICT = JO_PARSER_STRICT_JSON | JO_PARSER_STRICT_UTF8 | JO_PARSER_DISALLOW_COMMENTS, + }; + + public: + TJsonOpts(int opts = JO_SORT_KEYS) : Opts(opts) , SortKeys(opts & JO_SORT_KEYS) - , FormatJson(opts & JO_FORMAT) - , StringPolicy((opts & JO_SKIP_UNSAFE) ? StringPolicySafe : StringPolicyUnsafe) - { - AllowComments = !(opts & JO_PARSER_DISALLOW_COMMENTS); - RelaxedJson = !(opts & JO_PARSER_STRICT_JSON); - DontValidateUtf8 = !(opts & JO_PARSER_STRICT_UTF8); - } - - public: + , FormatJson(opts & JO_FORMAT) + , StringPolicy((opts & JO_SKIP_UNSAFE) ? StringPolicySafe : StringPolicyUnsafe) + { + AllowComments = !(opts & JO_PARSER_DISALLOW_COMMENTS); + RelaxedJson = !(opts & JO_PARSER_STRICT_JSON); + DontValidateUtf8 = !(opts & JO_PARSER_STRICT_UTF8); + } + + public: bool RelaxedJson = false; int Opts = 0; - bool SortKeys = true; - bool FormatJson = false; - - // return true to proceed with output, false to skip, optionally modify value - std::function<bool(double&)> NumberPolicy = NumberPolicySafe; - std::function<bool(TStringBuf&)> StringPolicy = StringPolicyUnsafe; - - public: - static bool NumberPolicySafe(double&); // skip if nan or inf + bool SortKeys = true; + bool FormatJson = false; + + // return true to proceed with output, false to skip, optionally modify value + std::function<bool(double&)> NumberPolicy = NumberPolicySafe; + std::function<bool(TStringBuf&)> StringPolicy = StringPolicyUnsafe; + + public: + static bool NumberPolicySafe(double&); // skip if nan or inf static bool NumberPolicyUnsafe(double&) { return true; } - - static bool StringPolicySafe(TStringBuf&); // skip if not utf8 + + static bool StringPolicySafe(TStringBuf&); // skip if not utf8 static bool StringPolicyUnsafe(TStringBuf&) { return true; } - }; - + }; + struct TProtoOpts { // Serialization throws on unknown enum value if not set, else use default value bool UnknownEnumValueIsDefault = false; @@ -125,16 +125,16 @@ namespace NSc { bool SkipTypeMismatch = false; }; - namespace NImpl { - class TKeySortContext; - class TSelfLoopContext; - class TSelfOverrideContext; - } -} + namespace NImpl { + class TKeySortContext; + class TSelfLoopContext; + class TSelfOverrideContext; + } +} namespace google { - namespace protobuf { - class Message; - class FieldDescriptor; - } + namespace protobuf { + class Message; + class FieldDescriptor; + } } |