diff options
author | eeight <eeight@yandex-team.ru> | 2022-02-10 16:46:18 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:18 +0300 |
commit | 475c0a46f28166e83fd263badc7546377cddcabe (patch) | |
tree | 39c5a49b8aaad78fe390b6f1f2886bdbda40f3e7 | |
parent | a6e0145a095c7bb3770d6e07aee301de5c73f96e (diff) | |
download | ydb-475c0a46f28166e83fd263badc7546377cddcabe.tar.gz |
Restoring authorship annotation for <eeight@yandex-team.ru>. Commit 1 of 2.
716 files changed, 10388 insertions, 10388 deletions
diff --git a/build/rules/library_deprecated.policy b/build/rules/library_deprecated.policy index af1eb06386..1222b413e4 100644 --- a/build/rules/library_deprecated.policy +++ b/build/rules/library_deprecated.policy @@ -1,7 +1,7 @@ -ALLOW kernel/geo -> library/cpp/deprecated/small_array -ALLOW ysite/yandex/clicks -> library/cpp/deprecated/small_array -ALLOW ysite/yandex/indexuser -> library/cpp/deprecated/small_array -DENY .* -> library/cpp/deprecated/small_array +ALLOW kernel/geo -> library/cpp/deprecated/small_array +ALLOW ysite/yandex/clicks -> library/cpp/deprecated/small_array +ALLOW ysite/yandex/indexuser -> library/cpp/deprecated/small_array +DENY .* -> library/cpp/deprecated/small_array ALLOW jupytercloud/arcadia_kernel -> library/python/clickhouse_client ALLOW market/idx/export/mbi_qdata_reporter/bin -> library/python/clickhouse_client diff --git a/build/scripts/fetch_from_sandbox.py b/build/scripts/fetch_from_sandbox.py index a99542e174..0eab446342 100755 --- a/build/scripts/fetch_from_sandbox.py +++ b/build/scripts/fetch_from_sandbox.py @@ -53,7 +53,7 @@ def _is_skynet_avaliable(): def download_by_skynet(resource_info, file_name): def sky_get(skynet_id, target_dir, timeout=None): - cmd_args = [_sky_path(), 'get', "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] + cmd_args = [_sky_path(), 'get', "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] if timeout is not None: cmd_args += ["--timeout", str(timeout)] logging.info('Call skynet with args: %s', cmd_args) diff --git a/build/scripts/gen_mx_table.py b/build/scripts/gen_mx_table.py index 187c21c539..ee62f9074a 100644 --- a/build/scripts/gen_mx_table.py +++ b/build/scripts/gen_mx_table.py @@ -35,7 +35,7 @@ namespace { %s } - inline const TMnSseInfo& at(size_t n) const noexcept { + inline const TMnSseInfo& at(size_t n) const noexcept { return *find(n)->second; } }; diff --git a/build/stdafx.hpp b/build/stdafx.hpp index 98b15adda0..5f34b70c7b 100644 --- a/build/stdafx.hpp +++ b/build/stdafx.hpp @@ -264,11 +264,11 @@ #include <util/digest/fnv.h> #include <util/digest/murmur.h> #include <util/ysaveload.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <util/thread/lfstack.h> #include <util/thread/singleton.h> #include <util/thread/lfqueue.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/str_stl.h> #include <util/folder/path.h> #include <util/folder/dirut.h> diff --git a/build/ymake_conf.py b/build/ymake_conf.py index 30219eb85e..6f1e0865f9 100755 --- a/build/ymake_conf.py +++ b/build/ymake_conf.py @@ -1390,9 +1390,9 @@ class GnuCompiler(Compiler): if self.target.is_linux or self.target.is_android or self.target.is_cygwin: self.c_defines.append('-D_GNU_SOURCE') - if self.tc.is_clang and self.target.is_linux and self.target.is_x86_64: - self.c_defines.append('-D_YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE') - + if self.tc.is_clang and self.target.is_linux and self.target.is_x86_64: + self.c_defines.append('-D_YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE') + if self.target.is_ios: self.c_defines.extend(['-D_XOPEN_SOURCE', '-D_DARWIN_C_SOURCE']) if preset('MAPSMOBI_BUILD_TARGET') and self.target.is_arm: diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3filestream.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3filestream.hpp index 140b1a5f67..4fde62ced5 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3filestream.hpp +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3filestream.hpp @@ -57,7 +57,7 @@ public: class ParseFileAbsentException : public std::exception { - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return " Parse File not Present"; } diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp index d167f5b392..0db4895897 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp @@ -312,7 +312,7 @@ public: class ParseNullStringException : public std::exception { - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return "Null String"; } diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3memory.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3memory.hpp index 7b85f67545..31a9f7563d 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3memory.hpp +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3memory.hpp @@ -50,9 +50,9 @@ public: typedef AllocatorType<U> other; }; - AllocatorType() noexcept {} - AllocatorType( const AllocatorType& ) noexcept {} - template<typename U> AllocatorType(const AllocatorType<U>& ) noexcept{} + AllocatorType() noexcept {} + AllocatorType( const AllocatorType& ) noexcept {} + template<typename U> AllocatorType(const AllocatorType<U>& ) noexcept{} }; template<class TYPE> diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3tokenstream.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3tokenstream.hpp index 947ac097c8..498c51eae0 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3tokenstream.hpp +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3tokenstream.hpp @@ -393,7 +393,7 @@ public: class TokenAccessException : public std::exception { - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return " Attempted access on Deleted Token"; } diff --git a/contrib/libs/cxxsupp/libcxxrt/cxxabi.h b/contrib/libs/cxxsupp/libcxxrt/cxxabi.h index 7a8cb6745f..23c8b49162 100644 --- a/contrib/libs/cxxsupp/libcxxrt/cxxabi.h +++ b/contrib/libs/cxxsupp/libcxxrt/cxxabi.h @@ -236,10 +236,10 @@ char* __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status); - -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE -size_t __cxa_collect_current_exception_backtrace(void** dest, size_t size); -#endif + +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE +size_t __cxa_collect_current_exception_backtrace(void** dest, size_t size); +#endif #ifdef __cplusplus } // extern "C" } // namespace diff --git a/contrib/libs/cxxsupp/libcxxrt/exception.cc b/contrib/libs/cxxsupp/libcxxrt/exception.cc index 6baf428ead..4bf2811551 100644 --- a/contrib/libs/cxxsupp/libcxxrt/exception.cc +++ b/contrib/libs/cxxsupp/libcxxrt/exception.cc @@ -197,7 +197,7 @@ struct __cxa_dependent_exception _Unwind_Exception unwindHeader; }; -static_assert(sizeof(__cxa_dependent_exception) == sizeof(__cxa_exception)); +static_assert(sizeof(__cxa_dependent_exception) == sizeof(__cxa_exception)); namespace std { @@ -205,8 +205,8 @@ namespace std class exception { public: - virtual ~exception(); - virtual const char* what() const noexcept; + virtual ~exception(); + virtual const char* what() const noexcept; }; } @@ -219,20 +219,20 @@ namespace std * various checks may test for equality of the class, which is incorrect. */ static const uint64_t exception_class = -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE - _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS; -#else +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE + _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS; +#else EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\0'); -#endif +#endif /** * Class used for dependent exceptions. */ static const uint64_t dependent_exception_class = -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE - _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS; -#else +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE + _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS; +#else EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\x01'); -#endif +#endif /** * The low four bytes of the exception class, indicating that we conform to the * Itanium C++ ABI. This is currently unused, but should be used in the future @@ -660,18 +660,18 @@ static_assert(align_to(15, 16) == 16); static_assert(align_to(16, 16) == 16); static_assert(align_to(17, 16) == 32); -static constexpr size_t exception_size = align_to(sizeof(__cxa_exception), 16); -static constexpr size_t dependent_exception_size = align_to(sizeof(__cxa_dependent_exception), 16); -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE -static constexpr size_t backtrace_buffer_size = align_to(sizeof(_Unwind_Backtrace_Buffer), 16); - -static_assert( - _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET == - offsetof(__cxa_exception, unwindHeader) + backtrace_buffer_size - sizeof(_Unwind_Backtrace_Buffer)); -#else -static constexpr size_t backtrace_buffer_size = 0; -#endif - +static constexpr size_t exception_size = align_to(sizeof(__cxa_exception), 16); +static constexpr size_t dependent_exception_size = align_to(sizeof(__cxa_dependent_exception), 16); +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE +static constexpr size_t backtrace_buffer_size = align_to(sizeof(_Unwind_Backtrace_Buffer), 16); + +static_assert( + _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET == + offsetof(__cxa_exception, unwindHeader) + backtrace_buffer_size - sizeof(_Unwind_Backtrace_Buffer)); +#else +static constexpr size_t backtrace_buffer_size = 0; +#endif + /** * Allocates an exception structure. Returns a pointer to the space that can * be used to store an object of thrown_size bytes. This function will use an @@ -680,19 +680,19 @@ static constexpr size_t backtrace_buffer_size = 0; */ extern "C" void *__cxa_allocate_exception(size_t thrown_size) { - size_t size = thrown_size + exception_size + backtrace_buffer_size; + size_t size = thrown_size + exception_size + backtrace_buffer_size; char *buffer = alloc_or_die(size); -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE - ((_Unwind_Backtrace_Buffer *)buffer)->size = 0; -#endif - return buffer + exception_size + backtrace_buffer_size; +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE + ((_Unwind_Backtrace_Buffer *)buffer)->size = 0; +#endif + return buffer + exception_size + backtrace_buffer_size; } extern "C" void *__cxa_allocate_dependent_exception(void) { - size_t size = dependent_exception_size + backtrace_buffer_size; + size_t size = dependent_exception_size + backtrace_buffer_size; char *buffer = alloc_or_die(size); - return buffer + dependent_exception_size + backtrace_buffer_size; + return buffer + dependent_exception_size + backtrace_buffer_size; } /** @@ -720,8 +720,8 @@ extern "C" void __cxa_free_exception(void *thrown_exception) } } - free_exception( - reinterpret_cast<char*>(thrown_exception) - exception_size - backtrace_buffer_size); + free_exception( + reinterpret_cast<char*>(thrown_exception) - exception_size - backtrace_buffer_size); } static void releaseException(__cxa_exception *exception) @@ -748,7 +748,7 @@ void __cxa_free_dependent_exception(void *thrown_exception) { releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex))); } - free_exception(reinterpret_cast<char*>(thrown_exception) - dependent_exception_size - backtrace_buffer_size); + free_exception(reinterpret_cast<char*>(thrown_exception) - dependent_exception_size - backtrace_buffer_size); } /** @@ -758,7 +758,7 @@ void __cxa_free_dependent_exception(void *thrown_exception) * a handler, prints a back trace before aborting. */ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -extern "C" void *__cxa_begin_catch(void *e) noexcept; +extern "C" void *__cxa_begin_catch(void *e) noexcept; #else extern "C" void *__cxa_begin_catch(void *e); #endif @@ -910,32 +910,32 @@ extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception) releaseException(ex); } -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE -static size_t __cxa_collect_backtrace(__cxa_exception* ex, void** dest, size_t size) { - if (!ex) { - return 0; - } - if (!isCXXException(ex->unwindHeader.exception_class)) { - return 0; - } - size_t i = 0; - if (isDependentException(ex->unwindHeader.exception_class)) { - i = __cxa_collect_backtrace( - (__cxa_exception *)((__cxa_dependent_exception *)ex)->primaryException - 1, dest, size); - } - _Unwind_Backtrace_Buffer* backtraceBuffer = (_Unwind_Backtrace_Buffer*)( - (char *)(ex + 1) - exception_size - backtrace_buffer_size); - for (size_t j = 0; i != size && j != backtraceBuffer->size; ++i, ++j) { - dest[i] = backtraceBuffer->backtrace[j]; - } - return i; -} - -extern "C" size_t __cxa_collect_current_exception_backtrace(void** dest, size_t size) { - return __cxa_collect_backtrace(__cxa_get_globals()->caughtExceptions, dest, size); -} -#endif - +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE +static size_t __cxa_collect_backtrace(__cxa_exception* ex, void** dest, size_t size) { + if (!ex) { + return 0; + } + if (!isCXXException(ex->unwindHeader.exception_class)) { + return 0; + } + size_t i = 0; + if (isDependentException(ex->unwindHeader.exception_class)) { + i = __cxa_collect_backtrace( + (__cxa_exception *)((__cxa_dependent_exception *)ex)->primaryException - 1, dest, size); + } + _Unwind_Backtrace_Buffer* backtraceBuffer = (_Unwind_Backtrace_Buffer*)( + (char *)(ex + 1) - exception_size - backtrace_buffer_size); + for (size_t j = 0; i != size && j != backtraceBuffer->size; ++i, ++j) { + dest[i] = backtraceBuffer->backtrace[j]; + } + return i; +} + +extern "C" size_t __cxa_collect_current_exception_backtrace(void** dest, size_t size) { + return __cxa_collect_backtrace(__cxa_get_globals()->caughtExceptions, dest, size); +} +#endif + /** * ABI function. Rethrows the current exception. Does not remove the * exception from the stack or decrement its handler count - the compiler is @@ -1322,7 +1322,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) * C++ exceptions) of the unadjusted pointer (for foreign exceptions). */ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -extern "C" void *__cxa_begin_catch(void *e) noexcept +extern "C" void *__cxa_begin_catch(void *e) noexcept #else extern "C" void *__cxa_begin_catch(void *e) #endif @@ -1531,14 +1531,14 @@ namespace pathscale /** * Sets whether unexpected and terminate handlers should be thread-local. */ - void set_use_thread_local_handlers(bool flag) noexcept + void set_use_thread_local_handlers(bool flag) noexcept { thread_local_handlers = flag; } /** * Sets a thread-local unexpected handler. */ - unexpected_handler set_unexpected(unexpected_handler f) noexcept + unexpected_handler set_unexpected(unexpected_handler f) noexcept { static __cxa_thread_info *info = thread_info(); unexpected_handler old = info->unexpectedHandler; @@ -1548,7 +1548,7 @@ namespace pathscale /** * Sets a thread-local terminate handler. */ - terminate_handler set_terminate(terminate_handler f) noexcept + terminate_handler set_terminate(terminate_handler f) noexcept { static __cxa_thread_info *info = thread_info(); terminate_handler old = info->terminateHandler; @@ -1563,7 +1563,7 @@ namespace std * Sets the function that will be called when an exception specification is * violated. */ - unexpected_handler set_unexpected(unexpected_handler f) noexcept + unexpected_handler set_unexpected(unexpected_handler f) noexcept { if (thread_local_handlers) { return pathscale::set_unexpected(f); } @@ -1572,7 +1572,7 @@ namespace std /** * Sets the function that is called to terminate the program. */ - terminate_handler set_terminate(terminate_handler f) noexcept + terminate_handler set_terminate(terminate_handler f) noexcept { if (thread_local_handlers) { return pathscale::set_terminate(f); } @@ -1615,7 +1615,7 @@ namespace std * Returns whether there are any exceptions currently being thrown that * have not been caught. This can occur inside a nested catch statement. */ - bool uncaught_exception() noexcept + bool uncaught_exception() noexcept { __cxa_thread_info *info = thread_info(); return info->globals.uncaughtExceptions != 0; @@ -1624,7 +1624,7 @@ namespace std * Returns the number of exceptions currently being thrown that have not * been caught. This can occur inside a nested catch statement. */ - int uncaught_exceptions() noexcept + int uncaught_exceptions() noexcept { __cxa_thread_info *info = thread_info(); return info->globals.uncaughtExceptions; @@ -1632,7 +1632,7 @@ namespace std /** * Returns the current unexpected handler. */ - unexpected_handler get_unexpected() noexcept + unexpected_handler get_unexpected() noexcept { __cxa_thread_info *info = thread_info(); if (info->unexpectedHandler) @@ -1644,7 +1644,7 @@ namespace std /** * Returns the current terminate handler. */ - terminate_handler get_terminate() noexcept + terminate_handler get_terminate() noexcept { __cxa_thread_info *info = thread_info(); if (info->terminateHandler) diff --git a/contrib/libs/cxxsupp/libcxxrt/memory.cc b/contrib/libs/cxxsupp/libcxxrt/memory.cc index 694c5d5037..9daa043ff2 100644 --- a/contrib/libs/cxxsupp/libcxxrt/memory.cc +++ b/contrib/libs/cxxsupp/libcxxrt/memory.cc @@ -59,12 +59,12 @@ namespace std * Sets a function to be called when there is a failure in new. */ __attribute__((weak)) - new_handler set_new_handler(new_handler handler) noexcept + new_handler set_new_handler(new_handler handler) noexcept { return ATOMIC_SWAP(&new_handl, handler); } __attribute__((weak)) - new_handler get_new_handler(void) noexcept + new_handler get_new_handler(void) noexcept { return ATOMIC_LOAD(&new_handl); } diff --git a/contrib/libs/cxxsupp/libcxxrt/stdexcept.cc b/contrib/libs/cxxsupp/libcxxrt/stdexcept.cc index 07c62a731b..964c4adb44 100644 --- a/contrib/libs/cxxsupp/libcxxrt/stdexcept.cc +++ b/contrib/libs/cxxsupp/libcxxrt/stdexcept.cc @@ -31,66 +31,66 @@ namespace std { -exception::exception() noexcept {} -exception::~exception() {} -exception::exception(const exception&) noexcept {} -exception& exception::operator=(const exception&) noexcept +exception::exception() noexcept {} +exception::~exception() {} +exception::exception(const exception&) noexcept {} +exception& exception::operator=(const exception&) noexcept { return *this; } -const char* exception::what() const noexcept +const char* exception::what() const noexcept { return "std::exception"; } -bad_alloc::bad_alloc() noexcept {} -bad_alloc::~bad_alloc() {} -bad_alloc::bad_alloc(const bad_alloc&) noexcept {} -bad_alloc& bad_alloc::operator=(const bad_alloc&) noexcept +bad_alloc::bad_alloc() noexcept {} +bad_alloc::~bad_alloc() {} +bad_alloc::bad_alloc(const bad_alloc&) noexcept {} +bad_alloc& bad_alloc::operator=(const bad_alloc&) noexcept { return *this; } -const char* bad_alloc::what() const noexcept +const char* bad_alloc::what() const noexcept { return "cxxrt::bad_alloc"; } -bad_cast::bad_cast() noexcept {} -bad_cast::~bad_cast() {} -bad_cast::bad_cast(const bad_cast&) noexcept {} -bad_cast& bad_cast::operator=(const bad_cast&) noexcept +bad_cast::bad_cast() noexcept {} +bad_cast::~bad_cast() {} +bad_cast::bad_cast(const bad_cast&) noexcept {} +bad_cast& bad_cast::operator=(const bad_cast&) noexcept { return *this; } -const char* bad_cast::what() const noexcept +const char* bad_cast::what() const noexcept { return "std::bad_cast"; } -bad_typeid::bad_typeid() noexcept {} -bad_typeid::~bad_typeid() {} -bad_typeid::bad_typeid(const bad_typeid &__rhs) noexcept {} -bad_typeid& bad_typeid::operator=(const bad_typeid &__rhs) noexcept +bad_typeid::bad_typeid() noexcept {} +bad_typeid::~bad_typeid() {} +bad_typeid::bad_typeid(const bad_typeid &__rhs) noexcept {} +bad_typeid& bad_typeid::operator=(const bad_typeid &__rhs) noexcept { return *this; } -const char* bad_typeid::what() const noexcept +const char* bad_typeid::what() const noexcept { return "std::bad_typeid"; } -bad_array_new_length::bad_array_new_length() noexcept {} +bad_array_new_length::bad_array_new_length() noexcept {} bad_array_new_length::~bad_array_new_length() {} -bad_array_new_length::bad_array_new_length(const bad_array_new_length&) noexcept {} -bad_array_new_length& bad_array_new_length::operator=(const bad_array_new_length&) noexcept +bad_array_new_length::bad_array_new_length(const bad_array_new_length&) noexcept {} +bad_array_new_length& bad_array_new_length::operator=(const bad_array_new_length&) noexcept { return *this; } -const char* bad_array_new_length::what() const noexcept +const char* bad_array_new_length::what() const noexcept { return "std::bad_array_new_length"; } diff --git a/contrib/libs/cxxsupp/libcxxrt/stdexcept.h b/contrib/libs/cxxsupp/libcxxrt/stdexcept.h index 13763f4824..a442a9f3ee 100644 --- a/contrib/libs/cxxsupp/libcxxrt/stdexcept.h +++ b/contrib/libs/cxxsupp/libcxxrt/stdexcept.h @@ -35,11 +35,11 @@ namespace std class exception { public: - exception() noexcept; - exception(const exception&) noexcept; - exception& operator=(const exception&) noexcept; - virtual ~exception(); - virtual const char* what() const noexcept; + exception() noexcept; + exception(const exception&) noexcept; + exception& operator=(const exception&) noexcept; + virtual ~exception(); + virtual const char* what() const noexcept; }; @@ -49,11 +49,11 @@ namespace std class bad_alloc: public exception { public: - bad_alloc() noexcept; - bad_alloc(const bad_alloc&) noexcept; - bad_alloc& operator=(const bad_alloc&) noexcept; - ~bad_alloc(); - virtual const char* what() const noexcept; + bad_alloc() noexcept; + bad_alloc(const bad_alloc&) noexcept; + bad_alloc& operator=(const bad_alloc&) noexcept; + ~bad_alloc(); + virtual const char* what() const noexcept; }; /** @@ -61,11 +61,11 @@ namespace std */ class bad_cast: public exception { public: - bad_cast() noexcept; - bad_cast(const bad_cast&) noexcept; - bad_cast& operator=(const bad_cast&) noexcept; - virtual ~bad_cast(); - virtual const char* what() const noexcept; + bad_cast() noexcept; + bad_cast(const bad_cast&) noexcept; + bad_cast& operator=(const bad_cast&) noexcept; + virtual ~bad_cast(); + virtual const char* what() const noexcept; }; /** @@ -74,21 +74,21 @@ namespace std class bad_typeid: public exception { public: - bad_typeid() noexcept; - bad_typeid(const bad_typeid &__rhs) noexcept; - virtual ~bad_typeid(); - bad_typeid& operator=(const bad_typeid &__rhs) noexcept; - virtual const char* what() const noexcept; + bad_typeid() noexcept; + bad_typeid(const bad_typeid &__rhs) noexcept; + virtual ~bad_typeid(); + bad_typeid& operator=(const bad_typeid &__rhs) noexcept; + virtual const char* what() const noexcept; }; class bad_array_new_length: public bad_alloc { public: - bad_array_new_length() noexcept; - bad_array_new_length(const bad_array_new_length&) noexcept; - bad_array_new_length& operator=(const bad_array_new_length&) noexcept; + bad_array_new_length() noexcept; + bad_array_new_length(const bad_array_new_length&) noexcept; + bad_array_new_length& operator=(const bad_array_new_length&) noexcept; virtual ~bad_array_new_length(); - virtual const char *what() const noexcept; + virtual const char *what() const noexcept; }; diff --git a/contrib/libs/flatbuffers/include/flatbuffers/base.h b/contrib/libs/flatbuffers/include/flatbuffers/base.h index e2defddb80..3f46d8e037 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/base.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/base.h @@ -1,73 +1,73 @@ -#ifndef FLATBUFFERS_BASE_H_ -#define FLATBUFFERS_BASE_H_ - -// clang-format off +#ifndef FLATBUFFERS_BASE_H_ +#define FLATBUFFERS_BASE_H_ + +// clang-format off // If activate should be declared and included first. -#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \ - defined(_MSC_VER) && defined(_DEBUG) +#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \ + defined(_MSC_VER) && defined(_DEBUG) // The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace // calloc/free (etc) to its debug version using #define directives. - #define _CRTDBG_MAP_ALLOC + #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> // Replace operator new by trace-enabled version. #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define new DEBUG_NEW -#endif - +#endif + #if !defined(FLATBUFFERS_ASSERT) -#include <assert.h> -#define FLATBUFFERS_ASSERT assert +#include <assert.h> +#define FLATBUFFERS_ASSERT assert #elif defined(FLATBUFFERS_ASSERT_INCLUDE) // Include file with forward declaration #include FLATBUFFERS_ASSERT_INCLUDE -#endif - -#ifndef ARDUINO -#include <cstdint> -#endif - -#include <cstddef> -#include <cstdlib> -#include <cstring> - -#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H) +#endif + +#ifndef ARDUINO +#include <cstdint> +#endif + +#include <cstddef> +#include <cstdlib> +#include <cstring> + +#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H) #error #include <utility.h> -#else - #include <utility> -#endif - -#include <string> -#include <type_traits> -#include <vector> -#include <set> -#include <algorithm> -#include <iterator> -#include <memory> - +#else + #include <utility> +#endif + +#include <string> +#include <type_traits> +#include <vector> +#include <set> +#include <algorithm> +#include <iterator> +#include <memory> + #if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT) #include <unistd.h> #endif -#ifdef _STLPORT_VERSION - #define FLATBUFFERS_CPP98_STL -#endif +#ifdef _STLPORT_VERSION + #define FLATBUFFERS_CPP98_STL +#endif #ifdef __ANDROID__ #include <android/api-level.h> -#endif - +#endif + #if defined(__ICCARM__) #include <intrinsics.h> #endif -// Note the __clang__ check is needed, because clang presents itself -// as an older GNUC compiler (4.2). -// Clang 3.3 and later implement all of the ISO C++ 2011 standard. -// Clang 3.4 and later implement all of the ISO C++ 2014 standard. -// http://clang.llvm.org/cxx_status.html - +// Note the __clang__ check is needed, because clang presents itself +// as an older GNUC compiler (4.2). +// Clang 3.3 and later implement all of the ISO C++ 2011 standard. +// Clang 3.4 and later implement all of the ISO C++ 2014 standard. +// http://clang.llvm.org/cxx_status.html + // Note the MSVC value '__cplusplus' may be incorrect: // The '__cplusplus' predefined macro in the MSVC stuck at the value 199711L, // indicating (erroneously!) that the compiler conformed to the C++98 Standard. @@ -89,119 +89,119 @@ #define FLATBUFFERS_CLANG 0 #endif -/// @cond FLATBUFFERS_INTERNAL -#if __cplusplus <= 199711L && \ - (!defined(_MSC_VER) || _MSC_VER < 1600) && \ - (!defined(__GNUC__) || \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400)) - #error A C++11 compatible compiler with support for the auto typing is \ - required for FlatBuffers. - #error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ -#endif - -#if !defined(__clang__) && \ - defined(__GNUC__) && \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600) +/// @cond FLATBUFFERS_INTERNAL +#if __cplusplus <= 199711L && \ + (!defined(_MSC_VER) || _MSC_VER < 1600) && \ + (!defined(__GNUC__) || \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400)) + #error A C++11 compatible compiler with support for the auto typing is \ + required for FlatBuffers. + #error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ +#endif + +#if !defined(__clang__) && \ + defined(__GNUC__) && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600) // Backwards compatibility for g++ 4.4, and 4.5 which don't have the nullptr - // and constexpr keywords. Note the __clang__ check is needed, because clang - // presents itself as an older GNUC compiler. - #ifndef nullptr_t - const class nullptr_t { - public: - template<class T> inline operator T*() const { return 0; } - private: - void operator&() const; - } nullptr = {}; - #endif - #ifndef constexpr - #define constexpr const - #endif -#endif - -// The wire format uses a little endian encoding (since that's efficient for -// the common platforms). -#if defined(__s390x__) - #define FLATBUFFERS_LITTLEENDIAN 0 -#endif // __s390x__ -#if !defined(FLATBUFFERS_LITTLEENDIAN) + // and constexpr keywords. Note the __clang__ check is needed, because clang + // presents itself as an older GNUC compiler. + #ifndef nullptr_t + const class nullptr_t { + public: + template<class T> inline operator T*() const { return 0; } + private: + void operator&() const; + } nullptr = {}; + #endif + #ifndef constexpr + #define constexpr const + #endif +#endif + +// The wire format uses a little endian encoding (since that's efficient for +// the common platforms). +#if defined(__s390x__) + #define FLATBUFFERS_LITTLEENDIAN 0 +#endif // __s390x__ +#if !defined(FLATBUFFERS_LITTLEENDIAN) #if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__) #if (defined(__BIG_ENDIAN__) || \ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) - #define FLATBUFFERS_LITTLEENDIAN 0 - #else - #define FLATBUFFERS_LITTLEENDIAN 1 - #endif // __BIG_ENDIAN__ - #elif defined(_MSC_VER) - #if defined(_M_PPC) - #define FLATBUFFERS_LITTLEENDIAN 0 - #else - #define FLATBUFFERS_LITTLEENDIAN 1 - #endif - #else - #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN. - #endif -#endif // !defined(FLATBUFFERS_LITTLEENDIAN) - + #define FLATBUFFERS_LITTLEENDIAN 0 + #else + #define FLATBUFFERS_LITTLEENDIAN 1 + #endif // __BIG_ENDIAN__ + #elif defined(_MSC_VER) + #if defined(_M_PPC) + #define FLATBUFFERS_LITTLEENDIAN 0 + #else + #define FLATBUFFERS_LITTLEENDIAN 1 + #endif + #else + #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN. + #endif +#endif // !defined(FLATBUFFERS_LITTLEENDIAN) + #define FLATBUFFERS_VERSION_MAJOR 2 #define FLATBUFFERS_VERSION_MINOR 0 -#define FLATBUFFERS_VERSION_REVISION 0 -#define FLATBUFFERS_STRING_EXPAND(X) #X -#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) +#define FLATBUFFERS_VERSION_REVISION 0 +#define FLATBUFFERS_STRING_EXPAND(X) #X +#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) namespace flatbuffers { // Returns version as string "MAJOR.MINOR.REVISION". const char* FLATBUFFERS_VERSION(); } - -#if (!defined(_MSC_VER) || _MSC_VER > 1600) && \ - (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) || \ - defined(__clang__) - #define FLATBUFFERS_FINAL_CLASS final - #define FLATBUFFERS_OVERRIDE override + +#if (!defined(_MSC_VER) || _MSC_VER > 1600) && \ + (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) || \ + defined(__clang__) + #define FLATBUFFERS_FINAL_CLASS final + #define FLATBUFFERS_OVERRIDE override #define FLATBUFFERS_EXPLICIT_CPP11 explicit #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t -#else - #define FLATBUFFERS_FINAL_CLASS - #define FLATBUFFERS_OVERRIDE +#else + #define FLATBUFFERS_FINAL_CLASS + #define FLATBUFFERS_OVERRIDE #define FLATBUFFERS_EXPLICIT_CPP11 #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE -#endif - -#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \ - (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \ - (defined(__cpp_constexpr) && __cpp_constexpr >= 200704) - #define FLATBUFFERS_CONSTEXPR constexpr +#endif + +#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \ + (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \ + (defined(__cpp_constexpr) && __cpp_constexpr >= 200704) + #define FLATBUFFERS_CONSTEXPR constexpr #define FLATBUFFERS_CONSTEXPR_CPP11 constexpr #define FLATBUFFERS_CONSTEXPR_DEFINED -#else +#else #define FLATBUFFERS_CONSTEXPR const #define FLATBUFFERS_CONSTEXPR_CPP11 -#endif - -#if (defined(__cplusplus) && __cplusplus >= 201402L) || \ - (defined(__cpp_constexpr) && __cpp_constexpr >= 201304) +#endif + +#if (defined(__cplusplus) && __cplusplus >= 201402L) || \ + (defined(__cpp_constexpr) && __cpp_constexpr >= 201304) #define FLATBUFFERS_CONSTEXPR_CPP14 FLATBUFFERS_CONSTEXPR_CPP11 -#else - #define FLATBUFFERS_CONSTEXPR_CPP14 -#endif - -#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \ - (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023026)) || \ - defined(__clang__) - #define FLATBUFFERS_NOEXCEPT noexcept -#else - #define FLATBUFFERS_NOEXCEPT -#endif - -// NOTE: the FLATBUFFERS_DELETE_FUNC macro may change the access mode to -// private, so be sure to put it at the end or reset access mode explicitly. -#if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \ - (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \ - defined(__clang__) +#else + #define FLATBUFFERS_CONSTEXPR_CPP14 +#endif + +#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \ + (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023026)) || \ + defined(__clang__) + #define FLATBUFFERS_NOEXCEPT noexcept +#else + #define FLATBUFFERS_NOEXCEPT +#endif + +// NOTE: the FLATBUFFERS_DELETE_FUNC macro may change the access mode to +// private, so be sure to put it at the end or reset access mode explicitly. +#if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \ + (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \ + defined(__clang__) #define FLATBUFFERS_DELETE_FUNC(func) func = delete -#else +#else #define FLATBUFFERS_DELETE_FUNC(func) private: func -#endif - +#endif + #if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \ (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \ defined(__clang__) @@ -218,24 +218,24 @@ namespace flatbuffers { #define FLATBUFFERS_TEMPLATES_ALIASES #endif -#ifndef FLATBUFFERS_HAS_STRING_VIEW - // Only provide flatbuffers::string_view if __has_include can be used - // to detect a header that provides an implementation - #if defined(__has_include) - // Check for std::string_view (in c++17) +#ifndef FLATBUFFERS_HAS_STRING_VIEW + // Only provide flatbuffers::string_view if __has_include can be used + // to detect a header that provides an implementation + #if defined(__has_include) + // Check for std::string_view (in c++17) #if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17)) - #include <string_view> - namespace flatbuffers { - typedef std::string_view string_view; - } - #define FLATBUFFERS_HAS_STRING_VIEW 1 - // Check for std::experimental::string_view (in c++14, compiler-dependent) - #elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411) + #include <string_view> + namespace flatbuffers { + typedef std::string_view string_view; + } + #define FLATBUFFERS_HAS_STRING_VIEW 1 + // Check for std::experimental::string_view (in c++14, compiler-dependent) + #elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411) #error #include <experimental/string_view> - namespace flatbuffers { - typedef std::experimental::string_view string_view; - } - #define FLATBUFFERS_HAS_STRING_VIEW 1 + namespace flatbuffers { + typedef std::experimental::string_view string_view; + } + #define FLATBUFFERS_HAS_STRING_VIEW 1 // Check for absl::string_view #elif __has_include("absl/strings/string_view.h") #error #include "absl/strings/string_view.h" @@ -243,10 +243,10 @@ namespace flatbuffers { typedef absl::string_view string_view; } #define FLATBUFFERS_HAS_STRING_VIEW 1 - #endif - #endif // __has_include -#endif // !FLATBUFFERS_HAS_STRING_VIEW - + #endif + #endif // __has_include +#endif // !FLATBUFFERS_HAS_STRING_VIEW + #ifndef FLATBUFFERS_HAS_NEW_STRTOD // Modern (C++11) strtod and strtof functions are available for use. // 1) nan/inf strings as argument of strtod; @@ -306,104 +306,104 @@ template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) { #endif #endif -/// @endcond - -/// @file -namespace flatbuffers { - -/// @cond FLATBUFFERS_INTERNAL -// Our default offset / size type, 32bit on purpose on 64bit systems. -// Also, using a consistent offset type maintains compatibility of serialized -// offset values between 32bit and 64bit systems. -typedef uint32_t uoffset_t; - -// Signed offsets for references that can go in both directions. -typedef int32_t soffset_t; - -// Offset/index used in v-tables, can be changed to uint8_t in -// format forks to save a bit of space if desired. -typedef uint16_t voffset_t; - -typedef uintmax_t largest_scalar_t; - -// In 32bits, this evaluates to 2GB - 1 +/// @endcond + +/// @file +namespace flatbuffers { + +/// @cond FLATBUFFERS_INTERNAL +// Our default offset / size type, 32bit on purpose on 64bit systems. +// Also, using a consistent offset type maintains compatibility of serialized +// offset values between 32bit and 64bit systems. +typedef uint32_t uoffset_t; + +// Signed offsets for references that can go in both directions. +typedef int32_t soffset_t; + +// Offset/index used in v-tables, can be changed to uint8_t in +// format forks to save a bit of space if desired. +typedef uint16_t voffset_t; + +typedef uintmax_t largest_scalar_t; + +// In 32bits, this evaluates to 2GB - 1 #define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(flatbuffers::soffset_t) * 8 - 1)) - 1) - -// We support aligning the contents of buffers up to this size. -#define FLATBUFFERS_MAX_ALIGNMENT 16 - + +// We support aligning the contents of buffers up to this size. +#define FLATBUFFERS_MAX_ALIGNMENT 16 + inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) { return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) && (align & (align - 1)) == 0; // must be power of 2 } -#if defined(_MSC_VER) +#if defined(_MSC_VER) #pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized - #pragma warning(push) - #pragma warning(disable: 4127) // C4127: conditional expression is constant -#endif - -template<typename T> T EndianSwap(T t) { - #if defined(_MSC_VER) - #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort - #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong - #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64 + #pragma warning(push) + #pragma warning(disable: 4127) // C4127: conditional expression is constant +#endif + +template<typename T> T EndianSwap(T t) { + #if defined(_MSC_VER) + #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort + #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong + #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64 #elif defined(__ICCARM__) #define FLATBUFFERS_BYTESWAP16 __REV16 #define FLATBUFFERS_BYTESWAP32 __REV #define FLATBUFFERS_BYTESWAP64(x) \ ((__REV(static_cast<uint32_t>(x >> 32U))) | (static_cast<uint64_t>(__REV(static_cast<uint32_t>(x)))) << 32U) - #else - #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__) - // __builtin_bswap16 was missing prior to GCC 4.8. - #define FLATBUFFERS_BYTESWAP16(x) \ - static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16)) - #else - #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16 - #endif - #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32 - #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64 - #endif - if (sizeof(T) == 1) { // Compile-time if-then's. - return t; - } else if (sizeof(T) == 2) { + #else + #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__) + // __builtin_bswap16 was missing prior to GCC 4.8. + #define FLATBUFFERS_BYTESWAP16(x) \ + static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16)) + #else + #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16 + #endif + #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32 + #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64 + #endif + if (sizeof(T) == 1) { // Compile-time if-then's. + return t; + } else if (sizeof(T) == 2) { union { T t; uint16_t i; } u = { t }; - u.i = FLATBUFFERS_BYTESWAP16(u.i); - return u.t; - } else if (sizeof(T) == 4) { + u.i = FLATBUFFERS_BYTESWAP16(u.i); + return u.t; + } else if (sizeof(T) == 4) { union { T t; uint32_t i; } u = { t }; - u.i = FLATBUFFERS_BYTESWAP32(u.i); - return u.t; - } else if (sizeof(T) == 8) { + u.i = FLATBUFFERS_BYTESWAP32(u.i); + return u.t; + } else if (sizeof(T) == 8) { union { T t; uint64_t i; } u = { t }; - u.i = FLATBUFFERS_BYTESWAP64(u.i); - return u.t; - } else { - FLATBUFFERS_ASSERT(0); - return t; - } -} - -#if defined(_MSC_VER) - #pragma warning(pop) -#endif - - -template<typename T> T EndianScalar(T t) { - #if FLATBUFFERS_LITTLEENDIAN + u.i = FLATBUFFERS_BYTESWAP64(u.i); + return u.t; + } else { + FLATBUFFERS_ASSERT(0); return t; - #else - return EndianSwap(t); - #endif -} - + } +} + +#if defined(_MSC_VER) + #pragma warning(pop) +#endif + + +template<typename T> T EndianScalar(T t) { + #if FLATBUFFERS_LITTLEENDIAN + return t; + #else + return EndianSwap(t); + #endif +} + template<typename T> // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details. __supress_ubsan__("alignment") T ReadScalar(const void *p) { return EndianScalar(*reinterpret_cast<const T *>(p)); -} - +} + // See https://github.com/google/flatbuffers/issues/5950 #if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000) @@ -415,9 +415,9 @@ template<typename T> // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details. __supress_ubsan__("alignment") void WriteScalar(void *p, T t) { - *reinterpret_cast<T *>(p) = EndianScalar(t); -} - + *reinterpret_cast<T *>(p) = EndianScalar(t); +} + template<typename T> struct Offset; template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) { *reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o); @@ -427,13 +427,13 @@ template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Of #pragma GCC diagnostic pop #endif -// Computes how many bytes you'd have to pad to be able to write an -// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in -// memory). +// Computes how many bytes you'd have to pad to be able to write an +// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in +// memory). __supress_ubsan__("unsigned-integer-overflow") -inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) { - return ((~buf_size) + 1) & (scalar_size - 1); -} - -} // namespace flatbuffers -#endif // FLATBUFFERS_BASE_H_ +inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) { + return ((~buf_size) + 1) & (scalar_size - 1); +} + +} // namespace flatbuffers +#endif // FLATBUFFERS_BASE_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/code_generators.h b/contrib/libs/flatbuffers/include/flatbuffers/code_generators.h index 09b773a468..f0c9612758 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/code_generators.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/code_generators.h @@ -1,74 +1,74 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_CODE_GENERATORS_H_ -#define FLATBUFFERS_CODE_GENERATORS_H_ - -#include <map> -#include <sstream> +/* + * Copyright 2014 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLATBUFFERS_CODE_GENERATORS_H_ +#define FLATBUFFERS_CODE_GENERATORS_H_ + +#include <map> +#include <sstream> #include "idl.h" - -namespace flatbuffers { - -// Utility class to assist in generating code through use of text templates. -// -// Example code: + +namespace flatbuffers { + +// Utility class to assist in generating code through use of text templates. +// +// Example code: // CodeWriter code("\t"); -// code.SetValue("NAME", "Foo"); -// code += "void {{NAME}}() { printf("%s", "{{NAME}}"); }"; -// code.SetValue("NAME", "Bar"); -// code += "void {{NAME}}() { printf("%s", "{{NAME}}"); }"; -// std::cout << code.ToString() << std::endl; -// -// Output: -// void Foo() { printf("%s", "Foo"); } -// void Bar() { printf("%s", "Bar"); } -class CodeWriter { - public: +// code.SetValue("NAME", "Foo"); +// code += "void {{NAME}}() { printf("%s", "{{NAME}}"); }"; +// code.SetValue("NAME", "Bar"); +// code += "void {{NAME}}() { printf("%s", "{{NAME}}"); }"; +// std::cout << code.ToString() << std::endl; +// +// Output: +// void Foo() { printf("%s", "Foo"); } +// void Bar() { printf("%s", "Bar"); } +class CodeWriter { + public: CodeWriter(std::string pad = std::string()) : pad_(pad), cur_ident_lvl_(0), ignore_ident_(false) {} - - // Clears the current "written" code. - void Clear() { - stream_.str(""); - stream_.clear(); - } - - // Associates a key with a value. All subsequent calls to operator+=, where - // the specified key is contained in {{ and }} delimiters will be replaced by - // the given value. - void SetValue(const std::string &key, const std::string &value) { - value_map_[key] = value; - } - + + // Clears the current "written" code. + void Clear() { + stream_.str(""); + stream_.clear(); + } + + // Associates a key with a value. All subsequent calls to operator+=, where + // the specified key is contained in {{ and }} delimiters will be replaced by + // the given value. + void SetValue(const std::string &key, const std::string &value) { + value_map_[key] = value; + } + std::string GetValue(const std::string &key) const { const auto it = value_map_.find(key); return it == value_map_.end() ? "" : it->second; } - // Appends the given text to the generated code as well as a newline + // Appends the given text to the generated code as well as a newline // character. Any text within {{ and }} delimiters is replaced by values - // previously stored in the CodeWriter by calling SetValue above. The newline - // will be suppressed if the text ends with the \\ character. - void operator+=(std::string text); - - // Returns the current contents of the CodeWriter as a std::string. - std::string ToString() const { return stream_.str(); } - + // previously stored in the CodeWriter by calling SetValue above. The newline + // will be suppressed if the text ends with the \\ character. + void operator+=(std::string text); + + // Returns the current contents of the CodeWriter as a std::string. + std::string ToString() const { return stream_.str(); } + // Increase ident level for writing code void IncrementIdentLevel() { cur_ident_lvl_++; } // Decrease ident level for writing code @@ -78,90 +78,90 @@ class CodeWriter { void SetPadding(const std::string &padding) { pad_ = padding; } - private: - std::map<std::string, std::string> value_map_; - std::stringstream stream_; + private: + std::map<std::string, std::string> value_map_; + std::stringstream stream_; std::string pad_; int cur_ident_lvl_; bool ignore_ident_; // Add ident padding (tab or space) based on ident level void AppendIdent(std::stringstream &stream); -}; - -class BaseGenerator { - public: - virtual bool generate() = 0; - - static std::string NamespaceDir(const Parser &parser, const std::string &path, +}; + +class BaseGenerator { + public: + virtual bool generate() = 0; + + static std::string NamespaceDir(const Parser &parser, const std::string &path, const Namespace &ns, const bool dasherize = false); - + static std::string ToDasherizedCase(const std::string pascal_case); std::string GeneratedFileName(const std::string &path, const std::string &file_name, const IDLOptions &options) const; - protected: - BaseGenerator(const Parser &parser, const std::string &path, + protected: + BaseGenerator(const Parser &parser, const std::string &path, const std::string &file_name, std::string qualifying_start, std::string qualifying_separator, std::string default_extension) - : parser_(parser), - path_(path), - file_name_(file_name), - qualifying_start_(qualifying_start), + : parser_(parser), + path_(path), + file_name_(file_name), + qualifying_start_(qualifying_start), qualifying_separator_(qualifying_separator), default_extension_(default_extension) {} - virtual ~BaseGenerator() {} - - // No copy/assign. - BaseGenerator &operator=(const BaseGenerator &); - BaseGenerator(const BaseGenerator &); - + virtual ~BaseGenerator() {} + + // No copy/assign. + BaseGenerator &operator=(const BaseGenerator &); + BaseGenerator(const BaseGenerator &); + std::string NamespaceDir(const Namespace &ns, const bool dasherize = false) const; - - static const char *FlatBuffersGeneratedWarning(); - - static std::string FullNamespace(const char *separator, const Namespace &ns); - - static std::string LastNamespacePart(const Namespace &ns); - - // tracks the current namespace for early exit in WrapInNameSpace - // c++, java and csharp returns a different namespace from - // the following default (no early exit, always fully qualify), - // which works for js and php - virtual const Namespace *CurrentNameSpace() const { return nullptr; } - + + static const char *FlatBuffersGeneratedWarning(); + + static std::string FullNamespace(const char *separator, const Namespace &ns); + + static std::string LastNamespacePart(const Namespace &ns); + + // tracks the current namespace for early exit in WrapInNameSpace + // c++, java and csharp returns a different namespace from + // the following default (no early exit, always fully qualify), + // which works for js and php + virtual const Namespace *CurrentNameSpace() const { return nullptr; } + // Ensure that a type is prefixed with its namespace even within // its own namespace to avoid conflict between generated method // names and similarly named classes or structs - std::string WrapInNameSpace(const Namespace *ns, - const std::string &name) const; - - std::string WrapInNameSpace(const Definition &def) const; - - std::string GetNameSpace(const Definition &def) const; - - const Parser &parser_; - const std::string &path_; - const std::string &file_name_; - const std::string qualifying_start_; - const std::string qualifying_separator_; + std::string WrapInNameSpace(const Namespace *ns, + const std::string &name) const; + + std::string WrapInNameSpace(const Definition &def) const; + + std::string GetNameSpace(const Definition &def) const; + + const Parser &parser_; + const std::string &path_; + const std::string &file_name_; + const std::string qualifying_start_; + const std::string qualifying_separator_; const std::string default_extension_; -}; - -struct CommentConfig { - const char *first_line; - const char *content_line_prefix; - const char *last_line; -}; - -extern void GenComment(const std::vector<std::string> &dc, - std::string *code_ptr, const CommentConfig *config, - const char *prefix = ""); - +}; + +struct CommentConfig { + const char *first_line; + const char *content_line_prefix; + const char *last_line; +}; + +extern void GenComment(const std::vector<std::string> &dc, + std::string *code_ptr, const CommentConfig *config, + const char *prefix = ""); + class FloatConstantGenerator { public: virtual ~FloatConstantGenerator() {} @@ -230,6 +230,6 @@ class TypedFloatConstantGenerator : public FloatConstantGenerator { const std::string neg_inf_number_; }; -} // namespace flatbuffers - -#endif // FLATBUFFERS_CODE_GENERATORS_H_ +} // namespace flatbuffers + +#endif // FLATBUFFERS_CODE_GENERATORS_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h b/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h index 20935307a6..dbe838cc70 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h @@ -17,7 +17,7 @@ #ifndef FLATBUFFERS_H_ #define FLATBUFFERS_H_ -#include "base.h" +#include "base.h" #include "stl_emulation.h" #ifndef FLATBUFFERS_CPP98_STL @@ -63,25 +63,25 @@ inline bool IsInRange(const T &v, const T &low, const T &high) { } // Wrapper for uoffset_t to allow safe template specialization. -// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset). +// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset). template<typename T> struct Offset { uoffset_t o; Offset() : o(0) {} Offset(uoffset_t _o) : o(_o) {} Offset<void> Union() const { return Offset<void>(o); } - bool IsNull() const { return !o; } + bool IsNull() const { return !o; } }; inline void EndianCheck() { int endiantest = 1; // If this fails, see FLATBUFFERS_LITTLEENDIAN above. - FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) == - FLATBUFFERS_LITTLEENDIAN); + FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) == + FLATBUFFERS_LITTLEENDIAN); (void)endiantest; } -template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() { - // clang-format off +template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() { + // clang-format off #ifdef _MSC_VER return __alignof(T); #else @@ -91,7 +91,7 @@ template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() { return alignof(T); #endif #endif - // clang-format on + // clang-format on } // When we read serialized data from memory, in the case of most scalars, @@ -104,7 +104,7 @@ template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() { // (avoiding the need for a trailing return decltype) template<typename T> struct IndirectHelper { typedef T return_type; - typedef T mutable_return_type; + typedef T mutable_return_type; static const size_t element_stride = sizeof(T); static return_type Read(const uint8_t *p, uoffset_t i) { return EndianScalar((reinterpret_cast<const T *>(p))[i]); @@ -112,7 +112,7 @@ template<typename T> struct IndirectHelper { }; template<typename T> struct IndirectHelper<Offset<T>> { typedef const T *return_type; - typedef T *mutable_return_type; + typedef T *mutable_return_type; static const size_t element_stride = sizeof(uoffset_t); static return_type Read(const uint8_t *p, uoffset_t i) { p += i * sizeof(uoffset_t); @@ -121,7 +121,7 @@ template<typename T> struct IndirectHelper<Offset<T>> { }; template<typename T> struct IndirectHelper<const T *> { typedef const T *return_type; - typedef T *mutable_return_type; + typedef T *mutable_return_type; static const size_t element_stride = sizeof(T); static return_type Read(const uint8_t *p, uoffset_t i) { return reinterpret_cast<const T *>(p + i * sizeof(T)); @@ -130,15 +130,15 @@ template<typename T> struct IndirectHelper<const T *> { // An STL compatible iterator implementation for Vector below, effectively // calling Get() for every element. -template<typename T, typename IT> struct VectorIterator { - typedef std::random_access_iterator_tag iterator_category; - typedef IT value_type; - typedef ptrdiff_t difference_type; - typedef IT *pointer; - typedef IT &reference; - - VectorIterator(const uint8_t *data, uoffset_t i) - : data_(data + IndirectHelper<T>::element_stride * i) {} +template<typename T, typename IT> struct VectorIterator { + typedef std::random_access_iterator_tag iterator_category; + typedef IT value_type; + typedef ptrdiff_t difference_type; + typedef IT *pointer; + typedef IT &reference; + + VectorIterator(const uint8_t *data, uoffset_t i) + : data_(data + IndirectHelper<T>::element_stride * i) {} VectorIterator(const VectorIterator &other) : data_(other.data_) {} VectorIterator() : data_(nullptr) {} @@ -156,29 +156,29 @@ template<typename T, typename IT> struct VectorIterator { #endif // !defined(FLATBUFFERS_CPP98_STL) // clang-format on - bool operator==(const VectorIterator &other) const { + bool operator==(const VectorIterator &other) const { return data_ == other.data_; } - bool operator<(const VectorIterator &other) const { - return data_ < other.data_; - } - - bool operator!=(const VectorIterator &other) const { + bool operator<(const VectorIterator &other) const { + return data_ < other.data_; + } + + bool operator!=(const VectorIterator &other) const { return data_ != other.data_; } - difference_type operator-(const VectorIterator &other) const { + difference_type operator-(const VectorIterator &other) const { return (data_ - other.data_) / IndirectHelper<T>::element_stride; } // Note: return type is incompatible with the standard // `reference operator*()`. - IT operator*() const { return IndirectHelper<T>::Read(data_, 0); } + IT operator*() const { return IndirectHelper<T>::Read(data_, 0); } // Note: return type is incompatible with the standard // `pointer operator->()`. - IT operator->() const { return IndirectHelper<T>::Read(data_, 0); } + IT operator->() const { return IndirectHelper<T>::Read(data_, 0); } VectorIterator &operator++() { data_ += IndirectHelper<T>::element_stride; @@ -186,17 +186,17 @@ template<typename T, typename IT> struct VectorIterator { } VectorIterator operator++(int) { - VectorIterator temp(data_, 0); + VectorIterator temp(data_, 0); data_ += IndirectHelper<T>::element_stride; return temp; } - VectorIterator operator+(const uoffset_t &offset) const { - return VectorIterator(data_ + offset * IndirectHelper<T>::element_stride, - 0); + VectorIterator operator+(const uoffset_t &offset) const { + return VectorIterator(data_ + offset * IndirectHelper<T>::element_stride, + 0); } - VectorIterator &operator+=(const uoffset_t &offset) { + VectorIterator &operator+=(const uoffset_t &offset) { data_ += offset * IndirectHelper<T>::element_stride; return *this; } @@ -207,22 +207,22 @@ template<typename T, typename IT> struct VectorIterator { } VectorIterator operator--(int) { - VectorIterator temp(data_, 0); + VectorIterator temp(data_, 0); data_ -= IndirectHelper<T>::element_stride; return temp; } VectorIterator operator-(const uoffset_t &offset) const { - return VectorIterator(data_ - offset * IndirectHelper<T>::element_stride, - 0); + return VectorIterator(data_ - offset * IndirectHelper<T>::element_stride, + 0); } - VectorIterator &operator-=(const uoffset_t &offset) { + VectorIterator &operator-=(const uoffset_t &offset) { data_ -= offset * IndirectHelper<T>::element_stride; return *this; } - private: + private: const uint8_t *data_; }; @@ -246,16 +246,16 @@ struct VectorReverseIterator : public std::reverse_iterator<Iterator> { } }; -struct String; - +struct String; + // This is used as a helper type for accessing vectors. // Vector::data() assumes the vector elements start after the length field. template<typename T> class Vector { - public: - typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type> - iterator; - typedef VectorIterator<T, typename IndirectHelper<T>::return_type> - const_iterator; + public: + typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type> + iterator; + typedef VectorIterator<T, typename IndirectHelper<T>::return_type> + const_iterator; typedef VectorReverseIterator<iterator> reverse_iterator; typedef VectorReverseIterator<const_iterator> const_reverse_iterator; @@ -266,11 +266,11 @@ template<typename T> class Vector { uoffset_t Length() const { return size(); } typedef typename IndirectHelper<T>::return_type return_type; - typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type; + typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type; typedef return_type value_type; return_type Get(uoffset_t i) const { - FLATBUFFERS_ASSERT(i < size()); + FLATBUFFERS_ASSERT(i < size()); return IndirectHelper<T>::Read(Data(), i); } @@ -283,18 +283,18 @@ template<typename T> class Vector { return static_cast<E>(Get(i)); } - // If this a vector of unions, this does the cast for you. There's no check - // to make sure this is the right type! - template<typename U> const U *GetAs(uoffset_t i) const { - return reinterpret_cast<const U *>(Get(i)); - } - - // If this a vector of unions, this does the cast for you. There's no check - // to make sure this is actually a string! - const String *GetAsString(uoffset_t i) const { - return reinterpret_cast<const String *>(Get(i)); - } - + // If this a vector of unions, this does the cast for you. There's no check + // to make sure this is the right type! + template<typename U> const U *GetAs(uoffset_t i) const { + return reinterpret_cast<const U *>(Get(i)); + } + + // If this a vector of unions, this does the cast for you. There's no check + // to make sure this is actually a string! + const String *GetAsString(uoffset_t i) const { + return reinterpret_cast<const String *>(Get(i)); + } + const void *GetStructFromOffset(size_t o) const { return reinterpret_cast<const void *>(Data() + o); } @@ -325,8 +325,8 @@ template<typename T> class Vector { // Change elements if you have a non-const pointer to this object. // Scalars only. See reflection.h, and the documentation. - void Mutate(uoffset_t i, const T &val) { - FLATBUFFERS_ASSERT(i < size()); + void Mutate(uoffset_t i, const T &val) { + FLATBUFFERS_ASSERT(i < size()); WriteScalar(data() + i, val); } @@ -334,32 +334,32 @@ template<typename T> class Vector { // "val" points to the new table/string, as you can obtain from // e.g. reflection::AddFlatBuffer(). void MutateOffset(uoffset_t i, const uint8_t *val) { - FLATBUFFERS_ASSERT(i < size()); - static_assert(sizeof(T) == sizeof(uoffset_t), "Unrelated types"); - WriteScalar(data() + i, - static_cast<uoffset_t>(val - (Data() + i * sizeof(uoffset_t)))); - } - - // Get a mutable pointer to tables/strings inside this vector. - mutable_return_type GetMutableObject(uoffset_t i) const { - FLATBUFFERS_ASSERT(i < size()); - return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i)); - } - + FLATBUFFERS_ASSERT(i < size()); + static_assert(sizeof(T) == sizeof(uoffset_t), "Unrelated types"); + WriteScalar(data() + i, + static_cast<uoffset_t>(val - (Data() + i * sizeof(uoffset_t)))); + } + + // Get a mutable pointer to tables/strings inside this vector. + mutable_return_type GetMutableObject(uoffset_t i) const { + FLATBUFFERS_ASSERT(i < size()); + return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i)); + } + // The raw data in little endian format. Use with care. const uint8_t *Data() const { return reinterpret_cast<const uint8_t *>(&length_ + 1); } - uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); } + uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); } // Similarly, but typed, much like std::vector::data const T *data() const { return reinterpret_cast<const T *>(Data()); } T *data() { return reinterpret_cast<T *>(Data()); } template<typename K> return_type LookupByKey(K key) const { - void *search_result = std::bsearch( - &key, Data(), size(), IndirectHelper<T>::element_stride, KeyCompare<K>); + void *search_result = std::bsearch( + &key, Data(), size(), IndirectHelper<T>::element_stride, KeyCompare<K>); if (!search_result) { return nullptr; // Key not found. @@ -370,19 +370,19 @@ template<typename T> class Vector { return IndirectHelper<T>::Read(element, 0); } - protected: + protected: // This class is only used to access pre-existing data. Don't ever // try to construct these manually. Vector(); uoffset_t length_; - private: - // This class is a pointer. Copying will therefore create an invalid object. - // Private and unimplemented copy constructor. - Vector(const Vector &); + private: + // This class is a pointer. Copying will therefore create an invalid object. + // Private and unimplemented copy constructor. + Vector(const Vector &); Vector &operator=(const Vector &); - + template<typename K> static int KeyCompare(const void *ap, const void *bp) { const K *key = reinterpret_cast<const K *>(ap); const uint8_t *data = reinterpret_cast<const uint8_t *>(bp); @@ -397,40 +397,40 @@ template<typename T> class Vector { // Represent a vector much like the template above, but in this case we // don't know what the element types are (used with reflection.h). class VectorOfAny { - public: + public: uoffset_t size() const { return EndianScalar(length_); } const uint8_t *Data() const { return reinterpret_cast<const uint8_t *>(&length_ + 1); } - uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); } - - protected: + uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); } + + protected: VectorOfAny(); uoffset_t length_; - - private: - VectorOfAny(const VectorOfAny &); + + private: + VectorOfAny(const VectorOfAny &); VectorOfAny &operator=(const VectorOfAny &); }; -#ifndef FLATBUFFERS_CPP98_STL -template<typename T, typename U> -Vector<Offset<T>> *VectorCast(Vector<Offset<U>> *ptr) { - static_assert(std::is_base_of<T, U>::value, "Unrelated types"); - return reinterpret_cast<Vector<Offset<T>> *>(ptr); -} - -template<typename T, typename U> -const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) { - static_assert(std::is_base_of<T, U>::value, "Unrelated types"); - return reinterpret_cast<const Vector<Offset<T>> *>(ptr); -} -#endif - +#ifndef FLATBUFFERS_CPP98_STL +template<typename T, typename U> +Vector<Offset<T>> *VectorCast(Vector<Offset<U>> *ptr) { + static_assert(std::is_base_of<T, U>::value, "Unrelated types"); + return reinterpret_cast<Vector<Offset<T>> *>(ptr); +} + +template<typename T, typename U> +const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) { + static_assert(std::is_base_of<T, U>::value, "Unrelated types"); + return reinterpret_cast<const Vector<Offset<T>> *>(ptr); +} +#endif + // Convenient helper function to get the length of any vector, regardless -// of whether it is null or not (the field is not set). +// of whether it is null or not (the field is not set). template<typename T> static inline size_t VectorLength(const Vector<T> *v) { return v ? v->size() : 0; } @@ -629,31 +629,31 @@ struct String : public Vector<char> { const char *c_str() const { return reinterpret_cast<const char *>(Data()); } std::string str() const { return std::string(c_str(), size()); } - // clang-format off - #ifdef FLATBUFFERS_HAS_STRING_VIEW - flatbuffers::string_view string_view() const { + // clang-format off + #ifdef FLATBUFFERS_HAS_STRING_VIEW + flatbuffers::string_view string_view() const { return flatbuffers::string_view(c_str(), size()); - } - #endif // FLATBUFFERS_HAS_STRING_VIEW - // clang-format on - - bool operator<(const String &o) const { + } + #endif // FLATBUFFERS_HAS_STRING_VIEW + // clang-format on + + bool operator<(const String &o) const { return StringLessThan(this->data(), this->size(), o.data(), o.size()); } }; -// Convenience function to get std::string from a String returning an empty -// string on null pointer. +// Convenience function to get std::string from a String returning an empty +// string on null pointer. static inline std::string GetString(const String *str) { - return str ? str->str() : ""; -} - -// Convenience function to get char* from a String returning an empty string on -// null pointer. + return str ? str->str() : ""; +} + +// Convenience function to get char* from a String returning an empty string on +// null pointer. static inline const char *GetCstring(const String *str) { - return str ? str->c_str() : ""; -} - + return str ? str->c_str() : ""; +} + #ifdef FLATBUFFERS_HAS_STRING_VIEW // Convenience function to get string_view from a String returning an empty // string_view on null pointer. @@ -662,231 +662,231 @@ static inline flatbuffers::string_view GetStringView(const String *str) { } #endif // FLATBUFFERS_HAS_STRING_VIEW -// Allocator interface. This is flatbuffers-specific and meant only for -// `vector_downward` usage. -class Allocator { +// Allocator interface. This is flatbuffers-specific and meant only for +// `vector_downward` usage. +class Allocator { public: - virtual ~Allocator() {} - - // Allocate `size` bytes of memory. - virtual uint8_t *allocate(size_t size) = 0; - - // Deallocate `size` bytes of memory at `p` allocated by this allocator. - virtual void deallocate(uint8_t *p, size_t size) = 0; - - // Reallocate `new_size` bytes of memory, replacing the old region of size - // `old_size` at `p`. In contrast to a normal realloc, this grows downwards, - // and is intended specifcally for `vector_downward` use. - // `in_use_back` and `in_use_front` indicate how much of `old_size` is - // actually in use at each end, and needs to be copied. - virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size, - size_t new_size, size_t in_use_back, - size_t in_use_front) { - FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows - uint8_t *new_p = allocate(new_size); - memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, - in_use_front); - deallocate(old_p, old_size); - return new_p; - } - - protected: - // Called by `reallocate_downward` to copy memory from `old_p` of `old_size` - // to `new_p` of `new_size`. Only memory of size `in_use_front` and - // `in_use_back` will be copied from the front and back of the old memory - // allocation. + virtual ~Allocator() {} + + // Allocate `size` bytes of memory. + virtual uint8_t *allocate(size_t size) = 0; + + // Deallocate `size` bytes of memory at `p` allocated by this allocator. + virtual void deallocate(uint8_t *p, size_t size) = 0; + + // Reallocate `new_size` bytes of memory, replacing the old region of size + // `old_size` at `p`. In contrast to a normal realloc, this grows downwards, + // and is intended specifcally for `vector_downward` use. + // `in_use_back` and `in_use_front` indicate how much of `old_size` is + // actually in use at each end, and needs to be copied. + virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size, + size_t new_size, size_t in_use_back, + size_t in_use_front) { + FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows + uint8_t *new_p = allocate(new_size); + memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, + in_use_front); + deallocate(old_p, old_size); + return new_p; + } + + protected: + // Called by `reallocate_downward` to copy memory from `old_p` of `old_size` + // to `new_p` of `new_size`. Only memory of size `in_use_front` and + // `in_use_back` will be copied from the front and back of the old memory + // allocation. void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p, size_t new_size, size_t in_use_back, size_t in_use_front) { - memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back, - in_use_back); - memcpy(new_p, old_p, in_use_front); - } + memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back, + in_use_back); + memcpy(new_p, old_p, in_use_front); + } }; -// DefaultAllocator uses new/delete to allocate memory regions -class DefaultAllocator : public Allocator { - public: - uint8_t *allocate(size_t size) FLATBUFFERS_OVERRIDE { - return new uint8_t[size]; - } - +// DefaultAllocator uses new/delete to allocate memory regions +class DefaultAllocator : public Allocator { + public: + uint8_t *allocate(size_t size) FLATBUFFERS_OVERRIDE { + return new uint8_t[size]; + } + void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; } static void dealloc(void *p, size_t) { delete[] static_cast<uint8_t *>(p); } -}; - -// These functions allow for a null allocator to mean use the default allocator, -// as used by DetachedBuffer and vector_downward below. -// This is to avoid having a statically or dynamically allocated default -// allocator, or having to move it between the classes that may own it. -inline uint8_t *Allocate(Allocator *allocator, size_t size) { - return allocator ? allocator->allocate(size) - : DefaultAllocator().allocate(size); -} - -inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) { +}; + +// These functions allow for a null allocator to mean use the default allocator, +// as used by DetachedBuffer and vector_downward below. +// This is to avoid having a statically or dynamically allocated default +// allocator, or having to move it between the classes that may own it. +inline uint8_t *Allocate(Allocator *allocator, size_t size) { + return allocator ? allocator->allocate(size) + : DefaultAllocator().allocate(size); +} + +inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) { if (allocator) allocator->deallocate(p, size); else DefaultAllocator().deallocate(p, size); -} - -inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p, - size_t old_size, size_t new_size, - size_t in_use_back, size_t in_use_front) { +} + +inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p, + size_t old_size, size_t new_size, + size_t in_use_back, size_t in_use_front) { return allocator ? allocator->reallocate_downward(old_p, old_size, new_size, in_use_back, in_use_front) : DefaultAllocator().reallocate_downward( old_p, old_size, new_size, in_use_back, in_use_front); -} - -// DetachedBuffer is a finished flatbuffer memory region, detached from its -// builder. The original memory region and allocator are also stored so that -// the DetachedBuffer can manage the memory lifetime. -class DetachedBuffer { - public: - DetachedBuffer() - : allocator_(nullptr), - own_allocator_(false), - buf_(nullptr), - reserved_(0), - cur_(nullptr), - size_(0) {} - - DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf, - size_t reserved, uint8_t *cur, size_t sz) - : allocator_(allocator), - own_allocator_(own_allocator), - buf_(buf), - reserved_(reserved), - cur_(cur), - size_(sz) {} - +} + +// DetachedBuffer is a finished flatbuffer memory region, detached from its +// builder. The original memory region and allocator are also stored so that +// the DetachedBuffer can manage the memory lifetime. +class DetachedBuffer { + public: + DetachedBuffer() + : allocator_(nullptr), + own_allocator_(false), + buf_(nullptr), + reserved_(0), + cur_(nullptr), + size_(0) {} + + DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf, + size_t reserved, uint8_t *cur, size_t sz) + : allocator_(allocator), + own_allocator_(own_allocator), + buf_(buf), + reserved_(reserved), + cur_(cur), + size_(sz) {} + // clang-format off #if !defined(FLATBUFFERS_CPP98_STL) // clang-format on - DetachedBuffer(DetachedBuffer &&other) - : allocator_(other.allocator_), - own_allocator_(other.own_allocator_), - buf_(other.buf_), - reserved_(other.reserved_), - cur_(other.cur_), - size_(other.size_) { - other.reset(); - } + DetachedBuffer(DetachedBuffer &&other) + : allocator_(other.allocator_), + own_allocator_(other.own_allocator_), + buf_(other.buf_), + reserved_(other.reserved_), + cur_(other.cur_), + size_(other.size_) { + other.reset(); + } // clang-format off #endif // !defined(FLATBUFFERS_CPP98_STL) // clang-format on - + // clang-format off #if !defined(FLATBUFFERS_CPP98_STL) // clang-format on - DetachedBuffer &operator=(DetachedBuffer &&other) { + DetachedBuffer &operator=(DetachedBuffer &&other) { if (this == &other) return *this; - destroy(); - - allocator_ = other.allocator_; - own_allocator_ = other.own_allocator_; - buf_ = other.buf_; - reserved_ = other.reserved_; - cur_ = other.cur_; - size_ = other.size_; - - other.reset(); - - return *this; - } + destroy(); + + allocator_ = other.allocator_; + own_allocator_ = other.own_allocator_; + buf_ = other.buf_; + reserved_ = other.reserved_; + cur_ = other.cur_; + size_ = other.size_; + + other.reset(); + + return *this; + } // clang-format off #endif // !defined(FLATBUFFERS_CPP98_STL) // clang-format on - - ~DetachedBuffer() { destroy(); } - - const uint8_t *data() const { return cur_; } - - uint8_t *data() { return cur_; } - - size_t size() const { return size_; } - - // clang-format off - #if 0 // disabled for now due to the ordering of classes in this header - template <class T> - bool Verify() const { - Verifier verifier(data(), size()); - return verifier.Verify<T>(nullptr); - } - - template <class T> - const T* GetRoot() const { - return flatbuffers::GetRoot<T>(data()); - } - - template <class T> - T* GetRoot() { - return flatbuffers::GetRoot<T>(data()); - } - #endif - // clang-format on - + + ~DetachedBuffer() { destroy(); } + + const uint8_t *data() const { return cur_; } + + uint8_t *data() { return cur_; } + + size_t size() const { return size_; } + + // clang-format off + #if 0 // disabled for now due to the ordering of classes in this header + template <class T> + bool Verify() const { + Verifier verifier(data(), size()); + return verifier.Verify<T>(nullptr); + } + + template <class T> + const T* GetRoot() const { + return flatbuffers::GetRoot<T>(data()); + } + + template <class T> + T* GetRoot() { + return flatbuffers::GetRoot<T>(data()); + } + #endif + // clang-format on + // clang-format off #if !defined(FLATBUFFERS_CPP98_STL) // clang-format on - // These may change access mode, leave these at end of public section + // These may change access mode, leave these at end of public section FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other)); - FLATBUFFERS_DELETE_FUNC( + FLATBUFFERS_DELETE_FUNC( DetachedBuffer &operator=(const DetachedBuffer &other)); // clang-format off #endif // !defined(FLATBUFFERS_CPP98_STL) // clang-format on - - protected: - Allocator *allocator_; - bool own_allocator_; - uint8_t *buf_; - size_t reserved_; - uint8_t *cur_; - size_t size_; - - inline void destroy() { - if (buf_) Deallocate(allocator_, buf_, reserved_); - if (own_allocator_ && allocator_) { delete allocator_; } - reset(); - } - - inline void reset() { - allocator_ = nullptr; - own_allocator_ = false; - buf_ = nullptr; - reserved_ = 0; - cur_ = nullptr; - size_ = 0; - } -}; - + + protected: + Allocator *allocator_; + bool own_allocator_; + uint8_t *buf_; + size_t reserved_; + uint8_t *cur_; + size_t size_; + + inline void destroy() { + if (buf_) Deallocate(allocator_, buf_, reserved_); + if (own_allocator_ && allocator_) { delete allocator_; } + reset(); + } + + inline void reset() { + allocator_ = nullptr; + own_allocator_ = false; + buf_ = nullptr; + reserved_ = 0; + cur_ = nullptr; + size_ = 0; + } +}; + // This is a minimal replication of std::vector<uint8_t> functionality, // except growing from higher to lower addresses. i.e push_back() inserts data // in the lowest address in the vector. -// Since this vector leaves the lower part unused, we support a "scratch-pad" -// that can be stored there for temporary data, to share the allocated space. -// Essentially, this supports 2 std::vectors in a single buffer. +// Since this vector leaves the lower part unused, we support a "scratch-pad" +// that can be stored there for temporary data, to share the allocated space. +// Essentially, this supports 2 std::vectors in a single buffer. class vector_downward { public: explicit vector_downward(size_t initial_size, Allocator *allocator, bool own_allocator, size_t buffer_minalign) - : allocator_(allocator), - own_allocator_(own_allocator), - initial_size_(initial_size), - buffer_minalign_(buffer_minalign), - reserved_(0), - buf_(nullptr), - cur_(nullptr), - scratch_(nullptr) {} - + : allocator_(allocator), + own_allocator_(own_allocator), + initial_size_(initial_size), + buffer_minalign_(buffer_minalign), + reserved_(0), + buf_(nullptr), + cur_(nullptr), + scratch_(nullptr) {} + // clang-format off #if !defined(FLATBUFFERS_CPP98_STL) - vector_downward(vector_downward &&other) + vector_downward(vector_downward &&other) #else vector_downward(vector_downward &other) #endif // defined(FLATBUFFERS_CPP98_STL) @@ -899,237 +899,237 @@ class vector_downward { buf_(other.buf_), cur_(other.cur_), scratch_(other.scratch_) { - // No change in other.allocator_ - // No change in other.initial_size_ - // No change in other.buffer_minalign_ - other.own_allocator_ = false; - other.reserved_ = 0; - other.buf_ = nullptr; - other.cur_ = nullptr; - other.scratch_ = nullptr; + // No change in other.allocator_ + // No change in other.initial_size_ + // No change in other.buffer_minalign_ + other.own_allocator_ = false; + other.reserved_ = 0; + other.buf_ = nullptr; + other.cur_ = nullptr; + other.scratch_ = nullptr; } // clang-format off #if !defined(FLATBUFFERS_CPP98_STL) // clang-format on - vector_downward &operator=(vector_downward &&other) { - // Move construct a temporary and swap idiom - vector_downward temp(std::move(other)); - swap(temp); - return *this; - } + vector_downward &operator=(vector_downward &&other) { + // Move construct a temporary and swap idiom + vector_downward temp(std::move(other)); + swap(temp); + return *this; + } // clang-format off #endif // defined(FLATBUFFERS_CPP98_STL) // clang-format on - + ~vector_downward() { - clear_buffer(); - clear_allocator(); + clear_buffer(); + clear_allocator(); } - void reset() { - clear_buffer(); - clear(); - } - - void clear() { - if (buf_) { - cur_ = buf_ + reserved_; - } else { - reserved_ = 0; - cur_ = nullptr; - } - clear_scratch(); + void reset() { + clear_buffer(); + clear(); + } + + void clear() { + if (buf_) { + cur_ = buf_ + reserved_; + } else { + reserved_ = 0; + cur_ = nullptr; + } + clear_scratch(); } void clear_scratch() { scratch_ = buf_; } - - void clear_allocator() { - if (own_allocator_ && allocator_) { delete allocator_; } - allocator_ = nullptr; - own_allocator_ = false; - } - - void clear_buffer() { - if (buf_) Deallocate(allocator_, buf_, reserved_); - buf_ = nullptr; - } - - // Relinquish the pointer to the caller. - uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) { - auto *buf = buf_; - allocated_bytes = reserved_; - offset = static_cast<size_t>(cur_ - buf_); - - // release_raw only relinquishes the buffer ownership. - // Does not deallocate or reset the allocator. Destructor will do that. - buf_ = nullptr; - clear(); - return buf; - } - + + void clear_allocator() { + if (own_allocator_ && allocator_) { delete allocator_; } + allocator_ = nullptr; + own_allocator_ = false; + } + + void clear_buffer() { + if (buf_) Deallocate(allocator_, buf_, reserved_); + buf_ = nullptr; + } + // Relinquish the pointer to the caller. - DetachedBuffer release() { - // allocator ownership (if any) is transferred to DetachedBuffer. - DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_, - size()); - if (own_allocator_) { - allocator_ = nullptr; - own_allocator_ = false; - } + uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) { + auto *buf = buf_; + allocated_bytes = reserved_; + offset = static_cast<size_t>(cur_ - buf_); + + // release_raw only relinquishes the buffer ownership. + // Does not deallocate or reset the allocator. Destructor will do that. + buf_ = nullptr; + clear(); + return buf; + } + + // Relinquish the pointer to the caller. + DetachedBuffer release() { + // allocator ownership (if any) is transferred to DetachedBuffer. + DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_, + size()); + if (own_allocator_) { + allocator_ = nullptr; + own_allocator_ = false; + } buf_ = nullptr; - clear(); - return fb; + clear(); + return fb; } - size_t ensure_space(size_t len) { - FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_); - if (len > static_cast<size_t>(cur_ - scratch_)) { reallocate(len); } - // Beyond this, signed offsets may not have enough range: - // (FlatBuffers > 2GB not supported). - FLATBUFFERS_ASSERT(size() < FLATBUFFERS_MAX_BUFFER_SIZE); - return len; + size_t ensure_space(size_t len) { + FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_); + if (len > static_cast<size_t>(cur_ - scratch_)) { reallocate(len); } + // Beyond this, signed offsets may not have enough range: + // (FlatBuffers > 2GB not supported). + FLATBUFFERS_ASSERT(size() < FLATBUFFERS_MAX_BUFFER_SIZE); + return len; } - inline uint8_t *make_space(size_t len) { - size_t space = ensure_space(len); - cur_ -= space; + inline uint8_t *make_space(size_t len) { + size_t space = ensure_space(len); + cur_ -= space; return cur_; } - // Returns nullptr if using the DefaultAllocator. - Allocator *get_custom_allocator() { return allocator_; } - + // Returns nullptr if using the DefaultAllocator. + Allocator *get_custom_allocator() { return allocator_; } + uoffset_t size() const { return static_cast<uoffset_t>(reserved_ - static_cast<size_t>(cur_ - buf_)); } - uoffset_t scratch_size() const { - return static_cast<uoffset_t>(scratch_ - buf_); - } - - size_t capacity() const { return reserved_; } - + uoffset_t scratch_size() const { + return static_cast<uoffset_t>(scratch_ - buf_); + } + + size_t capacity() const { return reserved_; } + uint8_t *data() const { - FLATBUFFERS_ASSERT(cur_); + FLATBUFFERS_ASSERT(cur_); return cur_; } - uint8_t *scratch_data() const { - FLATBUFFERS_ASSERT(buf_); - return buf_; - } - - uint8_t *scratch_end() const { - FLATBUFFERS_ASSERT(scratch_); - return scratch_; - } - - uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; } + uint8_t *scratch_data() const { + FLATBUFFERS_ASSERT(buf_); + return buf_; + } + + uint8_t *scratch_end() const { + FLATBUFFERS_ASSERT(scratch_); + return scratch_; + } + + uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; } void push(const uint8_t *bytes, size_t num) { if (num > 0) { memcpy(make_space(num), bytes, num); } } - // Specialized version of push() that avoids memcpy call for small data. - template<typename T> void push_small(const T &little_endian_t) { - make_space(sizeof(T)); - *reinterpret_cast<T *>(cur_) = little_endian_t; - } - - template<typename T> void scratch_push_small(const T &t) { - ensure_space(sizeof(T)); - *reinterpret_cast<T *>(scratch_) = t; - scratch_ += sizeof(T); - } - - // fill() is most frequently called with small byte counts (<= 4), - // which is why we're using loops rather than calling memset. + // Specialized version of push() that avoids memcpy call for small data. + template<typename T> void push_small(const T &little_endian_t) { + make_space(sizeof(T)); + *reinterpret_cast<T *>(cur_) = little_endian_t; + } + + template<typename T> void scratch_push_small(const T &t) { + ensure_space(sizeof(T)); + *reinterpret_cast<T *>(scratch_) = t; + scratch_ += sizeof(T); + } + + // fill() is most frequently called with small byte counts (<= 4), + // which is why we're using loops rather than calling memset. void fill(size_t zero_pad_bytes) { - make_space(zero_pad_bytes); - for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0; + make_space(zero_pad_bytes); + for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0; } - // Version for when we know the size is larger. + // Version for when we know the size is larger. // Precondition: zero_pad_bytes > 0 - void fill_big(size_t zero_pad_bytes) { - memset(make_space(zero_pad_bytes), 0, zero_pad_bytes); - } - + void fill_big(size_t zero_pad_bytes) { + memset(make_space(zero_pad_bytes), 0, zero_pad_bytes); + } + void pop(size_t bytes_to_remove) { cur_ += bytes_to_remove; } - void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; } - - void swap(vector_downward &other) { - using std::swap; - swap(allocator_, other.allocator_); - swap(own_allocator_, other.own_allocator_); - swap(initial_size_, other.initial_size_); - swap(buffer_minalign_, other.buffer_minalign_); - swap(reserved_, other.reserved_); - swap(buf_, other.buf_); - swap(cur_, other.cur_); - swap(scratch_, other.scratch_); - } - - void swap_allocator(vector_downward &other) { - using std::swap; - swap(allocator_, other.allocator_); - swap(own_allocator_, other.own_allocator_); - } - + void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; } + + void swap(vector_downward &other) { + using std::swap; + swap(allocator_, other.allocator_); + swap(own_allocator_, other.own_allocator_); + swap(initial_size_, other.initial_size_); + swap(buffer_minalign_, other.buffer_minalign_); + swap(reserved_, other.reserved_); + swap(buf_, other.buf_); + swap(cur_, other.cur_); + swap(scratch_, other.scratch_); + } + + void swap_allocator(vector_downward &other) { + using std::swap; + swap(allocator_, other.allocator_); + swap(own_allocator_, other.own_allocator_); + } + private: // You shouldn't really be copying instances of this class. FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward &)); FLATBUFFERS_DELETE_FUNC(vector_downward &operator=(const vector_downward &)); - Allocator *allocator_; - bool own_allocator_; - size_t initial_size_; - size_t buffer_minalign_; + Allocator *allocator_; + bool own_allocator_; + size_t initial_size_; + size_t buffer_minalign_; size_t reserved_; uint8_t *buf_; uint8_t *cur_; // Points at location between empty (below) and used (above). - uint8_t *scratch_; // Points to the end of the scratchpad in use. - - void reallocate(size_t len) { - auto old_reserved = reserved_; - auto old_size = size(); - auto old_scratch_size = scratch_size(); + uint8_t *scratch_; // Points to the end of the scratchpad in use. + + void reallocate(size_t len) { + auto old_reserved = reserved_; + auto old_size = size(); + auto old_scratch_size = scratch_size(); reserved_ += (std::max)(len, old_reserved ? old_reserved / 2 : initial_size_); - reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1); - if (buf_) { - buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_, - old_size, old_scratch_size); - } else { - buf_ = Allocate(allocator_, reserved_); - } - cur_ = buf_ + reserved_ - old_size; - scratch_ = buf_ + old_scratch_size; - } + reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1); + if (buf_) { + buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_, + old_size, old_scratch_size); + } else { + buf_ = Allocate(allocator_, reserved_); + } + cur_ = buf_ + reserved_ - old_size; + scratch_ = buf_ + old_scratch_size; + } }; // Converts a Field ID to a virtual table offset. inline voffset_t FieldIndexToOffset(voffset_t field_id) { // Should correspond to what EndTable() below builds up. const int fixed_fields = 2; // Vtable size and Object Size. - return static_cast<voffset_t>((field_id + fixed_fields) * sizeof(voffset_t)); + return static_cast<voffset_t>((field_id + fixed_fields) * sizeof(voffset_t)); } -template<typename T, typename Alloc> -const T *data(const std::vector<T, Alloc> &v) { +template<typename T, typename Alloc> +const T *data(const std::vector<T, Alloc> &v) { // Eventually the returned pointer gets passed down to memcpy, so // we need it to be non-null to avoid undefined behavior. static uint8_t t; return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front(); } -template<typename T, typename Alloc> T *data(std::vector<T, Alloc> &v) { +template<typename T, typename Alloc> T *data(std::vector<T, Alloc> &v) { // Eventually the returned pointer gets passed down to memcpy, so // we need it to be non-null to avoid undefined behavior. static uint8_t t; return v.empty() ? reinterpret_cast<T *>(&t) : &v.front(); -} - +} + /// @endcond /// @addtogroup flatbuffers_cpp_api @@ -1141,103 +1141,103 @@ template<typename T, typename Alloc> T *data(std::vector<T, Alloc> &v) { /// `PushElement`/`AddElement`/`EndTable`, or the builtin `CreateString`/ /// `CreateVector` functions. Do this is depth-first order to build up a tree to /// the root. `Finish()` wraps up the buffer ready for transport. -class FlatBufferBuilder { +class FlatBufferBuilder { public: /// @brief Default constructor for FlatBufferBuilder. /// @param[in] initial_size The initial size of the buffer, in bytes. Defaults - /// to `1024`. - /// @param[in] allocator An `Allocator` to use. If null will use - /// `DefaultAllocator`. - /// @param[in] own_allocator Whether the builder/vector should own the - /// allocator. Defaults to / `false`. - /// @param[in] buffer_minalign Force the buffer to be aligned to the given - /// minimum alignment upon reallocation. Only needed if you intend to store - /// types with custom alignment AND you wish to read the buffer in-place - /// directly after creation. + /// to `1024`. + /// @param[in] allocator An `Allocator` to use. If null will use + /// `DefaultAllocator`. + /// @param[in] own_allocator Whether the builder/vector should own the + /// allocator. Defaults to / `false`. + /// @param[in] buffer_minalign Force the buffer to be aligned to the given + /// minimum alignment upon reallocation. Only needed if you intend to store + /// types with custom alignment AND you wish to read the buffer in-place + /// directly after creation. explicit FlatBufferBuilder( size_t initial_size = 1024, Allocator *allocator = nullptr, bool own_allocator = false, size_t buffer_minalign = AlignOf<largest_scalar_t>()) - : buf_(initial_size, allocator, own_allocator, buffer_minalign), - num_field_loc(0), - max_voffset_(0), - nested(false), - finished(false), - minalign_(1), - force_defaults_(false), - dedup_vtables_(true), - string_pool(nullptr) { + : buf_(initial_size, allocator, own_allocator, buffer_minalign), + num_field_loc(0), + max_voffset_(0), + nested(false), + finished(false), + minalign_(1), + force_defaults_(false), + dedup_vtables_(true), + string_pool(nullptr) { EndianCheck(); } // clang-format off - /// @brief Move constructor for FlatBufferBuilder. + /// @brief Move constructor for FlatBufferBuilder. #if !defined(FLATBUFFERS_CPP98_STL) - FlatBufferBuilder(FlatBufferBuilder &&other) + FlatBufferBuilder(FlatBufferBuilder &&other) #else FlatBufferBuilder(FlatBufferBuilder &other) #endif // #if !defined(FLATBUFFERS_CPP98_STL) - : buf_(1024, nullptr, false, AlignOf<largest_scalar_t>()), - num_field_loc(0), - max_voffset_(0), - nested(false), - finished(false), - minalign_(1), - force_defaults_(false), - dedup_vtables_(true), - string_pool(nullptr) { - EndianCheck(); - // Default construct and swap idiom. - // Lack of delegating constructors in vs2010 makes it more verbose than needed. - Swap(other); - } + : buf_(1024, nullptr, false, AlignOf<largest_scalar_t>()), + num_field_loc(0), + max_voffset_(0), + nested(false), + finished(false), + minalign_(1), + force_defaults_(false), + dedup_vtables_(true), + string_pool(nullptr) { + EndianCheck(); + // Default construct and swap idiom. + // Lack of delegating constructors in vs2010 makes it more verbose than needed. + Swap(other); + } // clang-format on - + // clang-format off #if !defined(FLATBUFFERS_CPP98_STL) // clang-format on - /// @brief Move assignment operator for FlatBufferBuilder. - FlatBufferBuilder &operator=(FlatBufferBuilder &&other) { - // Move construct a temporary and swap idiom - FlatBufferBuilder temp(std::move(other)); - Swap(temp); - return *this; - } + /// @brief Move assignment operator for FlatBufferBuilder. + FlatBufferBuilder &operator=(FlatBufferBuilder &&other) { + // Move construct a temporary and swap idiom + FlatBufferBuilder temp(std::move(other)); + Swap(temp); + return *this; + } // clang-format off #endif // defined(FLATBUFFERS_CPP98_STL) // clang-format on - - void Swap(FlatBufferBuilder &other) { - using std::swap; - buf_.swap(other.buf_); - swap(num_field_loc, other.num_field_loc); - swap(max_voffset_, other.max_voffset_); - swap(nested, other.nested); - swap(finished, other.finished); - swap(minalign_, other.minalign_); - swap(force_defaults_, other.force_defaults_); - swap(dedup_vtables_, other.dedup_vtables_); - swap(string_pool, other.string_pool); - } - - ~FlatBufferBuilder() { - if (string_pool) delete string_pool; - } - - void Reset() { - Clear(); // clear builder state - buf_.reset(); // deallocate buffer - } - + + void Swap(FlatBufferBuilder &other) { + using std::swap; + buf_.swap(other.buf_); + swap(num_field_loc, other.num_field_loc); + swap(max_voffset_, other.max_voffset_); + swap(nested, other.nested); + swap(finished, other.finished); + swap(minalign_, other.minalign_); + swap(force_defaults_, other.force_defaults_); + swap(dedup_vtables_, other.dedup_vtables_); + swap(string_pool, other.string_pool); + } + + ~FlatBufferBuilder() { + if (string_pool) delete string_pool; + } + + void Reset() { + Clear(); // clear builder state + buf_.reset(); // deallocate buffer + } + /// @brief Reset all the state in this FlatBufferBuilder so it can be reused /// to construct another buffer. void Clear() { - ClearOffsets(); + ClearOffsets(); buf_.clear(); nested = false; finished = false; minalign_ = 1; - if (string_pool) string_pool->clear(); + if (string_pool) string_pool->clear(); } /// @brief The current size of the serialized buffer, counting from the end. @@ -1266,45 +1266,45 @@ class FlatBufferBuilder { /// @brief Get the released pointer to the serialized buffer. /// @warning Do NOT attempt to use this FlatBufferBuilder afterwards! - /// @return A `FlatBuffer` that owns the buffer and its allocator and - /// behaves similar to a `unique_ptr` with a deleter. + /// @return A `FlatBuffer` that owns the buffer and its allocator and + /// behaves similar to a `unique_ptr` with a deleter. FLATBUFFERS_ATTRIBUTE(deprecated("use Release() instead")) - DetachedBuffer ReleaseBufferPointer() { + DetachedBuffer ReleaseBufferPointer() { Finished(); return buf_.release(); } - /// @brief Get the released DetachedBuffer. - /// @return A `DetachedBuffer` that owns the buffer and its allocator. - DetachedBuffer Release() { - Finished(); - return buf_.release(); - } - - /// @brief Get the released pointer to the serialized buffer. + /// @brief Get the released DetachedBuffer. + /// @return A `DetachedBuffer` that owns the buffer and its allocator. + DetachedBuffer Release() { + Finished(); + return buf_.release(); + } + + /// @brief Get the released pointer to the serialized buffer. /// @param size The size of the memory block containing - /// the serialized `FlatBuffer`. + /// the serialized `FlatBuffer`. /// @param offset The offset from the released pointer where the finished - /// `FlatBuffer` starts. - /// @return A raw pointer to the start of the memory block containing - /// the serialized `FlatBuffer`. + /// `FlatBuffer` starts. + /// @return A raw pointer to the start of the memory block containing + /// the serialized `FlatBuffer`. /// @remark If the allocator is owned, it gets deleted when the destructor is /// called.. - uint8_t *ReleaseRaw(size_t &size, size_t &offset) { - Finished(); - return buf_.release_raw(size, offset); - } - - /// @brief get the minimum alignment this buffer needs to be accessed - /// properly. This is only known once all elements have been written (after - /// you call Finish()). You can use this information if you need to embed - /// a FlatBuffer in some other buffer, such that you can later read it - /// without first having to copy it into its own buffer. + uint8_t *ReleaseRaw(size_t &size, size_t &offset) { + Finished(); + return buf_.release_raw(size, offset); + } + + /// @brief get the minimum alignment this buffer needs to be accessed + /// properly. This is only known once all elements have been written (after + /// you call Finish()). You can use this information if you need to embed + /// a FlatBuffer in some other buffer, such that you can later read it + /// without first having to copy it into its own buffer. size_t GetBufferMinAlignment() const { - Finished(); - return minalign_; - } - + Finished(); + return minalign_; + } + /// @cond FLATBUFFERS_INTERNAL void Finished() const { // If you get this assert, you're attempting to get access a buffer @@ -1312,7 +1312,7 @@ class FlatBufferBuilder { // FlatBufferBuilder::Finish with your root table. // If you really need to access an unfinished buffer, call // GetCurrentBufferPointer instead. - FLATBUFFERS_ASSERT(finished); + FLATBUFFERS_ASSERT(finished); } /// @endcond @@ -1323,19 +1323,19 @@ class FlatBufferBuilder { /// serialized. void ForceDefaults(bool fd) { force_defaults_ = fd; } - /// @brief By default vtables are deduped in order to save space. + /// @brief By default vtables are deduped in order to save space. /// @param[in] dedup When set to `true`, dedup vtables. - void DedupVtables(bool dedup) { dedup_vtables_ = dedup; } - + void DedupVtables(bool dedup) { dedup_vtables_ = dedup; } + /// @cond FLATBUFFERS_INTERNAL void Pad(size_t num_bytes) { buf_.fill(num_bytes); } - void TrackMinAlign(size_t elem_size) { - if (elem_size > minalign_) minalign_ = elem_size; - } - + void TrackMinAlign(size_t elem_size) { + if (elem_size > minalign_) minalign_ = elem_size; + } + void Align(size_t elem_size) { - TrackMinAlign(elem_size); + TrackMinAlign(elem_size); buf_.fill(PaddingBytes(buf_.size(), elem_size)); } @@ -1344,13 +1344,13 @@ class FlatBufferBuilder { finished = true; } - void PushBytes(const uint8_t *bytes, size_t size) { buf_.push(bytes, size); } + void PushBytes(const uint8_t *bytes, size_t size) { buf_.push(bytes, size); } void PopBytes(size_t amount) { buf_.pop(amount); } template<typename T> void AssertScalarT() { // The code assumes power of 2 sizes and endian-swap-ability. - static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); + static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); } // Write a single aligned scalar to the buffer @@ -1358,7 +1358,7 @@ class FlatBufferBuilder { AssertScalarT<T>(); T litle_endian_element = EndianScalar(element); Align(sizeof(T)); - buf_.push_small(litle_endian_element); + buf_.push_small(litle_endian_element); return GetSize(); } @@ -1371,9 +1371,9 @@ class FlatBufferBuilder { // vtables later. void TrackField(voffset_t field, uoffset_t off) { FieldLoc fl = { off, field }; - buf_.scratch_push_small(fl); - num_field_loc++; - max_voffset_ = (std::max)(max_voffset_, field); + buf_.scratch_push_small(fl); + num_field_loc++; + max_voffset_ = (std::max)(max_voffset_, field); } // Like PushElement, but additionally tracks the field this represents. @@ -1390,14 +1390,14 @@ class FlatBufferBuilder { } template<typename T> void AddOffset(voffset_t field, Offset<T> off) { - if (off.IsNull()) return; // Don't store. + if (off.IsNull()) return; // Don't store. AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); } template<typename T> void AddStruct(voffset_t field, const T *structptr) { if (!structptr) return; // Default, don't store. Align(AlignOf<T>()); - buf_.push_small(*structptr); + buf_.push_small(*structptr); TrackField(field, GetSize()); } @@ -1412,8 +1412,8 @@ class FlatBufferBuilder { // Align to ensure GetSize() below is correct. Align(sizeof(uoffset_t)); // Offset must refer to something already in buffer. - FLATBUFFERS_ASSERT(off && off <= GetSize()); - return GetSize() - off + static_cast<uoffset_t>(sizeof(uoffset_t)); + FLATBUFFERS_ASSERT(off && off <= GetSize()); + return GetSize() - off + static_cast<uoffset_t>(sizeof(uoffset_t)); } void NotNested() { @@ -1425,9 +1425,9 @@ class FlatBufferBuilder { // Ignoring this assert may appear to work in simple cases, but the reason // it is here is that storing objects in-line may cause vtable offsets // to not fit anymore. It also leads to vtable duplication. - FLATBUFFERS_ASSERT(!nested); - // If you hit this, fields were added outside the scope of a table. - FLATBUFFERS_ASSERT(!num_field_loc); + FLATBUFFERS_ASSERT(!nested); + // If you hit this, fields were added outside the scope of a table. + FLATBUFFERS_ASSERT(!num_field_loc); } // From generated code (or from the parser), we call StartTable/EndTable @@ -1441,57 +1441,57 @@ class FlatBufferBuilder { // This finishes one serialized object by generating the vtable if it's a // table, comparing it against existing vtables, and writing the // resulting vtable offset. - uoffset_t EndTable(uoffset_t start) { + uoffset_t EndTable(uoffset_t start) { // If you get this assert, a corresponding StartTable wasn't called. - FLATBUFFERS_ASSERT(nested); + FLATBUFFERS_ASSERT(nested); // Write the vtable offset, which is the start of any Table. // We fill it's value later. auto vtableoffsetloc = PushElement<soffset_t>(0); // Write a vtable, which consists entirely of voffset_t elements. // It starts with the number of offsets, followed by a type id, followed // by the offsets themselves. In reverse: - // Include space for the last offset and ensure empty tables have a - // minimum size. - max_voffset_ = - (std::max)(static_cast<voffset_t>(max_voffset_ + sizeof(voffset_t)), - FieldIndexToOffset(0)); - buf_.fill_big(max_voffset_); + // Include space for the last offset and ensure empty tables have a + // minimum size. + max_voffset_ = + (std::max)(static_cast<voffset_t>(max_voffset_ + sizeof(voffset_t)), + FieldIndexToOffset(0)); + buf_.fill_big(max_voffset_); auto table_object_size = vtableoffsetloc - start; - // Vtable use 16bit offsets. - FLATBUFFERS_ASSERT(table_object_size < 0x10000); - WriteScalar<voffset_t>(buf_.data() + sizeof(voffset_t), - static_cast<voffset_t>(table_object_size)); - WriteScalar<voffset_t>(buf_.data(), max_voffset_); + // Vtable use 16bit offsets. + FLATBUFFERS_ASSERT(table_object_size < 0x10000); + WriteScalar<voffset_t>(buf_.data() + sizeof(voffset_t), + static_cast<voffset_t>(table_object_size)); + WriteScalar<voffset_t>(buf_.data(), max_voffset_); // Write the offsets into the table - for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc); - it < buf_.scratch_end(); it += sizeof(FieldLoc)) { - auto field_location = reinterpret_cast<FieldLoc *>(it); + for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc); + it < buf_.scratch_end(); it += sizeof(FieldLoc)) { + auto field_location = reinterpret_cast<FieldLoc *>(it); auto pos = static_cast<voffset_t>(vtableoffsetloc - field_location->off); // If this asserts, it means you've set a field twice. - FLATBUFFERS_ASSERT( - !ReadScalar<voffset_t>(buf_.data() + field_location->id)); + FLATBUFFERS_ASSERT( + !ReadScalar<voffset_t>(buf_.data() + field_location->id)); WriteScalar<voffset_t>(buf_.data() + field_location->id, pos); } - ClearOffsets(); + ClearOffsets(); auto vt1 = reinterpret_cast<voffset_t *>(buf_.data()); auto vt1_size = ReadScalar<voffset_t>(vt1); auto vt_use = GetSize(); // See if we already have generated a vtable with this exact same // layout before. If so, make it point to the old one, remove this one. - if (dedup_vtables_) { - for (auto it = buf_.scratch_data(); it < buf_.scratch_end(); - it += sizeof(uoffset_t)) { - auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it); - auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr)); + if (dedup_vtables_) { + for (auto it = buf_.scratch_data(); it < buf_.scratch_end(); + it += sizeof(uoffset_t)) { + auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it); + auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr)); auto vt2_size = ReadScalar<voffset_t>(vt2); if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue; - vt_use = *vt_offset_ptr; - buf_.pop(GetSize() - vtableoffsetloc); - break; - } + vt_use = *vt_offset_ptr; + buf_.pop(GetSize() - vtableoffsetloc); + break; + } } // If this is a new vtable, remember it. - if (vt_use == GetSize()) { buf_.scratch_push_small(vt_use); } + if (vt_use == GetSize()) { buf_.scratch_push_small(vt_use); } // Fill the vtable offset we created above. // The offset points from the beginning of the object to where the // vtable is stored. @@ -1499,20 +1499,20 @@ class FlatBufferBuilder { // flexibility (storing all vtables at the start of the file). WriteScalar(buf_.data_at(vtableoffsetloc), static_cast<soffset_t>(vt_use) - - static_cast<soffset_t>(vtableoffsetloc)); + static_cast<soffset_t>(vtableoffsetloc)); nested = false; return vtableoffsetloc; } FLATBUFFERS_ATTRIBUTE(deprecated("call the version above instead")) - uoffset_t EndTable(uoffset_t start, voffset_t /*numfields*/) { - return EndTable(start); - } - + uoffset_t EndTable(uoffset_t start, voffset_t /*numfields*/) { + return EndTable(start); + } + // This checks a required field has been set in a given table that has // just been constructed. - template<typename T> void Required(Offset<T> table, voffset_t field); + template<typename T> void Required(Offset<T> table, voffset_t field); uoffset_t StartStruct(size_t alignment) { Align(alignment); @@ -1521,16 +1521,16 @@ class FlatBufferBuilder { uoffset_t EndStruct() { return GetSize(); } - void ClearOffsets() { - buf_.scratch_pop(num_field_loc * sizeof(FieldLoc)); - num_field_loc = 0; - max_voffset_ = 0; - } + void ClearOffsets() { + buf_.scratch_pop(num_field_loc * sizeof(FieldLoc)); + num_field_loc = 0; + max_voffset_ = 0; + } // Aligns such that when "len" bytes are written, an object can be written // after it with "alignment" without padding. void PreAlign(size_t len, size_t alignment) { - TrackMinAlign(alignment); + TrackMinAlign(alignment); buf_.fill(PaddingBytes(GetSize() + len, alignment)); } template<typename T> void PreAlign(size_t len) { @@ -1552,20 +1552,20 @@ class FlatBufferBuilder { return Offset<String>(GetSize()); } - /// @brief Store a string in the buffer, which is null-terminated. + /// @brief Store a string in the buffer, which is null-terminated. /// @param[in] str A const char pointer to a C-string to add to the buffer. /// @return Returns the offset in the buffer where the string starts. Offset<String> CreateString(const char *str) { return CreateString(str, strlen(str)); } - /// @brief Store a string in the buffer, which is null-terminated. - /// @param[in] str A char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateString(char *str) { - return CreateString(str, strlen(str)); - } - + /// @brief Store a string in the buffer, which is null-terminated. + /// @param[in] str A char pointer to a C-string to add to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset<String> CreateString(char *str) { + return CreateString(str, strlen(str)); + } + /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const reference to a std::string to store in the buffer. /// @return Returns the offset in the buffer where the string starts. @@ -1573,57 +1573,57 @@ class FlatBufferBuilder { return CreateString(str.c_str(), str.length()); } - // clang-format off - #ifdef FLATBUFFERS_HAS_STRING_VIEW - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const string_view to copy in to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateString(flatbuffers::string_view str) { - return CreateString(str.data(), str.size()); - } - #endif // FLATBUFFERS_HAS_STRING_VIEW - // clang-format on - + // clang-format off + #ifdef FLATBUFFERS_HAS_STRING_VIEW /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const string_view to copy in to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset<String> CreateString(flatbuffers::string_view str) { + return CreateString(str.data(), str.size()); + } + #endif // FLATBUFFERS_HAS_STRING_VIEW + // clang-format on + + /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const pointer to a `String` struct to add to the buffer. /// @return Returns the offset in the buffer where the string starts Offset<String> CreateString(const String *str) { return str ? CreateString(str->c_str(), str->size()) : 0; } - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const reference to a std::string like type with support - /// of T::c_str() and T::length() to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - template<typename T> Offset<String> CreateString(const T &str) { + /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const reference to a std::string like type with support + /// of T::c_str() and T::length() to store in the buffer. + /// @return Returns the offset in the buffer where the string starts. + template<typename T> Offset<String> CreateString(const T &str) { return CreateString(str.data(), str.length()); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const char pointer to the data to be stored as a string. - /// @param[in] len The number of bytes that should be stored from `str`. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateSharedString(const char *str, size_t len) { - if (!string_pool) - string_pool = new StringOffsetMap(StringOffsetCompare(buf_)); - auto size_before_string = buf_.size(); - // Must first serialize the string, since the set is all offsets into - // buffer. - auto off = CreateString(str, len); - auto it = string_pool->find(off); - // If it exists we reuse existing serialized data! - if (it != string_pool->end()) { - // We can remove the string we serialized. - buf_.pop(buf_.size() - size_before_string); - return *it; - } - // Record this string for future use. - string_pool->insert(off); - return off; - } - + } + + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. + /// @param[in] str A const char pointer to the data to be stored as a string. + /// @param[in] len The number of bytes that should be stored from `str`. + /// @return Returns the offset in the buffer where the string starts. + Offset<String> CreateSharedString(const char *str, size_t len) { + if (!string_pool) + string_pool = new StringOffsetMap(StringOffsetCompare(buf_)); + auto size_before_string = buf_.size(); + // Must first serialize the string, since the set is all offsets into + // buffer. + auto off = CreateString(str, len); + auto it = string_pool->find(off); + // If it exists we reuse existing serialized data! + if (it != string_pool->end()) { + // We can remove the string we serialized. + buf_.pop(buf_.size() - size_before_string); + return *it; + } + // Record this string for future use. + string_pool->insert(off); + return off; + } + #ifdef FLATBUFFERS_HAS_STRING_VIEW /// @brief Store a string in the buffer, which can contain any binary data. /// If a string with this exact contents has already been serialized before, @@ -1634,37 +1634,37 @@ class FlatBufferBuilder { return CreateSharedString(str.data(), str.size()); } #else - /// @brief Store a string in the buffer, which null-terminated. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateSharedString(const char *str) { - return CreateSharedString(str, strlen(str)); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const reference to a std::string to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateSharedString(const std::string &str) { - return CreateSharedString(str.c_str(), str.length()); - } + /// @brief Store a string in the buffer, which null-terminated. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. + /// @param[in] str A const char pointer to a C-string to add to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset<String> CreateSharedString(const char *str) { + return CreateSharedString(str, strlen(str)); + } + + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. + /// @param[in] str A const reference to a std::string to store in the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset<String> CreateSharedString(const std::string &str) { + return CreateSharedString(str.c_str(), str.length()); + } #endif - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const pointer to a `String` struct to add to the buffer. - /// @return Returns the offset in the buffer where the string starts - Offset<String> CreateSharedString(const String *str) { + + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. + /// @param[in] str A const pointer to a `String` struct to add to the buffer. + /// @return Returns the offset in the buffer where the string starts + Offset<String> CreateSharedString(const String *str) { return CreateSharedString(str->c_str(), str->size()); - } - + } + /// @cond FLATBUFFERS_INTERNAL uoffset_t EndVector(size_t len) { - FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. + FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. nested = false; return PushElement(static_cast<uoffset_t>(len)); } @@ -1686,12 +1686,12 @@ class FlatBufferBuilder { PreAlign(len * elemsize, alignment); } - // Similar to ForceVectorAlignment but for String fields. - void ForceStringAlignment(size_t len, size_t alignment) { + // Similar to ForceVectorAlignment but for String fields. + void ForceStringAlignment(size_t len, size_t alignment) { FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); - PreAlign((len + 1) * sizeof(char), alignment); + PreAlign((len + 1) * sizeof(char), alignment); } - + /// @endcond /// @brief Serialize an array into a FlatBuffer `vector`. @@ -1702,32 +1702,32 @@ class FlatBufferBuilder { /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template<typename T> Offset<Vector<T>> CreateVector(const T *v, size_t len) { - // If this assert hits, you're specifying a template argument that is - // causing the wrong overload to be selected, remove it. - AssertScalarT<T>(); + // If this assert hits, you're specifying a template argument that is + // causing the wrong overload to be selected, remove it. + AssertScalarT<T>(); StartVector(len, sizeof(T)); if (len == 0) { return Offset<Vector<T>>(EndVector(len)); } - // clang-format off - #if FLATBUFFERS_LITTLEENDIAN - PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T)); - #else - if (sizeof(T) == 1) { - PushBytes(reinterpret_cast<const uint8_t *>(v), len); - } else { - for (auto i = len; i > 0; ) { - PushElement(v[--i]); - } - } - #endif - // clang-format on - return Offset<Vector<T>>(EndVector(len)); - } - - template<typename T> - Offset<Vector<Offset<T>>> CreateVector(const Offset<T> *v, size_t len) { - StartVector(len, sizeof(Offset<T>)); - for (auto i = len; i > 0;) { PushElement(v[--i]); } - return Offset<Vector<Offset<T>>>(EndVector(len)); + // clang-format off + #if FLATBUFFERS_LITTLEENDIAN + PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T)); + #else + if (sizeof(T) == 1) { + PushBytes(reinterpret_cast<const uint8_t *>(v), len); + } else { + for (auto i = len; i > 0; ) { + PushElement(v[--i]); + } + } + #endif + // clang-format on + return Offset<Vector<T>>(EndVector(len)); + } + + template<typename T> + Offset<Vector<Offset<T>>> CreateVector(const Offset<T> *v, size_t len) { + StartVector(len, sizeof(Offset<T>)); + for (auto i = len; i > 0;) { PushElement(v[--i]); } + return Offset<Vector<Offset<T>>>(EndVector(len)); } /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. @@ -1737,67 +1737,67 @@ class FlatBufferBuilder { /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template<typename T> Offset<Vector<T>> CreateVector(const std::vector<T> &v) { - return CreateVector(data(v), v.size()); - } - - // vector<bool> may be implemented using a bit-set, so we can't access it as - // an array. Instead, read elements manually. - // Background: https://isocpp.org/blog/2012/11/on-vectorbool - Offset<Vector<uint8_t>> CreateVector(const std::vector<bool> &v) { - StartVector(v.size(), sizeof(uint8_t)); - for (auto i = v.size(); i > 0;) { - PushElement(static_cast<uint8_t>(v[--i])); - } - return Offset<Vector<uint8_t>>(EndVector(v.size())); - } - - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Serialize values returned by a function into a FlatBuffer `vector`. - /// This is a convenience function that takes care of iteration for you. - /// @tparam T The data type of the `std::vector` elements. - /// @param f A function that takes the current iteration 0..vector_size-1 and - /// returns any type that you can construct a FlatBuffers vector out of. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<T>> CreateVector(size_t vector_size, - const std::function<T (size_t i)> &f) { - std::vector<T> elems(vector_size); - for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); - return CreateVector(elems); - } - #endif - // clang-format on - - /// @brief Serialize values returned by a function into a FlatBuffer `vector`. - /// This is a convenience function that takes care of iteration for you. - /// @tparam T The data type of the `std::vector` elements. - /// @param f A function that takes the current iteration 0..vector_size-1, - /// and the state parameter returning any type that you can construct a - /// FlatBuffers vector out of. - /// @param state State passed to f. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename F, typename S> - Offset<Vector<T>> CreateVector(size_t vector_size, F f, S *state) { - std::vector<T> elems(vector_size); - for (size_t i = 0; i < vector_size; i++) elems[i] = f(i, state); - return CreateVector(elems); - } - - /// @brief Serialize a `std::vector<std::string>` into a FlatBuffer `vector`. - /// This is a convenience function for a common case. - /// @param v A const reference to the `std::vector` to serialize into the - /// buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - Offset<Vector<Offset<String>>> CreateVectorOfStrings( - const std::vector<std::string> &v) { - std::vector<Offset<String>> offsets(v.size()); - for (size_t i = 0; i < v.size(); i++) offsets[i] = CreateString(v[i]); - return CreateVector(offsets); - } - + return CreateVector(data(v), v.size()); + } + + // vector<bool> may be implemented using a bit-set, so we can't access it as + // an array. Instead, read elements manually. + // Background: https://isocpp.org/blog/2012/11/on-vectorbool + Offset<Vector<uint8_t>> CreateVector(const std::vector<bool> &v) { + StartVector(v.size(), sizeof(uint8_t)); + for (auto i = v.size(); i > 0;) { + PushElement(static_cast<uint8_t>(v[--i])); + } + return Offset<Vector<uint8_t>>(EndVector(v.size())); + } + + // clang-format off + #ifndef FLATBUFFERS_CPP98_STL + /// @brief Serialize values returned by a function into a FlatBuffer `vector`. + /// This is a convenience function that takes care of iteration for you. + /// @tparam T The data type of the `std::vector` elements. + /// @param f A function that takes the current iteration 0..vector_size-1 and + /// returns any type that you can construct a FlatBuffers vector out of. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T> Offset<Vector<T>> CreateVector(size_t vector_size, + const std::function<T (size_t i)> &f) { + std::vector<T> elems(vector_size); + for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); + return CreateVector(elems); + } + #endif + // clang-format on + + /// @brief Serialize values returned by a function into a FlatBuffer `vector`. + /// This is a convenience function that takes care of iteration for you. + /// @tparam T The data type of the `std::vector` elements. + /// @param f A function that takes the current iteration 0..vector_size-1, + /// and the state parameter returning any type that you can construct a + /// FlatBuffers vector out of. + /// @param state State passed to f. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T, typename F, typename S> + Offset<Vector<T>> CreateVector(size_t vector_size, F f, S *state) { + std::vector<T> elems(vector_size); + for (size_t i = 0; i < vector_size; i++) elems[i] = f(i, state); + return CreateVector(elems); + } + + /// @brief Serialize a `std::vector<std::string>` into a FlatBuffer `vector`. + /// This is a convenience function for a common case. + /// @param v A const reference to the `std::vector` to serialize into the + /// buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + Offset<Vector<Offset<String>>> CreateVectorOfStrings( + const std::vector<std::string> &v) { + std::vector<Offset<String>> offsets(v.size()); + for (size_t i = 0; i < v.size(); i++) offsets[i] = CreateString(v[i]); + return CreateVector(offsets); + } + /// @brief Serialize an array of structs into a FlatBuffer `vector`. /// @tparam T The data type of the struct array elements. /// @param[in] v A pointer to the array of type `T` to serialize into the @@ -1805,24 +1805,24 @@ class FlatBufferBuilder { /// @param[in] len The number of elements to serialize. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template<typename T> - Offset<Vector<const T *>> CreateVectorOfStructs(const T *v, size_t len) { + template<typename T> + Offset<Vector<const T *>> CreateVectorOfStructs(const T *v, size_t len) { StartVector(len * sizeof(T) / AlignOf<T>(), AlignOf<T>()); PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len); return Offset<Vector<const T *>>(EndVector(len)); } - /// @brief Serialize an array of native structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. + /// @brief Serialize an array of native structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @tparam S The data type of the native struct array elements. + /// @param[in] v A pointer to the array of type `S` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. /// @param[in] pack_func Pointer to a function to convert the native struct /// to the FlatBuffer struct. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T, typename S> Offset<Vector<const T *>> CreateVectorOfNativeStructs( const S *v, size_t len, T((*const pack_func)(const S &))) { FLATBUFFERS_ASSERT(pack_func); @@ -1840,78 +1840,78 @@ class FlatBufferBuilder { /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template<typename T, typename S> - Offset<Vector<const T *>> CreateVectorOfNativeStructs(const S *v, - size_t len) { - extern T Pack(const S &); + Offset<Vector<const T *>> CreateVectorOfNativeStructs(const S *v, + size_t len) { + extern T Pack(const S &); return CreateVectorOfNativeStructs(v, len, Pack); - } - - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. + } + + // clang-format off + #ifndef FLATBUFFERS_CPP98_STL + /// @brief Serialize an array of structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. /// @param[in] filler A function that takes the current iteration 0..vector_size-1 - /// and a pointer to the struct that must be filled. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - /// This is mostly useful when flatbuffers are generated with mutation - /// accessors. - template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( - size_t vector_size, const std::function<void(size_t i, T *)> &filler) { - T* structs = StartVectorOfStructs<T>(vector_size); - for (size_t i = 0; i < vector_size; i++) { - filler(i, structs); - structs++; - } - return EndVectorOfStructs<T>(vector_size); - } - #endif - // clang-format on - - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @param[in] f A function that takes the current iteration 0..vector_size-1, - /// a pointer to the struct that must be filled and the state argument. - /// @param[in] state Arbitrary state to pass to f. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - /// This is mostly useful when flatbuffers are generated with mutation - /// accessors. - template<typename T, typename F, typename S> - Offset<Vector<const T *>> CreateVectorOfStructs(size_t vector_size, F f, - S *state) { - T *structs = StartVectorOfStructs<T>(vector_size); - for (size_t i = 0; i < vector_size; i++) { - f(i, structs, state); - structs++; - } - return EndVectorOfStructs<T>(vector_size); - } - + /// and a pointer to the struct that must be filled. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + /// This is mostly useful when flatbuffers are generated with mutation + /// accessors. + template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( + size_t vector_size, const std::function<void(size_t i, T *)> &filler) { + T* structs = StartVectorOfStructs<T>(vector_size); + for (size_t i = 0; i < vector_size; i++) { + filler(i, structs); + structs++; + } + return EndVectorOfStructs<T>(vector_size); + } + #endif + // clang-format on + + /// @brief Serialize an array of structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @param[in] f A function that takes the current iteration 0..vector_size-1, + /// a pointer to the struct that must be filled and the state argument. + /// @param[in] state Arbitrary state to pass to f. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + /// This is mostly useful when flatbuffers are generated with mutation + /// accessors. + template<typename T, typename F, typename S> + Offset<Vector<const T *>> CreateVectorOfStructs(size_t vector_size, F f, + S *state) { + T *structs = StartVectorOfStructs<T>(vector_size); + for (size_t i = 0; i < vector_size; i++) { + f(i, structs, state); + structs++; + } + return EndVectorOfStructs<T>(vector_size); + } + /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector`. /// @tparam T The data type of the `std::vector` struct elements. /// @param[in] v A const reference to the `std::vector` of structs to /// serialize into the buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template<typename T, typename Alloc> - Offset<Vector<const T *>> CreateVectorOfStructs( - const std::vector<T, Alloc> &v) { - return CreateVectorOfStructs(data(v), v.size()); + template<typename T, typename Alloc> + Offset<Vector<const T *>> CreateVectorOfStructs( + const std::vector<T, Alloc> &v) { + return CreateVectorOfStructs(data(v), v.size()); } - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer - /// `vector`. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. + /// @brief Serialize a `std::vector` of native structs into a FlatBuffer + /// `vector`. + /// @tparam T The data type of the `std::vector` struct elements. + /// @tparam S The data type of the `std::vector` native struct elements. /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. + /// serialize into the buffer as a `vector`. /// @param[in] pack_func Pointer to a function to convert the native struct /// to the FlatBuffer struct. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> - Offset<Vector<const T *>> CreateVectorOfNativeStructs( + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T, typename S> + Offset<Vector<const T *>> CreateVectorOfNativeStructs( const std::vector<S> &v, T((*const pack_func)(const S &))) { return CreateVectorOfNativeStructs<T, S>(data(v), v.size(), pack_func); } @@ -1926,92 +1926,92 @@ class FlatBufferBuilder { /// where the vector is stored. template<typename T, typename S> Offset<Vector<const T *>> CreateVectorOfNativeStructs( - const std::vector<S> &v) { - return CreateVectorOfNativeStructs<T, S>(data(v), v.size()); - } - + const std::vector<S> &v) { + return CreateVectorOfNativeStructs<T, S>(data(v), v.size()); + } + /// @cond FLATBUFFERS_INTERNAL - template<typename T> struct StructKeyComparator { - bool operator()(const T &a, const T &b) const { - return a.KeyCompareLessThan(&b); - } - + template<typename T> struct StructKeyComparator { + bool operator()(const T &a, const T &b) const { + return a.KeyCompareLessThan(&b); + } + FLATBUFFERS_DELETE_FUNC( StructKeyComparator &operator=(const StructKeyComparator &)); - }; - /// @endcond - - /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector` - /// in sorted order. - /// @tparam T The data type of the `std::vector` struct elements. + }; + /// @endcond + + /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector` + /// in sorted order. + /// @tparam T The data type of the `std::vector` struct elements. /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> - Offset<Vector<const T *>> CreateVectorOfSortedStructs(std::vector<T> *v) { - return CreateVectorOfSortedStructs(data(*v), v->size()); - } - - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer - /// `vector` in sorted order. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T> + Offset<Vector<const T *>> CreateVectorOfSortedStructs(std::vector<T> *v) { + return CreateVectorOfSortedStructs(data(*v), v->size()); + } + + /// @brief Serialize a `std::vector` of native structs into a FlatBuffer + /// `vector` in sorted order. + /// @tparam T The data type of the `std::vector` struct elements. + /// @tparam S The data type of the `std::vector` native struct elements. /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> - Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs( - std::vector<S> *v) { - return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size()); - } - - /// @brief Serialize an array of structs into a FlatBuffer `vector` in sorted - /// order. - /// @tparam T The data type of the struct array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> - Offset<Vector<const T *>> CreateVectorOfSortedStructs(T *v, size_t len) { - std::sort(v, v + len, StructKeyComparator<T>()); - return CreateVectorOfStructs(v, len); - } - - /// @brief Serialize an array of native structs into a FlatBuffer `vector` in - /// sorted order. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> - Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs(S *v, - size_t len) { - extern T Pack(const S &); - typedef T (*Pack_t)(const S &); - std::vector<T> vv(len); + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T, typename S> + Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs( + std::vector<S> *v) { + return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size()); + } + + /// @brief Serialize an array of structs into a FlatBuffer `vector` in sorted + /// order. + /// @tparam T The data type of the struct array elements. + /// @param[in] v A pointer to the array of type `T` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T> + Offset<Vector<const T *>> CreateVectorOfSortedStructs(T *v, size_t len) { + std::sort(v, v + len, StructKeyComparator<T>()); + return CreateVectorOfStructs(v, len); + } + + /// @brief Serialize an array of native structs into a FlatBuffer `vector` in + /// sorted order. + /// @tparam T The data type of the struct array elements. + /// @tparam S The data type of the native struct array elements. + /// @param[in] v A pointer to the array of type `S` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template<typename T, typename S> + Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs(S *v, + size_t len) { + extern T Pack(const S &); + typedef T (*Pack_t)(const S &); + std::vector<T> vv(len); std::transform(v, v + len, vv.begin(), static_cast<Pack_t &>(Pack)); - return CreateVectorOfSortedStructs<T>(vv, len); - } - - /// @cond FLATBUFFERS_INTERNAL - template<typename T> struct TableKeyComparator { - TableKeyComparator(vector_downward &buf) : buf_(buf) {} + return CreateVectorOfSortedStructs<T>(vv, len); + } + + /// @cond FLATBUFFERS_INTERNAL + template<typename T> struct TableKeyComparator { + TableKeyComparator(vector_downward &buf) : buf_(buf) {} TableKeyComparator(const TableKeyComparator &other) : buf_(other.buf_) {} bool operator()(const Offset<T> &a, const Offset<T> &b) const { auto table_a = reinterpret_cast<T *>(buf_.data_at(a.o)); auto table_b = reinterpret_cast<T *>(buf_.data_at(b.o)); return table_a->KeyCompareLessThan(table_b); } - vector_downward &buf_; + vector_downward &buf_; - private: + private: FLATBUFFERS_DELETE_FUNC( TableKeyComparator &operator=(const TableKeyComparator &other)); }; @@ -2025,9 +2025,9 @@ class FlatBufferBuilder { /// @param[in] len The number of elements to store in the `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template<typename T> - Offset<Vector<Offset<T>>> CreateVectorOfSortedTables(Offset<T> *v, - size_t len) { + template<typename T> + Offset<Vector<Offset<T>>> CreateVectorOfSortedTables(Offset<T> *v, + size_t len) { std::sort(v, v + len, TableKeyComparator<T>(buf_)); return CreateVector(v, len); } @@ -2039,10 +2039,10 @@ class FlatBufferBuilder { /// offsets to store in the buffer in sorted order. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template<typename T> - Offset<Vector<Offset<T>>> CreateVectorOfSortedTables( - std::vector<Offset<T>> *v) { - return CreateVectorOfSortedTables(data(*v), v->size()); + template<typename T> + Offset<Vector<Offset<T>>> CreateVectorOfSortedTables( + std::vector<Offset<T>> *v) { + return CreateVectorOfSortedTables(data(*v), v->size()); } /// @brief Specialized version of `CreateVector` for non-copying use cases. @@ -2056,11 +2056,11 @@ class FlatBufferBuilder { uint8_t **buf) { NotNested(); StartVector(len, elemsize); - buf_.make_space(len * elemsize); - auto vec_start = GetSize(); - auto vec_end = EndVector(len); - *buf = buf_.data_at(vec_start); - return vec_end; + buf_.make_space(len * elemsize); + auto vec_start = GetSize(); + auto vec_end = EndVector(len); + *buf = buf_.data_at(vec_start); + return vec_end; } /// @brief Specialized version of `CreateVector` for non-copying use cases. @@ -2071,20 +2071,20 @@ class FlatBufferBuilder { /// @param[out] buf A pointer to a pointer of type `T` that can be /// written to at a later time to serialize the data into a `vector` /// in the buffer. - template<typename T> - Offset<Vector<T>> CreateUninitializedVector(size_t len, T **buf) { - AssertScalarT<T>(); + template<typename T> + Offset<Vector<T>> CreateUninitializedVector(size_t len, T **buf) { + AssertScalarT<T>(); return CreateUninitializedVector(len, sizeof(T), reinterpret_cast<uint8_t **>(buf)); } - template<typename T> + template<typename T> Offset<Vector<const T *>> CreateUninitializedVectorOfStructs(size_t len, T **buf) { - return CreateUninitializedVector(len, sizeof(T), - reinterpret_cast<uint8_t **>(buf)); - } - + return CreateUninitializedVector(len, sizeof(T), + reinterpret_cast<uint8_t **>(buf)); + } + // @brief Create a vector of scalar type T given as input a vector of scalar // type U, useful with e.g. pre "enum class" enums, or any existing scalar // data of the wrong type. @@ -2097,61 +2097,61 @@ class FlatBufferBuilder { return Offset<Vector<T>>(EndVector(len)); } - /// @brief Write a struct by itself, typically to be part of a union. - template<typename T> Offset<const T *> CreateStruct(const T &structobj) { - NotNested(); - Align(AlignOf<T>()); - buf_.push_small(structobj); - return Offset<const T *>(GetSize()); - } - + /// @brief Write a struct by itself, typically to be part of a union. + template<typename T> Offset<const T *> CreateStruct(const T &structobj) { + NotNested(); + Align(AlignOf<T>()); + buf_.push_small(structobj); + return Offset<const T *>(GetSize()); + } + /// @brief The length of a FlatBuffer file header. static const size_t kFileIdentifierLength = 4; /// @brief Finish serializing a buffer by writing the root offset. /// @param[in] file_identifier If a `file_identifier` is given, the buffer /// will be prefixed with a standard FlatBuffers file header. - template<typename T> - void Finish(Offset<T> root, const char *file_identifier = nullptr) { - Finish(root.o, file_identifier, false); - } - - /// @brief Finish a buffer with a 32 bit size field pre-fixed (size of the - /// buffer following the size field). These buffers are NOT compatible - /// with standard buffers created by Finish, i.e. you can't call GetRoot - /// on them, you have to use GetSizePrefixedRoot instead. - /// All >32 bit quantities in this buffer will be aligned when the whole - /// size pre-fixed buffer is aligned. - /// These kinds of buffers are useful for creating a stream of FlatBuffers. - template<typename T> - void FinishSizePrefixed(Offset<T> root, - const char *file_identifier = nullptr) { - Finish(root.o, file_identifier, true); - } - + template<typename T> + void Finish(Offset<T> root, const char *file_identifier = nullptr) { + Finish(root.o, file_identifier, false); + } + + /// @brief Finish a buffer with a 32 bit size field pre-fixed (size of the + /// buffer following the size field). These buffers are NOT compatible + /// with standard buffers created by Finish, i.e. you can't call GetRoot + /// on them, you have to use GetSizePrefixedRoot instead. + /// All >32 bit quantities in this buffer will be aligned when the whole + /// size pre-fixed buffer is aligned. + /// These kinds of buffers are useful for creating a stream of FlatBuffers. + template<typename T> + void FinishSizePrefixed(Offset<T> root, + const char *file_identifier = nullptr) { + Finish(root.o, file_identifier, true); + } + void SwapBufAllocator(FlatBufferBuilder &other) { buf_.swap_allocator(other.buf_); } - protected: - // You shouldn't really be copying instances of this class. - FlatBufferBuilder(const FlatBufferBuilder &); - FlatBufferBuilder &operator=(const FlatBufferBuilder &); - - void Finish(uoffset_t root, const char *file_identifier, bool size_prefix) { + protected: + // You shouldn't really be copying instances of this class. + FlatBufferBuilder(const FlatBufferBuilder &); + FlatBufferBuilder &operator=(const FlatBufferBuilder &); + + void Finish(uoffset_t root, const char *file_identifier, bool size_prefix) { NotNested(); - buf_.clear_scratch(); + buf_.clear_scratch(); // This will cause the whole buffer to be aligned. - PreAlign((size_prefix ? sizeof(uoffset_t) : 0) + sizeof(uoffset_t) + - (file_identifier ? kFileIdentifierLength : 0), + PreAlign((size_prefix ? sizeof(uoffset_t) : 0) + sizeof(uoffset_t) + + (file_identifier ? kFileIdentifierLength : 0), minalign_); if (file_identifier) { - FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength); - PushBytes(reinterpret_cast<const uint8_t *>(file_identifier), + FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength); + PushBytes(reinterpret_cast<const uint8_t *>(file_identifier), kFileIdentifierLength); } - PushElement(ReferTo(root)); // Location of root. - if (size_prefix) { PushElement(GetSize()); } + PushElement(ReferTo(root)); // Location of root. + if (size_prefix) { PushElement(GetSize()); } finished = true; } @@ -2163,11 +2163,11 @@ class FlatBufferBuilder { vector_downward buf_; // Accumulating offsets of table members while it is being built. - // We store these in the scratch pad of buf_, after the vtable offsets. - uoffset_t num_field_loc; - // Track how much of the vtable is in use, so we can output the most compact - // possible vtable. - voffset_t max_voffset_; + // We store these in the scratch pad of buf_, after the vtable offsets. + uoffset_t num_field_loc; + // Track how much of the vtable is in use, so we can output the most compact + // possible vtable. + voffset_t max_voffset_; // Ensure objects are not nested. bool nested; @@ -2178,38 +2178,38 @@ class FlatBufferBuilder { size_t minalign_; bool force_defaults_; // Serialize values equal to their defaults anyway. - - bool dedup_vtables_; - - struct StringOffsetCompare { - StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {} - bool operator()(const Offset<String> &a, const Offset<String> &b) const { - auto stra = reinterpret_cast<const String *>(buf_->data_at(a.o)); - auto strb = reinterpret_cast<const String *>(buf_->data_at(b.o)); + + bool dedup_vtables_; + + struct StringOffsetCompare { + StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {} + bool operator()(const Offset<String> &a, const Offset<String> &b) const { + auto stra = reinterpret_cast<const String *>(buf_->data_at(a.o)); + auto strb = reinterpret_cast<const String *>(buf_->data_at(b.o)); return StringLessThan(stra->data(), stra->size(), strb->data(), strb->size()); - } - const vector_downward *buf_; - }; - - // For use with CreateSharedString. Instantiated on first use only. - typedef std::set<Offset<String>, StringOffsetCompare> StringOffsetMap; - StringOffsetMap *string_pool; - - private: - // Allocates space for a vector of structures. - // Must be completed with EndVectorOfStructs(). - template<typename T> T *StartVectorOfStructs(size_t vector_size) { - StartVector(vector_size * sizeof(T) / AlignOf<T>(), AlignOf<T>()); - return reinterpret_cast<T *>(buf_.make_space(vector_size * sizeof(T))); - } - - // End the vector of structues in the flatbuffers. - // Vector should have previously be started with StartVectorOfStructs(). - template<typename T> - Offset<Vector<const T *>> EndVectorOfStructs(size_t vector_size) { - return Offset<Vector<const T *>>(EndVector(vector_size)); - } + } + const vector_downward *buf_; + }; + + // For use with CreateSharedString. Instantiated on first use only. + typedef std::set<Offset<String>, StringOffsetCompare> StringOffsetMap; + StringOffsetMap *string_pool; + + private: + // Allocates space for a vector of structures. + // Must be completed with EndVectorOfStructs(). + template<typename T> T *StartVectorOfStructs(size_t vector_size) { + StartVector(vector_size * sizeof(T) / AlignOf<T>(), AlignOf<T>()); + return reinterpret_cast<T *>(buf_.make_space(vector_size * sizeof(T))); + } + + // End the vector of structues in the flatbuffers. + // Vector should have previously be started with StartVectorOfStructs(). + template<typename T> + Offset<Vector<const T *>> EndVectorOfStructs(size_t vector_size) { + return Offset<Vector<const T *>>(EndVector(vector_size)); + } }; /// @} @@ -2217,102 +2217,102 @@ class FlatBufferBuilder { // Helpers to get a typed pointer to the root object contained in the buffer. template<typename T> T *GetMutableRoot(void *buf) { EndianCheck(); - return reinterpret_cast<T *>( - reinterpret_cast<uint8_t *>(buf) + - EndianScalar(*reinterpret_cast<uoffset_t *>(buf))); + return reinterpret_cast<T *>( + reinterpret_cast<uint8_t *>(buf) + + EndianScalar(*reinterpret_cast<uoffset_t *>(buf))); } template<typename T> const T *GetRoot(const void *buf) { return GetMutableRoot<T>(const_cast<void *>(buf)); } -template<typename T> const T *GetSizePrefixedRoot(const void *buf) { - return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(uoffset_t)); -} - -/// Helpers to get a typed pointer to objects that are currently being built. -/// @warning Creating new objects will lead to reallocations and invalidates -/// the pointer! -template<typename T> -T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) { - return reinterpret_cast<T *>(fbb.GetCurrentBufferPointer() + fbb.GetSize() - - offset.o); -} - -template<typename T> -const T *GetTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) { - return GetMutableTemporaryPointer<T>(fbb, offset); -} - -/// @brief Get a pointer to the the file_identifier section of the buffer. -/// @return Returns a const char pointer to the start of the file_identifier -/// characters in the buffer. The returned char * has length -/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'. -/// This function is UNDEFINED for FlatBuffers whose schema does not include -/// a file_identifier (likely points at padding or the start of a the root -/// vtable). +template<typename T> const T *GetSizePrefixedRoot(const void *buf) { + return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(uoffset_t)); +} + +/// Helpers to get a typed pointer to objects that are currently being built. +/// @warning Creating new objects will lead to reallocations and invalidates +/// the pointer! +template<typename T> +T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) { + return reinterpret_cast<T *>(fbb.GetCurrentBufferPointer() + fbb.GetSize() - + offset.o); +} + +template<typename T> +const T *GetTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) { + return GetMutableTemporaryPointer<T>(fbb, offset); +} + +/// @brief Get a pointer to the the file_identifier section of the buffer. +/// @return Returns a const char pointer to the start of the file_identifier +/// characters in the buffer. The returned char * has length +/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'. +/// This function is UNDEFINED for FlatBuffers whose schema does not include +/// a file_identifier (likely points at padding or the start of a the root +/// vtable). inline const char *GetBufferIdentifier(const void *buf, bool size_prefixed = false) { - return reinterpret_cast<const char *>(buf) + - ((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t)); -} - + return reinterpret_cast<const char *>(buf) + + ((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t)); +} + // Helper to see if the identifier in a buffer has the expected value. inline bool BufferHasIdentifier(const void *buf, const char *identifier, bool size_prefixed = false) { - return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier, - FlatBufferBuilder::kFileIdentifierLength) == 0; + return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier, + FlatBufferBuilder::kFileIdentifierLength) == 0; } // Helper class to verify the integrity of a FlatBuffer class Verifier FLATBUFFERS_FINAL_CLASS { public: - Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64, + Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64, uoffset_t _max_tables = 1000000, bool _check_alignment = true) - : buf_(buf), - size_(buf_len), - depth_(0), - max_depth_(_max_depth), - num_tables_(0), + : buf_(buf), + size_(buf_len), + depth_(0), + max_depth_(_max_depth), + num_tables_(0), max_tables_(_max_tables), upper_bound_(0), check_alignment_(_check_alignment) { FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE); - } + } // Central location where any verification failures register. bool Check(bool ok) const { - // clang-format off + // clang-format off #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE - FLATBUFFERS_ASSERT(ok); - #endif - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - if (!ok) - upper_bound_ = 0; + FLATBUFFERS_ASSERT(ok); #endif - // clang-format on + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + if (!ok) + upper_bound_ = 0; + #endif + // clang-format on return ok; } // Verify any range within the buffer. - bool Verify(size_t elem, size_t elem_len) const { - // clang-format off - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - auto upper_bound = elem + elem_len; - if (upper_bound_ < upper_bound) - upper_bound_ = upper_bound; - #endif - // clang-format on - return Check(elem_len < size_ && elem <= size_ - elem_len); - } - - template<typename T> bool VerifyAlignment(size_t elem) const { + bool Verify(size_t elem, size_t elem_len) const { + // clang-format off + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + auto upper_bound = elem + elem_len; + if (upper_bound_ < upper_bound) + upper_bound_ = upper_bound; + #endif + // clang-format on + return Check(elem_len < size_ && elem <= size_ - elem_len); + } + + template<typename T> bool VerifyAlignment(size_t elem) const { return Check((elem & (sizeof(T) - 1)) == 0 || !check_alignment_); - } - + } + // Verify a range indicated by sizeof(T). - template<typename T> bool Verify(size_t elem) const { - return VerifyAlignment<T>(elem) && Verify(elem, sizeof(T)); + template<typename T> bool Verify(size_t elem) const { + return VerifyAlignment<T>(elem) && Verify(elem, sizeof(T)); } bool VerifyFromPointer(const uint8_t *p, size_t len) { @@ -2320,35 +2320,35 @@ class Verifier FLATBUFFERS_FINAL_CLASS { return Verify(o, len); } - // Verify relative to a known-good base pointer. - bool Verify(const uint8_t *base, voffset_t elem_off, size_t elem_len) const { - return Verify(static_cast<size_t>(base - buf_) + elem_off, elem_len); - } - + // Verify relative to a known-good base pointer. + bool Verify(const uint8_t *base, voffset_t elem_off, size_t elem_len) const { + return Verify(static_cast<size_t>(base - buf_) + elem_off, elem_len); + } + template<typename T> bool Verify(const uint8_t *base, voffset_t elem_off) const { - return Verify(static_cast<size_t>(base - buf_) + elem_off, sizeof(T)); - } - + return Verify(static_cast<size_t>(base - buf_) + elem_off, sizeof(T)); + } + // Verify a pointer (may be NULL) of a table type. template<typename T> bool VerifyTable(const T *table) { return !table || table->Verify(*this); } // Verify a pointer (may be NULL) of any vector type. - template<typename T> bool VerifyVector(const Vector<T> *vec) const { - return !vec || VerifyVectorOrString(reinterpret_cast<const uint8_t *>(vec), - sizeof(T)); + template<typename T> bool VerifyVector(const Vector<T> *vec) const { + return !vec || VerifyVectorOrString(reinterpret_cast<const uint8_t *>(vec), + sizeof(T)); } // Verify a pointer (may be NULL) of a vector to struct. - template<typename T> bool VerifyVector(const Vector<const T *> *vec) const { - return VerifyVector(reinterpret_cast<const Vector<T> *>(vec)); + template<typename T> bool VerifyVector(const Vector<const T *> *vec) const { + return VerifyVector(reinterpret_cast<const Vector<T> *>(vec)); } // Verify a pointer (may be NULL) to string. - bool VerifyString(const String *str) const { - size_t end; + bool VerifyString(const String *str) const { + size_t end; return !str || (VerifyVectorOrString(reinterpret_cast<const uint8_t *>(str), 1, &end) && Verify(end, 1) && // Must have terminator @@ -2356,30 +2356,30 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } // Common code between vectors and strings. - bool VerifyVectorOrString(const uint8_t *vec, size_t elem_size, + bool VerifyVectorOrString(const uint8_t *vec, size_t elem_size, size_t *end = nullptr) const { - auto veco = static_cast<size_t>(vec - buf_); + auto veco = static_cast<size_t>(vec - buf_); // Check we can read the size field. - if (!Verify<uoffset_t>(veco)) return false; + if (!Verify<uoffset_t>(veco)) return false; // Check the whole array. If this is a string, the byte past the array // must be 0. auto size = ReadScalar<uoffset_t>(vec); - auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; - if (!Check(size < max_elems)) - return false; // Protect against byte_size overflowing. + auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; + if (!Check(size < max_elems)) + return false; // Protect against byte_size overflowing. auto byte_size = sizeof(size) + elem_size * size; - if (end) *end = veco + byte_size; - return Verify(veco, byte_size); + if (end) *end = veco + byte_size; + return Verify(veco, byte_size); } // Special case for string contents, after the above has been called. bool VerifyVectorOfStrings(const Vector<Offset<String>> *vec) const { - if (vec) { - for (uoffset_t i = 0; i < vec->size(); i++) { - if (!VerifyString(vec->Get(i))) return false; + if (vec) { + for (uoffset_t i = 0; i < vec->size(); i++) { + if (!VerifyString(vec->Get(i))) return false; } - } - return true; + } + return true; } // Special case for table contents, after the above has been called. @@ -2394,66 +2394,66 @@ class Verifier FLATBUFFERS_FINAL_CLASS { __supress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart( const uint8_t *table) { - // Check the vtable offset. - auto tableo = static_cast<size_t>(table - buf_); - if (!Verify<soffset_t>(tableo)) return false; + // Check the vtable offset. + auto tableo = static_cast<size_t>(table - buf_); + if (!Verify<soffset_t>(tableo)) return false; // This offset may be signed, but doing the subtraction unsigned always - // gives the result we want. - auto vtableo = tableo - static_cast<size_t>(ReadScalar<soffset_t>(table)); - // Check the vtable size field, then check vtable fits in its entirety. - return VerifyComplexity() && Verify<voffset_t>(vtableo) && - VerifyAlignment<voffset_t>(ReadScalar<voffset_t>(buf_ + vtableo)) && - Verify(vtableo, ReadScalar<voffset_t>(buf_ + vtableo)); - } - - template<typename T> - bool VerifyBufferFromStart(const char *identifier, size_t start) { + // gives the result we want. + auto vtableo = tableo - static_cast<size_t>(ReadScalar<soffset_t>(table)); + // Check the vtable size field, then check vtable fits in its entirety. + return VerifyComplexity() && Verify<voffset_t>(vtableo) && + VerifyAlignment<voffset_t>(ReadScalar<voffset_t>(buf_ + vtableo)) && + Verify(vtableo, ReadScalar<voffset_t>(buf_ + vtableo)); + } + + template<typename T> + bool VerifyBufferFromStart(const char *identifier, size_t start) { if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) && BufferHasIdentifier(buf_ + start, identifier)))) { - return false; - } - - // Call T::Verify, which must be in the generated code for this type. - auto o = VerifyOffset(start); - return o && reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this) - // clang-format off - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - && GetComputedSize() - #endif - ; - // clang-format on - } - + return false; + } + + // Call T::Verify, which must be in the generated code for this type. + auto o = VerifyOffset(start); + return o && reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this) + // clang-format off + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + && GetComputedSize() + #endif + ; + // clang-format on + } + // Verify this whole buffer, starting with root type T. - template<typename T> bool VerifyBuffer() { return VerifyBuffer<T>(nullptr); } - - template<typename T> bool VerifyBuffer(const char *identifier) { - return VerifyBufferFromStart<T>(identifier, 0); - } - - template<typename T> bool VerifySizePrefixedBuffer(const char *identifier) { - return Verify<uoffset_t>(0U) && - ReadScalar<uoffset_t>(buf_) == size_ - sizeof(uoffset_t) && - VerifyBufferFromStart<T>(identifier, sizeof(uoffset_t)); - } - - uoffset_t VerifyOffset(size_t start) const { - if (!Verify<uoffset_t>(start)) return 0; - auto o = ReadScalar<uoffset_t>(buf_ + start); - // May not point to itself. + template<typename T> bool VerifyBuffer() { return VerifyBuffer<T>(nullptr); } + + template<typename T> bool VerifyBuffer(const char *identifier) { + return VerifyBufferFromStart<T>(identifier, 0); + } + + template<typename T> bool VerifySizePrefixedBuffer(const char *identifier) { + return Verify<uoffset_t>(0U) && + ReadScalar<uoffset_t>(buf_) == size_ - sizeof(uoffset_t) && + VerifyBufferFromStart<T>(identifier, sizeof(uoffset_t)); + } + + uoffset_t VerifyOffset(size_t start) const { + if (!Verify<uoffset_t>(start)) return 0; + auto o = ReadScalar<uoffset_t>(buf_ + start); + // May not point to itself. if (!Check(o != 0)) return 0; - // Can't wrap around / buffers are max 2GB. - if (!Check(static_cast<soffset_t>(o) >= 0)) return 0; - // Must be inside the buffer to create a pointer from it (pointer outside - // buffer is UB). - if (!Verify(start + o, 1)) return 0; - return o; - } - - uoffset_t VerifyOffset(const uint8_t *base, voffset_t start) const { - return VerifyOffset(static_cast<size_t>(base - buf_) + start); - } - + // Can't wrap around / buffers are max 2GB. + if (!Check(static_cast<soffset_t>(o) >= 0)) return 0; + // Must be inside the buffer to create a pointer from it (pointer outside + // buffer is UB). + if (!Verify(start + o, 1)) return 0; + return o; + } + + uoffset_t VerifyOffset(const uint8_t *base, voffset_t start) const { + return VerifyOffset(static_cast<size_t>(base - buf_) + start); + } + // Called at the start of a table to increase counters measuring data // structure depth and amount, and possibly bails out with false if // limits set by the constructor have been hit. Needs to be balanced @@ -2470,8 +2470,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS { return true; } - // Returns the message size in bytes - size_t GetComputedSize() const { + // Returns the message size in bytes + size_t GetComputedSize() const { // clang-format off #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE uintptr_t size = upper_bound_; @@ -2485,44 +2485,44 @@ class Verifier FLATBUFFERS_FINAL_CLASS { return 0; #endif // clang-format on - } - + } + private: const uint8_t *buf_; - size_t size_; - uoffset_t depth_; - uoffset_t max_depth_; - uoffset_t num_tables_; - uoffset_t max_tables_; + size_t size_; + uoffset_t depth_; + uoffset_t max_depth_; + uoffset_t num_tables_; + uoffset_t max_tables_; mutable size_t upper_bound_; bool check_alignment_; }; -// Convenient way to bundle a buffer and its length, to pass it around -// typed by its root. -// A BufferRef does not own its buffer. -struct BufferRefBase {}; // for std::is_base_of -template<typename T> struct BufferRef : BufferRefBase { - BufferRef() : buf(nullptr), len(0), must_free(false) {} - BufferRef(uint8_t *_buf, uoffset_t _len) - : buf(_buf), len(_len), must_free(false) {} - - ~BufferRef() { - if (must_free) free(buf); - } - - const T *GetRoot() const { return flatbuffers::GetRoot<T>(buf); } - - bool Verify() { - Verifier verifier(buf, len); - return verifier.VerifyBuffer<T>(nullptr); - } - - uint8_t *buf; - uoffset_t len; - bool must_free; -}; - +// Convenient way to bundle a buffer and its length, to pass it around +// typed by its root. +// A BufferRef does not own its buffer. +struct BufferRefBase {}; // for std::is_base_of +template<typename T> struct BufferRef : BufferRefBase { + BufferRef() : buf(nullptr), len(0), must_free(false) {} + BufferRef(uint8_t *_buf, uoffset_t _len) + : buf(_buf), len(_len), must_free(false) {} + + ~BufferRef() { + if (must_free) free(buf); + } + + const T *GetRoot() const { return flatbuffers::GetRoot<T>(buf); } + + bool Verify() { + Verifier verifier(buf, len); + return verifier.VerifyBuffer<T>(nullptr); + } + + uint8_t *buf; + uoffset_t len; + bool must_free; +}; + // "structs" are flat structures that do not have an offset table, thus // always have all members present and do not support forwards/backwards // compatible extensions. @@ -2554,15 +2554,15 @@ class Struct FLATBUFFERS_FINAL_CLASS { // omitted and added at will, but uses an extra indirection to read. class Table { public: - const uint8_t *GetVTable() const { - return data_ - ReadScalar<soffset_t>(data_); - } - + const uint8_t *GetVTable() const { + return data_ - ReadScalar<soffset_t>(data_); + } + // This gets the field offset for any of the functions below it, or 0 // if the field was not present. voffset_t GetOptionalFieldOffset(voffset_t field) const { // The vtable offset is always at the start. - auto vtable = GetVTable(); + auto vtable = GetVTable(); // The first element is the size of the vtable (fields + type id + itself). auto vtsize = ReadScalar<voffset_t>(vtable); // If the field we're accessing is outside the vtable, we're reading older @@ -2578,8 +2578,8 @@ class Table { template<typename P> P GetPointer(voffset_t field) { auto field_offset = GetOptionalFieldOffset(field); auto p = data_ + field_offset; - return field_offset ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p)) - : nullptr; + return field_offset ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p)) + : nullptr; } template<typename P> P GetPointer(voffset_t field) const { return const_cast<Table *>(this)->GetPointer<P>(field); @@ -2599,7 +2599,7 @@ class Table { : Optional<Face>(); } - template<typename T> bool SetField(voffset_t field, T val, T def) { + template<typename T> bool SetField(voffset_t field, T val, T def) { auto field_offset = GetOptionalFieldOffset(field); if (!field_offset) return IsTheSameAs(val, def); WriteScalar(data_ + field_offset, val); @@ -2615,8 +2615,8 @@ class Table { bool SetPointer(voffset_t field, const uint8_t *val) { auto field_offset = GetOptionalFieldOffset(field); if (!field_offset) return false; - WriteScalar(data_ + field_offset, - static_cast<uoffset_t>(val - (data_ + field_offset))); + WriteScalar(data_ + field_offset, + static_cast<uoffset_t>(val - (data_ + field_offset))); return true; } @@ -2635,39 +2635,39 @@ class Table { // Verify the vtable of this table. // Call this once per table, followed by VerifyField once per field. bool VerifyTableStart(Verifier &verifier) const { - return verifier.VerifyTableStart(data_); + return verifier.VerifyTableStart(data_); } // Verify a particular field. - template<typename T> - bool VerifyField(const Verifier &verifier, voffset_t field) const { + template<typename T> + bool VerifyField(const Verifier &verifier, voffset_t field) const { // Calling GetOptionalFieldOffset should be safe now thanks to // VerifyTable(). auto field_offset = GetOptionalFieldOffset(field); // Check the actual field. - return !field_offset || verifier.Verify<T>(data_, field_offset); + return !field_offset || verifier.Verify<T>(data_, field_offset); } // VerifyField for required fields. - template<typename T> - bool VerifyFieldRequired(const Verifier &verifier, voffset_t field) const { + template<typename T> + bool VerifyFieldRequired(const Verifier &verifier, voffset_t field) const { auto field_offset = GetOptionalFieldOffset(field); return verifier.Check(field_offset != 0) && - verifier.Verify<T>(data_, field_offset); - } - - // Versions for offsets. - bool VerifyOffset(const Verifier &verifier, voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - return !field_offset || verifier.VerifyOffset(data_, field_offset); - } - - bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - return verifier.Check(field_offset != 0) && - verifier.VerifyOffset(data_, field_offset); - } - + verifier.Verify<T>(data_, field_offset); + } + + // Versions for offsets. + bool VerifyOffset(const Verifier &verifier, voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + return !field_offset || verifier.VerifyOffset(data_, field_offset); + } + + bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + return verifier.Check(field_offset != 0) && + verifier.VerifyOffset(data_, field_offset); + } + private: // private constructor & copy constructor: you obtain instances of this // class by pointing to existing data only @@ -2691,81 +2691,81 @@ inline flatbuffers::Optional<bool> Table::GetOptional<uint8_t, bool>( template<typename T> void FlatBufferBuilder::Required(Offset<T> table, voffset_t field) { - auto table_ptr = reinterpret_cast<const Table *>(buf_.data_at(table.o)); - bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; - // If this fails, the caller will show what field needs to be set. - FLATBUFFERS_ASSERT(ok); - (void)ok; -} - -/// @brief This can compute the start of a FlatBuffer from a root pointer, i.e. -/// it is the opposite transformation of GetRoot(). -/// This may be useful if you want to pass on a root and have the recipient -/// delete the buffer afterwards. -inline const uint8_t *GetBufferStartFromRootPointer(const void *root) { - auto table = reinterpret_cast<const Table *>(root); - auto vtable = table->GetVTable(); - // Either the vtable is before the root or after the root. - auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root)); - // Align to at least sizeof(uoffset_t). - start = reinterpret_cast<const uint8_t *>(reinterpret_cast<uintptr_t>(start) & - ~(sizeof(uoffset_t) - 1)); - // Additionally, there may be a file_identifier in the buffer, and the root - // offset. The buffer may have been aligned to any size between - // sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align"). - // Sadly, the exact alignment is only known when constructing the buffer, - // since it depends on the presence of values with said alignment properties. - // So instead, we simply look at the next uoffset_t values (root, - // file_identifier, and alignment padding) to see which points to the root. - // None of the other values can "impersonate" the root since they will either - // be 0 or four ASCII characters. - static_assert(FlatBufferBuilder::kFileIdentifierLength == sizeof(uoffset_t), - "file_identifier is assumed to be the same size as uoffset_t"); - for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1; - possible_roots; possible_roots--) { - start -= sizeof(uoffset_t); - if (ReadScalar<uoffset_t>(start) + start == - reinterpret_cast<const uint8_t *>(root)) - return start; - } - // We didn't find the root, either the "root" passed isn't really a root, - // or the buffer is corrupt. - // Assert, because calling this function with bad data may cause reads - // outside of buffer boundaries. - FLATBUFFERS_ASSERT(false); - return nullptr; -} - -/// @brief This return the prefixed size of a FlatBuffer. + auto table_ptr = reinterpret_cast<const Table *>(buf_.data_at(table.o)); + bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; + // If this fails, the caller will show what field needs to be set. + FLATBUFFERS_ASSERT(ok); + (void)ok; +} + +/// @brief This can compute the start of a FlatBuffer from a root pointer, i.e. +/// it is the opposite transformation of GetRoot(). +/// This may be useful if you want to pass on a root and have the recipient +/// delete the buffer afterwards. +inline const uint8_t *GetBufferStartFromRootPointer(const void *root) { + auto table = reinterpret_cast<const Table *>(root); + auto vtable = table->GetVTable(); + // Either the vtable is before the root or after the root. + auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root)); + // Align to at least sizeof(uoffset_t). + start = reinterpret_cast<const uint8_t *>(reinterpret_cast<uintptr_t>(start) & + ~(sizeof(uoffset_t) - 1)); + // Additionally, there may be a file_identifier in the buffer, and the root + // offset. The buffer may have been aligned to any size between + // sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align"). + // Sadly, the exact alignment is only known when constructing the buffer, + // since it depends on the presence of values with said alignment properties. + // So instead, we simply look at the next uoffset_t values (root, + // file_identifier, and alignment padding) to see which points to the root. + // None of the other values can "impersonate" the root since they will either + // be 0 or four ASCII characters. + static_assert(FlatBufferBuilder::kFileIdentifierLength == sizeof(uoffset_t), + "file_identifier is assumed to be the same size as uoffset_t"); + for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1; + possible_roots; possible_roots--) { + start -= sizeof(uoffset_t); + if (ReadScalar<uoffset_t>(start) + start == + reinterpret_cast<const uint8_t *>(root)) + return start; + } + // We didn't find the root, either the "root" passed isn't really a root, + // or the buffer is corrupt. + // Assert, because calling this function with bad data may cause reads + // outside of buffer boundaries. + FLATBUFFERS_ASSERT(false); + return nullptr; +} + +/// @brief This return the prefixed size of a FlatBuffer. inline uoffset_t GetPrefixedSize(const uint8_t *buf) { return ReadScalar<uoffset_t>(buf); } - -// Base class for native objects (FlatBuffer data de-serialized into native -// C++ data structures). -// Contains no functionality, purely documentative. -struct NativeTable {}; - -/// @brief Function types to be used with resolving hashes into objects and -/// back again. The resolver gets a pointer to a field inside an object API -/// object that is of the type specified in the schema using the attribute -/// `cpp_type` (it is thus important whatever you write to this address -/// matches that type). The value of this field is initially null, so you -/// may choose to implement a delayed binding lookup using this function -/// if you wish. The resolver does the opposite lookup, for when the object -/// is being serialized again. -typedef uint64_t hash_value_t; -// clang-format off -#ifdef FLATBUFFERS_CPP98_STL - typedef void (*resolver_function_t)(void **pointer_adr, hash_value_t hash); - typedef hash_value_t (*rehasher_function_t)(void *pointer); -#else - typedef std::function<void (void **pointer_adr, hash_value_t hash)> - resolver_function_t; - typedef std::function<hash_value_t (void *pointer)> rehasher_function_t; -#endif -// clang-format on - + +// Base class for native objects (FlatBuffer data de-serialized into native +// C++ data structures). +// Contains no functionality, purely documentative. +struct NativeTable {}; + +/// @brief Function types to be used with resolving hashes into objects and +/// back again. The resolver gets a pointer to a field inside an object API +/// object that is of the type specified in the schema using the attribute +/// `cpp_type` (it is thus important whatever you write to this address +/// matches that type). The value of this field is initially null, so you +/// may choose to implement a delayed binding lookup using this function +/// if you wish. The resolver does the opposite lookup, for when the object +/// is being serialized again. +typedef uint64_t hash_value_t; +// clang-format off +#ifdef FLATBUFFERS_CPP98_STL + typedef void (*resolver_function_t)(void **pointer_adr, hash_value_t hash); + typedef hash_value_t (*rehasher_function_t)(void *pointer); +#else + typedef std::function<void (void **pointer_adr, hash_value_t hash)> + resolver_function_t; + typedef std::function<hash_value_t (void *pointer)> rehasher_function_t; +#endif +// clang-format on + // Helper function to test if a field is present, using any of the field // enums in the generated code. // `table` must be a generated table type. Since this is a template parameter, @@ -2785,7 +2785,7 @@ bool IsFieldPresent(const T *table, typename T::FlatBuffersVTableOffset field) { // names must be NULL terminated. inline int LookupEnum(const char **names, const char *name) { for (const char **p = names; *p; p++) - if (!strcmp(*p, name)) return static_cast<int>(p - names); + if (!strcmp(*p, name)) return static_cast<int>(p - names); return -1; } @@ -2799,102 +2799,102 @@ inline int LookupEnum(const char **names, const char *name) { // by the force_align attribute. // These are used in the generated code only. -// clang-format off +// clang-format off #if defined(_MSC_VER) - #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \ + #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \ __pragma(pack(1)) \ struct __declspec(align(alignment)) - #define FLATBUFFERS_STRUCT_END(name, size) \ + #define FLATBUFFERS_STRUCT_END(name, size) \ __pragma(pack()) \ static_assert(sizeof(name) == size, "compiler breaks packing rules") #elif defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__) - #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \ + #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \ _Pragma("pack(1)") \ struct __attribute__((aligned(alignment))) - #define FLATBUFFERS_STRUCT_END(name, size) \ + #define FLATBUFFERS_STRUCT_END(name, size) \ _Pragma("pack()") \ static_assert(sizeof(name) == size, "compiler breaks packing rules") #else #error Unknown compiler, please define structure alignment macros #endif -// clang-format on - -// Minimal reflection via code generation. -// Besides full-fat reflection (see reflection.h) and parsing/printing by -// loading schemas (see idl.h), we can also have code generation for mimimal -// reflection data which allows pretty-printing and other uses without needing -// a schema or a parser. -// Generate code with --reflect-types (types only) or --reflect-names (names -// also) to enable. -// See minireflect.h for utilities using this functionality. - -// These types are organized slightly differently as the ones in idl.h. -enum SequenceType { ST_TABLE, ST_STRUCT, ST_UNION, ST_ENUM }; - -// Scalars have the same order as in idl.h -// clang-format off -#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET) \ - ET(ET_UTYPE) \ - ET(ET_BOOL) \ - ET(ET_CHAR) \ - ET(ET_UCHAR) \ - ET(ET_SHORT) \ - ET(ET_USHORT) \ - ET(ET_INT) \ - ET(ET_UINT) \ - ET(ET_LONG) \ - ET(ET_ULONG) \ - ET(ET_FLOAT) \ - ET(ET_DOUBLE) \ - ET(ET_STRING) \ - ET(ET_SEQUENCE) // See SequenceType. - -enum ElementaryType { - #define FLATBUFFERS_ET(E) E, - FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET) - #undef FLATBUFFERS_ET -}; - -inline const char * const *ElementaryTypeNames() { - static const char * const names[] = { - #define FLATBUFFERS_ET(E) #E, - FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET) - #undef FLATBUFFERS_ET - }; - return names; -} -// clang-format on - -// Basic type info cost just 16bits per field! +// clang-format on + +// Minimal reflection via code generation. +// Besides full-fat reflection (see reflection.h) and parsing/printing by +// loading schemas (see idl.h), we can also have code generation for mimimal +// reflection data which allows pretty-printing and other uses without needing +// a schema or a parser. +// Generate code with --reflect-types (types only) or --reflect-names (names +// also) to enable. +// See minireflect.h for utilities using this functionality. + +// These types are organized slightly differently as the ones in idl.h. +enum SequenceType { ST_TABLE, ST_STRUCT, ST_UNION, ST_ENUM }; + +// Scalars have the same order as in idl.h +// clang-format off +#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET) \ + ET(ET_UTYPE) \ + ET(ET_BOOL) \ + ET(ET_CHAR) \ + ET(ET_UCHAR) \ + ET(ET_SHORT) \ + ET(ET_USHORT) \ + ET(ET_INT) \ + ET(ET_UINT) \ + ET(ET_LONG) \ + ET(ET_ULONG) \ + ET(ET_FLOAT) \ + ET(ET_DOUBLE) \ + ET(ET_STRING) \ + ET(ET_SEQUENCE) // See SequenceType. + +enum ElementaryType { + #define FLATBUFFERS_ET(E) E, + FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET) + #undef FLATBUFFERS_ET +}; + +inline const char * const *ElementaryTypeNames() { + static const char * const names[] = { + #define FLATBUFFERS_ET(E) #E, + FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET) + #undef FLATBUFFERS_ET + }; + return names; +} +// clang-format on + +// Basic type info cost just 16bits per field! // We're explicitly defining the signedness since the signedness of integer // bitfields is otherwise implementation-defined and causes warnings on older // GCC compilers. -struct TypeCode { +struct TypeCode { // ElementaryType unsigned short base_type : 4; // Either vector (in table) or array (in struct) unsigned short is_repeating : 1; // Index into type_refs below, or -1 for none. signed short sequence_ref : 11; -}; - -static_assert(sizeof(TypeCode) == 2, "TypeCode"); - -struct TypeTable; - -// Signature of the static method present in each type. -typedef const TypeTable *(*TypeFunction)(); - -struct TypeTable { - SequenceType st; - size_t num_elems; // of type_codes, values, names (but not type_refs). +}; + +static_assert(sizeof(TypeCode) == 2, "TypeCode"); + +struct TypeTable; + +// Signature of the static method present in each type. +typedef const TypeTable *(*TypeFunction)(); + +struct TypeTable { + SequenceType st; + size_t num_elems; // of type_codes, values, names (but not type_refs). const TypeCode *type_codes; // num_elems count - const TypeFunction *type_refs; // less than num_elems entries (see TypeCode). + const TypeFunction *type_refs; // less than num_elems entries (see TypeCode). const int16_t *array_sizes; // less than num_elems entries (see TypeCode). const int64_t *values; // Only set for non-consecutive enum/union or structs. const char *const *names; // Only set if compiled with --reflect-names. -}; - +}; + // String which identifies the current version of FlatBuffers. // flatbuffer_version_string is used by Google developers to identify which // applications uploaded to Google Play are using this library. This allows @@ -2905,7 +2905,7 @@ struct TypeTable { // appreciate if you left it in. // Weak linkage is culled by VS & doesn't work on cygwin. -// clang-format off +// clang-format off #if !defined(_WIN32) && !defined(__CYGWIN__) extern volatile __attribute__((weak)) const char *flatbuffer_version_string; @@ -2917,38 +2917,38 @@ volatile __attribute__((weak)) const char *flatbuffer_version_string = #endif // !defined(_WIN32) && !defined(__CYGWIN__) -#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\ - inline E operator | (E lhs, E rhs){\ - return E(T(lhs) | T(rhs));\ - }\ - inline E operator & (E lhs, E rhs){\ - return E(T(lhs) & T(rhs));\ - }\ - inline E operator ^ (E lhs, E rhs){\ - return E(T(lhs) ^ T(rhs));\ - }\ - inline E operator ~ (E lhs){\ - return E(~T(lhs));\ - }\ - inline E operator |= (E &lhs, E rhs){\ - lhs = lhs | rhs;\ - return lhs;\ - }\ - inline E operator &= (E &lhs, E rhs){\ - lhs = lhs & rhs;\ - return lhs;\ - }\ - inline E operator ^= (E &lhs, E rhs){\ - lhs = lhs ^ rhs;\ - return lhs;\ - }\ - inline bool operator !(E rhs) \ - {\ - return !bool(T(rhs)); \ - } +#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\ + inline E operator | (E lhs, E rhs){\ + return E(T(lhs) | T(rhs));\ + }\ + inline E operator & (E lhs, E rhs){\ + return E(T(lhs) & T(rhs));\ + }\ + inline E operator ^ (E lhs, E rhs){\ + return E(T(lhs) ^ T(rhs));\ + }\ + inline E operator ~ (E lhs){\ + return E(~T(lhs));\ + }\ + inline E operator |= (E &lhs, E rhs){\ + lhs = lhs | rhs;\ + return lhs;\ + }\ + inline E operator &= (E &lhs, E rhs){\ + lhs = lhs & rhs;\ + return lhs;\ + }\ + inline E operator ^= (E &lhs, E rhs){\ + lhs = lhs ^ rhs;\ + return lhs;\ + }\ + inline bool operator !(E rhs) \ + {\ + return !bool(T(rhs)); \ + } /// @endcond } // namespace flatbuffers -// clang-format on - +// clang-format on + #endif // FLATBUFFERS_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/flatc.h b/contrib/libs/flatbuffers/include/flatbuffers/flatc.h index 1466b3651d..cb160491ac 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/flatc.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/flatc.h @@ -1,100 +1,100 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * Copyright 2017 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef FLATBUFFERS_FLATC_H_ #define FLATBUFFERS_FLATC_H_ -#include <functional> -#include <limits> -#include <string> +#include <functional> +#include <limits> +#include <string> #include "flatbuffers.h" #include "idl.h" #include "util.h" - -namespace flatbuffers { - + +namespace flatbuffers { + extern void LogCompilerWarn(const std::string &warn); extern void LogCompilerError(const std::string &err); -class FlatCompiler { - public: - // Output generator for the various programming languages and formats we - // support. - struct Generator { - typedef bool (*GenerateFn)(const flatbuffers::Parser &parser, - const std::string &path, - const std::string &file_name); - typedef std::string (*MakeRuleFn)(const flatbuffers::Parser &parser, - const std::string &path, - const std::string &file_name); - - GenerateFn generate; - const char *generator_opt_short; - const char *generator_opt_long; - const char *lang_name; - bool schema_only; - GenerateFn generateGRPC; - flatbuffers::IDLOptions::Language lang; - const char *generator_help; - MakeRuleFn make_rule; - }; - - typedef void (*WarnFn)(const FlatCompiler *flatc, const std::string &warn, - bool show_exe_name); - - typedef void (*ErrorFn)(const FlatCompiler *flatc, const std::string &err, - bool usage, bool show_exe_name); - - // Parameters required to initialize the FlatCompiler. - struct InitParams { - InitParams() - : generators(nullptr), - num_generators(0), - warn_fn(nullptr), - error_fn(nullptr) {} - - const Generator *generators; - size_t num_generators; - WarnFn warn_fn; - ErrorFn error_fn; - }; - - explicit FlatCompiler(const InitParams ¶ms) : params_(params) {} - - int Compile(int argc, const char **argv); - - std::string GetUsageString(const char *program_name) const; - - private: - void ParseFile(flatbuffers::Parser &parser, const std::string &filename, - const std::string &contents, - std::vector<const char *> &include_directories) const; - +class FlatCompiler { + public: + // Output generator for the various programming languages and formats we + // support. + struct Generator { + typedef bool (*GenerateFn)(const flatbuffers::Parser &parser, + const std::string &path, + const std::string &file_name); + typedef std::string (*MakeRuleFn)(const flatbuffers::Parser &parser, + const std::string &path, + const std::string &file_name); + + GenerateFn generate; + const char *generator_opt_short; + const char *generator_opt_long; + const char *lang_name; + bool schema_only; + GenerateFn generateGRPC; + flatbuffers::IDLOptions::Language lang; + const char *generator_help; + MakeRuleFn make_rule; + }; + + typedef void (*WarnFn)(const FlatCompiler *flatc, const std::string &warn, + bool show_exe_name); + + typedef void (*ErrorFn)(const FlatCompiler *flatc, const std::string &err, + bool usage, bool show_exe_name); + + // Parameters required to initialize the FlatCompiler. + struct InitParams { + InitParams() + : generators(nullptr), + num_generators(0), + warn_fn(nullptr), + error_fn(nullptr) {} + + const Generator *generators; + size_t num_generators; + WarnFn warn_fn; + ErrorFn error_fn; + }; + + explicit FlatCompiler(const InitParams ¶ms) : params_(params) {} + + int Compile(int argc, const char **argv); + + std::string GetUsageString(const char *program_name) const; + + private: + void ParseFile(flatbuffers::Parser &parser, const std::string &filename, + const std::string &contents, + std::vector<const char *> &include_directories) const; + void LoadBinarySchema(Parser &parser, const std::string &filename, const std::string &contents); - void Warn(const std::string &warn, bool show_exe_name = true) const; - - void Error(const std::string &err, bool usage = true, - bool show_exe_name = true) const; - - InitParams params_; -}; - -} // namespace flatbuffers - + void Warn(const std::string &warn, bool show_exe_name = true) const; + + void Error(const std::string &err, bool usage = true, + bool show_exe_name = true) const; + + InitParams params_; +}; + +} // namespace flatbuffers + #endif // FLATBUFFERS_FLATC_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h b/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h index d855b67731..be45e97fdf 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h @@ -1,222 +1,222 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_FLEXBUFFERS_H_ -#define FLATBUFFERS_FLEXBUFFERS_H_ - -#include <map> -// Used to select STL variant. +/* + * Copyright 2017 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLATBUFFERS_FLEXBUFFERS_H_ +#define FLATBUFFERS_FLEXBUFFERS_H_ + +#include <map> +// Used to select STL variant. #include "base.h" -// We use the basic binary writing functions from the regular FlatBuffers. +// We use the basic binary writing functions from the regular FlatBuffers. #include "util.h" - -#ifdef _MSC_VER -# include <intrin.h> -#endif - -#if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4127) // C4127: conditional expression is constant -#endif - -namespace flexbuffers { - -class Reference; -class Map; - -// These are used in the lower 2 bits of a type field to determine the size of -// the elements (and or size field) of the item pointed to (e.g. vector). -enum BitWidth { - BIT_WIDTH_8 = 0, - BIT_WIDTH_16 = 1, - BIT_WIDTH_32 = 2, - BIT_WIDTH_64 = 3, -}; - -// These are used as the upper 6 bits of a type field to indicate the actual -// type. -enum Type { - FBT_NULL = 0, - FBT_INT = 1, - FBT_UINT = 2, - FBT_FLOAT = 3, - // Types above stored inline, types below store an offset. - FBT_KEY = 4, - FBT_STRING = 5, - FBT_INDIRECT_INT = 6, - FBT_INDIRECT_UINT = 7, - FBT_INDIRECT_FLOAT = 8, - FBT_MAP = 9, - FBT_VECTOR = 10, // Untyped. - FBT_VECTOR_INT = 11, // Typed any size (stores no type table). - FBT_VECTOR_UINT = 12, - FBT_VECTOR_FLOAT = 13, - FBT_VECTOR_KEY = 14, + +#ifdef _MSC_VER +# include <intrin.h> +#endif + +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4127) // C4127: conditional expression is constant +#endif + +namespace flexbuffers { + +class Reference; +class Map; + +// These are used in the lower 2 bits of a type field to determine the size of +// the elements (and or size field) of the item pointed to (e.g. vector). +enum BitWidth { + BIT_WIDTH_8 = 0, + BIT_WIDTH_16 = 1, + BIT_WIDTH_32 = 2, + BIT_WIDTH_64 = 3, +}; + +// These are used as the upper 6 bits of a type field to indicate the actual +// type. +enum Type { + FBT_NULL = 0, + FBT_INT = 1, + FBT_UINT = 2, + FBT_FLOAT = 3, + // Types above stored inline, types below store an offset. + FBT_KEY = 4, + FBT_STRING = 5, + FBT_INDIRECT_INT = 6, + FBT_INDIRECT_UINT = 7, + FBT_INDIRECT_FLOAT = 8, + FBT_MAP = 9, + FBT_VECTOR = 10, // Untyped. + FBT_VECTOR_INT = 11, // Typed any size (stores no type table). + FBT_VECTOR_UINT = 12, + FBT_VECTOR_FLOAT = 13, + FBT_VECTOR_KEY = 14, // DEPRECATED, use FBT_VECTOR or FBT_VECTOR_KEY instead. // Read test.cpp/FlexBuffersDeprecatedTest() for details on why. FBT_VECTOR_STRING_DEPRECATED = 15, - FBT_VECTOR_INT2 = 16, // Typed tuple (no type table, no size field). - FBT_VECTOR_UINT2 = 17, - FBT_VECTOR_FLOAT2 = 18, - FBT_VECTOR_INT3 = 19, // Typed triple (no type table, no size field). - FBT_VECTOR_UINT3 = 20, - FBT_VECTOR_FLOAT3 = 21, - FBT_VECTOR_INT4 = 22, // Typed quad (no type table, no size field). - FBT_VECTOR_UINT4 = 23, - FBT_VECTOR_FLOAT4 = 24, - FBT_BLOB = 25, - FBT_BOOL = 26, - FBT_VECTOR_BOOL = - 36, // To Allow the same type of conversion of type to vector type -}; - -inline bool IsInline(Type t) { return t <= FBT_FLOAT || t == FBT_BOOL; } - -inline bool IsTypedVectorElementType(Type t) { - return (t >= FBT_INT && t <= FBT_STRING) || t == FBT_BOOL; -} - -inline bool IsTypedVector(Type t) { + FBT_VECTOR_INT2 = 16, // Typed tuple (no type table, no size field). + FBT_VECTOR_UINT2 = 17, + FBT_VECTOR_FLOAT2 = 18, + FBT_VECTOR_INT3 = 19, // Typed triple (no type table, no size field). + FBT_VECTOR_UINT3 = 20, + FBT_VECTOR_FLOAT3 = 21, + FBT_VECTOR_INT4 = 22, // Typed quad (no type table, no size field). + FBT_VECTOR_UINT4 = 23, + FBT_VECTOR_FLOAT4 = 24, + FBT_BLOB = 25, + FBT_BOOL = 26, + FBT_VECTOR_BOOL = + 36, // To Allow the same type of conversion of type to vector type +}; + +inline bool IsInline(Type t) { return t <= FBT_FLOAT || t == FBT_BOOL; } + +inline bool IsTypedVectorElementType(Type t) { + return (t >= FBT_INT && t <= FBT_STRING) || t == FBT_BOOL; +} + +inline bool IsTypedVector(Type t) { return (t >= FBT_VECTOR_INT && t <= FBT_VECTOR_STRING_DEPRECATED) || - t == FBT_VECTOR_BOOL; -} - -inline bool IsFixedTypedVector(Type t) { - return t >= FBT_VECTOR_INT2 && t <= FBT_VECTOR_FLOAT4; -} - -inline Type ToTypedVector(Type t, size_t fixed_len = 0) { - FLATBUFFERS_ASSERT(IsTypedVectorElementType(t)); - switch (fixed_len) { - case 0: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT); - case 2: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT2); - case 3: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT3); - case 4: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT4); - default: FLATBUFFERS_ASSERT(0); return FBT_NULL; - } -} - -inline Type ToTypedVectorElementType(Type t) { - FLATBUFFERS_ASSERT(IsTypedVector(t)); - return static_cast<Type>(t - FBT_VECTOR_INT + FBT_INT); -} - -inline Type ToFixedTypedVectorElementType(Type t, uint8_t *len) { - FLATBUFFERS_ASSERT(IsFixedTypedVector(t)); - auto fixed_type = t - FBT_VECTOR_INT2; - *len = static_cast<uint8_t>(fixed_type / 3 + - 2); // 3 types each, starting from length 2. - return static_cast<Type>(fixed_type % 3 + FBT_INT); -} - -// TODO: implement proper support for 8/16bit floats, or decide not to -// support them. -typedef int16_t half; -typedef int8_t quarter; - -// TODO: can we do this without conditionals using intrinsics or inline asm -// on some platforms? Given branch prediction the method below should be -// decently quick, but it is the most frequently executed function. -// We could do an (unaligned) 64-bit read if we ifdef out the platforms for -// which that doesn't work (or where we'd read into un-owned memory). -template<typename R, typename T1, typename T2, typename T4, typename T8> -R ReadSizedScalar(const uint8_t *data, uint8_t byte_width) { - return byte_width < 4 - ? (byte_width < 2 - ? static_cast<R>(flatbuffers::ReadScalar<T1>(data)) - : static_cast<R>(flatbuffers::ReadScalar<T2>(data))) - : (byte_width < 8 - ? static_cast<R>(flatbuffers::ReadScalar<T4>(data)) - : static_cast<R>(flatbuffers::ReadScalar<T8>(data))); -} - -inline int64_t ReadInt64(const uint8_t *data, uint8_t byte_width) { - return ReadSizedScalar<int64_t, int8_t, int16_t, int32_t, int64_t>( - data, byte_width); -} - -inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) { - // This is the "hottest" function (all offset lookups use this), so worth - // optimizing if possible. - // TODO: GCC apparently replaces memcpy by a rep movsb, but only if count is a - // constant, which here it isn't. Test if memcpy is still faster than - // the conditionals in ReadSizedScalar. Can also use inline asm. - // clang-format off + t == FBT_VECTOR_BOOL; +} + +inline bool IsFixedTypedVector(Type t) { + return t >= FBT_VECTOR_INT2 && t <= FBT_VECTOR_FLOAT4; +} + +inline Type ToTypedVector(Type t, size_t fixed_len = 0) { + FLATBUFFERS_ASSERT(IsTypedVectorElementType(t)); + switch (fixed_len) { + case 0: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT); + case 2: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT2); + case 3: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT3); + case 4: return static_cast<Type>(t - FBT_INT + FBT_VECTOR_INT4); + default: FLATBUFFERS_ASSERT(0); return FBT_NULL; + } +} + +inline Type ToTypedVectorElementType(Type t) { + FLATBUFFERS_ASSERT(IsTypedVector(t)); + return static_cast<Type>(t - FBT_VECTOR_INT + FBT_INT); +} + +inline Type ToFixedTypedVectorElementType(Type t, uint8_t *len) { + FLATBUFFERS_ASSERT(IsFixedTypedVector(t)); + auto fixed_type = t - FBT_VECTOR_INT2; + *len = static_cast<uint8_t>(fixed_type / 3 + + 2); // 3 types each, starting from length 2. + return static_cast<Type>(fixed_type % 3 + FBT_INT); +} + +// TODO: implement proper support for 8/16bit floats, or decide not to +// support them. +typedef int16_t half; +typedef int8_t quarter; + +// TODO: can we do this without conditionals using intrinsics or inline asm +// on some platforms? Given branch prediction the method below should be +// decently quick, but it is the most frequently executed function. +// We could do an (unaligned) 64-bit read if we ifdef out the platforms for +// which that doesn't work (or where we'd read into un-owned memory). +template<typename R, typename T1, typename T2, typename T4, typename T8> +R ReadSizedScalar(const uint8_t *data, uint8_t byte_width) { + return byte_width < 4 + ? (byte_width < 2 + ? static_cast<R>(flatbuffers::ReadScalar<T1>(data)) + : static_cast<R>(flatbuffers::ReadScalar<T2>(data))) + : (byte_width < 8 + ? static_cast<R>(flatbuffers::ReadScalar<T4>(data)) + : static_cast<R>(flatbuffers::ReadScalar<T8>(data))); +} + +inline int64_t ReadInt64(const uint8_t *data, uint8_t byte_width) { + return ReadSizedScalar<int64_t, int8_t, int16_t, int32_t, int64_t>( + data, byte_width); +} + +inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) { + // This is the "hottest" function (all offset lookups use this), so worth + // optimizing if possible. + // TODO: GCC apparently replaces memcpy by a rep movsb, but only if count is a + // constant, which here it isn't. Test if memcpy is still faster than + // the conditionals in ReadSizedScalar. Can also use inline asm. + // clang-format off #if defined(_MSC_VER) && ((defined(_M_X64) && !defined(_M_ARM64EC)) || defined _M_IX86) - uint64_t u = 0; - __movsb(reinterpret_cast<uint8_t *>(&u), - reinterpret_cast<const uint8_t *>(data), byte_width); - return flatbuffers::EndianScalar(u); - #else - return ReadSizedScalar<uint64_t, uint8_t, uint16_t, uint32_t, uint64_t>( - data, byte_width); - #endif - // clang-format on -} - -inline double ReadDouble(const uint8_t *data, uint8_t byte_width) { - return ReadSizedScalar<double, quarter, half, float, double>(data, - byte_width); -} - -inline const uint8_t *Indirect(const uint8_t *offset, uint8_t byte_width) { - return offset - ReadUInt64(offset, byte_width); -} - -template<typename T> const uint8_t *Indirect(const uint8_t *offset) { - return offset - flatbuffers::ReadScalar<T>(offset); -} - -inline BitWidth WidthU(uint64_t u) { -#define FLATBUFFERS_GET_FIELD_BIT_WIDTH(value, width) \ - { \ - if (!((u) & ~((1ULL << (width)) - 1ULL))) return BIT_WIDTH_##width; \ - } - FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 8); - FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 16); - FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 32); -#undef FLATBUFFERS_GET_FIELD_BIT_WIDTH - return BIT_WIDTH_64; -} - -inline BitWidth WidthI(int64_t i) { - auto u = static_cast<uint64_t>(i) << 1; - return WidthU(i >= 0 ? u : ~u); -} - -inline BitWidth WidthF(double f) { - return static_cast<double>(static_cast<float>(f)) == f ? BIT_WIDTH_32 - : BIT_WIDTH_64; -} - -// Base class of all types below. -// Points into the data buffer and allows access to one type. -class Object { - public: - Object(const uint8_t *data, uint8_t byte_width) - : data_(data), byte_width_(byte_width) {} - - protected: - const uint8_t *data_; - uint8_t byte_width_; -}; - + uint64_t u = 0; + __movsb(reinterpret_cast<uint8_t *>(&u), + reinterpret_cast<const uint8_t *>(data), byte_width); + return flatbuffers::EndianScalar(u); + #else + return ReadSizedScalar<uint64_t, uint8_t, uint16_t, uint32_t, uint64_t>( + data, byte_width); + #endif + // clang-format on +} + +inline double ReadDouble(const uint8_t *data, uint8_t byte_width) { + return ReadSizedScalar<double, quarter, half, float, double>(data, + byte_width); +} + +inline const uint8_t *Indirect(const uint8_t *offset, uint8_t byte_width) { + return offset - ReadUInt64(offset, byte_width); +} + +template<typename T> const uint8_t *Indirect(const uint8_t *offset) { + return offset - flatbuffers::ReadScalar<T>(offset); +} + +inline BitWidth WidthU(uint64_t u) { +#define FLATBUFFERS_GET_FIELD_BIT_WIDTH(value, width) \ + { \ + if (!((u) & ~((1ULL << (width)) - 1ULL))) return BIT_WIDTH_##width; \ + } + FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 8); + FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 16); + FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 32); +#undef FLATBUFFERS_GET_FIELD_BIT_WIDTH + return BIT_WIDTH_64; +} + +inline BitWidth WidthI(int64_t i) { + auto u = static_cast<uint64_t>(i) << 1; + return WidthU(i >= 0 ? u : ~u); +} + +inline BitWidth WidthF(double f) { + return static_cast<double>(static_cast<float>(f)) == f ? BIT_WIDTH_32 + : BIT_WIDTH_64; +} + +// Base class of all types below. +// Points into the data buffer and allows access to one type. +class Object { + public: + Object(const uint8_t *data, uint8_t byte_width) + : data_(data), byte_width_(byte_width) {} + + protected: + const uint8_t *data_; + uint8_t byte_width_; +}; + // Object that has a size, obtained either from size prefix, or elsewhere. -class Sized : public Object { - public: +class Sized : public Object { + public: // Size prefix. Sized(const uint8_t *data, uint8_t byte_width) : Object(data, byte_width), size_(read_size()) {} @@ -226,135 +226,135 @@ class Sized : public Object { size_t size() const { return size_; } // Access size stored in `byte_width_` bytes before data_ pointer. size_t read_size() const { - return static_cast<size_t>(ReadUInt64(data_ - byte_width_, byte_width_)); - } + return static_cast<size_t>(ReadUInt64(data_ - byte_width_, byte_width_)); + } protected: size_t size_; -}; - -class String : public Sized { - public: +}; + +class String : public Sized { + public: // Size prefix. - String(const uint8_t *data, uint8_t byte_width) : Sized(data, byte_width) {} + String(const uint8_t *data, uint8_t byte_width) : Sized(data, byte_width) {} // Manual size. String(const uint8_t *data, uint8_t byte_width, size_t sz) : Sized(data, byte_width, sz) {} - - size_t length() const { return size(); } - const char *c_str() const { return reinterpret_cast<const char *>(data_); } + + size_t length() const { return size(); } + const char *c_str() const { return reinterpret_cast<const char *>(data_); } std::string str() const { return std::string(c_str(), size()); } - - static String EmptyString() { + + static String EmptyString() { static const char *empty_string = ""; return String(reinterpret_cast<const uint8_t *>(empty_string), 1, 0); - } - bool IsTheEmptyString() const { return data_ == EmptyString().data_; } -}; - -class Blob : public Sized { - public: - Blob(const uint8_t *data_buf, uint8_t byte_width) - : Sized(data_buf, byte_width) {} - - static Blob EmptyBlob() { - static const uint8_t empty_blob[] = { 0 /*len*/ }; - return Blob(empty_blob + 1, 1); - } - bool IsTheEmptyBlob() const { return data_ == EmptyBlob().data_; } - const uint8_t *data() const { return data_; } -}; - -class Vector : public Sized { - public: - Vector(const uint8_t *data, uint8_t byte_width) : Sized(data, byte_width) {} - - Reference operator[](size_t i) const; - - static Vector EmptyVector() { - static const uint8_t empty_vector[] = { 0 /*len*/ }; - return Vector(empty_vector + 1, 1); - } - bool IsTheEmptyVector() const { return data_ == EmptyVector().data_; } -}; - -class TypedVector : public Sized { - public: - TypedVector(const uint8_t *data, uint8_t byte_width, Type element_type) - : Sized(data, byte_width), type_(element_type) {} - - Reference operator[](size_t i) const; - - static TypedVector EmptyTypedVector() { - static const uint8_t empty_typed_vector[] = { 0 /*len*/ }; - return TypedVector(empty_typed_vector + 1, 1, FBT_INT); - } - bool IsTheEmptyVector() const { - return data_ == TypedVector::EmptyTypedVector().data_; - } - - Type ElementType() { return type_; } - + } + bool IsTheEmptyString() const { return data_ == EmptyString().data_; } +}; + +class Blob : public Sized { + public: + Blob(const uint8_t *data_buf, uint8_t byte_width) + : Sized(data_buf, byte_width) {} + + static Blob EmptyBlob() { + static const uint8_t empty_blob[] = { 0 /*len*/ }; + return Blob(empty_blob + 1, 1); + } + bool IsTheEmptyBlob() const { return data_ == EmptyBlob().data_; } + const uint8_t *data() const { return data_; } +}; + +class Vector : public Sized { + public: + Vector(const uint8_t *data, uint8_t byte_width) : Sized(data, byte_width) {} + + Reference operator[](size_t i) const; + + static Vector EmptyVector() { + static const uint8_t empty_vector[] = { 0 /*len*/ }; + return Vector(empty_vector + 1, 1); + } + bool IsTheEmptyVector() const { return data_ == EmptyVector().data_; } +}; + +class TypedVector : public Sized { + public: + TypedVector(const uint8_t *data, uint8_t byte_width, Type element_type) + : Sized(data, byte_width), type_(element_type) {} + + Reference operator[](size_t i) const; + + static TypedVector EmptyTypedVector() { + static const uint8_t empty_typed_vector[] = { 0 /*len*/ }; + return TypedVector(empty_typed_vector + 1, 1, FBT_INT); + } + bool IsTheEmptyVector() const { + return data_ == TypedVector::EmptyTypedVector().data_; + } + + Type ElementType() { return type_; } + friend Reference; - private: - Type type_; - - friend Map; -}; - -class FixedTypedVector : public Object { - public: - FixedTypedVector(const uint8_t *data, uint8_t byte_width, Type element_type, - uint8_t len) - : Object(data, byte_width), type_(element_type), len_(len) {} - - Reference operator[](size_t i) const; - - static FixedTypedVector EmptyFixedTypedVector() { - static const uint8_t fixed_empty_vector[] = { 0 /* unused */ }; - return FixedTypedVector(fixed_empty_vector, 1, FBT_INT, 0); - } - bool IsTheEmptyFixedTypedVector() const { - return data_ == FixedTypedVector::EmptyFixedTypedVector().data_; - } - - Type ElementType() { return type_; } - uint8_t size() { return len_; } - - private: - Type type_; - uint8_t len_; -}; - -class Map : public Vector { - public: - Map(const uint8_t *data, uint8_t byte_width) : Vector(data, byte_width) {} - - Reference operator[](const char *key) const; - Reference operator[](const std::string &key) const; - - Vector Values() const { return Vector(data_, byte_width_); } - - TypedVector Keys() const { - const size_t num_prefixed_fields = 3; - auto keys_offset = data_ - byte_width_ * num_prefixed_fields; - return TypedVector(Indirect(keys_offset, byte_width_), - static_cast<uint8_t>( - ReadUInt64(keys_offset + byte_width_, byte_width_)), - FBT_KEY); - } - - static Map EmptyMap() { - static const uint8_t empty_map[] = { - 0 /*keys_len*/, 0 /*keys_offset*/, 1 /*keys_width*/, 0 /*len*/ - }; - return Map(empty_map + 4, 1); - } - - bool IsTheEmptyMap() const { return data_ == EmptyMap().data_; } -}; - + private: + Type type_; + + friend Map; +}; + +class FixedTypedVector : public Object { + public: + FixedTypedVector(const uint8_t *data, uint8_t byte_width, Type element_type, + uint8_t len) + : Object(data, byte_width), type_(element_type), len_(len) {} + + Reference operator[](size_t i) const; + + static FixedTypedVector EmptyFixedTypedVector() { + static const uint8_t fixed_empty_vector[] = { 0 /* unused */ }; + return FixedTypedVector(fixed_empty_vector, 1, FBT_INT, 0); + } + bool IsTheEmptyFixedTypedVector() const { + return data_ == FixedTypedVector::EmptyFixedTypedVector().data_; + } + + Type ElementType() { return type_; } + uint8_t size() { return len_; } + + private: + Type type_; + uint8_t len_; +}; + +class Map : public Vector { + public: + Map(const uint8_t *data, uint8_t byte_width) : Vector(data, byte_width) {} + + Reference operator[](const char *key) const; + Reference operator[](const std::string &key) const; + + Vector Values() const { return Vector(data_, byte_width_); } + + TypedVector Keys() const { + const size_t num_prefixed_fields = 3; + auto keys_offset = data_ - byte_width_ * num_prefixed_fields; + return TypedVector(Indirect(keys_offset, byte_width_), + static_cast<uint8_t>( + ReadUInt64(keys_offset + byte_width_, byte_width_)), + FBT_KEY); + } + + static Map EmptyMap() { + static const uint8_t empty_map[] = { + 0 /*keys_len*/, 0 /*keys_offset*/, 1 /*keys_width*/, 0 /*len*/ + }; + return Map(empty_map + 4, 1); + } + + bool IsTheEmptyMap() const { return data_ == EmptyMap().data_; } +}; + template<typename T> void AppendToString(std::string &s, T &&v, bool keys_quoted) { s += "[ "; @@ -365,220 +365,220 @@ void AppendToString(std::string &s, T &&v, bool keys_quoted) { s += " ]"; } -class Reference { - public: +class Reference { + public: Reference() : data_(nullptr), parent_width_(0), byte_width_(BIT_WIDTH_8), type_(FBT_NULL) {} - Reference(const uint8_t *data, uint8_t parent_width, uint8_t byte_width, - Type type) - : data_(data), - parent_width_(parent_width), - byte_width_(byte_width), - type_(type) {} - - Reference(const uint8_t *data, uint8_t parent_width, uint8_t packed_type) - : data_(data), parent_width_(parent_width) { - byte_width_ = 1U << static_cast<BitWidth>(packed_type & 3); - type_ = static_cast<Type>(packed_type >> 2); - } - - Type GetType() const { return type_; } - - bool IsNull() const { return type_ == FBT_NULL; } - bool IsBool() const { return type_ == FBT_BOOL; } - bool IsInt() const { return type_ == FBT_INT || type_ == FBT_INDIRECT_INT; } - bool IsUInt() const { - return type_ == FBT_UINT || type_ == FBT_INDIRECT_UINT; - } - bool IsIntOrUint() const { return IsInt() || IsUInt(); } - bool IsFloat() const { - return type_ == FBT_FLOAT || type_ == FBT_INDIRECT_FLOAT; - } - bool IsNumeric() const { return IsIntOrUint() || IsFloat(); } - bool IsString() const { return type_ == FBT_STRING; } - bool IsKey() const { return type_ == FBT_KEY; } - bool IsVector() const { return type_ == FBT_VECTOR || type_ == FBT_MAP; } + Reference(const uint8_t *data, uint8_t parent_width, uint8_t byte_width, + Type type) + : data_(data), + parent_width_(parent_width), + byte_width_(byte_width), + type_(type) {} + + Reference(const uint8_t *data, uint8_t parent_width, uint8_t packed_type) + : data_(data), parent_width_(parent_width) { + byte_width_ = 1U << static_cast<BitWidth>(packed_type & 3); + type_ = static_cast<Type>(packed_type >> 2); + } + + Type GetType() const { return type_; } + + bool IsNull() const { return type_ == FBT_NULL; } + bool IsBool() const { return type_ == FBT_BOOL; } + bool IsInt() const { return type_ == FBT_INT || type_ == FBT_INDIRECT_INT; } + bool IsUInt() const { + return type_ == FBT_UINT || type_ == FBT_INDIRECT_UINT; + } + bool IsIntOrUint() const { return IsInt() || IsUInt(); } + bool IsFloat() const { + return type_ == FBT_FLOAT || type_ == FBT_INDIRECT_FLOAT; + } + bool IsNumeric() const { return IsIntOrUint() || IsFloat(); } + bool IsString() const { return type_ == FBT_STRING; } + bool IsKey() const { return type_ == FBT_KEY; } + bool IsVector() const { return type_ == FBT_VECTOR || type_ == FBT_MAP; } bool IsUntypedVector() const { return type_ == FBT_VECTOR; } - bool IsTypedVector() const { return flexbuffers::IsTypedVector(type_); } + bool IsTypedVector() const { return flexbuffers::IsTypedVector(type_); } bool IsFixedTypedVector() const { return flexbuffers::IsFixedTypedVector(type_); } bool IsAnyVector() const { return (IsTypedVector() || IsFixedTypedVector() || IsVector()); } - bool IsMap() const { return type_ == FBT_MAP; } - bool IsBlob() const { return type_ == FBT_BLOB; } - bool AsBool() const { - return (type_ == FBT_BOOL ? ReadUInt64(data_, parent_width_) + bool IsMap() const { return type_ == FBT_MAP; } + bool IsBlob() const { return type_ == FBT_BLOB; } + bool AsBool() const { + return (type_ == FBT_BOOL ? ReadUInt64(data_, parent_width_) : AsUInt64()) != 0; - } - - // Reads any type as a int64_t. Never fails, does most sensible conversion. - // Truncates floats, strings are attempted to be parsed for a number, - // vectors/maps return their size. Returns 0 if all else fails. - int64_t AsInt64() const { - if (type_ == FBT_INT) { - // A fast path for the common case. - return ReadInt64(data_, parent_width_); - } else - switch (type_) { - case FBT_INDIRECT_INT: return ReadInt64(Indirect(), byte_width_); - case FBT_UINT: return ReadUInt64(data_, parent_width_); - case FBT_INDIRECT_UINT: return ReadUInt64(Indirect(), byte_width_); - case FBT_FLOAT: - return static_cast<int64_t>(ReadDouble(data_, parent_width_)); - case FBT_INDIRECT_FLOAT: - return static_cast<int64_t>(ReadDouble(Indirect(), byte_width_)); - case FBT_NULL: return 0; - case FBT_STRING: return flatbuffers::StringToInt(AsString().c_str()); - case FBT_VECTOR: return static_cast<int64_t>(AsVector().size()); - case FBT_BOOL: return ReadInt64(data_, parent_width_); - default: - // Convert other things to int. - return 0; - } - } - - // TODO: could specialize these to not use AsInt64() if that saves - // extension ops in generated code, and use a faster op than ReadInt64. - int32_t AsInt32() const { return static_cast<int32_t>(AsInt64()); } - int16_t AsInt16() const { return static_cast<int16_t>(AsInt64()); } - int8_t AsInt8() const { return static_cast<int8_t>(AsInt64()); } - - uint64_t AsUInt64() const { - if (type_ == FBT_UINT) { - // A fast path for the common case. - return ReadUInt64(data_, parent_width_); - } else - switch (type_) { - case FBT_INDIRECT_UINT: return ReadUInt64(Indirect(), byte_width_); - case FBT_INT: return ReadInt64(data_, parent_width_); - case FBT_INDIRECT_INT: return ReadInt64(Indirect(), byte_width_); - case FBT_FLOAT: - return static_cast<uint64_t>(ReadDouble(data_, parent_width_)); - case FBT_INDIRECT_FLOAT: - return static_cast<uint64_t>(ReadDouble(Indirect(), byte_width_)); - case FBT_NULL: return 0; - case FBT_STRING: return flatbuffers::StringToUInt(AsString().c_str()); - case FBT_VECTOR: return static_cast<uint64_t>(AsVector().size()); - case FBT_BOOL: return ReadUInt64(data_, parent_width_); - default: - // Convert other things to uint. - return 0; - } - } - - uint32_t AsUInt32() const { return static_cast<uint32_t>(AsUInt64()); } - uint16_t AsUInt16() const { return static_cast<uint16_t>(AsUInt64()); } - uint8_t AsUInt8() const { return static_cast<uint8_t>(AsUInt64()); } - - double AsDouble() const { - if (type_ == FBT_FLOAT) { - // A fast path for the common case. - return ReadDouble(data_, parent_width_); - } else - switch (type_) { - case FBT_INDIRECT_FLOAT: return ReadDouble(Indirect(), byte_width_); - case FBT_INT: - return static_cast<double>(ReadInt64(data_, parent_width_)); - case FBT_UINT: - return static_cast<double>(ReadUInt64(data_, parent_width_)); - case FBT_INDIRECT_INT: - return static_cast<double>(ReadInt64(Indirect(), byte_width_)); - case FBT_INDIRECT_UINT: - return static_cast<double>(ReadUInt64(Indirect(), byte_width_)); - case FBT_NULL: return 0.0; + } + + // Reads any type as a int64_t. Never fails, does most sensible conversion. + // Truncates floats, strings are attempted to be parsed for a number, + // vectors/maps return their size. Returns 0 if all else fails. + int64_t AsInt64() const { + if (type_ == FBT_INT) { + // A fast path for the common case. + return ReadInt64(data_, parent_width_); + } else + switch (type_) { + case FBT_INDIRECT_INT: return ReadInt64(Indirect(), byte_width_); + case FBT_UINT: return ReadUInt64(data_, parent_width_); + case FBT_INDIRECT_UINT: return ReadUInt64(Indirect(), byte_width_); + case FBT_FLOAT: + return static_cast<int64_t>(ReadDouble(data_, parent_width_)); + case FBT_INDIRECT_FLOAT: + return static_cast<int64_t>(ReadDouble(Indirect(), byte_width_)); + case FBT_NULL: return 0; + case FBT_STRING: return flatbuffers::StringToInt(AsString().c_str()); + case FBT_VECTOR: return static_cast<int64_t>(AsVector().size()); + case FBT_BOOL: return ReadInt64(data_, parent_width_); + default: + // Convert other things to int. + return 0; + } + } + + // TODO: could specialize these to not use AsInt64() if that saves + // extension ops in generated code, and use a faster op than ReadInt64. + int32_t AsInt32() const { return static_cast<int32_t>(AsInt64()); } + int16_t AsInt16() const { return static_cast<int16_t>(AsInt64()); } + int8_t AsInt8() const { return static_cast<int8_t>(AsInt64()); } + + uint64_t AsUInt64() const { + if (type_ == FBT_UINT) { + // A fast path for the common case. + return ReadUInt64(data_, parent_width_); + } else + switch (type_) { + case FBT_INDIRECT_UINT: return ReadUInt64(Indirect(), byte_width_); + case FBT_INT: return ReadInt64(data_, parent_width_); + case FBT_INDIRECT_INT: return ReadInt64(Indirect(), byte_width_); + case FBT_FLOAT: + return static_cast<uint64_t>(ReadDouble(data_, parent_width_)); + case FBT_INDIRECT_FLOAT: + return static_cast<uint64_t>(ReadDouble(Indirect(), byte_width_)); + case FBT_NULL: return 0; + case FBT_STRING: return flatbuffers::StringToUInt(AsString().c_str()); + case FBT_VECTOR: return static_cast<uint64_t>(AsVector().size()); + case FBT_BOOL: return ReadUInt64(data_, parent_width_); + default: + // Convert other things to uint. + return 0; + } + } + + uint32_t AsUInt32() const { return static_cast<uint32_t>(AsUInt64()); } + uint16_t AsUInt16() const { return static_cast<uint16_t>(AsUInt64()); } + uint8_t AsUInt8() const { return static_cast<uint8_t>(AsUInt64()); } + + double AsDouble() const { + if (type_ == FBT_FLOAT) { + // A fast path for the common case. + return ReadDouble(data_, parent_width_); + } else + switch (type_) { + case FBT_INDIRECT_FLOAT: return ReadDouble(Indirect(), byte_width_); + case FBT_INT: + return static_cast<double>(ReadInt64(data_, parent_width_)); + case FBT_UINT: + return static_cast<double>(ReadUInt64(data_, parent_width_)); + case FBT_INDIRECT_INT: + return static_cast<double>(ReadInt64(Indirect(), byte_width_)); + case FBT_INDIRECT_UINT: + return static_cast<double>(ReadUInt64(Indirect(), byte_width_)); + case FBT_NULL: return 0.0; case FBT_STRING: { double d; flatbuffers::StringToNumber(AsString().c_str(), &d); return d; } - case FBT_VECTOR: return static_cast<double>(AsVector().size()); - case FBT_BOOL: - return static_cast<double>(ReadUInt64(data_, parent_width_)); - default: - // Convert strings and other things to float. - return 0; - } - } - - float AsFloat() const { return static_cast<float>(AsDouble()); } - - const char *AsKey() const { + case FBT_VECTOR: return static_cast<double>(AsVector().size()); + case FBT_BOOL: + return static_cast<double>(ReadUInt64(data_, parent_width_)); + default: + // Convert strings and other things to float. + return 0; + } + } + + float AsFloat() const { return static_cast<float>(AsDouble()); } + + const char *AsKey() const { if (type_ == FBT_KEY || type_ == FBT_STRING) { - return reinterpret_cast<const char *>(Indirect()); - } else { - return ""; - } - } - + return reinterpret_cast<const char *>(Indirect()); + } else { + return ""; + } + } + // This function returns the empty string if you try to read something that // is not a string or key. - String AsString() const { - if (type_ == FBT_STRING) { - return String(Indirect(), byte_width_); + String AsString() const { + if (type_ == FBT_STRING) { + return String(Indirect(), byte_width_); } else if (type_ == FBT_KEY) { auto key = Indirect(); return String(key, byte_width_, strlen(reinterpret_cast<const char *>(key))); - } else { - return String::EmptyString(); - } - } - - // Unlike AsString(), this will convert any type to a std::string. + } else { + return String::EmptyString(); + } + } + + // Unlike AsString(), this will convert any type to a std::string. std::string ToString() const { - std::string s; - ToString(false, false, s); - return s; - } - - // Convert any type to a JSON-like string. strings_quoted determines if - // string values at the top level receive "" quotes (inside other values - // they always do). keys_quoted determines if keys are quoted, at any level. - // TODO(wvo): add further options to have indentation/newlines. - void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const { - if (type_ == FBT_STRING) { - String str(Indirect(), byte_width_); - if (strings_quoted) { - flatbuffers::EscapeString(str.c_str(), str.length(), &s, true, false); - } else { - s.append(str.c_str(), str.length()); - } - } else if (IsKey()) { - auto str = AsKey(); - if (keys_quoted) { - flatbuffers::EscapeString(str, strlen(str), &s, true, false); - } else { - s += str; - } - } else if (IsInt()) { - s += flatbuffers::NumToString(AsInt64()); - } else if (IsUInt()) { - s += flatbuffers::NumToString(AsUInt64()); - } else if (IsFloat()) { - s += flatbuffers::NumToString(AsDouble()); - } else if (IsNull()) { - s += "null"; - } else if (IsBool()) { - s += AsBool() ? "true" : "false"; - } else if (IsMap()) { - s += "{ "; - auto m = AsMap(); - auto keys = m.Keys(); - auto vals = m.Values(); - for (size_t i = 0; i < keys.size(); i++) { - keys[i].ToString(true, keys_quoted, s); - s += ": "; - vals[i].ToString(true, keys_quoted, s); - if (i < keys.size() - 1) s += ", "; - } - s += " }"; - } else if (IsVector()) { + std::string s; + ToString(false, false, s); + return s; + } + + // Convert any type to a JSON-like string. strings_quoted determines if + // string values at the top level receive "" quotes (inside other values + // they always do). keys_quoted determines if keys are quoted, at any level. + // TODO(wvo): add further options to have indentation/newlines. + void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const { + if (type_ == FBT_STRING) { + String str(Indirect(), byte_width_); + if (strings_quoted) { + flatbuffers::EscapeString(str.c_str(), str.length(), &s, true, false); + } else { + s.append(str.c_str(), str.length()); + } + } else if (IsKey()) { + auto str = AsKey(); + if (keys_quoted) { + flatbuffers::EscapeString(str, strlen(str), &s, true, false); + } else { + s += str; + } + } else if (IsInt()) { + s += flatbuffers::NumToString(AsInt64()); + } else if (IsUInt()) { + s += flatbuffers::NumToString(AsUInt64()); + } else if (IsFloat()) { + s += flatbuffers::NumToString(AsDouble()); + } else if (IsNull()) { + s += "null"; + } else if (IsBool()) { + s += AsBool() ? "true" : "false"; + } else if (IsMap()) { + s += "{ "; + auto m = AsMap(); + auto keys = m.Keys(); + auto vals = m.Values(); + for (size_t i = 0; i < keys.size(); i++) { + keys[i].ToString(true, keys_quoted, s); + s += ": "; + vals[i].ToString(true, keys_quoted, s); + if (i < keys.size() - 1) s += ", "; + } + s += " }"; + } else if (IsVector()) { AppendToString<Vector>(s, AsVector(), keys_quoted); } else if (IsTypedVector()) { AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted); @@ -588,33 +588,33 @@ class Reference { auto blob = AsBlob(); flatbuffers::EscapeString(reinterpret_cast<const char *>(blob.data()), blob.size(), &s, true, false); - } else { - s += "(?)"; - } - } - - // This function returns the empty blob if you try to read a not-blob. - // Strings can be viewed as blobs too. - Blob AsBlob() const { - if (type_ == FBT_BLOB || type_ == FBT_STRING) { - return Blob(Indirect(), byte_width_); - } else { - return Blob::EmptyBlob(); - } - } - - // This function returns the empty vector if you try to read a not-vector. - // Maps can be viewed as vectors too. - Vector AsVector() const { - if (type_ == FBT_VECTOR || type_ == FBT_MAP) { - return Vector(Indirect(), byte_width_); - } else { - return Vector::EmptyVector(); - } - } - - TypedVector AsTypedVector() const { - if (IsTypedVector()) { + } else { + s += "(?)"; + } + } + + // This function returns the empty blob if you try to read a not-blob. + // Strings can be viewed as blobs too. + Blob AsBlob() const { + if (type_ == FBT_BLOB || type_ == FBT_STRING) { + return Blob(Indirect(), byte_width_); + } else { + return Blob::EmptyBlob(); + } + } + + // This function returns the empty vector if you try to read a not-vector. + // Maps can be viewed as vectors too. + Vector AsVector() const { + if (type_ == FBT_VECTOR || type_ == FBT_MAP) { + return Vector(Indirect(), byte_width_); + } else { + return Vector::EmptyVector(); + } + } + + TypedVector AsTypedVector() const { + if (IsTypedVector()) { auto tv = TypedVector(Indirect(), byte_width_, ToTypedVectorElementType(type_)); if (tv.type_ == FBT_STRING) { @@ -627,149 +627,149 @@ class Reference { tv.type_ = FBT_KEY; } return tv; - } else { - return TypedVector::EmptyTypedVector(); - } - } - - FixedTypedVector AsFixedTypedVector() const { - if (IsFixedTypedVector()) { - uint8_t len = 0; - auto vtype = ToFixedTypedVectorElementType(type_, &len); - return FixedTypedVector(Indirect(), byte_width_, vtype, len); - } else { - return FixedTypedVector::EmptyFixedTypedVector(); - } - } - - Map AsMap() const { - if (type_ == FBT_MAP) { - return Map(Indirect(), byte_width_); - } else { - return Map::EmptyMap(); - } - } - + } else { + return TypedVector::EmptyTypedVector(); + } + } + + FixedTypedVector AsFixedTypedVector() const { + if (IsFixedTypedVector()) { + uint8_t len = 0; + auto vtype = ToFixedTypedVectorElementType(type_, &len); + return FixedTypedVector(Indirect(), byte_width_, vtype, len); + } else { + return FixedTypedVector::EmptyFixedTypedVector(); + } + } + + Map AsMap() const { + if (type_ == FBT_MAP) { + return Map(Indirect(), byte_width_); + } else { + return Map::EmptyMap(); + } + } + template<typename T> T As() const; - - // Experimental: Mutation functions. - // These allow scalars in an already created buffer to be updated in-place. - // Since by default scalars are stored in the smallest possible space, - // the new value may not fit, in which case these functions return false. - // To avoid this, you can construct the values you intend to mutate using - // Builder::ForceMinimumBitWidth. - bool MutateInt(int64_t i) { - if (type_ == FBT_INT) { - return Mutate(data_, i, parent_width_, WidthI(i)); - } else if (type_ == FBT_INDIRECT_INT) { - return Mutate(Indirect(), i, byte_width_, WidthI(i)); - } else if (type_ == FBT_UINT) { - auto u = static_cast<uint64_t>(i); - return Mutate(data_, u, parent_width_, WidthU(u)); - } else if (type_ == FBT_INDIRECT_UINT) { - auto u = static_cast<uint64_t>(i); - return Mutate(Indirect(), u, byte_width_, WidthU(u)); - } else { - return false; - } - } - - bool MutateBool(bool b) { - return type_ == FBT_BOOL && Mutate(data_, b, parent_width_, BIT_WIDTH_8); - } - - bool MutateUInt(uint64_t u) { - if (type_ == FBT_UINT) { - return Mutate(data_, u, parent_width_, WidthU(u)); - } else if (type_ == FBT_INDIRECT_UINT) { - return Mutate(Indirect(), u, byte_width_, WidthU(u)); - } else if (type_ == FBT_INT) { - auto i = static_cast<int64_t>(u); - return Mutate(data_, i, parent_width_, WidthI(i)); - } else if (type_ == FBT_INDIRECT_INT) { - auto i = static_cast<int64_t>(u); - return Mutate(Indirect(), i, byte_width_, WidthI(i)); - } else { - return false; - } - } - - bool MutateFloat(float f) { - if (type_ == FBT_FLOAT) { - return MutateF(data_, f, parent_width_, BIT_WIDTH_32); - } else if (type_ == FBT_INDIRECT_FLOAT) { - return MutateF(Indirect(), f, byte_width_, BIT_WIDTH_32); - } else { - return false; - } - } - - bool MutateFloat(double d) { - if (type_ == FBT_FLOAT) { - return MutateF(data_, d, parent_width_, WidthF(d)); - } else if (type_ == FBT_INDIRECT_FLOAT) { - return MutateF(Indirect(), d, byte_width_, WidthF(d)); - } else { - return false; - } - } - - bool MutateString(const char *str, size_t len) { - auto s = AsString(); - if (s.IsTheEmptyString()) return false; - // This is very strict, could allow shorter strings, but that creates - // garbage. - if (s.length() != len) return false; - memcpy(const_cast<char *>(s.c_str()), str, len); - return true; - } - bool MutateString(const char *str) { return MutateString(str, strlen(str)); } - bool MutateString(const std::string &str) { - return MutateString(str.data(), str.length()); - } - - private: - const uint8_t *Indirect() const { - return flexbuffers::Indirect(data_, parent_width_); - } - - template<typename T> - bool Mutate(const uint8_t *dest, T t, size_t byte_width, - BitWidth value_width) { - auto fits = static_cast<size_t>(static_cast<size_t>(1U) << value_width) <= - byte_width; - if (fits) { - t = flatbuffers::EndianScalar(t); - memcpy(const_cast<uint8_t *>(dest), &t, byte_width); - } - return fits; - } - - template<typename T> - bool MutateF(const uint8_t *dest, T t, size_t byte_width, - BitWidth value_width) { - if (byte_width == sizeof(double)) - return Mutate(dest, static_cast<double>(t), byte_width, value_width); - if (byte_width == sizeof(float)) - return Mutate(dest, static_cast<float>(t), byte_width, value_width); - FLATBUFFERS_ASSERT(false); - return false; - } - - const uint8_t *data_; - uint8_t parent_width_; - uint8_t byte_width_; - Type type_; -}; - -// Template specialization for As(). + + // Experimental: Mutation functions. + // These allow scalars in an already created buffer to be updated in-place. + // Since by default scalars are stored in the smallest possible space, + // the new value may not fit, in which case these functions return false. + // To avoid this, you can construct the values you intend to mutate using + // Builder::ForceMinimumBitWidth. + bool MutateInt(int64_t i) { + if (type_ == FBT_INT) { + return Mutate(data_, i, parent_width_, WidthI(i)); + } else if (type_ == FBT_INDIRECT_INT) { + return Mutate(Indirect(), i, byte_width_, WidthI(i)); + } else if (type_ == FBT_UINT) { + auto u = static_cast<uint64_t>(i); + return Mutate(data_, u, parent_width_, WidthU(u)); + } else if (type_ == FBT_INDIRECT_UINT) { + auto u = static_cast<uint64_t>(i); + return Mutate(Indirect(), u, byte_width_, WidthU(u)); + } else { + return false; + } + } + + bool MutateBool(bool b) { + return type_ == FBT_BOOL && Mutate(data_, b, parent_width_, BIT_WIDTH_8); + } + + bool MutateUInt(uint64_t u) { + if (type_ == FBT_UINT) { + return Mutate(data_, u, parent_width_, WidthU(u)); + } else if (type_ == FBT_INDIRECT_UINT) { + return Mutate(Indirect(), u, byte_width_, WidthU(u)); + } else if (type_ == FBT_INT) { + auto i = static_cast<int64_t>(u); + return Mutate(data_, i, parent_width_, WidthI(i)); + } else if (type_ == FBT_INDIRECT_INT) { + auto i = static_cast<int64_t>(u); + return Mutate(Indirect(), i, byte_width_, WidthI(i)); + } else { + return false; + } + } + + bool MutateFloat(float f) { + if (type_ == FBT_FLOAT) { + return MutateF(data_, f, parent_width_, BIT_WIDTH_32); + } else if (type_ == FBT_INDIRECT_FLOAT) { + return MutateF(Indirect(), f, byte_width_, BIT_WIDTH_32); + } else { + return false; + } + } + + bool MutateFloat(double d) { + if (type_ == FBT_FLOAT) { + return MutateF(data_, d, parent_width_, WidthF(d)); + } else if (type_ == FBT_INDIRECT_FLOAT) { + return MutateF(Indirect(), d, byte_width_, WidthF(d)); + } else { + return false; + } + } + + bool MutateString(const char *str, size_t len) { + auto s = AsString(); + if (s.IsTheEmptyString()) return false; + // This is very strict, could allow shorter strings, but that creates + // garbage. + if (s.length() != len) return false; + memcpy(const_cast<char *>(s.c_str()), str, len); + return true; + } + bool MutateString(const char *str) { return MutateString(str, strlen(str)); } + bool MutateString(const std::string &str) { + return MutateString(str.data(), str.length()); + } + + private: + const uint8_t *Indirect() const { + return flexbuffers::Indirect(data_, parent_width_); + } + + template<typename T> + bool Mutate(const uint8_t *dest, T t, size_t byte_width, + BitWidth value_width) { + auto fits = static_cast<size_t>(static_cast<size_t>(1U) << value_width) <= + byte_width; + if (fits) { + t = flatbuffers::EndianScalar(t); + memcpy(const_cast<uint8_t *>(dest), &t, byte_width); + } + return fits; + } + + template<typename T> + bool MutateF(const uint8_t *dest, T t, size_t byte_width, + BitWidth value_width) { + if (byte_width == sizeof(double)) + return Mutate(dest, static_cast<double>(t), byte_width, value_width); + if (byte_width == sizeof(float)) + return Mutate(dest, static_cast<float>(t), byte_width, value_width); + FLATBUFFERS_ASSERT(false); + return false; + } + + const uint8_t *data_; + uint8_t parent_width_; + uint8_t byte_width_; + Type type_; +}; + +// Template specialization for As(). template<> inline bool Reference::As<bool>() const { return AsBool(); } - + template<> inline int8_t Reference::As<int8_t>() const { return AsInt8(); } template<> inline int16_t Reference::As<int16_t>() const { return AsInt16(); } template<> inline int32_t Reference::As<int32_t>() const { return AsInt32(); } template<> inline int64_t Reference::As<int64_t>() const { return AsInt64(); } - + template<> inline uint8_t Reference::As<uint8_t>() const { return AsUInt8(); } template<> inline uint16_t Reference::As<uint16_t>() const { return AsUInt16(); @@ -780,488 +780,488 @@ template<> inline uint32_t Reference::As<uint32_t>() const { template<> inline uint64_t Reference::As<uint64_t>() const { return AsUInt64(); } - + template<> inline double Reference::As<double>() const { return AsDouble(); } template<> inline float Reference::As<float>() const { return AsFloat(); } - + template<> inline String Reference::As<String>() const { return AsString(); } template<> inline std::string Reference::As<std::string>() const { - return AsString().str(); -} - + return AsString().str(); +} + template<> inline Blob Reference::As<Blob>() const { return AsBlob(); } template<> inline Vector Reference::As<Vector>() const { return AsVector(); } template<> inline TypedVector Reference::As<TypedVector>() const { - return AsTypedVector(); -} + return AsTypedVector(); +} template<> inline FixedTypedVector Reference::As<FixedTypedVector>() const { - return AsFixedTypedVector(); -} + return AsFixedTypedVector(); +} template<> inline Map Reference::As<Map>() const { return AsMap(); } - -inline uint8_t PackedType(BitWidth bit_width, Type type) { - return static_cast<uint8_t>(bit_width | (type << 2)); -} - -inline uint8_t NullPackedType() { return PackedType(BIT_WIDTH_8, FBT_NULL); } - -// Vector accessors. -// Note: if you try to access outside of bounds, you get a Null value back -// instead. Normally this would be an assert, but since this is "dynamically -// typed" data, you may not want that (someone sends you a 2d vector and you -// wanted 3d). -// The Null converts seamlessly into a default value for any other type. -// TODO(wvo): Could introduce an #ifdef that makes this into an assert? -inline Reference Vector::operator[](size_t i) const { - auto len = size(); - if (i >= len) return Reference(nullptr, 1, NullPackedType()); - auto packed_type = (data_ + len * byte_width_)[i]; - auto elem = data_ + i * byte_width_; - return Reference(elem, byte_width_, packed_type); -} - -inline Reference TypedVector::operator[](size_t i) const { - auto len = size(); - if (i >= len) return Reference(nullptr, 1, NullPackedType()); - auto elem = data_ + i * byte_width_; - return Reference(elem, byte_width_, 1, type_); -} - -inline Reference FixedTypedVector::operator[](size_t i) const { - if (i >= len_) return Reference(nullptr, 1, NullPackedType()); - auto elem = data_ + i * byte_width_; - return Reference(elem, byte_width_, 1, type_); -} - -template<typename T> int KeyCompare(const void *key, const void *elem) { - auto str_elem = reinterpret_cast<const char *>( - Indirect<T>(reinterpret_cast<const uint8_t *>(elem))); - auto skey = reinterpret_cast<const char *>(key); - return strcmp(skey, str_elem); -} - -inline Reference Map::operator[](const char *key) const { - auto keys = Keys(); - // We can't pass keys.byte_width_ to the comparison function, so we have - // to pick the right one ahead of time. - int (*comp)(const void *, const void *) = nullptr; - switch (keys.byte_width_) { - case 1: comp = KeyCompare<uint8_t>; break; - case 2: comp = KeyCompare<uint16_t>; break; - case 4: comp = KeyCompare<uint32_t>; break; - case 8: comp = KeyCompare<uint64_t>; break; - } - auto res = std::bsearch(key, keys.data_, keys.size(), keys.byte_width_, comp); - if (!res) return Reference(nullptr, 1, NullPackedType()); - auto i = (reinterpret_cast<uint8_t *>(res) - keys.data_) / keys.byte_width_; - return (*static_cast<const Vector *>(this))[i]; -} - -inline Reference Map::operator[](const std::string &key) const { - return (*this)[key.c_str()]; -} - -inline Reference GetRoot(const uint8_t *buffer, size_t size) { - // See Finish() below for the serialization counterpart of this. - // The root starts at the end of the buffer, so we parse backwards from there. - auto end = buffer + size; - auto byte_width = *--end; - auto packed_type = *--end; - end -= byte_width; // The root data item. - return Reference(end, byte_width, packed_type); -} - -inline Reference GetRoot(const std::vector<uint8_t> &buffer) { - return GetRoot(flatbuffers::vector_data(buffer), buffer.size()); -} - -// Flags that configure how the Builder behaves. -// The "Share" flags determine if the Builder automatically tries to pool -// this type. Pooling can reduce the size of serialized data if there are -// multiple maps of the same kind, at the expense of slightly slower -// serialization (the cost of lookups) and more memory use (std::set). -// By default this is on for keys, but off for strings. -// Turn keys off if you have e.g. only one map. -// Turn strings on if you expect many non-unique string values. -// Additionally, sharing key vectors can save space if you have maps with -// identical field populations. -enum BuilderFlag { - BUILDER_FLAG_NONE = 0, - BUILDER_FLAG_SHARE_KEYS = 1, - BUILDER_FLAG_SHARE_STRINGS = 2, - BUILDER_FLAG_SHARE_KEYS_AND_STRINGS = 3, - BUILDER_FLAG_SHARE_KEY_VECTORS = 4, - BUILDER_FLAG_SHARE_ALL = 7, -}; - -class Builder FLATBUFFERS_FINAL_CLASS { - public: - Builder(size_t initial_size = 256, - BuilderFlag flags = BUILDER_FLAG_SHARE_KEYS) - : buf_(initial_size), - finished_(false), + +inline uint8_t PackedType(BitWidth bit_width, Type type) { + return static_cast<uint8_t>(bit_width | (type << 2)); +} + +inline uint8_t NullPackedType() { return PackedType(BIT_WIDTH_8, FBT_NULL); } + +// Vector accessors. +// Note: if you try to access outside of bounds, you get a Null value back +// instead. Normally this would be an assert, but since this is "dynamically +// typed" data, you may not want that (someone sends you a 2d vector and you +// wanted 3d). +// The Null converts seamlessly into a default value for any other type. +// TODO(wvo): Could introduce an #ifdef that makes this into an assert? +inline Reference Vector::operator[](size_t i) const { + auto len = size(); + if (i >= len) return Reference(nullptr, 1, NullPackedType()); + auto packed_type = (data_ + len * byte_width_)[i]; + auto elem = data_ + i * byte_width_; + return Reference(elem, byte_width_, packed_type); +} + +inline Reference TypedVector::operator[](size_t i) const { + auto len = size(); + if (i >= len) return Reference(nullptr, 1, NullPackedType()); + auto elem = data_ + i * byte_width_; + return Reference(elem, byte_width_, 1, type_); +} + +inline Reference FixedTypedVector::operator[](size_t i) const { + if (i >= len_) return Reference(nullptr, 1, NullPackedType()); + auto elem = data_ + i * byte_width_; + return Reference(elem, byte_width_, 1, type_); +} + +template<typename T> int KeyCompare(const void *key, const void *elem) { + auto str_elem = reinterpret_cast<const char *>( + Indirect<T>(reinterpret_cast<const uint8_t *>(elem))); + auto skey = reinterpret_cast<const char *>(key); + return strcmp(skey, str_elem); +} + +inline Reference Map::operator[](const char *key) const { + auto keys = Keys(); + // We can't pass keys.byte_width_ to the comparison function, so we have + // to pick the right one ahead of time. + int (*comp)(const void *, const void *) = nullptr; + switch (keys.byte_width_) { + case 1: comp = KeyCompare<uint8_t>; break; + case 2: comp = KeyCompare<uint16_t>; break; + case 4: comp = KeyCompare<uint32_t>; break; + case 8: comp = KeyCompare<uint64_t>; break; + } + auto res = std::bsearch(key, keys.data_, keys.size(), keys.byte_width_, comp); + if (!res) return Reference(nullptr, 1, NullPackedType()); + auto i = (reinterpret_cast<uint8_t *>(res) - keys.data_) / keys.byte_width_; + return (*static_cast<const Vector *>(this))[i]; +} + +inline Reference Map::operator[](const std::string &key) const { + return (*this)[key.c_str()]; +} + +inline Reference GetRoot(const uint8_t *buffer, size_t size) { + // See Finish() below for the serialization counterpart of this. + // The root starts at the end of the buffer, so we parse backwards from there. + auto end = buffer + size; + auto byte_width = *--end; + auto packed_type = *--end; + end -= byte_width; // The root data item. + return Reference(end, byte_width, packed_type); +} + +inline Reference GetRoot(const std::vector<uint8_t> &buffer) { + return GetRoot(flatbuffers::vector_data(buffer), buffer.size()); +} + +// Flags that configure how the Builder behaves. +// The "Share" flags determine if the Builder automatically tries to pool +// this type. Pooling can reduce the size of serialized data if there are +// multiple maps of the same kind, at the expense of slightly slower +// serialization (the cost of lookups) and more memory use (std::set). +// By default this is on for keys, but off for strings. +// Turn keys off if you have e.g. only one map. +// Turn strings on if you expect many non-unique string values. +// Additionally, sharing key vectors can save space if you have maps with +// identical field populations. +enum BuilderFlag { + BUILDER_FLAG_NONE = 0, + BUILDER_FLAG_SHARE_KEYS = 1, + BUILDER_FLAG_SHARE_STRINGS = 2, + BUILDER_FLAG_SHARE_KEYS_AND_STRINGS = 3, + BUILDER_FLAG_SHARE_KEY_VECTORS = 4, + BUILDER_FLAG_SHARE_ALL = 7, +}; + +class Builder FLATBUFFERS_FINAL_CLASS { + public: + Builder(size_t initial_size = 256, + BuilderFlag flags = BUILDER_FLAG_SHARE_KEYS) + : buf_(initial_size), + finished_(false), has_duplicate_keys_(false), - flags_(flags), - force_min_bit_width_(BIT_WIDTH_8), - key_pool(KeyOffsetCompare(buf_)), - string_pool(StringOffsetCompare(buf_)) { - buf_.clear(); - } - + flags_(flags), + force_min_bit_width_(BIT_WIDTH_8), + key_pool(KeyOffsetCompare(buf_)), + string_pool(StringOffsetCompare(buf_)) { + buf_.clear(); + } + #ifdef FLATBUFFERS_DEFAULT_DECLARATION Builder(Builder &&) = default; Builder &operator=(Builder &&) = default; #endif - /// @brief Get the serialized buffer (after you call `Finish()`). - /// @return Returns a vector owned by this class. - const std::vector<uint8_t> &GetBuffer() const { - Finished(); - return buf_; - } - - // Size of the buffer. Does not include unfinished values. - size_t GetSize() const { return buf_.size(); } - - // Reset all state so we can re-use the buffer. - void Clear() { - buf_.clear(); - stack_.clear(); - finished_ = false; - // flags_ remains as-is; - force_min_bit_width_ = BIT_WIDTH_8; - key_pool.clear(); - string_pool.clear(); - } - - // All value constructing functions below have two versions: one that - // takes a key (for placement inside a map) and one that doesn't (for inside - // vectors and elsewhere). - - void Null() { stack_.push_back(Value()); } - void Null(const char *key) { - Key(key); - Null(); - } - - void Int(int64_t i) { stack_.push_back(Value(i, FBT_INT, WidthI(i))); } - void Int(const char *key, int64_t i) { - Key(key); - Int(i); - } - - void UInt(uint64_t u) { stack_.push_back(Value(u, FBT_UINT, WidthU(u))); } - void UInt(const char *key, uint64_t u) { - Key(key); - UInt(u); - } - - void Float(float f) { stack_.push_back(Value(f)); } - void Float(const char *key, float f) { - Key(key); - Float(f); - } - - void Double(double f) { stack_.push_back(Value(f)); } - void Double(const char *key, double d) { - Key(key); - Double(d); - } - - void Bool(bool b) { stack_.push_back(Value(b)); } - void Bool(const char *key, bool b) { - Key(key); - Bool(b); - } - - void IndirectInt(int64_t i) { PushIndirect(i, FBT_INDIRECT_INT, WidthI(i)); } - void IndirectInt(const char *key, int64_t i) { - Key(key); - IndirectInt(i); - } - - void IndirectUInt(uint64_t u) { - PushIndirect(u, FBT_INDIRECT_UINT, WidthU(u)); - } - void IndirectUInt(const char *key, uint64_t u) { - Key(key); - IndirectUInt(u); - } - - void IndirectFloat(float f) { - PushIndirect(f, FBT_INDIRECT_FLOAT, BIT_WIDTH_32); - } - void IndirectFloat(const char *key, float f) { - Key(key); - IndirectFloat(f); - } - - void IndirectDouble(double f) { - PushIndirect(f, FBT_INDIRECT_FLOAT, WidthF(f)); - } - void IndirectDouble(const char *key, double d) { - Key(key); - IndirectDouble(d); - } - - size_t Key(const char *str, size_t len) { - auto sloc = buf_.size(); - WriteBytes(str, len + 1); - if (flags_ & BUILDER_FLAG_SHARE_KEYS) { - auto it = key_pool.find(sloc); - if (it != key_pool.end()) { - // Already in the buffer. Remove key we just serialized, and use - // existing offset instead. - buf_.resize(sloc); - sloc = *it; - } else { - key_pool.insert(sloc); - } - } - stack_.push_back(Value(static_cast<uint64_t>(sloc), FBT_KEY, BIT_WIDTH_8)); - return sloc; - } - - size_t Key(const char *str) { return Key(str, strlen(str)); } - size_t Key(const std::string &str) { return Key(str.c_str(), str.size()); } - - size_t String(const char *str, size_t len) { - auto reset_to = buf_.size(); - auto sloc = CreateBlob(str, len, 1, FBT_STRING); - if (flags_ & BUILDER_FLAG_SHARE_STRINGS) { - StringOffset so(sloc, len); - auto it = string_pool.find(so); - if (it != string_pool.end()) { - // Already in the buffer. Remove string we just serialized, and use - // existing offset instead. - buf_.resize(reset_to); - sloc = it->first; - stack_.back().u_ = sloc; - } else { - string_pool.insert(so); - } - } - return sloc; - } - size_t String(const char *str) { return String(str, strlen(str)); } - size_t String(const std::string &str) { - return String(str.c_str(), str.size()); - } - void String(const flexbuffers::String &str) { - String(str.c_str(), str.length()); - } - - void String(const char *key, const char *str) { - Key(key); - String(str); - } - void String(const char *key, const std::string &str) { - Key(key); - String(str); - } - void String(const char *key, const flexbuffers::String &str) { - Key(key); - String(str); - } - - size_t Blob(const void *data, size_t len) { - return CreateBlob(data, len, 0, FBT_BLOB); - } - size_t Blob(const std::vector<uint8_t> &v) { - return CreateBlob(flatbuffers::vector_data(v), v.size(), 0, FBT_BLOB); - } - - // TODO(wvo): support all the FlexBuffer types (like flexbuffers::String), - // e.g. Vector etc. Also in overloaded versions. - // Also some FlatBuffers types? - - size_t StartVector() { return stack_.size(); } - size_t StartVector(const char *key) { - Key(key); - return stack_.size(); - } - size_t StartMap() { return stack_.size(); } - size_t StartMap(const char *key) { - Key(key); - return stack_.size(); - } - - // TODO(wvo): allow this to specify an aligment greater than the natural - // alignment. - size_t EndVector(size_t start, bool typed, bool fixed) { - auto vec = CreateVector(start, stack_.size() - start, 1, typed, fixed); - // Remove temp elements and return vector. - stack_.resize(start); - stack_.push_back(vec); - return static_cast<size_t>(vec.u_); - } - - size_t EndMap(size_t start) { - // We should have interleaved keys and values on the stack. - // Make sure it is an even number: - auto len = stack_.size() - start; - FLATBUFFERS_ASSERT(!(len & 1)); - len /= 2; - // Make sure keys are all strings: - for (auto key = start; key < stack_.size(); key += 2) { - FLATBUFFERS_ASSERT(stack_[key].type_ == FBT_KEY); - } + /// @brief Get the serialized buffer (after you call `Finish()`). + /// @return Returns a vector owned by this class. + const std::vector<uint8_t> &GetBuffer() const { + Finished(); + return buf_; + } + + // Size of the buffer. Does not include unfinished values. + size_t GetSize() const { return buf_.size(); } + + // Reset all state so we can re-use the buffer. + void Clear() { + buf_.clear(); + stack_.clear(); + finished_ = false; + // flags_ remains as-is; + force_min_bit_width_ = BIT_WIDTH_8; + key_pool.clear(); + string_pool.clear(); + } + + // All value constructing functions below have two versions: one that + // takes a key (for placement inside a map) and one that doesn't (for inside + // vectors and elsewhere). + + void Null() { stack_.push_back(Value()); } + void Null(const char *key) { + Key(key); + Null(); + } + + void Int(int64_t i) { stack_.push_back(Value(i, FBT_INT, WidthI(i))); } + void Int(const char *key, int64_t i) { + Key(key); + Int(i); + } + + void UInt(uint64_t u) { stack_.push_back(Value(u, FBT_UINT, WidthU(u))); } + void UInt(const char *key, uint64_t u) { + Key(key); + UInt(u); + } + + void Float(float f) { stack_.push_back(Value(f)); } + void Float(const char *key, float f) { + Key(key); + Float(f); + } + + void Double(double f) { stack_.push_back(Value(f)); } + void Double(const char *key, double d) { + Key(key); + Double(d); + } + + void Bool(bool b) { stack_.push_back(Value(b)); } + void Bool(const char *key, bool b) { + Key(key); + Bool(b); + } + + void IndirectInt(int64_t i) { PushIndirect(i, FBT_INDIRECT_INT, WidthI(i)); } + void IndirectInt(const char *key, int64_t i) { + Key(key); + IndirectInt(i); + } + + void IndirectUInt(uint64_t u) { + PushIndirect(u, FBT_INDIRECT_UINT, WidthU(u)); + } + void IndirectUInt(const char *key, uint64_t u) { + Key(key); + IndirectUInt(u); + } + + void IndirectFloat(float f) { + PushIndirect(f, FBT_INDIRECT_FLOAT, BIT_WIDTH_32); + } + void IndirectFloat(const char *key, float f) { + Key(key); + IndirectFloat(f); + } + + void IndirectDouble(double f) { + PushIndirect(f, FBT_INDIRECT_FLOAT, WidthF(f)); + } + void IndirectDouble(const char *key, double d) { + Key(key); + IndirectDouble(d); + } + + size_t Key(const char *str, size_t len) { + auto sloc = buf_.size(); + WriteBytes(str, len + 1); + if (flags_ & BUILDER_FLAG_SHARE_KEYS) { + auto it = key_pool.find(sloc); + if (it != key_pool.end()) { + // Already in the buffer. Remove key we just serialized, and use + // existing offset instead. + buf_.resize(sloc); + sloc = *it; + } else { + key_pool.insert(sloc); + } + } + stack_.push_back(Value(static_cast<uint64_t>(sloc), FBT_KEY, BIT_WIDTH_8)); + return sloc; + } + + size_t Key(const char *str) { return Key(str, strlen(str)); } + size_t Key(const std::string &str) { return Key(str.c_str(), str.size()); } + + size_t String(const char *str, size_t len) { + auto reset_to = buf_.size(); + auto sloc = CreateBlob(str, len, 1, FBT_STRING); + if (flags_ & BUILDER_FLAG_SHARE_STRINGS) { + StringOffset so(sloc, len); + auto it = string_pool.find(so); + if (it != string_pool.end()) { + // Already in the buffer. Remove string we just serialized, and use + // existing offset instead. + buf_.resize(reset_to); + sloc = it->first; + stack_.back().u_ = sloc; + } else { + string_pool.insert(so); + } + } + return sloc; + } + size_t String(const char *str) { return String(str, strlen(str)); } + size_t String(const std::string &str) { + return String(str.c_str(), str.size()); + } + void String(const flexbuffers::String &str) { + String(str.c_str(), str.length()); + } + + void String(const char *key, const char *str) { + Key(key); + String(str); + } + void String(const char *key, const std::string &str) { + Key(key); + String(str); + } + void String(const char *key, const flexbuffers::String &str) { + Key(key); + String(str); + } + + size_t Blob(const void *data, size_t len) { + return CreateBlob(data, len, 0, FBT_BLOB); + } + size_t Blob(const std::vector<uint8_t> &v) { + return CreateBlob(flatbuffers::vector_data(v), v.size(), 0, FBT_BLOB); + } + + // TODO(wvo): support all the FlexBuffer types (like flexbuffers::String), + // e.g. Vector etc. Also in overloaded versions. + // Also some FlatBuffers types? + + size_t StartVector() { return stack_.size(); } + size_t StartVector(const char *key) { + Key(key); + return stack_.size(); + } + size_t StartMap() { return stack_.size(); } + size_t StartMap(const char *key) { + Key(key); + return stack_.size(); + } + + // TODO(wvo): allow this to specify an aligment greater than the natural + // alignment. + size_t EndVector(size_t start, bool typed, bool fixed) { + auto vec = CreateVector(start, stack_.size() - start, 1, typed, fixed); + // Remove temp elements and return vector. + stack_.resize(start); + stack_.push_back(vec); + return static_cast<size_t>(vec.u_); + } + + size_t EndMap(size_t start) { + // We should have interleaved keys and values on the stack. + // Make sure it is an even number: + auto len = stack_.size() - start; + FLATBUFFERS_ASSERT(!(len & 1)); + len /= 2; + // Make sure keys are all strings: + for (auto key = start; key < stack_.size(); key += 2) { + FLATBUFFERS_ASSERT(stack_[key].type_ == FBT_KEY); + } // Now sort values, so later we can do a binary search lookup. - // We want to sort 2 array elements at a time. - struct TwoValue { - Value key; - Value val; - }; - // TODO(wvo): strict aliasing? - // TODO(wvo): allow the caller to indicate the data is already sorted - // for maximum efficiency? With an assert to check sortedness to make sure - // we're not breaking binary search. - // Or, we can track if the map is sorted as keys are added which would be - // be quite cheap (cheaper than checking it here), so we can skip this - // step automatically when appliccable, and encourage people to write in - // sorted fashion. - // std::sort is typically already a lot faster on sorted data though. - auto dict = - reinterpret_cast<TwoValue *>(flatbuffers::vector_data(stack_) + start); - std::sort(dict, dict + len, - [&](const TwoValue &a, const TwoValue &b) -> bool { - auto as = reinterpret_cast<const char *>( - flatbuffers::vector_data(buf_) + a.key.u_); - auto bs = reinterpret_cast<const char *>( - flatbuffers::vector_data(buf_) + b.key.u_); - auto comp = strcmp(as, bs); + // We want to sort 2 array elements at a time. + struct TwoValue { + Value key; + Value val; + }; + // TODO(wvo): strict aliasing? + // TODO(wvo): allow the caller to indicate the data is already sorted + // for maximum efficiency? With an assert to check sortedness to make sure + // we're not breaking binary search. + // Or, we can track if the map is sorted as keys are added which would be + // be quite cheap (cheaper than checking it here), so we can skip this + // step automatically when appliccable, and encourage people to write in + // sorted fashion. + // std::sort is typically already a lot faster on sorted data though. + auto dict = + reinterpret_cast<TwoValue *>(flatbuffers::vector_data(stack_) + start); + std::sort(dict, dict + len, + [&](const TwoValue &a, const TwoValue &b) -> bool { + auto as = reinterpret_cast<const char *>( + flatbuffers::vector_data(buf_) + a.key.u_); + auto bs = reinterpret_cast<const char *>( + flatbuffers::vector_data(buf_) + b.key.u_); + auto comp = strcmp(as, bs); // We want to disallow duplicate keys, since this results in a // map where values cannot be found. // But we can't assert here (since we don't want to fail on // random JSON input) or have an error mechanism. // Instead, we set has_duplicate_keys_ in the builder to // signal this. - // TODO: Have to check for pointer equality, as some sort - // implementation apparently call this function with the same - // element?? Why? + // TODO: Have to check for pointer equality, as some sort + // implementation apparently call this function with the same + // element?? Why? if (!comp && &a != &b) has_duplicate_keys_ = true; - return comp < 0; - }); - // First create a vector out of all keys. - // TODO(wvo): if kBuilderFlagShareKeyVectors is true, see if we can share - // the first vector. - auto keys = CreateVector(start, len, 2, true, false); - auto vec = CreateVector(start + 1, len, 2, false, false, &keys); - // Remove temp elements and return map. - stack_.resize(start); - stack_.push_back(vec); - return static_cast<size_t>(vec.u_); - } - + return comp < 0; + }); + // First create a vector out of all keys. + // TODO(wvo): if kBuilderFlagShareKeyVectors is true, see if we can share + // the first vector. + auto keys = CreateVector(start, len, 2, true, false); + auto vec = CreateVector(start + 1, len, 2, false, false, &keys); + // Remove temp elements and return map. + stack_.resize(start); + stack_.push_back(vec); + return static_cast<size_t>(vec.u_); + } + // Call this after EndMap to see if the map had any duplicate keys. // Any map with such keys won't be able to retrieve all values. bool HasDuplicateKeys() const { return has_duplicate_keys_; } - template<typename F> size_t Vector(F f) { - auto start = StartVector(); - f(); - return EndVector(start, false, false); - } - template<typename F, typename T> size_t Vector(F f, T &state) { - auto start = StartVector(); - f(state); - return EndVector(start, false, false); - } - template<typename F> size_t Vector(const char *key, F f) { - auto start = StartVector(key); - f(); - return EndVector(start, false, false); - } - template<typename F, typename T> - size_t Vector(const char *key, F f, T &state) { - auto start = StartVector(key); - f(state); - return EndVector(start, false, false); - } - - template<typename T> void Vector(const T *elems, size_t len) { - if (flatbuffers::is_scalar<T>::value) { - // This path should be a lot quicker and use less space. - ScalarVector(elems, len, false); - } else { - auto start = StartVector(); - for (size_t i = 0; i < len; i++) Add(elems[i]); - EndVector(start, false, false); - } - } - template<typename T> - void Vector(const char *key, const T *elems, size_t len) { - Key(key); - Vector(elems, len); - } - template<typename T> void Vector(const std::vector<T> &vec) { - Vector(flatbuffers::vector_data(vec), vec.size()); - } - - template<typename F> size_t TypedVector(F f) { - auto start = StartVector(); - f(); - return EndVector(start, true, false); - } - template<typename F, typename T> size_t TypedVector(F f, T &state) { - auto start = StartVector(); - f(state); - return EndVector(start, true, false); - } - template<typename F> size_t TypedVector(const char *key, F f) { - auto start = StartVector(key); - f(); - return EndVector(start, true, false); - } - template<typename F, typename T> - size_t TypedVector(const char *key, F f, T &state) { - auto start = StartVector(key); - f(state); - return EndVector(start, true, false); - } - - template<typename T> size_t FixedTypedVector(const T *elems, size_t len) { - // We only support a few fixed vector lengths. Anything bigger use a - // regular typed vector. - FLATBUFFERS_ASSERT(len >= 2 && len <= 4); - // And only scalar values. - static_assert(flatbuffers::is_scalar<T>::value, "Unrelated types"); - return ScalarVector(elems, len, true); - } - - template<typename T> - size_t FixedTypedVector(const char *key, const T *elems, size_t len) { - Key(key); - return FixedTypedVector(elems, len); - } - - template<typename F> size_t Map(F f) { - auto start = StartMap(); - f(); - return EndMap(start); - } - template<typename F, typename T> size_t Map(F f, T &state) { - auto start = StartMap(); - f(state); - return EndMap(start); - } - template<typename F> size_t Map(const char *key, F f) { - auto start = StartMap(key); - f(); - return EndMap(start); - } - template<typename F, typename T> size_t Map(const char *key, F f, T &state) { - auto start = StartMap(key); - f(state); - return EndMap(start); - } - template<typename T> void Map(const std::map<std::string, T> &map) { - auto start = StartMap(); - for (auto it = map.begin(); it != map.end(); ++it) - Add(it->first.c_str(), it->second); - EndMap(start); - } - + template<typename F> size_t Vector(F f) { + auto start = StartVector(); + f(); + return EndVector(start, false, false); + } + template<typename F, typename T> size_t Vector(F f, T &state) { + auto start = StartVector(); + f(state); + return EndVector(start, false, false); + } + template<typename F> size_t Vector(const char *key, F f) { + auto start = StartVector(key); + f(); + return EndVector(start, false, false); + } + template<typename F, typename T> + size_t Vector(const char *key, F f, T &state) { + auto start = StartVector(key); + f(state); + return EndVector(start, false, false); + } + + template<typename T> void Vector(const T *elems, size_t len) { + if (flatbuffers::is_scalar<T>::value) { + // This path should be a lot quicker and use less space. + ScalarVector(elems, len, false); + } else { + auto start = StartVector(); + for (size_t i = 0; i < len; i++) Add(elems[i]); + EndVector(start, false, false); + } + } + template<typename T> + void Vector(const char *key, const T *elems, size_t len) { + Key(key); + Vector(elems, len); + } + template<typename T> void Vector(const std::vector<T> &vec) { + Vector(flatbuffers::vector_data(vec), vec.size()); + } + + template<typename F> size_t TypedVector(F f) { + auto start = StartVector(); + f(); + return EndVector(start, true, false); + } + template<typename F, typename T> size_t TypedVector(F f, T &state) { + auto start = StartVector(); + f(state); + return EndVector(start, true, false); + } + template<typename F> size_t TypedVector(const char *key, F f) { + auto start = StartVector(key); + f(); + return EndVector(start, true, false); + } + template<typename F, typename T> + size_t TypedVector(const char *key, F f, T &state) { + auto start = StartVector(key); + f(state); + return EndVector(start, true, false); + } + + template<typename T> size_t FixedTypedVector(const T *elems, size_t len) { + // We only support a few fixed vector lengths. Anything bigger use a + // regular typed vector. + FLATBUFFERS_ASSERT(len >= 2 && len <= 4); + // And only scalar values. + static_assert(flatbuffers::is_scalar<T>::value, "Unrelated types"); + return ScalarVector(elems, len, true); + } + + template<typename T> + size_t FixedTypedVector(const char *key, const T *elems, size_t len) { + Key(key); + return FixedTypedVector(elems, len); + } + + template<typename F> size_t Map(F f) { + auto start = StartMap(); + f(); + return EndMap(start); + } + template<typename F, typename T> size_t Map(F f, T &state) { + auto start = StartMap(); + f(state); + return EndMap(start); + } + template<typename F> size_t Map(const char *key, F f) { + auto start = StartMap(key); + f(); + return EndMap(start); + } + template<typename F, typename T> size_t Map(const char *key, F f, T &state) { + auto start = StartMap(key); + f(state); + return EndMap(start); + } + template<typename T> void Map(const std::map<std::string, T> &map) { + auto start = StartMap(); + for (auto it = map.begin(); it != map.end(); ++it) + Add(it->first.c_str(), it->second); + EndMap(start); + } + // If you wish to share a value explicitly (a value not shared automatically // through one of the BUILDER_FLAG_SHARE_* flags) you can do so with these // functions. Or if you wish to turn those flags off for performance reasons @@ -1280,357 +1280,357 @@ class Builder FLATBUFFERS_FINAL_CLASS { ReuseValue(v); } - // Overloaded Add that tries to call the correct function above. - void Add(int8_t i) { Int(i); } - void Add(int16_t i) { Int(i); } - void Add(int32_t i) { Int(i); } - void Add(int64_t i) { Int(i); } - void Add(uint8_t u) { UInt(u); } - void Add(uint16_t u) { UInt(u); } - void Add(uint32_t u) { UInt(u); } - void Add(uint64_t u) { UInt(u); } - void Add(float f) { Float(f); } - void Add(double d) { Double(d); } - void Add(bool b) { Bool(b); } - void Add(const char *str) { String(str); } - void Add(const std::string &str) { String(str); } - void Add(const flexbuffers::String &str) { String(str); } - - template<typename T> void Add(const std::vector<T> &vec) { Vector(vec); } - - template<typename T> void Add(const char *key, const T &t) { - Key(key); - Add(t); - } - - template<typename T> void Add(const std::map<std::string, T> &map) { - Map(map); - } - - template<typename T> void operator+=(const T &t) { Add(t); } - - // This function is useful in combination with the Mutate* functions above. - // It forces elements of vectors and maps to have a minimum size, such that - // they can later be updated without failing. - // Call with no arguments to reset. - void ForceMinimumBitWidth(BitWidth bw = BIT_WIDTH_8) { - force_min_bit_width_ = bw; - } - - void Finish() { - // If you hit this assert, you likely have objects that were never included - // in a parent. You need to have exactly one root to finish a buffer. - // Check your Start/End calls are matched, and all objects are inside - // some other object. - FLATBUFFERS_ASSERT(stack_.size() == 1); - - // Write root value. - auto byte_width = Align(stack_[0].ElemWidth(buf_.size(), 0)); - WriteAny(stack_[0], byte_width); - // Write root type. - Write(stack_[0].StoredPackedType(), 1); - // Write root size. Normally determined by parent, but root has no parent :) - Write(byte_width, 1); - - finished_ = true; - } - - private: - void Finished() const { - // If you get this assert, you're attempting to get access a buffer - // which hasn't been finished yet. Be sure to call - // Builder::Finish with your root object. - FLATBUFFERS_ASSERT(finished_); - } - - // Align to prepare for writing a scalar with a certain size. - uint8_t Align(BitWidth alignment) { - auto byte_width = 1U << alignment; - buf_.insert(buf_.end(), flatbuffers::PaddingBytes(buf_.size(), byte_width), - 0); - return static_cast<uint8_t>(byte_width); - } - - void WriteBytes(const void *val, size_t size) { - buf_.insert(buf_.end(), reinterpret_cast<const uint8_t *>(val), - reinterpret_cast<const uint8_t *>(val) + size); - } - - template<typename T> void Write(T val, size_t byte_width) { - FLATBUFFERS_ASSERT(sizeof(T) >= byte_width); - val = flatbuffers::EndianScalar(val); - WriteBytes(&val, byte_width); - } - - void WriteDouble(double f, uint8_t byte_width) { - switch (byte_width) { - case 8: Write(f, byte_width); break; - case 4: Write(static_cast<float>(f), byte_width); break; - // case 2: Write(static_cast<half>(f), byte_width); break; - // case 1: Write(static_cast<quarter>(f), byte_width); break; - default: FLATBUFFERS_ASSERT(0); - } - } - - void WriteOffset(uint64_t o, uint8_t byte_width) { - auto reloff = buf_.size() - o; - FLATBUFFERS_ASSERT(byte_width == 8 || reloff < 1ULL << (byte_width * 8)); - Write(reloff, byte_width); - } - - template<typename T> void PushIndirect(T val, Type type, BitWidth bit_width) { - auto byte_width = Align(bit_width); - auto iloc = buf_.size(); - Write(val, byte_width); - stack_.push_back(Value(static_cast<uint64_t>(iloc), type, bit_width)); - } - - static BitWidth WidthB(size_t byte_width) { - switch (byte_width) { - case 1: return BIT_WIDTH_8; - case 2: return BIT_WIDTH_16; - case 4: return BIT_WIDTH_32; - case 8: return BIT_WIDTH_64; - default: FLATBUFFERS_ASSERT(false); return BIT_WIDTH_64; - } - } - - template<typename T> static Type GetScalarType() { - static_assert(flatbuffers::is_scalar<T>::value, "Unrelated types"); - return flatbuffers::is_floating_point<T>::value - ? FBT_FLOAT - : flatbuffers::is_same<T, bool>::value - ? FBT_BOOL - : (flatbuffers::is_unsigned<T>::value ? FBT_UINT - : FBT_INT); - } - + // Overloaded Add that tries to call the correct function above. + void Add(int8_t i) { Int(i); } + void Add(int16_t i) { Int(i); } + void Add(int32_t i) { Int(i); } + void Add(int64_t i) { Int(i); } + void Add(uint8_t u) { UInt(u); } + void Add(uint16_t u) { UInt(u); } + void Add(uint32_t u) { UInt(u); } + void Add(uint64_t u) { UInt(u); } + void Add(float f) { Float(f); } + void Add(double d) { Double(d); } + void Add(bool b) { Bool(b); } + void Add(const char *str) { String(str); } + void Add(const std::string &str) { String(str); } + void Add(const flexbuffers::String &str) { String(str); } + + template<typename T> void Add(const std::vector<T> &vec) { Vector(vec); } + + template<typename T> void Add(const char *key, const T &t) { + Key(key); + Add(t); + } + + template<typename T> void Add(const std::map<std::string, T> &map) { + Map(map); + } + + template<typename T> void operator+=(const T &t) { Add(t); } + + // This function is useful in combination with the Mutate* functions above. + // It forces elements of vectors and maps to have a minimum size, such that + // they can later be updated without failing. + // Call with no arguments to reset. + void ForceMinimumBitWidth(BitWidth bw = BIT_WIDTH_8) { + force_min_bit_width_ = bw; + } + + void Finish() { + // If you hit this assert, you likely have objects that were never included + // in a parent. You need to have exactly one root to finish a buffer. + // Check your Start/End calls are matched, and all objects are inside + // some other object. + FLATBUFFERS_ASSERT(stack_.size() == 1); + + // Write root value. + auto byte_width = Align(stack_[0].ElemWidth(buf_.size(), 0)); + WriteAny(stack_[0], byte_width); + // Write root type. + Write(stack_[0].StoredPackedType(), 1); + // Write root size. Normally determined by parent, but root has no parent :) + Write(byte_width, 1); + + finished_ = true; + } + + private: + void Finished() const { + // If you get this assert, you're attempting to get access a buffer + // which hasn't been finished yet. Be sure to call + // Builder::Finish with your root object. + FLATBUFFERS_ASSERT(finished_); + } + + // Align to prepare for writing a scalar with a certain size. + uint8_t Align(BitWidth alignment) { + auto byte_width = 1U << alignment; + buf_.insert(buf_.end(), flatbuffers::PaddingBytes(buf_.size(), byte_width), + 0); + return static_cast<uint8_t>(byte_width); + } + + void WriteBytes(const void *val, size_t size) { + buf_.insert(buf_.end(), reinterpret_cast<const uint8_t *>(val), + reinterpret_cast<const uint8_t *>(val) + size); + } + + template<typename T> void Write(T val, size_t byte_width) { + FLATBUFFERS_ASSERT(sizeof(T) >= byte_width); + val = flatbuffers::EndianScalar(val); + WriteBytes(&val, byte_width); + } + + void WriteDouble(double f, uint8_t byte_width) { + switch (byte_width) { + case 8: Write(f, byte_width); break; + case 4: Write(static_cast<float>(f), byte_width); break; + // case 2: Write(static_cast<half>(f), byte_width); break; + // case 1: Write(static_cast<quarter>(f), byte_width); break; + default: FLATBUFFERS_ASSERT(0); + } + } + + void WriteOffset(uint64_t o, uint8_t byte_width) { + auto reloff = buf_.size() - o; + FLATBUFFERS_ASSERT(byte_width == 8 || reloff < 1ULL << (byte_width * 8)); + Write(reloff, byte_width); + } + + template<typename T> void PushIndirect(T val, Type type, BitWidth bit_width) { + auto byte_width = Align(bit_width); + auto iloc = buf_.size(); + Write(val, byte_width); + stack_.push_back(Value(static_cast<uint64_t>(iloc), type, bit_width)); + } + + static BitWidth WidthB(size_t byte_width) { + switch (byte_width) { + case 1: return BIT_WIDTH_8; + case 2: return BIT_WIDTH_16; + case 4: return BIT_WIDTH_32; + case 8: return BIT_WIDTH_64; + default: FLATBUFFERS_ASSERT(false); return BIT_WIDTH_64; + } + } + + template<typename T> static Type GetScalarType() { + static_assert(flatbuffers::is_scalar<T>::value, "Unrelated types"); + return flatbuffers::is_floating_point<T>::value + ? FBT_FLOAT + : flatbuffers::is_same<T, bool>::value + ? FBT_BOOL + : (flatbuffers::is_unsigned<T>::value ? FBT_UINT + : FBT_INT); + } + public: // This was really intended to be private, except for LastValue/ReuseValue. - struct Value { - union { - int64_t i_; - uint64_t u_; - double f_; - }; - - Type type_; - - // For scalars: of itself, for vector: of its elements, for string: length. - BitWidth min_bit_width_; - - Value() : i_(0), type_(FBT_NULL), min_bit_width_(BIT_WIDTH_8) {} - - Value(bool b) - : u_(static_cast<uint64_t>(b)), - type_(FBT_BOOL), - min_bit_width_(BIT_WIDTH_8) {} - - Value(int64_t i, Type t, BitWidth bw) - : i_(i), type_(t), min_bit_width_(bw) {} - Value(uint64_t u, Type t, BitWidth bw) - : u_(u), type_(t), min_bit_width_(bw) {} - + struct Value { + union { + int64_t i_; + uint64_t u_; + double f_; + }; + + Type type_; + + // For scalars: of itself, for vector: of its elements, for string: length. + BitWidth min_bit_width_; + + Value() : i_(0), type_(FBT_NULL), min_bit_width_(BIT_WIDTH_8) {} + + Value(bool b) + : u_(static_cast<uint64_t>(b)), + type_(FBT_BOOL), + min_bit_width_(BIT_WIDTH_8) {} + + Value(int64_t i, Type t, BitWidth bw) + : i_(i), type_(t), min_bit_width_(bw) {} + Value(uint64_t u, Type t, BitWidth bw) + : u_(u), type_(t), min_bit_width_(bw) {} + Value(float f) : f_(static_cast<double>(f)), type_(FBT_FLOAT), min_bit_width_(BIT_WIDTH_32) {} - Value(double f) : f_(f), type_(FBT_FLOAT), min_bit_width_(WidthF(f)) {} - - uint8_t StoredPackedType(BitWidth parent_bit_width_ = BIT_WIDTH_8) const { - return PackedType(StoredWidth(parent_bit_width_), type_); - } - - BitWidth ElemWidth(size_t buf_size, size_t elem_index) const { - if (IsInline(type_)) { - return min_bit_width_; - } else { - // We have an absolute offset, but want to store a relative offset - // elem_index elements beyond the current buffer end. Since whether - // the relative offset fits in a certain byte_width depends on - // the size of the elements before it (and their alignment), we have - // to test for each size in turn. - for (size_t byte_width = 1; - byte_width <= sizeof(flatbuffers::largest_scalar_t); - byte_width *= 2) { - // Where are we going to write this offset? - auto offset_loc = buf_size + - flatbuffers::PaddingBytes(buf_size, byte_width) + - elem_index * byte_width; - // Compute relative offset. - auto offset = offset_loc - u_; - // Does it fit? - auto bit_width = WidthU(offset); - if (static_cast<size_t>(static_cast<size_t>(1U) << bit_width) == - byte_width) - return bit_width; - } - FLATBUFFERS_ASSERT(false); // Must match one of the sizes above. - return BIT_WIDTH_64; - } - } - - BitWidth StoredWidth(BitWidth parent_bit_width_ = BIT_WIDTH_8) const { - if (IsInline(type_)) { - return (std::max)(min_bit_width_, parent_bit_width_); - } else { - return min_bit_width_; - } - } - }; - + Value(double f) : f_(f), type_(FBT_FLOAT), min_bit_width_(WidthF(f)) {} + + uint8_t StoredPackedType(BitWidth parent_bit_width_ = BIT_WIDTH_8) const { + return PackedType(StoredWidth(parent_bit_width_), type_); + } + + BitWidth ElemWidth(size_t buf_size, size_t elem_index) const { + if (IsInline(type_)) { + return min_bit_width_; + } else { + // We have an absolute offset, but want to store a relative offset + // elem_index elements beyond the current buffer end. Since whether + // the relative offset fits in a certain byte_width depends on + // the size of the elements before it (and their alignment), we have + // to test for each size in turn. + for (size_t byte_width = 1; + byte_width <= sizeof(flatbuffers::largest_scalar_t); + byte_width *= 2) { + // Where are we going to write this offset? + auto offset_loc = buf_size + + flatbuffers::PaddingBytes(buf_size, byte_width) + + elem_index * byte_width; + // Compute relative offset. + auto offset = offset_loc - u_; + // Does it fit? + auto bit_width = WidthU(offset); + if (static_cast<size_t>(static_cast<size_t>(1U) << bit_width) == + byte_width) + return bit_width; + } + FLATBUFFERS_ASSERT(false); // Must match one of the sizes above. + return BIT_WIDTH_64; + } + } + + BitWidth StoredWidth(BitWidth parent_bit_width_ = BIT_WIDTH_8) const { + if (IsInline(type_)) { + return (std::max)(min_bit_width_, parent_bit_width_); + } else { + return min_bit_width_; + } + } + }; + private: - void WriteAny(const Value &val, uint8_t byte_width) { - switch (val.type_) { - case FBT_NULL: - case FBT_INT: Write(val.i_, byte_width); break; - case FBT_BOOL: - case FBT_UINT: Write(val.u_, byte_width); break; - case FBT_FLOAT: WriteDouble(val.f_, byte_width); break; - default: WriteOffset(val.u_, byte_width); break; - } - } - - size_t CreateBlob(const void *data, size_t len, size_t trailing, Type type) { - auto bit_width = WidthU(len); - auto byte_width = Align(bit_width); - Write<uint64_t>(len, byte_width); - auto sloc = buf_.size(); - WriteBytes(data, len + trailing); - stack_.push_back(Value(static_cast<uint64_t>(sloc), type, bit_width)); - return sloc; - } - - template<typename T> - size_t ScalarVector(const T *elems, size_t len, bool fixed) { - auto vector_type = GetScalarType<T>(); - auto byte_width = sizeof(T); - auto bit_width = WidthB(byte_width); - // If you get this assert, you're trying to write a vector with a size - // field that is bigger than the scalars you're trying to write (e.g. a - // byte vector > 255 elements). For such types, write a "blob" instead. - // TODO: instead of asserting, could write vector with larger elements - // instead, though that would be wasteful. - FLATBUFFERS_ASSERT(WidthU(len) <= bit_width); + void WriteAny(const Value &val, uint8_t byte_width) { + switch (val.type_) { + case FBT_NULL: + case FBT_INT: Write(val.i_, byte_width); break; + case FBT_BOOL: + case FBT_UINT: Write(val.u_, byte_width); break; + case FBT_FLOAT: WriteDouble(val.f_, byte_width); break; + default: WriteOffset(val.u_, byte_width); break; + } + } + + size_t CreateBlob(const void *data, size_t len, size_t trailing, Type type) { + auto bit_width = WidthU(len); + auto byte_width = Align(bit_width); + Write<uint64_t>(len, byte_width); + auto sloc = buf_.size(); + WriteBytes(data, len + trailing); + stack_.push_back(Value(static_cast<uint64_t>(sloc), type, bit_width)); + return sloc; + } + + template<typename T> + size_t ScalarVector(const T *elems, size_t len, bool fixed) { + auto vector_type = GetScalarType<T>(); + auto byte_width = sizeof(T); + auto bit_width = WidthB(byte_width); + // If you get this assert, you're trying to write a vector with a size + // field that is bigger than the scalars you're trying to write (e.g. a + // byte vector > 255 elements). For such types, write a "blob" instead. + // TODO: instead of asserting, could write vector with larger elements + // instead, though that would be wasteful. + FLATBUFFERS_ASSERT(WidthU(len) <= bit_width); Align(bit_width); - if (!fixed) Write<uint64_t>(len, byte_width); - auto vloc = buf_.size(); - for (size_t i = 0; i < len; i++) Write(elems[i], byte_width); - stack_.push_back(Value(static_cast<uint64_t>(vloc), - ToTypedVector(vector_type, fixed ? len : 0), - bit_width)); - return vloc; - } - - Value CreateVector(size_t start, size_t vec_len, size_t step, bool typed, - bool fixed, const Value *keys = nullptr) { + if (!fixed) Write<uint64_t>(len, byte_width); + auto vloc = buf_.size(); + for (size_t i = 0; i < len; i++) Write(elems[i], byte_width); + stack_.push_back(Value(static_cast<uint64_t>(vloc), + ToTypedVector(vector_type, fixed ? len : 0), + bit_width)); + return vloc; + } + + Value CreateVector(size_t start, size_t vec_len, size_t step, bool typed, + bool fixed, const Value *keys = nullptr) { FLATBUFFERS_ASSERT( !fixed || typed); // typed=false, fixed=true combination is not supported. - // Figure out smallest bit width we can store this vector with. - auto bit_width = (std::max)(force_min_bit_width_, WidthU(vec_len)); - auto prefix_elems = 1; - if (keys) { - // If this vector is part of a map, we will pre-fix an offset to the keys - // to this vector. - bit_width = (std::max)(bit_width, keys->ElemWidth(buf_.size(), 0)); - prefix_elems += 2; - } - Type vector_type = FBT_KEY; - // Check bit widths and types for all elements. - for (size_t i = start; i < stack_.size(); i += step) { + // Figure out smallest bit width we can store this vector with. + auto bit_width = (std::max)(force_min_bit_width_, WidthU(vec_len)); + auto prefix_elems = 1; + if (keys) { + // If this vector is part of a map, we will pre-fix an offset to the keys + // to this vector. + bit_width = (std::max)(bit_width, keys->ElemWidth(buf_.size(), 0)); + prefix_elems += 2; + } + Type vector_type = FBT_KEY; + // Check bit widths and types for all elements. + for (size_t i = start; i < stack_.size(); i += step) { auto elem_width = stack_[i].ElemWidth(buf_.size(), i - start + prefix_elems); - bit_width = (std::max)(bit_width, elem_width); - if (typed) { - if (i == start) { - vector_type = stack_[i].type_; - } else { - // If you get this assert, you are writing a typed vector with - // elements that are not all the same type. - FLATBUFFERS_ASSERT(vector_type == stack_[i].type_); - } - } - } - // If you get this assert, your fixed types are not one of: - // Int / UInt / Float / Key. - FLATBUFFERS_ASSERT(!fixed || IsTypedVectorElementType(vector_type)); - auto byte_width = Align(bit_width); - // Write vector. First the keys width/offset if available, and size. - if (keys) { - WriteOffset(keys->u_, byte_width); - Write<uint64_t>(1ULL << keys->min_bit_width_, byte_width); - } - if (!fixed) Write<uint64_t>(vec_len, byte_width); - // Then the actual data. - auto vloc = buf_.size(); - for (size_t i = start; i < stack_.size(); i += step) { - WriteAny(stack_[i], byte_width); - } - // Then the types. - if (!typed) { - for (size_t i = start; i < stack_.size(); i += step) { - buf_.push_back(stack_[i].StoredPackedType(bit_width)); - } - } - return Value(static_cast<uint64_t>(vloc), - keys ? FBT_MAP - : (typed ? ToTypedVector(vector_type, fixed ? vec_len : 0) - : FBT_VECTOR), - bit_width); - } - - // You shouldn't really be copying instances of this class. - Builder(const Builder &); - Builder &operator=(const Builder &); - - std::vector<uint8_t> buf_; - std::vector<Value> stack_; - - bool finished_; + bit_width = (std::max)(bit_width, elem_width); + if (typed) { + if (i == start) { + vector_type = stack_[i].type_; + } else { + // If you get this assert, you are writing a typed vector with + // elements that are not all the same type. + FLATBUFFERS_ASSERT(vector_type == stack_[i].type_); + } + } + } + // If you get this assert, your fixed types are not one of: + // Int / UInt / Float / Key. + FLATBUFFERS_ASSERT(!fixed || IsTypedVectorElementType(vector_type)); + auto byte_width = Align(bit_width); + // Write vector. First the keys width/offset if available, and size. + if (keys) { + WriteOffset(keys->u_, byte_width); + Write<uint64_t>(1ULL << keys->min_bit_width_, byte_width); + } + if (!fixed) Write<uint64_t>(vec_len, byte_width); + // Then the actual data. + auto vloc = buf_.size(); + for (size_t i = start; i < stack_.size(); i += step) { + WriteAny(stack_[i], byte_width); + } + // Then the types. + if (!typed) { + for (size_t i = start; i < stack_.size(); i += step) { + buf_.push_back(stack_[i].StoredPackedType(bit_width)); + } + } + return Value(static_cast<uint64_t>(vloc), + keys ? FBT_MAP + : (typed ? ToTypedVector(vector_type, fixed ? vec_len : 0) + : FBT_VECTOR), + bit_width); + } + + // You shouldn't really be copying instances of this class. + Builder(const Builder &); + Builder &operator=(const Builder &); + + std::vector<uint8_t> buf_; + std::vector<Value> stack_; + + bool finished_; bool has_duplicate_keys_; - - BuilderFlag flags_; - - BitWidth force_min_bit_width_; - - struct KeyOffsetCompare { - explicit KeyOffsetCompare(const std::vector<uint8_t> &buf) : buf_(&buf) {} - bool operator()(size_t a, size_t b) const { - auto stra = - reinterpret_cast<const char *>(flatbuffers::vector_data(*buf_) + a); - auto strb = - reinterpret_cast<const char *>(flatbuffers::vector_data(*buf_) + b); - return strcmp(stra, strb) < 0; - } - const std::vector<uint8_t> *buf_; - }; - - typedef std::pair<size_t, size_t> StringOffset; - struct StringOffsetCompare { + + BuilderFlag flags_; + + BitWidth force_min_bit_width_; + + struct KeyOffsetCompare { + explicit KeyOffsetCompare(const std::vector<uint8_t> &buf) : buf_(&buf) {} + bool operator()(size_t a, size_t b) const { + auto stra = + reinterpret_cast<const char *>(flatbuffers::vector_data(*buf_) + a); + auto strb = + reinterpret_cast<const char *>(flatbuffers::vector_data(*buf_) + b); + return strcmp(stra, strb) < 0; + } + const std::vector<uint8_t> *buf_; + }; + + typedef std::pair<size_t, size_t> StringOffset; + struct StringOffsetCompare { explicit StringOffsetCompare(const std::vector<uint8_t> &buf) : buf_(&buf) {} - bool operator()(const StringOffset &a, const StringOffset &b) const { - auto stra = reinterpret_cast<const char *>( - flatbuffers::vector_data(*buf_) + a.first); - auto strb = reinterpret_cast<const char *>( - flatbuffers::vector_data(*buf_) + b.first); - return strncmp(stra, strb, (std::min)(a.second, b.second) + 1) < 0; - } - const std::vector<uint8_t> *buf_; - }; - - typedef std::set<size_t, KeyOffsetCompare> KeyOffsetMap; - typedef std::set<StringOffset, StringOffsetCompare> StringOffsetMap; - - KeyOffsetMap key_pool; - StringOffsetMap string_pool; -}; - -} // namespace flexbuffers - + bool operator()(const StringOffset &a, const StringOffset &b) const { + auto stra = reinterpret_cast<const char *>( + flatbuffers::vector_data(*buf_) + a.first); + auto strb = reinterpret_cast<const char *>( + flatbuffers::vector_data(*buf_) + b.first); + return strncmp(stra, strb, (std::min)(a.second, b.second) + 1) < 0; + } + const std::vector<uint8_t> *buf_; + }; + + typedef std::set<size_t, KeyOffsetCompare> KeyOffsetMap; + typedef std::set<StringOffset, StringOffsetCompare> StringOffsetMap; + + KeyOffsetMap key_pool; + StringOffsetMap string_pool; +}; + +} // namespace flexbuffers + #if defined(_MSC_VER) # pragma warning(pop) #endif - -#endif // FLATBUFFERS_FLEXBUFFERS_H_ + +#endif // FLATBUFFERS_FLEXBUFFERS_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/grpc.h b/contrib/libs/flatbuffers/include/flatbuffers/grpc.h index da7830e7dc..b6b38d0642 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/grpc.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/grpc.h @@ -1,179 +1,179 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_GRPC_H_ -#define FLATBUFFERS_GRPC_H_ - -// Helper functionality to glue FlatBuffers and GRPC. - +/* + * Copyright 2014 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLATBUFFERS_GRPC_H_ +#define FLATBUFFERS_GRPC_H_ + +// Helper functionality to glue FlatBuffers and GRPC. + #include "flatbuffers.h" -#include "grpc/byte_buffer_reader.h" +#include "grpc/byte_buffer_reader.h" #include "grpcpp/support/byte_buffer.h" - -namespace flatbuffers { -namespace grpc { - -// Message is a typed wrapper around a buffer that manages the underlying -// `grpc_slice` and also provides flatbuffers-specific helpers such as `Verify` -// and `GetRoot`. Since it is backed by a `grpc_slice`, the underlying buffer -// is refcounted and ownership is be managed automatically. -template<class T> class Message { - public: - Message() : slice_(grpc_empty_slice()) {} - - Message(grpc_slice slice, bool add_ref) - : slice_(add_ref ? grpc_slice_ref(slice) : slice) {} - - Message &operator=(const Message &other) = delete; - - Message(Message &&other) : slice_(other.slice_) { - other.slice_ = grpc_empty_slice(); - } - - Message(const Message &other) = delete; - - Message &operator=(Message &&other) { - grpc_slice_unref(slice_); - slice_ = other.slice_; - other.slice_ = grpc_empty_slice(); - return *this; - } - - ~Message() { grpc_slice_unref(slice_); } - - const uint8_t *mutable_data() const { return GRPC_SLICE_START_PTR(slice_); } - - const uint8_t *data() const { return GRPC_SLICE_START_PTR(slice_); } - - size_t size() const { return GRPC_SLICE_LENGTH(slice_); } - - bool Verify() const { - Verifier verifier(data(), size()); - return verifier.VerifyBuffer<T>(nullptr); - } - - T *GetMutableRoot() { return flatbuffers::GetMutableRoot<T>(mutable_data()); } - - const T *GetRoot() const { return flatbuffers::GetRoot<T>(data()); } - - // This is only intended for serializer use, or if you know what you're doing - const grpc_slice &BorrowSlice() const { return slice_; } - - private: - grpc_slice slice_; -}; - -class MessageBuilder; - -// SliceAllocator is a gRPC-specific allocator that uses the `grpc_slice` -// refcounted slices to manage memory ownership. This makes it easy and -// efficient to transfer buffers to gRPC. -class SliceAllocator : public Allocator { - public: - SliceAllocator() : slice_(grpc_empty_slice()) {} - - SliceAllocator(const SliceAllocator &other) = delete; - SliceAllocator &operator=(const SliceAllocator &other) = delete; - + +namespace flatbuffers { +namespace grpc { + +// Message is a typed wrapper around a buffer that manages the underlying +// `grpc_slice` and also provides flatbuffers-specific helpers such as `Verify` +// and `GetRoot`. Since it is backed by a `grpc_slice`, the underlying buffer +// is refcounted and ownership is be managed automatically. +template<class T> class Message { + public: + Message() : slice_(grpc_empty_slice()) {} + + Message(grpc_slice slice, bool add_ref) + : slice_(add_ref ? grpc_slice_ref(slice) : slice) {} + + Message &operator=(const Message &other) = delete; + + Message(Message &&other) : slice_(other.slice_) { + other.slice_ = grpc_empty_slice(); + } + + Message(const Message &other) = delete; + + Message &operator=(Message &&other) { + grpc_slice_unref(slice_); + slice_ = other.slice_; + other.slice_ = grpc_empty_slice(); + return *this; + } + + ~Message() { grpc_slice_unref(slice_); } + + const uint8_t *mutable_data() const { return GRPC_SLICE_START_PTR(slice_); } + + const uint8_t *data() const { return GRPC_SLICE_START_PTR(slice_); } + + size_t size() const { return GRPC_SLICE_LENGTH(slice_); } + + bool Verify() const { + Verifier verifier(data(), size()); + return verifier.VerifyBuffer<T>(nullptr); + } + + T *GetMutableRoot() { return flatbuffers::GetMutableRoot<T>(mutable_data()); } + + const T *GetRoot() const { return flatbuffers::GetRoot<T>(data()); } + + // This is only intended for serializer use, or if you know what you're doing + const grpc_slice &BorrowSlice() const { return slice_; } + + private: + grpc_slice slice_; +}; + +class MessageBuilder; + +// SliceAllocator is a gRPC-specific allocator that uses the `grpc_slice` +// refcounted slices to manage memory ownership. This makes it easy and +// efficient to transfer buffers to gRPC. +class SliceAllocator : public Allocator { + public: + SliceAllocator() : slice_(grpc_empty_slice()) {} + + SliceAllocator(const SliceAllocator &other) = delete; + SliceAllocator &operator=(const SliceAllocator &other) = delete; + SliceAllocator(SliceAllocator &&other) : slice_(grpc_empty_slice()) { - // default-construct and swap idiom - swap(other); - } - - SliceAllocator &operator=(SliceAllocator &&other) { - // move-construct and swap idiom - SliceAllocator temp(std::move(other)); - swap(temp); - return *this; - } - - void swap(SliceAllocator &other) { - using std::swap; - swap(slice_, other.slice_); - } - - virtual ~SliceAllocator() { grpc_slice_unref(slice_); } - - virtual uint8_t *allocate(size_t size) override { - FLATBUFFERS_ASSERT(GRPC_SLICE_IS_EMPTY(slice_)); - slice_ = grpc_slice_malloc(size); - return GRPC_SLICE_START_PTR(slice_); - } - - virtual void deallocate(uint8_t *p, size_t size) override { - FLATBUFFERS_ASSERT(p == GRPC_SLICE_START_PTR(slice_)); - FLATBUFFERS_ASSERT(size == GRPC_SLICE_LENGTH(slice_)); - grpc_slice_unref(slice_); - slice_ = grpc_empty_slice(); - } - - virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size, - size_t new_size, size_t in_use_back, - size_t in_use_front) override { - FLATBUFFERS_ASSERT(old_p == GRPC_SLICE_START_PTR(slice_)); - FLATBUFFERS_ASSERT(old_size == GRPC_SLICE_LENGTH(slice_)); - FLATBUFFERS_ASSERT(new_size > old_size); - grpc_slice old_slice = slice_; - grpc_slice new_slice = grpc_slice_malloc(new_size); - uint8_t *new_p = GRPC_SLICE_START_PTR(new_slice); - memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, - in_use_front); - slice_ = new_slice; - grpc_slice_unref(old_slice); - return new_p; - } - - private: - grpc_slice &get_slice(uint8_t *p, size_t size) { - FLATBUFFERS_ASSERT(p == GRPC_SLICE_START_PTR(slice_)); - FLATBUFFERS_ASSERT(size == GRPC_SLICE_LENGTH(slice_)); - return slice_; - } - - grpc_slice slice_; - - friend class MessageBuilder; -}; - -// SliceAllocatorMember is a hack to ensure that the MessageBuilder's -// slice_allocator_ member is constructed before the FlatBufferBuilder, since -// the allocator is used in the FlatBufferBuilder ctor. -namespace detail { -struct SliceAllocatorMember { - SliceAllocator slice_allocator_; -}; -} // namespace detail - -// MessageBuilder is a gRPC-specific FlatBufferBuilder that uses SliceAllocator -// to allocate gRPC buffers. -class MessageBuilder : private detail::SliceAllocatorMember, - public FlatBufferBuilder { - public: - explicit MessageBuilder(uoffset_t initial_size = 1024) - : FlatBufferBuilder(initial_size, &slice_allocator_, false) {} - - MessageBuilder(const MessageBuilder &other) = delete; - MessageBuilder &operator=(const MessageBuilder &other) = delete; - - MessageBuilder(MessageBuilder &&other) + // default-construct and swap idiom + swap(other); + } + + SliceAllocator &operator=(SliceAllocator &&other) { + // move-construct and swap idiom + SliceAllocator temp(std::move(other)); + swap(temp); + return *this; + } + + void swap(SliceAllocator &other) { + using std::swap; + swap(slice_, other.slice_); + } + + virtual ~SliceAllocator() { grpc_slice_unref(slice_); } + + virtual uint8_t *allocate(size_t size) override { + FLATBUFFERS_ASSERT(GRPC_SLICE_IS_EMPTY(slice_)); + slice_ = grpc_slice_malloc(size); + return GRPC_SLICE_START_PTR(slice_); + } + + virtual void deallocate(uint8_t *p, size_t size) override { + FLATBUFFERS_ASSERT(p == GRPC_SLICE_START_PTR(slice_)); + FLATBUFFERS_ASSERT(size == GRPC_SLICE_LENGTH(slice_)); + grpc_slice_unref(slice_); + slice_ = grpc_empty_slice(); + } + + virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size, + size_t new_size, size_t in_use_back, + size_t in_use_front) override { + FLATBUFFERS_ASSERT(old_p == GRPC_SLICE_START_PTR(slice_)); + FLATBUFFERS_ASSERT(old_size == GRPC_SLICE_LENGTH(slice_)); + FLATBUFFERS_ASSERT(new_size > old_size); + grpc_slice old_slice = slice_; + grpc_slice new_slice = grpc_slice_malloc(new_size); + uint8_t *new_p = GRPC_SLICE_START_PTR(new_slice); + memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, + in_use_front); + slice_ = new_slice; + grpc_slice_unref(old_slice); + return new_p; + } + + private: + grpc_slice &get_slice(uint8_t *p, size_t size) { + FLATBUFFERS_ASSERT(p == GRPC_SLICE_START_PTR(slice_)); + FLATBUFFERS_ASSERT(size == GRPC_SLICE_LENGTH(slice_)); + return slice_; + } + + grpc_slice slice_; + + friend class MessageBuilder; +}; + +// SliceAllocatorMember is a hack to ensure that the MessageBuilder's +// slice_allocator_ member is constructed before the FlatBufferBuilder, since +// the allocator is used in the FlatBufferBuilder ctor. +namespace detail { +struct SliceAllocatorMember { + SliceAllocator slice_allocator_; +}; +} // namespace detail + +// MessageBuilder is a gRPC-specific FlatBufferBuilder that uses SliceAllocator +// to allocate gRPC buffers. +class MessageBuilder : private detail::SliceAllocatorMember, + public FlatBufferBuilder { + public: + explicit MessageBuilder(uoffset_t initial_size = 1024) + : FlatBufferBuilder(initial_size, &slice_allocator_, false) {} + + MessageBuilder(const MessageBuilder &other) = delete; + MessageBuilder &operator=(const MessageBuilder &other) = delete; + + MessageBuilder(MessageBuilder &&other) : FlatBufferBuilder(1024, &slice_allocator_, false) { - // Default construct and swap idiom. - Swap(other); - } - + // Default construct and swap idiom. + Swap(other); + } + /// Create a MessageBuilder from a FlatBufferBuilder. explicit MessageBuilder(FlatBufferBuilder &&src, void (*dealloc)(void *, @@ -200,132 +200,132 @@ class MessageBuilder : private detail::SliceAllocatorMember, return *this; } - MessageBuilder &operator=(MessageBuilder &&other) { - // Move construct a temporary and swap - MessageBuilder temp(std::move(other)); - Swap(temp); - return *this; - } - - void Swap(MessageBuilder &other) { - slice_allocator_.swap(other.slice_allocator_); - FlatBufferBuilder::Swap(other); + MessageBuilder &operator=(MessageBuilder &&other) { + // Move construct a temporary and swap + MessageBuilder temp(std::move(other)); + Swap(temp); + return *this; + } + + void Swap(MessageBuilder &other) { + slice_allocator_.swap(other.slice_allocator_); + FlatBufferBuilder::Swap(other); // After swapping the FlatBufferBuilder, we swap back the allocator, which // restores the original allocator back in place. This is necessary because // MessageBuilder's allocator is its own member (SliceAllocatorMember). The // allocator passed to FlatBufferBuilder::vector_downward must point to this // member. - buf_.swap_allocator(other.buf_); - } - - // Releases the ownership of the buffer pointer. - // Returns the size, offset, and the original grpc_slice that - // allocated the buffer. Also see grpc_slice_unref(). - uint8_t *ReleaseRaw(size_t &size, size_t &offset, grpc_slice &slice) { - uint8_t *buf = FlatBufferBuilder::ReleaseRaw(size, offset); - slice = slice_allocator_.slice_; - slice_allocator_.slice_ = grpc_empty_slice(); - return buf; - } - - ~MessageBuilder() {} - - // GetMessage extracts the subslice of the buffer corresponding to the - // flatbuffers-encoded region and wraps it in a `Message<T>` to handle buffer - // ownership. - template<class T> Message<T> GetMessage() { + buf_.swap_allocator(other.buf_); + } + + // Releases the ownership of the buffer pointer. + // Returns the size, offset, and the original grpc_slice that + // allocated the buffer. Also see grpc_slice_unref(). + uint8_t *ReleaseRaw(size_t &size, size_t &offset, grpc_slice &slice) { + uint8_t *buf = FlatBufferBuilder::ReleaseRaw(size, offset); + slice = slice_allocator_.slice_; + slice_allocator_.slice_ = grpc_empty_slice(); + return buf; + } + + ~MessageBuilder() {} + + // GetMessage extracts the subslice of the buffer corresponding to the + // flatbuffers-encoded region and wraps it in a `Message<T>` to handle buffer + // ownership. + template<class T> Message<T> GetMessage() { auto buf_data = buf_.scratch_data(); // pointer to memory auto buf_size = buf_.capacity(); // size of memory auto msg_data = buf_.data(); // pointer to msg auto msg_size = buf_.size(); // size of msg - // Do some sanity checks on data/size - FLATBUFFERS_ASSERT(msg_data); - FLATBUFFERS_ASSERT(msg_size); - FLATBUFFERS_ASSERT(msg_data >= buf_data); - FLATBUFFERS_ASSERT(msg_data + msg_size <= buf_data + buf_size); - // Calculate offsets from the buffer start - auto begin = msg_data - buf_data; - auto end = begin + msg_size; - // Get the slice we are working with (no refcount change) - grpc_slice slice = slice_allocator_.get_slice(buf_data, buf_size); - // Extract a subslice of the existing slice (increment refcount) - grpc_slice subslice = grpc_slice_sub(slice, begin, end); - // Wrap the subslice in a `Message<T>`, but don't increment refcount - Message<T> msg(subslice, false); - return msg; - } - - template<class T> Message<T> ReleaseMessage() { - Message<T> msg = GetMessage<T>(); - Reset(); - return msg; - } - - private: - // SliceAllocator slice_allocator_; // part of SliceAllocatorMember -}; - -} // namespace grpc -} // namespace flatbuffers - -namespace grpc { - -template<class T> class SerializationTraits<flatbuffers::grpc::Message<T>> { - public: - static grpc::Status Serialize(const flatbuffers::grpc::Message<T> &msg, - grpc_byte_buffer **buffer, bool *own_buffer) { - // We are passed in a `Message<T>`, which is a wrapper around a - // `grpc_slice`. We extract it here using `BorrowSlice()`. The const cast + // Do some sanity checks on data/size + FLATBUFFERS_ASSERT(msg_data); + FLATBUFFERS_ASSERT(msg_size); + FLATBUFFERS_ASSERT(msg_data >= buf_data); + FLATBUFFERS_ASSERT(msg_data + msg_size <= buf_data + buf_size); + // Calculate offsets from the buffer start + auto begin = msg_data - buf_data; + auto end = begin + msg_size; + // Get the slice we are working with (no refcount change) + grpc_slice slice = slice_allocator_.get_slice(buf_data, buf_size); + // Extract a subslice of the existing slice (increment refcount) + grpc_slice subslice = grpc_slice_sub(slice, begin, end); + // Wrap the subslice in a `Message<T>`, but don't increment refcount + Message<T> msg(subslice, false); + return msg; + } + + template<class T> Message<T> ReleaseMessage() { + Message<T> msg = GetMessage<T>(); + Reset(); + return msg; + } + + private: + // SliceAllocator slice_allocator_; // part of SliceAllocatorMember +}; + +} // namespace grpc +} // namespace flatbuffers + +namespace grpc { + +template<class T> class SerializationTraits<flatbuffers::grpc::Message<T>> { + public: + static grpc::Status Serialize(const flatbuffers::grpc::Message<T> &msg, + grpc_byte_buffer **buffer, bool *own_buffer) { + // We are passed in a `Message<T>`, which is a wrapper around a + // `grpc_slice`. We extract it here using `BorrowSlice()`. The const cast // is necessary because the `grpc_raw_byte_buffer_create` func expects - // non-const slices in order to increment their refcounts. - grpc_slice *slice = const_cast<grpc_slice *>(&msg.BorrowSlice()); - // Now use `grpc_raw_byte_buffer_create` to package the single slice into a - // `grpc_byte_buffer`, incrementing the refcount in the process. - *buffer = grpc_raw_byte_buffer_create(slice, 1); - *own_buffer = true; - return grpc::Status::OK; - } - - // Deserialize by pulling the + // non-const slices in order to increment their refcounts. + grpc_slice *slice = const_cast<grpc_slice *>(&msg.BorrowSlice()); + // Now use `grpc_raw_byte_buffer_create` to package the single slice into a + // `grpc_byte_buffer`, incrementing the refcount in the process. + *buffer = grpc_raw_byte_buffer_create(slice, 1); + *own_buffer = true; + return grpc::Status::OK; + } + + // Deserialize by pulling the static grpc::Status Deserialize(ByteBuffer *buf, - flatbuffers::grpc::Message<T> *msg) { + flatbuffers::grpc::Message<T> *msg) { grpc_byte_buffer *buffer = *reinterpret_cast<grpc_byte_buffer **>(buf); - if (!buffer) { - return ::grpc::Status(::grpc::StatusCode::INTERNAL, "No payload"); - } - // Check if this is a single uncompressed slice. - if ((buffer->type == GRPC_BB_RAW) && - (buffer->data.raw.compression == GRPC_COMPRESS_NONE) && - (buffer->data.raw.slice_buffer.count == 1)) { - // If it is, then we can reference the `grpc_slice` directly. - grpc_slice slice = buffer->data.raw.slice_buffer.slices[0]; - // We wrap a `Message<T>` around the slice, incrementing the refcount. - *msg = flatbuffers::grpc::Message<T>(slice, true); - } else { - // Otherwise, we need to use `grpc_byte_buffer_reader_readall` to read - // `buffer` into a single contiguous `grpc_slice`. The gRPC reader gives - // us back a new slice with the refcount already incremented. - grpc_byte_buffer_reader reader; - grpc_byte_buffer_reader_init(&reader, buffer); - grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); - grpc_byte_buffer_reader_destroy(&reader); + if (!buffer) { + return ::grpc::Status(::grpc::StatusCode::INTERNAL, "No payload"); + } + // Check if this is a single uncompressed slice. + if ((buffer->type == GRPC_BB_RAW) && + (buffer->data.raw.compression == GRPC_COMPRESS_NONE) && + (buffer->data.raw.slice_buffer.count == 1)) { + // If it is, then we can reference the `grpc_slice` directly. + grpc_slice slice = buffer->data.raw.slice_buffer.slices[0]; + // We wrap a `Message<T>` around the slice, incrementing the refcount. + *msg = flatbuffers::grpc::Message<T>(slice, true); + } else { + // Otherwise, we need to use `grpc_byte_buffer_reader_readall` to read + // `buffer` into a single contiguous `grpc_slice`. The gRPC reader gives + // us back a new slice with the refcount already incremented. + grpc_byte_buffer_reader reader; + grpc_byte_buffer_reader_init(&reader, buffer); + grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); + grpc_byte_buffer_reader_destroy(&reader); // We wrap a `Message<T>` around the slice, but don't increment refcount - *msg = flatbuffers::grpc::Message<T>(slice, false); - } - grpc_byte_buffer_destroy(buffer); -#if FLATBUFFERS_GRPC_DISABLE_AUTO_VERIFICATION - return ::grpc::Status::OK; -#else - if (msg->Verify()) { - return ::grpc::Status::OK; - } else { - return ::grpc::Status(::grpc::StatusCode::INTERNAL, - "Message verification failed"); - } -#endif - } -}; - -} // namespace grpc - -#endif // FLATBUFFERS_GRPC_H_ + *msg = flatbuffers::grpc::Message<T>(slice, false); + } + grpc_byte_buffer_destroy(buffer); +#if FLATBUFFERS_GRPC_DISABLE_AUTO_VERIFICATION + return ::grpc::Status::OK; +#else + if (msg->Verify()) { + return ::grpc::Status::OK; + } else { + return ::grpc::Status(::grpc::StatusCode::INTERNAL, + "Message verification failed"); + } +#endif + } +}; + +} // namespace grpc + +#endif // FLATBUFFERS_GRPC_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/hash.h b/contrib/libs/flatbuffers/include/flatbuffers/hash.h index 52cc628cdf..d25caa423a 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/hash.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/hash.h @@ -24,17 +24,17 @@ namespace flatbuffers { -template<typename T> struct FnvTraits { +template<typename T> struct FnvTraits { static const T kFnvPrime; static const T kOffsetBasis; }; -template<> struct FnvTraits<uint32_t> { +template<> struct FnvTraits<uint32_t> { static const uint32_t kFnvPrime = 0x01000193; static const uint32_t kOffsetBasis = 0x811C9DC5; }; -template<> struct FnvTraits<uint64_t> { +template<> struct FnvTraits<uint64_t> { static const uint64_t kFnvPrime = 0x00000100000001b3ULL; static const uint64_t kOffsetBasis = 0xcbf29ce484222645ULL; }; @@ -58,48 +58,48 @@ template<typename T> T HashFnv1a(const char *input) { } template<> inline uint16_t HashFnv1<uint16_t>(const char *input) { - uint32_t hash = HashFnv1<uint32_t>(input); - return (hash >> 16) ^ (hash & 0xffff); -} - + uint32_t hash = HashFnv1<uint32_t>(input); + return (hash >> 16) ^ (hash & 0xffff); +} + template<> inline uint16_t HashFnv1a<uint16_t>(const char *input) { - uint32_t hash = HashFnv1a<uint32_t>(input); - return (hash >> 16) ^ (hash & 0xffff); -} - + uint32_t hash = HashFnv1a<uint32_t>(input); + return (hash >> 16) ^ (hash & 0xffff); +} + template<typename T> struct NamedHashFunction { const char *name; - typedef T (*HashFunction)(const char *); + typedef T (*HashFunction)(const char *); HashFunction function; }; -const NamedHashFunction<uint16_t> kHashFunctions16[] = { +const NamedHashFunction<uint16_t> kHashFunctions16[] = { { "fnv1_16", HashFnv1<uint16_t> }, - { "fnv1a_16", HashFnv1a<uint16_t> }, -}; - + { "fnv1a_16", HashFnv1a<uint16_t> }, +}; + const NamedHashFunction<uint32_t> kHashFunctions32[] = { - { "fnv1_32", HashFnv1<uint32_t> }, + { "fnv1_32", HashFnv1<uint32_t> }, { "fnv1a_32", HashFnv1a<uint32_t> }, }; const NamedHashFunction<uint64_t> kHashFunctions64[] = { - { "fnv1_64", HashFnv1<uint64_t> }, + { "fnv1_64", HashFnv1<uint64_t> }, { "fnv1a_64", HashFnv1a<uint64_t> }, }; -inline NamedHashFunction<uint16_t>::HashFunction FindHashFunction16( - const char *name) { - std::size_t size = sizeof(kHashFunctions16) / sizeof(kHashFunctions16[0]); - for (std::size_t i = 0; i < size; ++i) { - if (std::strcmp(name, kHashFunctions16[i].name) == 0) { - return kHashFunctions16[i].function; - } - } - return nullptr; -} - +inline NamedHashFunction<uint16_t>::HashFunction FindHashFunction16( + const char *name) { + std::size_t size = sizeof(kHashFunctions16) / sizeof(kHashFunctions16[0]); + for (std::size_t i = 0; i < size; ++i) { + if (std::strcmp(name, kHashFunctions16[i].name) == 0) { + return kHashFunctions16[i].function; + } + } + return nullptr; +} + inline NamedHashFunction<uint32_t>::HashFunction FindHashFunction32( const char *name) { std::size_t size = sizeof(kHashFunctions32) / sizeof(kHashFunctions32[0]); diff --git a/contrib/libs/flatbuffers/include/flatbuffers/idl.h b/contrib/libs/flatbuffers/include/flatbuffers/idl.h index a82ff8a694..651761d922 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/idl.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/idl.h @@ -18,7 +18,7 @@ #define FLATBUFFERS_IDL_H_ #include <map> -#include <memory> +#include <memory> #include <stack> #include "base.h" @@ -27,10 +27,10 @@ #include "hash.h" #include "reflection.h" -#if !defined(FLATBUFFERS_CPP98_STL) -# include <functional> -#endif // !defined(FLATBUFFERS_CPP98_STL) - +#if !defined(FLATBUFFERS_CPP98_STL) +# include <functional> +#endif // !defined(FLATBUFFERS_CPP98_STL) + // This file defines the data types representing a parsed IDL (Interface // Definition Language) / schema file. @@ -45,7 +45,7 @@ namespace flatbuffers { // The order of these matters for Is*() functions below. // Additionally, Parser::ParseType assumes bool..string is a contiguous range // of type tokens. -// clang-format off +// clang-format off #define FLATBUFFERS_GEN_TYPES_SCALAR(TD) \ TD(NONE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) \ TD(UTYPE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) /* begin scalar/int */ \ @@ -75,14 +75,14 @@ namespace flatbuffers { // - Go type. // - C# / .Net type. // - Python type. -// - Rust type. +// - Rust type. // - Kotlin type. // using these macros, we can now write code dealing with types just once, e.g. /* switch (type) { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \ + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \ RTYPE, KTYPE) \ case BASE_TYPE_ ## ENUM: \ // do something specific to CTYPE here @@ -133,11 +133,11 @@ inline bool IsInteger(BaseType t) { return t >= BASE_TYPE_UTYPE && t <= BASE_TYPE_ULONG; } inline bool IsFloat (BaseType t) { return t == BASE_TYPE_FLOAT || t == BASE_TYPE_DOUBLE; } -inline bool IsLong (BaseType t) { return t == BASE_TYPE_LONG || - t == BASE_TYPE_ULONG; } -inline bool IsBool (BaseType t) { return t == BASE_TYPE_BOOL; } -inline bool IsOneByte(BaseType t) { return t >= BASE_TYPE_UTYPE && - t <= BASE_TYPE_UCHAR; } +inline bool IsLong (BaseType t) { return t == BASE_TYPE_LONG || + t == BASE_TYPE_ULONG; } +inline bool IsBool (BaseType t) { return t == BASE_TYPE_BOOL; } +inline bool IsOneByte(BaseType t) { return t >= BASE_TYPE_UTYPE && + t <= BASE_TYPE_UCHAR; } inline bool IsUnsigned(BaseType t) { return (t == BASE_TYPE_UTYPE) || (t == BASE_TYPE_UCHAR) || @@ -145,25 +145,25 @@ inline bool IsUnsigned(BaseType t) { (t == BASE_TYPE_ULONG); } -// clang-format on +// clang-format on extern const char *const kTypeNames[]; extern const char kTypeSizes[]; -inline size_t SizeOf(BaseType t) { return kTypeSizes[t]; } +inline size_t SizeOf(BaseType t) { return kTypeSizes[t]; } struct StructDef; struct EnumDef; -class Parser; +class Parser; // Represents any type in the IDL, which is a combination of the BaseType // and additional information for vectors/structs_. struct Type { - explicit Type(BaseType _base_type = BASE_TYPE_NONE, StructDef *_sd = nullptr, + explicit Type(BaseType _base_type = BASE_TYPE_NONE, StructDef *_sd = nullptr, EnumDef *_ed = nullptr, uint16_t _fixed_length = 0) - : base_type(_base_type), - element(BASE_TYPE_NONE), - struct_def(_sd), + : base_type(_base_type), + element(BASE_TYPE_NONE), + struct_def(_sd), enum_def(_ed), fixed_length(_fixed_length) {} @@ -190,9 +190,9 @@ struct Type { // Represents a parsed scalar value, it's type, and field offset. struct Value { - Value() - : constant("0"), - offset(static_cast<voffset_t>(~(static_cast<voffset_t>(0U)))) {} + Value() + : constant("0"), + offset(static_cast<voffset_t>(~(static_cast<voffset_t>(0U)))) {} Type type; std::string constant; voffset_t offset; @@ -203,11 +203,11 @@ struct Value { template<typename T> class SymbolTable { public: ~SymbolTable() { - for (auto it = vec.begin(); it != vec.end(); ++it) { delete *it; } + for (auto it = vec.begin(); it != vec.end(); ++it) { delete *it; } } bool Add(const std::string &name, T *e) { - vector_emplace_back(&vec, e); + vector_emplace_back(&vec, e); auto it = dict.find(name); if (it != dict.end()) return true; dict[name] = e; @@ -221,7 +221,7 @@ template<typename T> class SymbolTable { dict.erase(it); dict[newname] = obj; } else { - FLATBUFFERS_ASSERT(false); + FLATBUFFERS_ASSERT(false); } } @@ -230,14 +230,14 @@ template<typename T> class SymbolTable { return it == dict.end() ? nullptr : it->second; } - public: - std::map<std::string, T *> dict; // quick lookup - std::vector<T *> vec; // Used to iterate in order of insertion + public: + std::map<std::string, T *> dict; // quick lookup + std::vector<T *> vec; // Used to iterate in order of insertion }; // A name space, as set in the schema. struct Namespace { - Namespace() : from_table(0) {} + Namespace() : from_table(0) {} // Given a (potentially unqualified) name, return the "fully qualified" name // which has a full namespaced descriptor. @@ -245,9 +245,9 @@ struct Namespace { // the current namespace has. std::string GetFullyQualifiedName(const std::string &name, size_t max_components = 1000) const; - - std::vector<std::string> components; - size_t from_table; // Part of the namespace corresponds to a message/table. + + std::vector<std::string> components; + size_t from_table; // Part of the namespace corresponds to a message/table. }; inline bool operator<(const Namespace &a, const Namespace &b) { @@ -261,17 +261,17 @@ inline bool operator<(const Namespace &a, const Namespace &b) { // Base class for all definition types (fields, structs_, enums_). struct Definition { - Definition() - : generated(false), - defined_namespace(nullptr), - serialized_location(0), - index(-1), - refcount(1) {} - - flatbuffers::Offset< - flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> - SerializeAttributes(FlatBufferBuilder *builder, const Parser &parser) const; - + Definition() + : generated(false), + defined_namespace(nullptr), + serialized_location(0), + index(-1), + refcount(1) {} + + flatbuffers::Offset< + flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> + SerializeAttributes(FlatBufferBuilder *builder, const Parser &parser) const; + bool DeserializeAttributes(Parser &parser, const Vector<Offset<reflection::KeyValue>> *attrs); @@ -285,22 +285,22 @@ struct Definition { // For use with Serialize() uoffset_t serialized_location; int index; // Inside the vector it is stored. - int refcount; + int refcount; }; struct FieldDef : public Definition { - FieldDef() - : deprecated(false), - key(false), + FieldDef() + : deprecated(false), + key(false), shared(false), - native_inline(false), - flexbuffer(false), + native_inline(false), + flexbuffer(false), presence(kDefault), - nested_flatbuffer(NULL), - padding(0) {} + nested_flatbuffer(NULL), + padding(0) {} - Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id, - const Parser &parser) const; + Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id, + const Parser &parser) const; bool Deserialize(Parser &parser, const reflection::Field *field); @@ -318,14 +318,14 @@ struct FieldDef : public Definition { } Value value; - bool deprecated; // Field is allowed to be present in old data, but can't be. - // written in new data nor accessed in new code. - bool key; // Field functions as a key for creating sorted vectors. + bool deprecated; // Field is allowed to be present in old data, but can't be. + // written in new data nor accessed in new code. + bool key; // Field functions as a key for creating sorted vectors. bool shared; // Field will be using string pooling (i.e. CreateSharedString) // as default serialization behavior if field is a string. - bool native_inline; // Field will be defined inline (instead of as a pointer) - // for native tables if field is a struct. - bool flexbuffer; // This field contains FlexBuffer data. + bool native_inline; // Field will be defined inline (instead of as a pointer) + // for native tables if field is a struct. + bool flexbuffer; // This field contains FlexBuffer data. enum Presence { // Field must always be present. @@ -346,18 +346,18 @@ struct FieldDef : public Definition { } Presence presence; - StructDef *nested_flatbuffer; // This field contains nested FlatBuffer data. - size_t padding; // Bytes to always pad after this field. + StructDef *nested_flatbuffer; // This field contains nested FlatBuffer data. + size_t padding; // Bytes to always pad after this field. }; struct StructDef : public Definition { StructDef() - : fixed(false), - predecl(true), - sortbysize(true), - has_key(false), - minalign(1), - bytesize(0) {} + : fixed(false), + predecl(true), + sortbysize(true), + has_key(false), + minalign(1), + bytesize(0) {} void PadLastField(size_t min_align) { auto padding = PaddingBytes(bytesize, min_align); @@ -365,21 +365,21 @@ struct StructDef : public Definition { if (fields.vec.size()) fields.vec.back()->padding = padding; } - Offset<reflection::Object> Serialize(FlatBufferBuilder *builder, - const Parser &parser) const; + Offset<reflection::Object> Serialize(FlatBufferBuilder *builder, + const Parser &parser) const; bool Deserialize(Parser &parser, const reflection::Object *object); SymbolTable<FieldDef> fields; - + bool fixed; // If it's struct, not a table. bool predecl; // If it's used before it was defined. bool sortbysize; // Whether fields come in the declaration or size order. bool has_key; // It has a key field. size_t minalign; // What the whole object needs to be aligned to. size_t bytesize; // Size if fixed. - - flatbuffers::unique_ptr<std::string> original_location; + + flatbuffers::unique_ptr<std::string> original_location; }; struct EnumDef; @@ -516,30 +516,30 @@ inline bool operator!=(const EnumVal &lhs, const EnumVal &rhs) { return !(lhs == rhs); } -inline bool EqualByName(const Type &a, const Type &b) { - return a.base_type == b.base_type && a.element == b.element && - (a.struct_def == b.struct_def || - a.struct_def->name == b.struct_def->name) && - (a.enum_def == b.enum_def || a.enum_def->name == b.enum_def->name); -} - -struct RPCCall : public Definition { +inline bool EqualByName(const Type &a, const Type &b) { + return a.base_type == b.base_type && a.element == b.element && + (a.struct_def == b.struct_def || + a.struct_def->name == b.struct_def->name) && + (a.enum_def == b.enum_def || a.enum_def->name == b.enum_def->name); +} + +struct RPCCall : public Definition { Offset<reflection::RPCCall> Serialize(FlatBufferBuilder *builder, const Parser &parser) const; - + bool Deserialize(Parser &parser, const reflection::RPCCall *call); - StructDef *request, *response; -}; - -struct ServiceDef : public Definition { + StructDef *request, *response; +}; + +struct ServiceDef : public Definition { Offset<reflection::Service> Serialize(FlatBufferBuilder *builder, const Parser &parser) const; bool Deserialize(Parser &parser, const reflection::Service *service); - - SymbolTable<RPCCall> calls; -}; - + + SymbolTable<RPCCall> calls; +}; + // Container of options that may apply to any of the source/text generators. struct IDLOptions { bool gen_jvmstatic; @@ -555,35 +555,35 @@ struct IDLOptions { bool mutable_buffer; bool one_file; bool proto_mode; - bool proto_oneof_union; + bool proto_oneof_union; bool generate_all; bool skip_unexpected_fields_in_json; - bool generate_name_strings; - bool generate_object_based_api; - bool gen_compare; - std::string cpp_object_api_pointer_type; - std::string cpp_object_api_string_type; + bool generate_name_strings; + bool generate_object_based_api; + bool gen_compare; + std::string cpp_object_api_pointer_type; + std::string cpp_object_api_string_type; bool cpp_object_api_string_flexible_constructor; bool cpp_direct_copy; - bool gen_nullable; + bool gen_nullable; bool java_checkerframework; bool gen_generated; - std::string object_prefix; - std::string object_suffix; - bool union_value_namespacing; - bool allow_non_utf8; - bool natural_utf8; - std::string include_prefix; - bool keep_include_path; - bool binary_schema_comments; - bool binary_schema_builtins; + std::string object_prefix; + std::string object_suffix; + bool union_value_namespacing; + bool allow_non_utf8; + bool natural_utf8; + std::string include_prefix; + bool keep_include_path; + bool binary_schema_comments; + bool binary_schema_builtins; bool binary_schema_gen_embed; - std::string go_import; - std::string go_namespace; - bool protobuf_ascii_alike; - bool size_prefixed; - std::string root_type; - bool force_defaults; + std::string go_import; + std::string go_namespace; + bool protobuf_ascii_alike; + bool size_prefixed; + std::string root_type; + bool force_defaults; bool java_primitive_has_method; bool cs_gen_json_serializer; std::vector<std::string> cpp_includes; @@ -595,44 +595,44 @@ struct IDLOptions { bool no_warnings; // Possible options for the more general generator below. - enum Language { - kJava = 1 << 0, - kCSharp = 1 << 1, - kGo = 1 << 2, - kCpp = 1 << 3, - kPython = 1 << 5, - kPhp = 1 << 6, - kJson = 1 << 7, - kBinary = 1 << 8, - kTs = 1 << 9, - kJsonSchema = 1 << 10, - kDart = 1 << 11, - kLua = 1 << 12, - kLobster = 1 << 13, - kRust = 1 << 14, + enum Language { + kJava = 1 << 0, + kCSharp = 1 << 1, + kGo = 1 << 2, + kCpp = 1 << 3, + kPython = 1 << 5, + kPhp = 1 << 6, + kJson = 1 << 7, + kBinary = 1 << 8, + kTs = 1 << 9, + kJsonSchema = 1 << 10, + kDart = 1 << 11, + kLua = 1 << 12, + kLobster = 1 << 13, + kRust = 1 << 14, kKotlin = 1 << 15, kSwift = 1 << 16, kCppYandexMapsIter = 1 << 17, - kMAX - }; + kMAX + }; Language lang; - enum MiniReflect { kNone, kTypes, kTypesAndNames }; - - MiniReflect mini_reflect; - + enum MiniReflect { kNone, kTypes, kTypesAndNames }; + + MiniReflect mini_reflect; + // If set, require all fields in a table to be explicitly numbered. bool require_explicit_ids; - // The corresponding language bit will be set if a language is included - // for code generation. - unsigned long lang_to_generate; - + // The corresponding language bit will be set if a language is included + // for code generation. + unsigned long lang_to_generate; + // If set (default behavior), empty string fields will be set to nullptr to // make the flatbuffer more compact. bool set_empty_strings_to_null; - + // If set (default behavior), empty vector fields will be set to nullptr to // make the flatbuffer more compact. bool set_empty_vectors_to_null; @@ -641,91 +641,91 @@ struct IDLOptions { : gen_jvmstatic(false), use_flexbuffers(false), strict_json(false), - output_default_scalars_in_json(false), - indent_step(2), - output_enum_identifiers(true), - prefixed_enums(true), - scoped_enums(false), - include_dependence_headers(true), - mutable_buffer(false), - one_file(false), - proto_mode(false), - proto_oneof_union(false), - generate_all(false), - skip_unexpected_fields_in_json(false), - generate_name_strings(false), - generate_object_based_api(false), - gen_compare(false), - cpp_object_api_pointer_type("std::unique_ptr"), + output_default_scalars_in_json(false), + indent_step(2), + output_enum_identifiers(true), + prefixed_enums(true), + scoped_enums(false), + include_dependence_headers(true), + mutable_buffer(false), + one_file(false), + proto_mode(false), + proto_oneof_union(false), + generate_all(false), + skip_unexpected_fields_in_json(false), + generate_name_strings(false), + generate_object_based_api(false), + gen_compare(false), + cpp_object_api_pointer_type("std::unique_ptr"), cpp_object_api_string_flexible_constructor(false), cpp_direct_copy(true), - gen_nullable(false), + gen_nullable(false), java_checkerframework(false), gen_generated(false), - object_suffix("T"), - union_value_namespacing(true), - allow_non_utf8(false), - natural_utf8(false), - keep_include_path(false), - binary_schema_comments(false), - binary_schema_builtins(false), + object_suffix("T"), + union_value_namespacing(true), + allow_non_utf8(false), + natural_utf8(false), + keep_include_path(false), + binary_schema_comments(false), + binary_schema_builtins(false), binary_schema_gen_embed(false), - protobuf_ascii_alike(false), - size_prefixed(false), - force_defaults(false), + protobuf_ascii_alike(false), + size_prefixed(false), + force_defaults(false), java_primitive_has_method(false), cs_gen_json_serializer(false), cpp_static_reflection(false), filename_suffix("_generated"), filename_extension(), no_warnings(false), - lang(IDLOptions::kJava), - mini_reflect(IDLOptions::kNone), + lang(IDLOptions::kJava), + mini_reflect(IDLOptions::kNone), require_explicit_ids(false), - lang_to_generate(0), + lang_to_generate(0), set_empty_strings_to_null(true), set_empty_vectors_to_null(true) {} }; -// This encapsulates where the parser is in the current source file. -struct ParserState { - ParserState() +// This encapsulates where the parser is in the current source file. +struct ParserState { + ParserState() : cursor_(nullptr), line_start_(nullptr), line_(0), token_(-1), attr_is_trivial_ascii_string_(true) {} - - protected: - void ResetState(const char *source) { - cursor_ = source; - line_ = 0; - MarkNewLine(); - } - - void MarkNewLine() { - line_start_ = cursor_; - line_ += 1; - } - - int64_t CursorPosition() const { - FLATBUFFERS_ASSERT(cursor_ && line_start_ && cursor_ >= line_start_); - return static_cast<int64_t>(cursor_ - line_start_); - } - - const char *cursor_; - const char *line_start_; - int line_; // the current line being parsed - int token_; - + + protected: + void ResetState(const char *source) { + cursor_ = source; + line_ = 0; + MarkNewLine(); + } + + void MarkNewLine() { + line_start_ = cursor_; + line_ += 1; + } + + int64_t CursorPosition() const { + FLATBUFFERS_ASSERT(cursor_ && line_start_ && cursor_ >= line_start_); + return static_cast<int64_t>(cursor_ - line_start_); + } + + const char *cursor_; + const char *line_start_; + int line_; // the current line being parsed + int token_; + // Flag: text in attribute_ is true ASCII string without escape // sequences. Only printable ASCII (without [\t\r\n]). // Used for number-in-string (and base64 string in future). bool attr_is_trivial_ascii_string_; - std::string attribute_; - std::vector<std::string> doc_comment_; -}; - + std::string attribute_; + std::vector<std::string> doc_comment_; +}; + // A way to make error propagation less error prone by requiring values to be // checked. // Once you create a value of this type you must either: @@ -736,7 +736,7 @@ struct ParserState { class CheckedError { public: explicit CheckedError(bool error) - : is_error_(error), has_been_checked_(false) {} + : is_error_(error), has_been_checked_(false) {} CheckedError &operator=(const CheckedError &other) { is_error_ = other.is_error_; @@ -749,12 +749,12 @@ class CheckedError { *this = other; // Use assignment operator. } - ~CheckedError() { FLATBUFFERS_ASSERT(has_been_checked_); } + ~CheckedError() { FLATBUFFERS_ASSERT(has_been_checked_); } - bool Check() { - has_been_checked_ = true; - return is_error_; - } + bool Check() { + has_been_checked_ = true; + return is_error_; + } private: bool is_error_; @@ -763,58 +763,58 @@ class CheckedError { // Additionally, in GCC we can get these errors statically, for additional // assurance: -// clang-format off +// clang-format off #ifdef __GNUC__ #define FLATBUFFERS_CHECKED_ERROR CheckedError \ __attribute__((warn_unused_result)) #else #define FLATBUFFERS_CHECKED_ERROR CheckedError #endif -// clang-format on +// clang-format on -class Parser : public ParserState { +class Parser : public ParserState { public: explicit Parser(const IDLOptions &options = IDLOptions()) - : current_namespace_(nullptr), - empty_namespace_(nullptr), + : current_namespace_(nullptr), + empty_namespace_(nullptr), flex_builder_(256, flexbuffers::BUILDER_FLAG_SHARE_ALL), - root_struct_def_(nullptr), - opts(options), - uses_flexbuffers_(false), + root_struct_def_(nullptr), + opts(options), + uses_flexbuffers_(false), advanced_features_(0), - source_(nullptr), + source_(nullptr), anonymous_counter_(0), parse_depth_counter_(0) { if (opts.force_defaults) { builder_.ForceDefaults(true); } - // Start out with the empty namespace being current. - empty_namespace_ = new Namespace(); - namespaces_.push_back(empty_namespace_); - current_namespace_ = empty_namespace_; - known_attributes_["deprecated"] = true; - known_attributes_["required"] = true; - known_attributes_["key"] = true; + // Start out with the empty namespace being current. + empty_namespace_ = new Namespace(); + namespaces_.push_back(empty_namespace_); + current_namespace_ = empty_namespace_; + known_attributes_["deprecated"] = true; + known_attributes_["required"] = true; + known_attributes_["key"] = true; known_attributes_["shared"] = true; - known_attributes_["hash"] = true; - known_attributes_["id"] = true; - known_attributes_["force_align"] = true; - known_attributes_["bit_flags"] = true; - known_attributes_["original_order"] = true; - known_attributes_["nested_flatbuffer"] = true; - known_attributes_["csharp_partial"] = true; - known_attributes_["streaming"] = true; - known_attributes_["idempotent"] = true; - known_attributes_["cpp_type"] = true; - known_attributes_["cpp_ptr_type"] = true; - known_attributes_["cpp_ptr_type_get"] = true; - known_attributes_["cpp_str_type"] = true; + known_attributes_["hash"] = true; + known_attributes_["id"] = true; + known_attributes_["force_align"] = true; + known_attributes_["bit_flags"] = true; + known_attributes_["original_order"] = true; + known_attributes_["nested_flatbuffer"] = true; + known_attributes_["csharp_partial"] = true; + known_attributes_["streaming"] = true; + known_attributes_["idempotent"] = true; + known_attributes_["cpp_type"] = true; + known_attributes_["cpp_ptr_type"] = true; + known_attributes_["cpp_ptr_type_get"] = true; + known_attributes_["cpp_str_type"] = true; known_attributes_["cpp_str_flex_ctor"] = true; - known_attributes_["native_inline"] = true; - known_attributes_["native_custom_alloc"] = true; - known_attributes_["native_type"] = true; + known_attributes_["native_inline"] = true; + known_attributes_["native_custom_alloc"] = true; + known_attributes_["native_type"] = true; known_attributes_["native_type_pack_name"] = true; - known_attributes_["native_default"] = true; - known_attributes_["flexbuffer"] = true; - known_attributes_["private"] = true; + known_attributes_["native_default"] = true; + known_attributes_["flexbuffer"] = true; + known_attributes_["private"] = true; } ~Parser() { @@ -832,8 +832,8 @@ class Parser : public ParserState { // directory. // If the source was loaded from a file and isn't an include file, // supply its name in source_filename. - // All paths specified in this call must be in posix format, if you accept - // paths from user input, please call PosixPath on them first. + // All paths specified in this call must be in posix format, if you accept + // paths from user input, please call PosixPath on them first. bool Parse(const char *_source, const char **include_paths = nullptr, const char *source_filename = nullptr); @@ -863,18 +863,18 @@ class Parser : public ParserState { Type *DeserializeType(const reflection::Type *type); - // Checks that the schema represented by this parser is a safe evolution - // of the schema provided. Returns non-empty error on any problems. - std::string ConformTo(const Parser &base); + // Checks that the schema represented by this parser is a safe evolution + // of the schema provided. Returns non-empty error on any problems. + std::string ConformTo(const Parser &base); - // Similar to Parse(), but now only accepts JSON to be parsed into a - // FlexBuffer. - bool ParseFlexBuffer(const char *source, const char *source_filename, - flexbuffers::Builder *builder); - - StructDef *LookupStruct(const std::string &id) const; + // Similar to Parse(), but now only accepts JSON to be parsed into a + // FlexBuffer. + bool ParseFlexBuffer(const char *source, const char *source_filename, + flexbuffers::Builder *builder); + + StructDef *LookupStruct(const std::string &id) const; StructDef *LookupStructThruParentNamespaces(const std::string &id) const; - + std::string UnqualifiedName(const std::string &fullQualifiedName); FLATBUFFERS_CHECKED_ERROR Error(const std::string &msg); @@ -884,18 +884,18 @@ class Parser : public ParserState { // @param opts Options used to parce a schema and generate code. static bool SupportsOptionalScalars(const flatbuffers::IDLOptions &opts); - private: + private: class ParseDepthGuard; - void Message(const std::string &msg); - void Warning(const std::string &msg); - FLATBUFFERS_CHECKED_ERROR ParseHexNum(int nibbles, uint64_t *val); + void Message(const std::string &msg); + void Warning(const std::string &msg); + FLATBUFFERS_CHECKED_ERROR ParseHexNum(int nibbles, uint64_t *val); FLATBUFFERS_CHECKED_ERROR Next(); FLATBUFFERS_CHECKED_ERROR SkipByteOrderMark(); - bool Is(int t) const; - bool IsIdent(const char *id) const; + bool Is(int t) const; + bool IsIdent(const char *id) const; FLATBUFFERS_CHECKED_ERROR Expect(int t); - std::string TokenToStringId(int t) const; + std::string TokenToStringId(int t) const; EnumDef *LookupEnum(const std::string &id); FLATBUFFERS_CHECKED_ERROR ParseNamespacing(std::string *id, std::string *last); @@ -906,15 +906,15 @@ class Parser : public ParserState { FieldDef **dest); FLATBUFFERS_CHECKED_ERROR ParseField(StructDef &struct_def); FLATBUFFERS_CHECKED_ERROR ParseString(Value &val, bool use_string_pooling); - FLATBUFFERS_CHECKED_ERROR ParseComma(); + FLATBUFFERS_CHECKED_ERROR ParseComma(); FLATBUFFERS_CHECKED_ERROR ParseAnyValue(Value &val, FieldDef *field, - size_t parent_fieldn, + size_t parent_fieldn, const StructDef *parent_struct_def, uoffset_t count, bool inside_vector = false); template<typename F> - FLATBUFFERS_CHECKED_ERROR ParseTableDelimiters(size_t &fieldn, - const StructDef *struct_def, + FLATBUFFERS_CHECKED_ERROR ParseTableDelimiters(size_t &fieldn, + const StructDef *struct_def, F body); FLATBUFFERS_CHECKED_ERROR ParseTable(const StructDef &struct_def, std::string *value, uoffset_t *ovalue); @@ -929,12 +929,12 @@ class Parser : public ParserState { FLATBUFFERS_CHECKED_ERROR ParseNestedFlatbuffer( Value &val, FieldDef *field, size_t fieldn, const StructDef *parent_struct_def); - FLATBUFFERS_CHECKED_ERROR ParseMetaData(SymbolTable<Value> *attributes); + FLATBUFFERS_CHECKED_ERROR ParseMetaData(SymbolTable<Value> *attributes); FLATBUFFERS_CHECKED_ERROR TryTypedValue(const std::string *name, int dtoken, bool check, Value &e, BaseType req, bool *destmatch); FLATBUFFERS_CHECKED_ERROR ParseHash(Value &e, FieldDef *field); - FLATBUFFERS_CHECKED_ERROR TokenError(); + FLATBUFFERS_CHECKED_ERROR TokenError(); FLATBUFFERS_CHECKED_ERROR ParseSingleValue(const std::string *name, Value &e, bool check_now); FLATBUFFERS_CHECKED_ERROR ParseFunction(const std::string *name, Value &e); @@ -948,9 +948,9 @@ class Parser : public ParserState { FLATBUFFERS_CHECKED_ERROR StartStruct(const std::string &name, StructDef **dest); FLATBUFFERS_CHECKED_ERROR StartEnum(const std::string &name, bool is_union, - EnumDef **dest); + EnumDef **dest); FLATBUFFERS_CHECKED_ERROR ParseDecl(); - FLATBUFFERS_CHECKED_ERROR ParseService(); + FLATBUFFERS_CHECKED_ERROR ParseService(); FLATBUFFERS_CHECKED_ERROR ParseProtoFields(StructDef *struct_def, bool isextend, bool inside_oneof); FLATBUFFERS_CHECKED_ERROR ParseProtoOption(); @@ -961,14 +961,14 @@ class Parser : public ParserState { FLATBUFFERS_CHECKED_ERROR SkipAnyJsonValue(); FLATBUFFERS_CHECKED_ERROR ParseFlexBufferNumericConstant( flexbuffers::Builder *builder); - FLATBUFFERS_CHECKED_ERROR ParseFlexBufferValue(flexbuffers::Builder *builder); - FLATBUFFERS_CHECKED_ERROR StartParseFile(const char *source, - const char *source_filename); - FLATBUFFERS_CHECKED_ERROR ParseRoot(const char *_source, + FLATBUFFERS_CHECKED_ERROR ParseFlexBufferValue(flexbuffers::Builder *builder); + FLATBUFFERS_CHECKED_ERROR StartParseFile(const char *source, + const char *source_filename); + FLATBUFFERS_CHECKED_ERROR ParseRoot(const char *_source, const char **include_paths, const char *source_filename); FLATBUFFERS_CHECKED_ERROR DoParse(const char *_source, - const char **include_paths, + const char **include_paths, const char *source_filename, const char *include_filename); FLATBUFFERS_CHECKED_ERROR DoParseJson(); @@ -982,19 +982,19 @@ class Parser : public ParserState { bool SupportsAdvancedArrayFeatures() const; bool SupportsOptionalScalars() const; bool SupportsDefaultVectorsAndStrings() const; - Namespace *UniqueNamespace(Namespace *ns); - - FLATBUFFERS_CHECKED_ERROR RecurseError(); + Namespace *UniqueNamespace(Namespace *ns); + + FLATBUFFERS_CHECKED_ERROR RecurseError(); template<typename F> CheckedError Recurse(F f); - + public: - SymbolTable<Type> types_; + SymbolTable<Type> types_; SymbolTable<StructDef> structs_; SymbolTable<EnumDef> enums_; - SymbolTable<ServiceDef> services_; + SymbolTable<ServiceDef> services_; std::vector<Namespace *> namespaces_; - Namespace *current_namespace_; - Namespace *empty_namespace_; + Namespace *current_namespace_; + Namespace *empty_namespace_; std::string error_; // User readable error_ if Parse() == false FlatBufferBuilder builder_; // any data contained in the file @@ -1006,18 +1006,18 @@ class Parser : public ParserState { std::map<uint64_t, std::string> included_files_; std::map<std::string, std::set<std::string>> files_included_per_file_; - std::vector<std::string> native_included_files_; - - std::map<std::string, bool> known_attributes_; + std::vector<std::string> native_included_files_; + std::map<std::string, bool> known_attributes_; + IDLOptions opts; - bool uses_flexbuffers_; + bool uses_flexbuffers_; uint64_t advanced_features_; private: - const char *source_; - + const char *source_; + std::string file_being_parsed_; std::vector<std::pair<Value, FieldDef *>> field_stack_; @@ -1038,8 +1038,8 @@ extern std::string MakeScreamingCamel(const std::string &in); // if it is less than 0, no linefeeds will be generated either. // See idl_gen_text.cpp. // strict_json adds "quotes" around field names if true. -// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8 -// byte arrays in String values), returns false. +// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8 +// byte arrays in String values), returns false. extern bool GenerateTextFromTable(const Parser &parser, const void *table, const std::string &tablename, std::string *text); @@ -1069,8 +1069,8 @@ extern bool GenerateCSharp(const Parser &parser, const std::string &path, const std::string &file_name); extern bool GenerateDart(const Parser &parser, const std::string &path, - const std::string &file_name); - + const std::string &file_name); + // Generate Java files from the definitions in the Parser object. // See idl_gen_java.cpp. extern bool GenerateJava(const Parser &parser, const std::string &path, @@ -1089,30 +1089,30 @@ extern bool GenerateGo(const Parser &parser, const std::string &path, // Generate Php code from the definitions in the Parser object. // See idl_gen_php. extern bool GeneratePhp(const Parser &parser, const std::string &path, - const std::string &file_name); + const std::string &file_name); // Generate Python files from the definitions in the Parser object. // See idl_gen_python.cpp. extern bool GeneratePython(const Parser &parser, const std::string &path, const std::string &file_name); -// Generate Lobster files from the definitions in the Parser object. -// See idl_gen_lobster.cpp. +// Generate Lobster files from the definitions in the Parser object. +// See idl_gen_lobster.cpp. extern bool GenerateLobster(const Parser &parser, const std::string &path, - const std::string &file_name); - -// Generate Lua files from the definitions in the Parser object. -// See idl_gen_lua.cpp. + const std::string &file_name); + +// Generate Lua files from the definitions in the Parser object. +// See idl_gen_lua.cpp. extern bool GenerateLua(const Parser &parser, const std::string &path, const std::string &file_name); - -// Generate Rust files from the definitions in the Parser object. -// See idl_gen_rust.cpp. + +// Generate Rust files from the definitions in the Parser object. +// See idl_gen_rust.cpp. extern bool GenerateRust(const Parser &parser, const std::string &path, - const std::string &file_name); - -// Generate Json schema file -// See idl_gen_json_schema.cpp. + const std::string &file_name); + +// Generate Json schema file +// See idl_gen_json_schema.cpp. extern bool GenerateJsonSchema(const Parser &parser, const std::string &path, const std::string &file_name); @@ -1150,16 +1150,16 @@ extern std::string TSMakeRule(const Parser &parser, const std::string &path, extern std::string CPPMakeRule(const Parser &parser, const std::string &path, const std::string &file_name); -// Generate a make rule for the generated Dart code -// see idl_gen_dart.cpp +// Generate a make rule for the generated Dart code +// see idl_gen_dart.cpp extern std::string DartMakeRule(const Parser &parser, const std::string &path, - const std::string &file_name); - -// Generate a make rule for the generated Rust code. -// See idl_gen_rust.cpp. + const std::string &file_name); + +// Generate a make rule for the generated Rust code. +// See idl_gen_rust.cpp. extern std::string RustMakeRule(const Parser &parser, const std::string &path, - const std::string &file_name); - + const std::string &file_name); + // Generate a make rule for generated Java or C# files. // See code_generators.cpp. extern std::string JavaCSharpMakeRule(const Parser &parser, @@ -1176,21 +1176,21 @@ extern std::string TextMakeRule(const Parser &parser, const std::string &path, extern std::string BinaryMakeRule(const Parser &parser, const std::string &path, const std::string &file_name); -// Generate GRPC Cpp interfaces. -// See idl_gen_grpc.cpp. +// Generate GRPC Cpp interfaces. +// See idl_gen_grpc.cpp. bool GenerateCppGRPC(const Parser &parser, const std::string &path, - const std::string &file_name); - -// Generate GRPC Go interfaces. -// See idl_gen_grpc.cpp. + const std::string &file_name); + +// Generate GRPC Go interfaces. +// See idl_gen_grpc.cpp. bool GenerateGoGRPC(const Parser &parser, const std::string &path, - const std::string &file_name); - -// Generate GRPC Java classes. -// See idl_gen_grpc.cpp + const std::string &file_name); + +// Generate GRPC Java classes. +// See idl_gen_grpc.cpp bool GenerateJavaGRPC(const Parser &parser, const std::string &path, - const std::string &file_name); - + const std::string &file_name); + // Generate GRPC Python interfaces. // See idl_gen_grpc.cpp. bool GeneratePythonGRPC(const Parser &parser, const std::string &path, diff --git a/contrib/libs/flatbuffers/include/flatbuffers/minireflect.h b/contrib/libs/flatbuffers/include/flatbuffers/minireflect.h index d95dd24b7e..a7cb4fbea7 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/minireflect.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/minireflect.h @@ -1,258 +1,258 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_MINIREFLECT_H_ -#define FLATBUFFERS_MINIREFLECT_H_ - +/* + * Copyright 2017 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLATBUFFERS_MINIREFLECT_H_ +#define FLATBUFFERS_MINIREFLECT_H_ + #include "flatbuffers.h" #include "util.h" - -namespace flatbuffers { - -// Utilities that can be used with the "mini reflection" tables present -// in generated code with --reflect-types (only types) or --reflect-names -// (also names). -// This allows basic reflection functionality such as pretty-printing -// that does not require the use of the schema parser or loading of binary -// schema files at runtime (reflection.h). - -// For any of the functions below that take `const TypeTable *`, you pass -// `FooTypeTable()` if the type of the root is `Foo`. - -// First, a generic iterator that can be used by multiple algorithms. - -struct IterationVisitor { - // These mark the scope of a table or struct. - virtual void StartSequence() {} - virtual void EndSequence() {} + +namespace flatbuffers { + +// Utilities that can be used with the "mini reflection" tables present +// in generated code with --reflect-types (only types) or --reflect-names +// (also names). +// This allows basic reflection functionality such as pretty-printing +// that does not require the use of the schema parser or loading of binary +// schema files at runtime (reflection.h). + +// For any of the functions below that take `const TypeTable *`, you pass +// `FooTypeTable()` if the type of the root is `Foo`. + +// First, a generic iterator that can be used by multiple algorithms. + +struct IterationVisitor { + // These mark the scope of a table or struct. + virtual void StartSequence() {} + virtual void EndSequence() {} // Called for each field regardless of whether it is present or not. - // If not present, val == nullptr. set_idx is the index of all set fields. - virtual void Field(size_t /*field_idx*/, size_t /*set_idx*/, - ElementaryType /*type*/, bool /*is_vector*/, - const TypeTable * /*type_table*/, const char * /*name*/, - const uint8_t * /*val*/) {} - // Called for a value that is actually present, after a field, or as part - // of a vector. - virtual void UType(uint8_t, const char *) {} - virtual void Bool(bool) {} - virtual void Char(int8_t, const char *) {} - virtual void UChar(uint8_t, const char *) {} - virtual void Short(int16_t, const char *) {} - virtual void UShort(uint16_t, const char *) {} - virtual void Int(int32_t, const char *) {} - virtual void UInt(uint32_t, const char *) {} - virtual void Long(int64_t) {} - virtual void ULong(uint64_t) {} - virtual void Float(float) {} - virtual void Double(double) {} - virtual void String(const String *) {} - virtual void Unknown(const uint8_t *) {} // From a future version. - // These mark the scope of a vector. - virtual void StartVector() {} - virtual void EndVector() {} - virtual void Element(size_t /*i*/, ElementaryType /*type*/, - const TypeTable * /*type_table*/, - const uint8_t * /*val*/) {} - virtual ~IterationVisitor() {} -}; - -inline size_t InlineSize(ElementaryType type, const TypeTable *type_table) { - switch (type) { - case ET_UTYPE: - case ET_BOOL: - case ET_CHAR: - case ET_UCHAR: return 1; - case ET_SHORT: - case ET_USHORT: return 2; - case ET_INT: - case ET_UINT: - case ET_FLOAT: - case ET_STRING: return 4; - case ET_LONG: - case ET_ULONG: - case ET_DOUBLE: return 8; - case ET_SEQUENCE: - switch (type_table->st) { - case ST_TABLE: - case ST_UNION: return 4; + // If not present, val == nullptr. set_idx is the index of all set fields. + virtual void Field(size_t /*field_idx*/, size_t /*set_idx*/, + ElementaryType /*type*/, bool /*is_vector*/, + const TypeTable * /*type_table*/, const char * /*name*/, + const uint8_t * /*val*/) {} + // Called for a value that is actually present, after a field, or as part + // of a vector. + virtual void UType(uint8_t, const char *) {} + virtual void Bool(bool) {} + virtual void Char(int8_t, const char *) {} + virtual void UChar(uint8_t, const char *) {} + virtual void Short(int16_t, const char *) {} + virtual void UShort(uint16_t, const char *) {} + virtual void Int(int32_t, const char *) {} + virtual void UInt(uint32_t, const char *) {} + virtual void Long(int64_t) {} + virtual void ULong(uint64_t) {} + virtual void Float(float) {} + virtual void Double(double) {} + virtual void String(const String *) {} + virtual void Unknown(const uint8_t *) {} // From a future version. + // These mark the scope of a vector. + virtual void StartVector() {} + virtual void EndVector() {} + virtual void Element(size_t /*i*/, ElementaryType /*type*/, + const TypeTable * /*type_table*/, + const uint8_t * /*val*/) {} + virtual ~IterationVisitor() {} +}; + +inline size_t InlineSize(ElementaryType type, const TypeTable *type_table) { + switch (type) { + case ET_UTYPE: + case ET_BOOL: + case ET_CHAR: + case ET_UCHAR: return 1; + case ET_SHORT: + case ET_USHORT: return 2; + case ET_INT: + case ET_UINT: + case ET_FLOAT: + case ET_STRING: return 4; + case ET_LONG: + case ET_ULONG: + case ET_DOUBLE: return 8; + case ET_SEQUENCE: + switch (type_table->st) { + case ST_TABLE: + case ST_UNION: return 4; case ST_STRUCT: return static_cast<size_t>(type_table->values[type_table->num_elems]); - default: FLATBUFFERS_ASSERT(false); return 1; - } - default: FLATBUFFERS_ASSERT(false); return 1; - } -} - + default: FLATBUFFERS_ASSERT(false); return 1; + } + default: FLATBUFFERS_ASSERT(false); return 1; + } +} + inline int64_t LookupEnum(int64_t enum_val, const int64_t *values, - size_t num_values) { - if (!values) return enum_val; - for (size_t i = 0; i < num_values; i++) { + size_t num_values) { + if (!values) return enum_val; + for (size_t i = 0; i < num_values; i++) { if (enum_val == values[i]) return static_cast<int64_t>(i); - } - return -1; // Unknown enum value. -} - -template<typename T> const char *EnumName(T tval, const TypeTable *type_table) { - if (!type_table || !type_table->names) return nullptr; + } + return -1; // Unknown enum value. +} + +template<typename T> const char *EnumName(T tval, const TypeTable *type_table) { + if (!type_table || !type_table->names) return nullptr; auto i = LookupEnum(static_cast<int64_t>(tval), type_table->values, - type_table->num_elems); + type_table->num_elems); if (i >= 0 && i < static_cast<int64_t>(type_table->num_elems)) { - return type_table->names[i]; - } - return nullptr; -} - -void IterateObject(const uint8_t *obj, const TypeTable *type_table, - IterationVisitor *visitor); - -inline void IterateValue(ElementaryType type, const uint8_t *val, - const TypeTable *type_table, const uint8_t *prev_val, - soffset_t vector_index, IterationVisitor *visitor) { - switch (type) { - case ET_UTYPE: { + return type_table->names[i]; + } + return nullptr; +} + +void IterateObject(const uint8_t *obj, const TypeTable *type_table, + IterationVisitor *visitor); + +inline void IterateValue(ElementaryType type, const uint8_t *val, + const TypeTable *type_table, const uint8_t *prev_val, + soffset_t vector_index, IterationVisitor *visitor) { + switch (type) { + case ET_UTYPE: { auto tval = ReadScalar<uint8_t>(val); - visitor->UType(tval, EnumName(tval, type_table)); - break; - } - case ET_BOOL: { + visitor->UType(tval, EnumName(tval, type_table)); + break; + } + case ET_BOOL: { visitor->Bool(ReadScalar<uint8_t>(val) != 0); - break; - } - case ET_CHAR: { + break; + } + case ET_CHAR: { auto tval = ReadScalar<int8_t>(val); - visitor->Char(tval, EnumName(tval, type_table)); - break; - } - case ET_UCHAR: { + visitor->Char(tval, EnumName(tval, type_table)); + break; + } + case ET_UCHAR: { auto tval = ReadScalar<uint8_t>(val); - visitor->UChar(tval, EnumName(tval, type_table)); - break; - } - case ET_SHORT: { + visitor->UChar(tval, EnumName(tval, type_table)); + break; + } + case ET_SHORT: { auto tval = ReadScalar<int16_t>(val); - visitor->Short(tval, EnumName(tval, type_table)); - break; - } - case ET_USHORT: { + visitor->Short(tval, EnumName(tval, type_table)); + break; + } + case ET_USHORT: { auto tval = ReadScalar<uint16_t>(val); - visitor->UShort(tval, EnumName(tval, type_table)); - break; - } - case ET_INT: { + visitor->UShort(tval, EnumName(tval, type_table)); + break; + } + case ET_INT: { auto tval = ReadScalar<int32_t>(val); - visitor->Int(tval, EnumName(tval, type_table)); - break; - } - case ET_UINT: { + visitor->Int(tval, EnumName(tval, type_table)); + break; + } + case ET_UINT: { auto tval = ReadScalar<uint32_t>(val); - visitor->UInt(tval, EnumName(tval, type_table)); - break; - } - case ET_LONG: { + visitor->UInt(tval, EnumName(tval, type_table)); + break; + } + case ET_LONG: { visitor->Long(ReadScalar<int64_t>(val)); - break; - } - case ET_ULONG: { + break; + } + case ET_ULONG: { visitor->ULong(ReadScalar<uint64_t>(val)); - break; - } - case ET_FLOAT: { + break; + } + case ET_FLOAT: { visitor->Float(ReadScalar<float>(val)); - break; - } - case ET_DOUBLE: { + break; + } + case ET_DOUBLE: { visitor->Double(ReadScalar<double>(val)); - break; - } - case ET_STRING: { - val += ReadScalar<uoffset_t>(val); - visitor->String(reinterpret_cast<const String *>(val)); - break; - } - case ET_SEQUENCE: { - switch (type_table->st) { - case ST_TABLE: - val += ReadScalar<uoffset_t>(val); - IterateObject(val, type_table, visitor); - break; - case ST_STRUCT: IterateObject(val, type_table, visitor); break; - case ST_UNION: { - val += ReadScalar<uoffset_t>(val); - FLATBUFFERS_ASSERT(prev_val); - auto union_type = *prev_val; // Always a uint8_t. - if (vector_index >= 0) { - auto type_vec = reinterpret_cast<const Vector<uint8_t> *>(prev_val); - union_type = type_vec->Get(static_cast<uoffset_t>(vector_index)); - } - auto type_code_idx = - LookupEnum(union_type, type_table->values, type_table->num_elems); - if (type_code_idx >= 0 && - type_code_idx < static_cast<int32_t>(type_table->num_elems)) { - auto type_code = type_table->type_codes[type_code_idx]; - switch (type_code.base_type) { - case ET_SEQUENCE: { - auto ref = type_table->type_refs[type_code.sequence_ref](); - IterateObject(val, ref, visitor); - break; - } - case ET_STRING: - visitor->String(reinterpret_cast<const String *>(val)); - break; - default: visitor->Unknown(val); - } - } else { - visitor->Unknown(val); - } - break; - } - case ST_ENUM: FLATBUFFERS_ASSERT(false); break; - } - break; - } - default: { - visitor->Unknown(val); - break; - } - } -} - -inline void IterateObject(const uint8_t *obj, const TypeTable *type_table, - IterationVisitor *visitor) { - visitor->StartSequence(); - const uint8_t *prev_val = nullptr; - size_t set_idx = 0; + break; + } + case ET_STRING: { + val += ReadScalar<uoffset_t>(val); + visitor->String(reinterpret_cast<const String *>(val)); + break; + } + case ET_SEQUENCE: { + switch (type_table->st) { + case ST_TABLE: + val += ReadScalar<uoffset_t>(val); + IterateObject(val, type_table, visitor); + break; + case ST_STRUCT: IterateObject(val, type_table, visitor); break; + case ST_UNION: { + val += ReadScalar<uoffset_t>(val); + FLATBUFFERS_ASSERT(prev_val); + auto union_type = *prev_val; // Always a uint8_t. + if (vector_index >= 0) { + auto type_vec = reinterpret_cast<const Vector<uint8_t> *>(prev_val); + union_type = type_vec->Get(static_cast<uoffset_t>(vector_index)); + } + auto type_code_idx = + LookupEnum(union_type, type_table->values, type_table->num_elems); + if (type_code_idx >= 0 && + type_code_idx < static_cast<int32_t>(type_table->num_elems)) { + auto type_code = type_table->type_codes[type_code_idx]; + switch (type_code.base_type) { + case ET_SEQUENCE: { + auto ref = type_table->type_refs[type_code.sequence_ref](); + IterateObject(val, ref, visitor); + break; + } + case ET_STRING: + visitor->String(reinterpret_cast<const String *>(val)); + break; + default: visitor->Unknown(val); + } + } else { + visitor->Unknown(val); + } + break; + } + case ST_ENUM: FLATBUFFERS_ASSERT(false); break; + } + break; + } + default: { + visitor->Unknown(val); + break; + } + } +} + +inline void IterateObject(const uint8_t *obj, const TypeTable *type_table, + IterationVisitor *visitor) { + visitor->StartSequence(); + const uint8_t *prev_val = nullptr; + size_t set_idx = 0; size_t array_idx = 0; - for (size_t i = 0; i < type_table->num_elems; i++) { - auto type_code = type_table->type_codes[i]; - auto type = static_cast<ElementaryType>(type_code.base_type); + for (size_t i = 0; i < type_table->num_elems; i++) { + auto type_code = type_table->type_codes[i]; + auto type = static_cast<ElementaryType>(type_code.base_type); auto is_repeating = type_code.is_repeating != 0; - auto ref_idx = type_code.sequence_ref; - const TypeTable *ref = nullptr; - if (ref_idx >= 0) { ref = type_table->type_refs[ref_idx](); } - auto name = type_table->names ? type_table->names[i] : nullptr; - const uint8_t *val = nullptr; - if (type_table->st == ST_TABLE) { - val = reinterpret_cast<const Table *>(obj)->GetAddressOf( - FieldIndexToOffset(static_cast<voffset_t>(i))); - } else { - val = obj + type_table->values[i]; - } + auto ref_idx = type_code.sequence_ref; + const TypeTable *ref = nullptr; + if (ref_idx >= 0) { ref = type_table->type_refs[ref_idx](); } + auto name = type_table->names ? type_table->names[i] : nullptr; + const uint8_t *val = nullptr; + if (type_table->st == ST_TABLE) { + val = reinterpret_cast<const Table *>(obj)->GetAddressOf( + FieldIndexToOffset(static_cast<voffset_t>(i))); + } else { + val = obj + type_table->values[i]; + } visitor->Field(i, set_idx, type, is_repeating, ref, name, val); - if (val) { - set_idx++; + if (val) { + set_idx++; if (is_repeating) { auto elem_ptr = val; size_t size = 0; @@ -267,38 +267,38 @@ inline void IterateObject(const uint8_t *obj, const TypeTable *type_table, size = type_table->array_sizes[array_idx]; ++array_idx; } - visitor->StartVector(); + visitor->StartVector(); for (size_t j = 0; j < size; j++) { - visitor->Element(j, type, ref, elem_ptr); - IterateValue(type, elem_ptr, ref, prev_val, static_cast<soffset_t>(j), - visitor); - elem_ptr += InlineSize(type, ref); - } - visitor->EndVector(); - } else { - IterateValue(type, val, ref, prev_val, -1, visitor); - } - } - prev_val = val; - } - visitor->EndSequence(); -} - -inline void IterateFlatBuffer(const uint8_t *buffer, - const TypeTable *type_table, - IterationVisitor *callback) { - IterateObject(GetRoot<uint8_t>(buffer), type_table, callback); -} - -// Outputting a Flatbuffer to a string. Tries to conform as close to JSON / -// the output generated by idl_gen_text.cpp. - -struct ToStringVisitor : public IterationVisitor { - std::string s; - std::string d; - bool q; - std::string in; - size_t indent_level; + visitor->Element(j, type, ref, elem_ptr); + IterateValue(type, elem_ptr, ref, prev_val, static_cast<soffset_t>(j), + visitor); + elem_ptr += InlineSize(type, ref); + } + visitor->EndVector(); + } else { + IterateValue(type, val, ref, prev_val, -1, visitor); + } + } + prev_val = val; + } + visitor->EndSequence(); +} + +inline void IterateFlatBuffer(const uint8_t *buffer, + const TypeTable *type_table, + IterationVisitor *callback) { + IterateObject(GetRoot<uint8_t>(buffer), type_table, callback); +} + +// Outputting a Flatbuffer to a string. Tries to conform as close to JSON / +// the output generated by idl_gen_text.cpp. + +struct ToStringVisitor : public IterationVisitor { + std::string s; + std::string d; + bool q; + std::string in; + size_t indent_level; bool vector_delimited; ToStringVisitor(std::string delimiter, bool quotes, std::string indent, bool vdelimited = true) @@ -307,71 +307,71 @@ struct ToStringVisitor : public IterationVisitor { in(indent), indent_level(0), vector_delimited(vdelimited) {} - ToStringVisitor(std::string delimiter) + ToStringVisitor(std::string delimiter) : d(delimiter), q(false), in(""), indent_level(0), vector_delimited(true) {} - - void append_indent() { - for (size_t i = 0; i < indent_level; i++) { s += in; } - } - - void StartSequence() { - s += "{"; - s += d; - indent_level++; - } - void EndSequence() { - s += d; - indent_level--; - append_indent(); - s += "}"; - } - void Field(size_t /*field_idx*/, size_t set_idx, ElementaryType /*type*/, - bool /*is_vector*/, const TypeTable * /*type_table*/, - const char *name, const uint8_t *val) { - if (!val) return; - if (set_idx) { - s += ","; - s += d; - } - append_indent(); - if (name) { - if (q) s += "\""; - s += name; - if (q) s += "\""; - s += ": "; - } - } - template<typename T> void Named(T x, const char *name) { - if (name) { - if (q) s += "\""; - s += name; - if (q) s += "\""; - } else { - s += NumToString(x); - } - } - void UType(uint8_t x, const char *name) { Named(x, name); } - void Bool(bool x) { s += x ? "true" : "false"; } - void Char(int8_t x, const char *name) { Named(x, name); } - void UChar(uint8_t x, const char *name) { Named(x, name); } - void Short(int16_t x, const char *name) { Named(x, name); } - void UShort(uint16_t x, const char *name) { Named(x, name); } - void Int(int32_t x, const char *name) { Named(x, name); } - void UInt(uint32_t x, const char *name) { Named(x, name); } - void Long(int64_t x) { s += NumToString(x); } - void ULong(uint64_t x) { s += NumToString(x); } - void Float(float x) { s += NumToString(x); } - void Double(double x) { s += NumToString(x); } - void String(const struct String *str) { - EscapeString(str->c_str(), str->size(), &s, true, false); - } - void Unknown(const uint8_t *) { s += "(?)"; } - void StartVector() { - s += "["; + + void append_indent() { + for (size_t i = 0; i < indent_level; i++) { s += in; } + } + + void StartSequence() { + s += "{"; + s += d; + indent_level++; + } + void EndSequence() { + s += d; + indent_level--; + append_indent(); + s += "}"; + } + void Field(size_t /*field_idx*/, size_t set_idx, ElementaryType /*type*/, + bool /*is_vector*/, const TypeTable * /*type_table*/, + const char *name, const uint8_t *val) { + if (!val) return; + if (set_idx) { + s += ","; + s += d; + } + append_indent(); + if (name) { + if (q) s += "\""; + s += name; + if (q) s += "\""; + s += ": "; + } + } + template<typename T> void Named(T x, const char *name) { + if (name) { + if (q) s += "\""; + s += name; + if (q) s += "\""; + } else { + s += NumToString(x); + } + } + void UType(uint8_t x, const char *name) { Named(x, name); } + void Bool(bool x) { s += x ? "true" : "false"; } + void Char(int8_t x, const char *name) { Named(x, name); } + void UChar(uint8_t x, const char *name) { Named(x, name); } + void Short(int16_t x, const char *name) { Named(x, name); } + void UShort(uint16_t x, const char *name) { Named(x, name); } + void Int(int32_t x, const char *name) { Named(x, name); } + void UInt(uint32_t x, const char *name) { Named(x, name); } + void Long(int64_t x) { s += NumToString(x); } + void ULong(uint64_t x) { s += NumToString(x); } + void Float(float x) { s += NumToString(x); } + void Double(double x) { s += NumToString(x); } + void String(const struct String *str) { + EscapeString(str->c_str(), str->size(), &s, true, false); + } + void Unknown(const uint8_t *) { s += "(?)"; } + void StartVector() { + s += "["; if (vector_delimited) { s += d; indent_level++; @@ -379,8 +379,8 @@ struct ToStringVisitor : public IterationVisitor { } else { s += " "; } - } - void EndVector() { + } + void EndVector() { if (vector_delimited) { s += d; indent_level--; @@ -388,32 +388,32 @@ struct ToStringVisitor : public IterationVisitor { } else { s += " "; } - s += "]"; - } - void Element(size_t i, ElementaryType /*type*/, - const TypeTable * /*type_table*/, const uint8_t * /*val*/) { - if (i) { - s += ","; + s += "]"; + } + void Element(size_t i, ElementaryType /*type*/, + const TypeTable * /*type_table*/, const uint8_t * /*val*/) { + if (i) { + s += ","; if (vector_delimited) { s += d; append_indent(); } else { s += " "; } - } - } -}; - -inline std::string FlatBufferToString(const uint8_t *buffer, - const TypeTable *type_table, + } + } +}; + +inline std::string FlatBufferToString(const uint8_t *buffer, + const TypeTable *type_table, bool multi_line = false, bool vector_delimited = true) { ToStringVisitor tostring_visitor(multi_line ? "\n" : " ", false, "", vector_delimited); - IterateFlatBuffer(buffer, type_table, &tostring_visitor); - return tostring_visitor.s; -} - -} // namespace flatbuffers - -#endif // FLATBUFFERS_MINIREFLECT_H_ + IterateFlatBuffer(buffer, type_table, &tostring_visitor); + return tostring_visitor.s; +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_MINIREFLECT_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/reflection.h b/contrib/libs/flatbuffers/include/flatbuffers/reflection.h index d268a3ffea..f7c534f1cd 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/reflection.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/reflection.h @@ -30,19 +30,19 @@ namespace flatbuffers { // ------------------------- GETTERS ------------------------- -inline bool IsScalar(reflection::BaseType t) { - return t >= reflection::UType && t <= reflection::Double; -} -inline bool IsInteger(reflection::BaseType t) { - return t >= reflection::UType && t <= reflection::ULong; -} -inline bool IsFloat(reflection::BaseType t) { - return t == reflection::Float || t == reflection::Double; -} -inline bool IsLong(reflection::BaseType t) { - return t == reflection::Long || t == reflection::ULong; -} - +inline bool IsScalar(reflection::BaseType t) { + return t >= reflection::UType && t <= reflection::Double; +} +inline bool IsInteger(reflection::BaseType t) { + return t >= reflection::UType && t <= reflection::ULong; +} +inline bool IsFloat(reflection::BaseType t) { + return t == reflection::Float || t == reflection::Double; +} +inline bool IsLong(reflection::BaseType t) { + return t == reflection::Long || t == reflection::ULong; +} + // Size of a basic type, don't use with structs. inline size_t GetTypeSize(reflection::BaseType base_type) { // This needs to correspond to the BaseType enum. @@ -77,7 +77,7 @@ inline size_t GetTypeSize(reflection::BaseType base_type) { // Same as above, but now correctly returns the size of a struct if // the field (or vector element) is a struct. -inline size_t GetTypeSizeInline(reflection::BaseType base_type, int type_index, +inline size_t GetTypeSizeInline(reflection::BaseType base_type, int type_index, const reflection::Schema &schema) { if (base_type == reflection::Obj && schema.objects()->Get(type_index)->is_struct()) { @@ -95,30 +95,30 @@ inline const Table *GetAnyRoot(const uint8_t *flatbuf) { return GetRoot<Table>(flatbuf); } -// Get a field's default, if you know it's an integer, and its exact type. -template<typename T> T GetFieldDefaultI(const reflection::Field &field) { - FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); - return static_cast<T>(field.default_integer()); -} - -// Get a field's default, if you know it's floating point and its exact type. -template<typename T> T GetFieldDefaultF(const reflection::Field &field) { - FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); - return static_cast<T>(field.default_real()); -} - +// Get a field's default, if you know it's an integer, and its exact type. +template<typename T> T GetFieldDefaultI(const reflection::Field &field) { + FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); + return static_cast<T>(field.default_integer()); +} + +// Get a field's default, if you know it's floating point and its exact type. +template<typename T> T GetFieldDefaultF(const reflection::Field &field) { + FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); + return static_cast<T>(field.default_real()); +} + // Get a field, if you know it's an integer, and its exact type. -template<typename T> -T GetFieldI(const Table &table, const reflection::Field &field) { - FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); +template<typename T> +T GetFieldI(const Table &table, const reflection::Field &field) { + FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); return table.GetField<T>(field.offset(), static_cast<T>(field.default_integer())); } // Get a field, if you know it's floating point and its exact type. -template<typename T> -T GetFieldF(const Table &table, const reflection::Field &field) { - FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); +template<typename T> +T GetFieldF(const Table &table, const reflection::Field &field) { + FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type())); return table.GetField<T>(field.offset(), static_cast<T>(field.default_real())); } @@ -126,15 +126,15 @@ T GetFieldF(const Table &table, const reflection::Field &field) { // Get a field, if you know it's a string. inline const String *GetFieldS(const Table &table, const reflection::Field &field) { - FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::String); + FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::String); return table.GetPointer<const String *>(field.offset()); } // Get a field, if you know it's a vector. -template<typename T> -Vector<T> *GetFieldV(const Table &table, const reflection::Field &field) { - FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Vector && - sizeof(T) == GetTypeSize(field.type()->element())); +template<typename T> +Vector<T> *GetFieldV(const Table &table, const reflection::Field &field) { + FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Vector && + sizeof(T) == GetTypeSize(field.type()->element())); return table.GetPointer<Vector<T> *>(field.offset()); } @@ -147,28 +147,28 @@ inline VectorOfAny *GetFieldAnyV(const Table &table, } // Get a field, if you know it's a table. -inline Table *GetFieldT(const Table &table, const reflection::Field &field) { - FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj || - field.type()->base_type() == reflection::Union); +inline Table *GetFieldT(const Table &table, const reflection::Field &field) { + FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj || + field.type()->base_type() == reflection::Union); return table.GetPointer<Table *>(field.offset()); } -// Get a field, if you know it's a struct. -inline const Struct *GetFieldStruct(const Table &table, - const reflection::Field &field) { - // TODO: This does NOT check if the field is a table or struct, but we'd need - // access to the schema to check the is_struct flag. - FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj); - return table.GetStruct<const Struct *>(field.offset()); -} - -// Get a structure's field, if you know it's a struct. -inline const Struct *GetFieldStruct(const Struct &structure, - const reflection::Field &field) { - FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj); - return structure.GetStruct<const Struct *>(field.offset()); -} - +// Get a field, if you know it's a struct. +inline const Struct *GetFieldStruct(const Table &table, + const reflection::Field &field) { + // TODO: This does NOT check if the field is a table or struct, but we'd need + // access to the schema to check the is_struct flag. + FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj); + return table.GetStruct<const Struct *>(field.offset()); +} + +// Get a structure's field, if you know it's a struct. +inline const Struct *GetFieldStruct(const Struct &structure, + const reflection::Field &field) { + FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj); + return structure.GetStruct<const Struct *>(field.offset()); +} + // Raw helper functions used below: get any value in memory as a 64bit int, a // double or a string. // All scalars get static_cast to an int64_t, strings use strtoull, every other @@ -180,7 +180,7 @@ double GetAnyValueF(reflection::BaseType type, const uint8_t *data); // All scalars converted using stringstream, strings as-is, and all other // data types provide some level of debug-pretty-printing. std::string GetAnyValueS(reflection::BaseType type, const uint8_t *data, - const reflection::Schema *schema, int type_index); + const reflection::Schema *schema, int type_index); // Get any table field as a 64bit int, regardless of what type it is. inline int64_t GetAnyFieldI(const Table &table, @@ -191,7 +191,7 @@ inline int64_t GetAnyFieldI(const Table &table, } // Get any table field as a double, regardless of what type it is. -inline double GetAnyFieldF(const Table &table, const reflection::Field &field) { +inline double GetAnyFieldF(const Table &table, const reflection::Field &field) { auto field_ptr = table.GetAddressOf(field.offset()); return field_ptr ? GetAnyValueF(field.type()->base_type(), field_ptr) : field.default_real(); @@ -210,13 +210,13 @@ inline std::string GetAnyFieldS(const Table &table, } // Get any struct field as a 64bit int, regardless of what type it is. -inline int64_t GetAnyFieldI(const Struct &st, const reflection::Field &field) { +inline int64_t GetAnyFieldI(const Struct &st, const reflection::Field &field) { return GetAnyValueI(field.type()->base_type(), st.GetAddressOf(field.offset())); } // Get any struct field as a double, regardless of what type it is. -inline double GetAnyFieldF(const Struct &st, const reflection::Field &field) { +inline double GetAnyFieldF(const Struct &st, const reflection::Field &field) { return GetAnyValueF(field.type()->base_type(), st.GetAddressOf(field.offset())); } @@ -250,8 +250,8 @@ inline std::string GetAnyVectorElemS(const VectorOfAny *vec, // Get a vector element that's a table/string/vector from a generic vector. // Pass Table/String/VectorOfAny as template parameter. // Warning: does no typechecking. -template<typename T> -T *GetAnyVectorElemPointer(const VectorOfAny *vec, size_t i) { +template<typename T> +T *GetAnyVectorElemPointer(const VectorOfAny *vec, size_t i) { auto elem_ptr = vec->Data() + sizeof(uoffset_t) * i; return reinterpret_cast<T *>(elem_ptr + ReadScalar<uoffset_t>(elem_ptr)); } @@ -261,40 +261,40 @@ T *GetAnyVectorElemPointer(const VectorOfAny *vec, size_t i) { // Get elem_size from GetTypeSizeInline(). // Note: little-endian data on all platforms, use EndianScalar() instead of // raw pointer access with scalars). -template<typename T> -T *GetAnyVectorElemAddressOf(const VectorOfAny *vec, size_t i, - size_t elem_size) { +template<typename T> +T *GetAnyVectorElemAddressOf(const VectorOfAny *vec, size_t i, + size_t elem_size) { return reinterpret_cast<T *>(vec->Data() + elem_size * i); } // Similarly, for elements of tables. -template<typename T> -T *GetAnyFieldAddressOf(const Table &table, const reflection::Field &field) { +template<typename T> +T *GetAnyFieldAddressOf(const Table &table, const reflection::Field &field) { return reinterpret_cast<T *>(table.GetAddressOf(field.offset())); } // Similarly, for elements of structs. -template<typename T> -T *GetAnyFieldAddressOf(const Struct &st, const reflection::Field &field) { +template<typename T> +T *GetAnyFieldAddressOf(const Struct &st, const reflection::Field &field) { return reinterpret_cast<T *>(st.GetAddressOf(field.offset())); } // ------------------------- SETTERS ------------------------- // Set any scalar field, if you know its exact type. -template<typename T> -bool SetField(Table *table, const reflection::Field &field, T val) { - reflection::BaseType type = field.type()->base_type(); - if (!IsScalar(type)) { return false; } - FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(type)); - T def; - if (IsInteger(type)) { - def = GetFieldDefaultI<T>(field); - } else { - FLATBUFFERS_ASSERT(IsFloat(type)); - def = GetFieldDefaultF<T>(field); - } - return table->SetField(field.offset(), val, def); +template<typename T> +bool SetField(Table *table, const reflection::Field &field, T val) { + reflection::BaseType type = field.type()->base_type(); + if (!IsScalar(type)) { return false; } + FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(type)); + T def; + if (IsInteger(type)) { + def = GetFieldDefaultI<T>(field); + } else { + FLATBUFFERS_ASSERT(IsFloat(type)); + def = GetFieldDefaultF<T>(field); + } + return table->SetField(field.offset(), val, def); } // Raw helper functions used below: set any value in memory as a 64bit int, a @@ -309,7 +309,7 @@ void SetAnyValueS(reflection::BaseType type, uint8_t *data, const char *val); inline bool SetAnyFieldI(Table *table, const reflection::Field &field, int64_t val) { auto field_ptr = table->GetAddressOf(field.offset()); - if (!field_ptr) return val == GetFieldDefaultI<int64_t>(field); + if (!field_ptr) return val == GetFieldDefaultI<int64_t>(field); SetAnyValueI(field.type()->base_type(), field_ptr, val); return true; } @@ -318,14 +318,14 @@ inline bool SetAnyFieldI(Table *table, const reflection::Field &field, inline bool SetAnyFieldF(Table *table, const reflection::Field &field, double val) { auto field_ptr = table->GetAddressOf(field.offset()); - if (!field_ptr) return val == GetFieldDefaultF<double>(field); + if (!field_ptr) return val == GetFieldDefaultF<double>(field); SetAnyValueF(field.type()->base_type(), field_ptr, val); return true; } // Set any table field as a string, regardless of what type it is. inline bool SetAnyFieldS(Table *table, const reflection::Field &field, - const char *val) { + const char *val) { auto field_ptr = table->GetAddressOf(field.offset()); if (!field_ptr) return false; SetAnyValueS(field.type()->base_type(), field_ptr, val); @@ -378,29 +378,29 @@ inline void SetAnyVectorElemS(VectorOfAny *vec, reflection::BaseType elem_type, template<typename T, typename U> class pointer_inside_vector { public: pointer_inside_vector(T *ptr, std::vector<U> &vec) - : offset_(reinterpret_cast<uint8_t *>(ptr) - - reinterpret_cast<uint8_t *>(flatbuffers::vector_data(vec))), - vec_(vec) {} + : offset_(reinterpret_cast<uint8_t *>(ptr) - + reinterpret_cast<uint8_t *>(flatbuffers::vector_data(vec))), + vec_(vec) {} T *operator*() const { return reinterpret_cast<T *>( - reinterpret_cast<uint8_t *>(flatbuffers::vector_data(vec_)) + offset_); + reinterpret_cast<uint8_t *>(flatbuffers::vector_data(vec_)) + offset_); } - T *operator->() const { return operator*(); } - + T *operator->() const { return operator*(); } + private: size_t offset_; std::vector<U> &vec_; }; // Helper to create the above easily without specifying template args. -template<typename T, typename U> -pointer_inside_vector<T, U> piv(T *ptr, std::vector<U> &vec) { +template<typename T, typename U> +pointer_inside_vector<T, U> piv(T *ptr, std::vector<U> &vec) { return pointer_inside_vector<T, U>(ptr, vec); } -inline const char *UnionTypeFieldSuffix() { return "_type"; } - +inline const char *UnionTypeFieldSuffix() { return "_type"; } + // Helper to figure out the actual table type a union refers to. inline const reflection::Object &GetUnionType( const reflection::Schema &schema, const reflection::Object &parent, @@ -408,8 +408,8 @@ inline const reflection::Object &GetUnionType( auto enumdef = schema.enums()->Get(unionfield.type()->index()); // TODO: this is clumsy and slow, but no other way to find it? auto type_field = parent.fields()->LookupByKey( - (unionfield.name()->str() + UnionTypeFieldSuffix()).c_str()); - FLATBUFFERS_ASSERT(type_field); + (unionfield.name()->str() + UnionTypeFieldSuffix()).c_str()); + FLATBUFFERS_ASSERT(type_field); auto union_type = GetFieldI<uint8_t>(table, *type_field); auto enumval = enumdef->values()->LookupByKey(union_type); return *enumval->object(); @@ -434,18 +434,18 @@ uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, uoffset_t elem_size, std::vector<uint8_t> *flatbuf, const reflection::Object *root_table = nullptr); -template<typename T> +template<typename T> void ResizeVector(const reflection::Schema &schema, uoffset_t newsize, T val, const Vector<T> *vec, std::vector<uint8_t> *flatbuf, const reflection::Object *root_table = nullptr) { auto delta_elem = static_cast<int>(newsize) - static_cast<int>(vec->size()); - auto newelems = ResizeAnyVector( - schema, newsize, reinterpret_cast<const VectorOfAny *>(vec), vec->size(), - static_cast<uoffset_t>(sizeof(T)), flatbuf, root_table); + auto newelems = ResizeAnyVector( + schema, newsize, reinterpret_cast<const VectorOfAny *>(vec), vec->size(), + static_cast<uoffset_t>(sizeof(T)), flatbuf, root_table); // Set new elements to "val". for (int i = 0; i < delta_elem; i++) { auto loc = newelems + i * sizeof(T); - auto is_scalar = flatbuffers::is_scalar<T>::value; + auto is_scalar = flatbuffers::is_scalar<T>::value; if (is_scalar) { WriteScalar(loc, val); } else { // struct @@ -467,8 +467,8 @@ const uint8_t *AddFlatBuffer(std::vector<uint8_t> &flatbuf, inline bool SetFieldT(Table *table, const reflection::Field &field, const uint8_t *val) { - FLATBUFFERS_ASSERT(sizeof(uoffset_t) == - GetTypeSize(field.type()->base_type())); + FLATBUFFERS_ASSERT(sizeof(uoffset_t) == + GetTypeSize(field.type()->base_type())); return table->SetPointer(field.offset(), val); } @@ -480,23 +480,23 @@ inline bool SetFieldT(Table *table, const reflection::Field &field, // above resizing functionality has introduced garbage in a buffer you want // to remove. // Note: this does not deal with DAGs correctly. If the table passed forms a -// DAG, the copy will be a tree instead (with duplicates). Strings can be -// shared however, by passing true for use_string_pooling. +// DAG, the copy will be a tree instead (with duplicates). Strings can be +// shared however, by passing true for use_string_pooling. Offset<const Table *> CopyTable(FlatBufferBuilder &fbb, const reflection::Schema &schema, const reflection::Object &objectdef, - const Table &table, - bool use_string_pooling = false); - -// Verifies the provided flatbuffer using reflection. -// root should point to the root type for this flatbuffer. -// buf should point to the start of flatbuffer data. -// length specifies the size of the flatbuffer data. -bool Verify(const reflection::Schema &schema, const reflection::Object &root, + const Table &table, + bool use_string_pooling = false); + +// Verifies the provided flatbuffer using reflection. +// root should point to the root type for this flatbuffer. +// buf should point to the start of flatbuffer data. +// length specifies the size of the flatbuffer data. +bool Verify(const reflection::Schema &schema, const reflection::Object &root, const uint8_t *buf, size_t length, uoffset_t max_depth = 64, uoffset_t max_tables = 1000000); - + } // namespace flatbuffers #endif // FLATBUFFERS_REFLECTION_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h b/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h index 93dc4b88b7..a95f7b055f 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h @@ -1,6 +1,6 @@ // automatically generated by the FlatBuffers compiler, do not modify - + #ifndef FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_ #define FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_ @@ -10,28 +10,28 @@ namespace reflection { struct Type; struct TypeBuilder; - -struct KeyValue; + +struct KeyValue; struct KeyValueBuilder; - + struct EnumVal; struct EnumValBuilder; - + struct Enum; struct EnumBuilder; - + struct Field; struct FieldBuilder; - + struct Object; struct ObjectBuilder; - -struct RPCCall; + +struct RPCCall; struct RPCCallBuilder; - -struct Service; + +struct Service; struct ServiceBuilder; - + struct Schema; struct SchemaBuilder; @@ -58,61 +58,61 @@ enum BaseType { }; inline const BaseType (&EnumValuesBaseType())[19] { - static const BaseType values[] = { - None, - UType, - Bool, - Byte, - UByte, - Short, - UShort, - Int, - UInt, - Long, - ULong, - Float, - Double, - String, - Vector, - Obj, + static const BaseType values[] = { + None, + UType, + Bool, + Byte, + UByte, + Short, + UShort, + Int, + UInt, + Long, + ULong, + Float, + Double, + String, + Vector, + Obj, Union, Array, MaxBaseType - }; - return values; -} - -inline const char * const *EnumNamesBaseType() { + }; + return values; +} + +inline const char * const *EnumNamesBaseType() { static const char * const names[20] = { - "None", - "UType", - "Bool", - "Byte", - "UByte", - "Short", - "UShort", - "Int", - "UInt", - "Long", - "ULong", - "Float", - "Double", - "String", - "Vector", - "Obj", - "Union", + "None", + "UType", + "Bool", + "Byte", + "UByte", + "Short", + "UShort", + "Int", + "UInt", + "Long", + "ULong", + "Float", + "Double", + "String", + "Vector", + "Obj", + "Union", "Array", "MaxBaseType", - nullptr - }; + nullptr + }; return names; } -inline const char *EnumNameBaseType(BaseType e) { +inline const char *EnumNameBaseType(BaseType e) { if (flatbuffers::IsOutRange(e, None, MaxBaseType)) return ""; const size_t index = static_cast<size_t>(e); - return EnumNamesBaseType()[index]; -} + return EnumNamesBaseType()[index]; +} enum AdvancedFeatures { AdvancedArrayFeatures = 1ULL, @@ -155,28 +155,28 @@ inline const char *EnumNameAdvancedFeatures(AdvancedFeatures e) { struct Type FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TypeBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_BASE_TYPE = 4, - VT_ELEMENT = 6, + VT_BASE_TYPE = 4, + VT_ELEMENT = 6, VT_INDEX = 8, VT_FIXED_LENGTH = 10 - }; + }; reflection::BaseType base_type() const { return static_cast<reflection::BaseType>(GetField<int8_t>(VT_BASE_TYPE, 0)); - } + } reflection::BaseType element() const { return static_cast<reflection::BaseType>(GetField<int8_t>(VT_ELEMENT, 0)); - } - int32_t index() const { - return GetField<int32_t>(VT_INDEX, -1); - } + } + int32_t index() const { + return GetField<int32_t>(VT_INDEX, -1); + } uint16_t fixed_length() const { return GetField<uint16_t>(VT_FIXED_LENGTH, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField<int8_t>(verifier, VT_BASE_TYPE) && - VerifyField<int8_t>(verifier, VT_ELEMENT) && - VerifyField<int32_t>(verifier, VT_INDEX) && + VerifyField<int8_t>(verifier, VT_BASE_TYPE) && + VerifyField<int8_t>(verifier, VT_ELEMENT) && + VerifyField<int32_t>(verifier, VT_INDEX) && VerifyField<uint16_t>(verifier, VT_FIXED_LENGTH) && verifier.EndTable(); } @@ -187,30 +187,30 @@ struct TypeBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_base_type(reflection::BaseType base_type) { - fbb_.AddElement<int8_t>(Type::VT_BASE_TYPE, static_cast<int8_t>(base_type), 0); - } + fbb_.AddElement<int8_t>(Type::VT_BASE_TYPE, static_cast<int8_t>(base_type), 0); + } void add_element(reflection::BaseType element) { - fbb_.AddElement<int8_t>(Type::VT_ELEMENT, static_cast<int8_t>(element), 0); - } - void add_index(int32_t index) { - fbb_.AddElement<int32_t>(Type::VT_INDEX, index, -1); - } + fbb_.AddElement<int8_t>(Type::VT_ELEMENT, static_cast<int8_t>(element), 0); + } + void add_index(int32_t index) { + fbb_.AddElement<int32_t>(Type::VT_INDEX, index, -1); + } void add_fixed_length(uint16_t fixed_length) { fbb_.AddElement<uint16_t>(Type::VT_FIXED_LENGTH, fixed_length, 0); } - explicit TypeBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } + explicit TypeBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } flatbuffers::Offset<Type> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Type>(end); + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<Type>(end); return o; } }; -inline flatbuffers::Offset<Type> CreateType( - flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset<Type> CreateType( + flatbuffers::FlatBufferBuilder &_fbb, reflection::BaseType base_type = reflection::None, reflection::BaseType element = reflection::None, int32_t index = -1, @@ -223,120 +223,120 @@ inline flatbuffers::Offset<Type> CreateType( return builder_.Finish(); } -struct KeyValue FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { +struct KeyValue FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef KeyValueBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_KEY = 4, - VT_VALUE = 6 - }; - const flatbuffers::String *key() const { - return GetPointer<const flatbuffers::String *>(VT_KEY); - } - bool KeyCompareLessThan(const KeyValue *o) const { - return *key() < *o->key(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(key()->c_str(), val); - } - const flatbuffers::String *value() const { - return GetPointer<const flatbuffers::String *>(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_KEY) && - verifier.VerifyString(key()) && - VerifyOffset(verifier, VT_VALUE) && - verifier.VerifyString(value()) && - verifier.EndTable(); - } -}; - -struct KeyValueBuilder { + VT_KEY = 4, + VT_VALUE = 6 + }; + const flatbuffers::String *key() const { + return GetPointer<const flatbuffers::String *>(VT_KEY); + } + bool KeyCompareLessThan(const KeyValue *o) const { + return *key() < *o->key(); + } + int KeyCompareWithValue(const char *val) const { + return strcmp(key()->c_str(), val); + } + const flatbuffers::String *value() const { + return GetPointer<const flatbuffers::String *>(VT_VALUE); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffsetRequired(verifier, VT_KEY) && + verifier.VerifyString(key()) && + VerifyOffset(verifier, VT_VALUE) && + verifier.VerifyString(value()) && + verifier.EndTable(); + } +}; + +struct KeyValueBuilder { typedef KeyValue Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_key(flatbuffers::Offset<flatbuffers::String> key) { - fbb_.AddOffset(KeyValue::VT_KEY, key); - } - void add_value(flatbuffers::Offset<flatbuffers::String> value) { - fbb_.AddOffset(KeyValue::VT_VALUE, value); - } - explicit KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset<KeyValue> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<KeyValue>(end); - fbb_.Required(o, KeyValue::VT_KEY); - return o; - } -}; - -inline flatbuffers::Offset<KeyValue> CreateKeyValue( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> key = 0, - flatbuffers::Offset<flatbuffers::String> value = 0) { - KeyValueBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_key(key); - return builder_.Finish(); -} - -inline flatbuffers::Offset<KeyValue> CreateKeyValueDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *key = nullptr, - const char *value = nullptr) { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_key(flatbuffers::Offset<flatbuffers::String> key) { + fbb_.AddOffset(KeyValue::VT_KEY, key); + } + void add_value(flatbuffers::Offset<flatbuffers::String> value) { + fbb_.AddOffset(KeyValue::VT_VALUE, value); + } + explicit KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset<KeyValue> Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<KeyValue>(end); + fbb_.Required(o, KeyValue::VT_KEY); + return o; + } +}; + +inline flatbuffers::Offset<KeyValue> CreateKeyValue( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> key = 0, + flatbuffers::Offset<flatbuffers::String> value = 0) { + KeyValueBuilder builder_(_fbb); + builder_.add_value(value); + builder_.add_key(key); + return builder_.Finish(); +} + +inline flatbuffers::Offset<KeyValue> CreateKeyValueDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *key = nullptr, + const char *value = nullptr) { auto key__ = key ? _fbb.CreateString(key) : 0; auto value__ = value ? _fbb.CreateString(value) : 0; - return reflection::CreateKeyValue( - _fbb, + return reflection::CreateKeyValue( + _fbb, key__, value__); -} - +} + struct EnumVal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef EnumValBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_VALUE = 6, - VT_OBJECT = 8, - VT_UNION_TYPE = 10, - VT_DOCUMENTATION = 12 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - int64_t value() const { - return GetField<int64_t>(VT_VALUE, 0); - } - bool KeyCompareLessThan(const EnumVal *o) const { - return value() < o->value(); - } - int KeyCompareWithValue(int64_t val) const { - return static_cast<int>(value() > val) - static_cast<int>(value() < val); - } + VT_NAME = 4, + VT_VALUE = 6, + VT_OBJECT = 8, + VT_UNION_TYPE = 10, + VT_DOCUMENTATION = 12 + }; + const flatbuffers::String *name() const { + return GetPointer<const flatbuffers::String *>(VT_NAME); + } + int64_t value() const { + return GetField<int64_t>(VT_VALUE, 0); + } + bool KeyCompareLessThan(const EnumVal *o) const { + return value() < o->value(); + } + int KeyCompareWithValue(int64_t val) const { + return static_cast<int>(value() > val) - static_cast<int>(value() < val); + } const reflection::Object *object() const { return GetPointer<const reflection::Object *>(VT_OBJECT); - } + } const reflection::Type *union_type() const { return GetPointer<const reflection::Type *>(VT_UNION_TYPE); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } + } + const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { + return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyField<int64_t>(verifier, VT_VALUE) && - VerifyOffset(verifier, VT_OBJECT) && + VerifyOffsetRequired(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField<int64_t>(verifier, VT_VALUE) && + VerifyOffset(verifier, VT_OBJECT) && verifier.VerifyTable(object()) && - VerifyOffset(verifier, VT_UNION_TYPE) && - verifier.VerifyTable(union_type()) && - VerifyOffset(verifier, VT_DOCUMENTATION) && - verifier.VerifyVector(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && + VerifyOffset(verifier, VT_UNION_TYPE) && + verifier.VerifyTable(union_type()) && + VerifyOffset(verifier, VT_DOCUMENTATION) && + verifier.VerifyVector(documentation()) && + verifier.VerifyVectorOfStrings(documentation()) && verifier.EndTable(); } }; @@ -345,117 +345,117 @@ struct EnumValBuilder { typedef EnumVal Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(EnumVal::VT_NAME, name); - } - void add_value(int64_t value) { - fbb_.AddElement<int64_t>(EnumVal::VT_VALUE, value, 0); - } + void add_name(flatbuffers::Offset<flatbuffers::String> name) { + fbb_.AddOffset(EnumVal::VT_NAME, name); + } + void add_value(int64_t value) { + fbb_.AddElement<int64_t>(EnumVal::VT_VALUE, value, 0); + } void add_object(flatbuffers::Offset<reflection::Object> object) { - fbb_.AddOffset(EnumVal::VT_OBJECT, object); - } + fbb_.AddOffset(EnumVal::VT_OBJECT, object); + } void add_union_type(flatbuffers::Offset<reflection::Type> union_type) { - fbb_.AddOffset(EnumVal::VT_UNION_TYPE, union_type); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(EnumVal::VT_DOCUMENTATION, documentation); - } - explicit EnumValBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } + fbb_.AddOffset(EnumVal::VT_UNION_TYPE, union_type); + } + void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { + fbb_.AddOffset(EnumVal::VT_DOCUMENTATION, documentation); + } + explicit EnumValBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } flatbuffers::Offset<EnumVal> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<EnumVal>(end); - fbb_.Required(o, EnumVal::VT_NAME); + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<EnumVal>(end); + fbb_.Required(o, EnumVal::VT_NAME); return o; } }; -inline flatbuffers::Offset<EnumVal> CreateEnumVal( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - int64_t value = 0, +inline flatbuffers::Offset<EnumVal> CreateEnumVal( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> name = 0, + int64_t value = 0, flatbuffers::Offset<reflection::Object> object = 0, flatbuffers::Offset<reflection::Type> union_type = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { + flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { EnumValBuilder builder_(_fbb); builder_.add_value(value); - builder_.add_documentation(documentation); - builder_.add_union_type(union_type); + builder_.add_documentation(documentation); + builder_.add_union_type(union_type); builder_.add_object(object); builder_.add_name(name); return builder_.Finish(); } -inline flatbuffers::Offset<EnumVal> CreateEnumValDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - int64_t value = 0, +inline flatbuffers::Offset<EnumVal> CreateEnumValDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, + int64_t value = 0, flatbuffers::Offset<reflection::Object> object = 0, flatbuffers::Offset<reflection::Type> union_type = 0, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { + const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { auto name__ = name ? _fbb.CreateString(name) : 0; auto documentation__ = documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0; - return reflection::CreateEnumVal( - _fbb, + return reflection::CreateEnumVal( + _fbb, name__, - value, - object, - union_type, + value, + object, + union_type, documentation__); -} - +} + struct Enum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef EnumBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_VALUES = 6, - VT_IS_UNION = 8, - VT_UNDERLYING_TYPE = 10, - VT_ATTRIBUTES = 12, - VT_DOCUMENTATION = 14 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Enum *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } + VT_NAME = 4, + VT_VALUES = 6, + VT_IS_UNION = 8, + VT_UNDERLYING_TYPE = 10, + VT_ATTRIBUTES = 12, + VT_DOCUMENTATION = 14 + }; + const flatbuffers::String *name() const { + return GetPointer<const flatbuffers::String *>(VT_NAME); + } + bool KeyCompareLessThan(const Enum *o) const { + return *name() < *o->name(); + } + int KeyCompareWithValue(const char *val) const { + return strcmp(name()->c_str(), val); + } const flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>> *values() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>> *>(VT_VALUES); - } - bool is_union() const { - return GetField<uint8_t>(VT_IS_UNION, 0) != 0; - } + } + bool is_union() const { + return GetField<uint8_t>(VT_IS_UNION, 0) != 0; + } const reflection::Type *underlying_type() const { return GetPointer<const reflection::Type *>(VT_UNDERLYING_TYPE); - } + } const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *attributes() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } + } + const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { + return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffsetRequired(verifier, VT_VALUES) && - verifier.VerifyVector(values()) && + VerifyOffsetRequired(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyOffsetRequired(verifier, VT_VALUES) && + verifier.VerifyVector(values()) && verifier.VerifyVectorOfTables(values()) && - VerifyField<uint8_t>(verifier, VT_IS_UNION) && - VerifyOffsetRequired(verifier, VT_UNDERLYING_TYPE) && + VerifyField<uint8_t>(verifier, VT_IS_UNION) && + VerifyOffsetRequired(verifier, VT_UNDERLYING_TYPE) && verifier.VerifyTable(underlying_type()) && - VerifyOffset(verifier, VT_ATTRIBUTES) && - verifier.VerifyVector(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyOffset(verifier, VT_DOCUMENTATION) && - verifier.VerifyVector(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && + VerifyOffset(verifier, VT_ATTRIBUTES) && + verifier.VerifyVector(attributes()) && + verifier.VerifyVectorOfTables(attributes()) && + VerifyOffset(verifier, VT_DOCUMENTATION) && + verifier.VerifyVector(documentation()) && + verifier.VerifyVectorOfStrings(documentation()) && verifier.EndTable(); } }; @@ -464,49 +464,49 @@ struct EnumBuilder { typedef Enum Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Enum::VT_NAME, name); - } + void add_name(flatbuffers::Offset<flatbuffers::String> name) { + fbb_.AddOffset(Enum::VT_NAME, name); + } void add_values(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>>> values) { - fbb_.AddOffset(Enum::VT_VALUES, values); - } - void add_is_union(bool is_union) { - fbb_.AddElement<uint8_t>(Enum::VT_IS_UNION, static_cast<uint8_t>(is_union), 0); - } + fbb_.AddOffset(Enum::VT_VALUES, values); + } + void add_is_union(bool is_union) { + fbb_.AddElement<uint8_t>(Enum::VT_IS_UNION, static_cast<uint8_t>(is_union), 0); + } void add_underlying_type(flatbuffers::Offset<reflection::Type> underlying_type) { - fbb_.AddOffset(Enum::VT_UNDERLYING_TYPE, underlying_type); - } + fbb_.AddOffset(Enum::VT_UNDERLYING_TYPE, underlying_type); + } void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes) { - fbb_.AddOffset(Enum::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Enum::VT_DOCUMENTATION, documentation); - } - explicit EnumBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } + fbb_.AddOffset(Enum::VT_ATTRIBUTES, attributes); + } + void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { + fbb_.AddOffset(Enum::VT_DOCUMENTATION, documentation); + } + explicit EnumBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } flatbuffers::Offset<Enum> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Enum>(end); - fbb_.Required(o, Enum::VT_NAME); - fbb_.Required(o, Enum::VT_VALUES); - fbb_.Required(o, Enum::VT_UNDERLYING_TYPE); + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<Enum>(end); + fbb_.Required(o, Enum::VT_NAME); + fbb_.Required(o, Enum::VT_VALUES); + fbb_.Required(o, Enum::VT_UNDERLYING_TYPE); return o; } }; -inline flatbuffers::Offset<Enum> CreateEnum( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, +inline flatbuffers::Offset<Enum> CreateEnum( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> name = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>>> values = 0, - bool is_union = false, + bool is_union = false, flatbuffers::Offset<reflection::Type> underlying_type = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { + flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { EnumBuilder builder_(_fbb); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); + builder_.add_documentation(documentation); + builder_.add_attributes(attributes); builder_.add_underlying_type(underlying_type); builder_.add_values(values); builder_.add_name(name); @@ -514,105 +514,105 @@ inline flatbuffers::Offset<Enum> CreateEnum( return builder_.Finish(); } -inline flatbuffers::Offset<Enum> CreateEnumDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, +inline flatbuffers::Offset<Enum> CreateEnumDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, std::vector<flatbuffers::Offset<reflection::EnumVal>> *values = nullptr, - bool is_union = false, + bool is_union = false, flatbuffers::Offset<reflection::Type> underlying_type = 0, std::vector<flatbuffers::Offset<reflection::KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { + const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { auto name__ = name ? _fbb.CreateString(name) : 0; auto values__ = values ? _fbb.CreateVectorOfSortedTables<reflection::EnumVal>(values) : 0; auto attributes__ = attributes ? _fbb.CreateVectorOfSortedTables<reflection::KeyValue>(attributes) : 0; auto documentation__ = documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0; - return reflection::CreateEnum( - _fbb, + return reflection::CreateEnum( + _fbb, name__, values__, - is_union, - underlying_type, + is_union, + underlying_type, attributes__, documentation__); -} - +} + struct Field FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef FieldBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_TYPE = 6, - VT_ID = 8, - VT_OFFSET = 10, - VT_DEFAULT_INTEGER = 12, - VT_DEFAULT_REAL = 14, - VT_DEPRECATED = 16, - VT_REQUIRED = 18, - VT_KEY = 20, - VT_ATTRIBUTES = 22, + VT_NAME = 4, + VT_TYPE = 6, + VT_ID = 8, + VT_OFFSET = 10, + VT_DEFAULT_INTEGER = 12, + VT_DEFAULT_REAL = 14, + VT_DEPRECATED = 16, + VT_REQUIRED = 18, + VT_KEY = 20, + VT_ATTRIBUTES = 22, VT_DOCUMENTATION = 24, VT_OPTIONAL = 26 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Field *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } + }; + const flatbuffers::String *name() const { + return GetPointer<const flatbuffers::String *>(VT_NAME); + } + bool KeyCompareLessThan(const Field *o) const { + return *name() < *o->name(); + } + int KeyCompareWithValue(const char *val) const { + return strcmp(name()->c_str(), val); + } const reflection::Type *type() const { return GetPointer<const reflection::Type *>(VT_TYPE); - } - uint16_t id() const { - return GetField<uint16_t>(VT_ID, 0); - } - uint16_t offset() const { - return GetField<uint16_t>(VT_OFFSET, 0); - } - int64_t default_integer() const { - return GetField<int64_t>(VT_DEFAULT_INTEGER, 0); - } - double default_real() const { - return GetField<double>(VT_DEFAULT_REAL, 0.0); - } - bool deprecated() const { - return GetField<uint8_t>(VT_DEPRECATED, 0) != 0; - } - bool required() const { - return GetField<uint8_t>(VT_REQUIRED, 0) != 0; - } - bool key() const { - return GetField<uint8_t>(VT_KEY, 0) != 0; - } + } + uint16_t id() const { + return GetField<uint16_t>(VT_ID, 0); + } + uint16_t offset() const { + return GetField<uint16_t>(VT_OFFSET, 0); + } + int64_t default_integer() const { + return GetField<int64_t>(VT_DEFAULT_INTEGER, 0); + } + double default_real() const { + return GetField<double>(VT_DEFAULT_REAL, 0.0); + } + bool deprecated() const { + return GetField<uint8_t>(VT_DEPRECATED, 0) != 0; + } + bool required() const { + return GetField<uint8_t>(VT_REQUIRED, 0) != 0; + } + bool key() const { + return GetField<uint8_t>(VT_KEY, 0) != 0; + } const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *attributes() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } + } + const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { + return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); + } bool optional() const { return GetField<uint8_t>(VT_OPTIONAL, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffsetRequired(verifier, VT_TYPE) && + VerifyOffsetRequired(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyOffsetRequired(verifier, VT_TYPE) && verifier.VerifyTable(type()) && - VerifyField<uint16_t>(verifier, VT_ID) && - VerifyField<uint16_t>(verifier, VT_OFFSET) && - VerifyField<int64_t>(verifier, VT_DEFAULT_INTEGER) && - VerifyField<double>(verifier, VT_DEFAULT_REAL) && - VerifyField<uint8_t>(verifier, VT_DEPRECATED) && - VerifyField<uint8_t>(verifier, VT_REQUIRED) && - VerifyField<uint8_t>(verifier, VT_KEY) && - VerifyOffset(verifier, VT_ATTRIBUTES) && - verifier.VerifyVector(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyOffset(verifier, VT_DOCUMENTATION) && - verifier.VerifyVector(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && + VerifyField<uint16_t>(verifier, VT_ID) && + VerifyField<uint16_t>(verifier, VT_OFFSET) && + VerifyField<int64_t>(verifier, VT_DEFAULT_INTEGER) && + VerifyField<double>(verifier, VT_DEFAULT_REAL) && + VerifyField<uint8_t>(verifier, VT_DEPRECATED) && + VerifyField<uint8_t>(verifier, VT_REQUIRED) && + VerifyField<uint8_t>(verifier, VT_KEY) && + VerifyOffset(verifier, VT_ATTRIBUTES) && + verifier.VerifyVector(attributes()) && + verifier.VerifyVectorOfTables(attributes()) && + VerifyOffset(verifier, VT_DOCUMENTATION) && + verifier.VerifyVector(documentation()) && + verifier.VerifyVectorOfStrings(documentation()) && VerifyField<uint8_t>(verifier, VT_OPTIONAL) && verifier.EndTable(); } @@ -622,74 +622,74 @@ struct FieldBuilder { typedef Field Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Field::VT_NAME, name); - } + void add_name(flatbuffers::Offset<flatbuffers::String> name) { + fbb_.AddOffset(Field::VT_NAME, name); + } void add_type(flatbuffers::Offset<reflection::Type> type) { - fbb_.AddOffset(Field::VT_TYPE, type); - } - void add_id(uint16_t id) { - fbb_.AddElement<uint16_t>(Field::VT_ID, id, 0); - } - void add_offset(uint16_t offset) { - fbb_.AddElement<uint16_t>(Field::VT_OFFSET, offset, 0); - } - void add_default_integer(int64_t default_integer) { - fbb_.AddElement<int64_t>(Field::VT_DEFAULT_INTEGER, default_integer, 0); - } - void add_default_real(double default_real) { - fbb_.AddElement<double>(Field::VT_DEFAULT_REAL, default_real, 0.0); - } - void add_deprecated(bool deprecated) { - fbb_.AddElement<uint8_t>(Field::VT_DEPRECATED, static_cast<uint8_t>(deprecated), 0); - } - void add_required(bool required) { - fbb_.AddElement<uint8_t>(Field::VT_REQUIRED, static_cast<uint8_t>(required), 0); - } - void add_key(bool key) { - fbb_.AddElement<uint8_t>(Field::VT_KEY, static_cast<uint8_t>(key), 0); - } + fbb_.AddOffset(Field::VT_TYPE, type); + } + void add_id(uint16_t id) { + fbb_.AddElement<uint16_t>(Field::VT_ID, id, 0); + } + void add_offset(uint16_t offset) { + fbb_.AddElement<uint16_t>(Field::VT_OFFSET, offset, 0); + } + void add_default_integer(int64_t default_integer) { + fbb_.AddElement<int64_t>(Field::VT_DEFAULT_INTEGER, default_integer, 0); + } + void add_default_real(double default_real) { + fbb_.AddElement<double>(Field::VT_DEFAULT_REAL, default_real, 0.0); + } + void add_deprecated(bool deprecated) { + fbb_.AddElement<uint8_t>(Field::VT_DEPRECATED, static_cast<uint8_t>(deprecated), 0); + } + void add_required(bool required) { + fbb_.AddElement<uint8_t>(Field::VT_REQUIRED, static_cast<uint8_t>(required), 0); + } + void add_key(bool key) { + fbb_.AddElement<uint8_t>(Field::VT_KEY, static_cast<uint8_t>(key), 0); + } void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes) { - fbb_.AddOffset(Field::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Field::VT_DOCUMENTATION, documentation); - } + fbb_.AddOffset(Field::VT_ATTRIBUTES, attributes); + } + void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { + fbb_.AddOffset(Field::VT_DOCUMENTATION, documentation); + } void add_optional(bool optional) { fbb_.AddElement<uint8_t>(Field::VT_OPTIONAL, static_cast<uint8_t>(optional), 0); } - explicit FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } + explicit FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } flatbuffers::Offset<Field> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Field>(end); - fbb_.Required(o, Field::VT_NAME); - fbb_.Required(o, Field::VT_TYPE); + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<Field>(end); + fbb_.Required(o, Field::VT_NAME); + fbb_.Required(o, Field::VT_TYPE); return o; } }; -inline flatbuffers::Offset<Field> CreateField( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, +inline flatbuffers::Offset<Field> CreateField( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> name = 0, flatbuffers::Offset<reflection::Type> type = 0, - uint16_t id = 0, - uint16_t offset = 0, - int64_t default_integer = 0, - double default_real = 0.0, - bool deprecated = false, - bool required = false, - bool key = false, + uint16_t id = 0, + uint16_t offset = 0, + int64_t default_integer = 0, + double default_real = 0.0, + bool deprecated = false, + bool required = false, + bool key = false, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0, bool optional = false) { FieldBuilder builder_(_fbb); builder_.add_default_real(default_real); builder_.add_default_integer(default_integer); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); + builder_.add_documentation(documentation); + builder_.add_attributes(attributes); builder_.add_type(type); builder_.add_name(name); builder_.add_offset(offset); @@ -701,93 +701,93 @@ inline flatbuffers::Offset<Field> CreateField( return builder_.Finish(); } -inline flatbuffers::Offset<Field> CreateFieldDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, +inline flatbuffers::Offset<Field> CreateFieldDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, flatbuffers::Offset<reflection::Type> type = 0, - uint16_t id = 0, - uint16_t offset = 0, - int64_t default_integer = 0, - double default_real = 0.0, - bool deprecated = false, - bool required = false, - bool key = false, + uint16_t id = 0, + uint16_t offset = 0, + int64_t default_integer = 0, + double default_real = 0.0, + bool deprecated = false, + bool required = false, + bool key = false, std::vector<flatbuffers::Offset<reflection::KeyValue>> *attributes = nullptr, const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr, bool optional = false) { auto name__ = name ? _fbb.CreateString(name) : 0; auto attributes__ = attributes ? _fbb.CreateVectorOfSortedTables<reflection::KeyValue>(attributes) : 0; auto documentation__ = documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0; - return reflection::CreateField( - _fbb, + return reflection::CreateField( + _fbb, name__, - type, - id, - offset, - default_integer, - default_real, - deprecated, - required, - key, + type, + id, + offset, + default_integer, + default_real, + deprecated, + required, + key, attributes__, documentation__, optional); -} - +} + struct Object FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ObjectBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_FIELDS = 6, - VT_IS_STRUCT = 8, - VT_MINALIGN = 10, - VT_BYTESIZE = 12, - VT_ATTRIBUTES = 14, - VT_DOCUMENTATION = 16 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Object *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } + VT_NAME = 4, + VT_FIELDS = 6, + VT_IS_STRUCT = 8, + VT_MINALIGN = 10, + VT_BYTESIZE = 12, + VT_ATTRIBUTES = 14, + VT_DOCUMENTATION = 16 + }; + const flatbuffers::String *name() const { + return GetPointer<const flatbuffers::String *>(VT_NAME); + } + bool KeyCompareLessThan(const Object *o) const { + return *name() < *o->name(); + } + int KeyCompareWithValue(const char *val) const { + return strcmp(name()->c_str(), val); + } const flatbuffers::Vector<flatbuffers::Offset<reflection::Field>> *fields() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::Field>> *>(VT_FIELDS); - } - bool is_struct() const { - return GetField<uint8_t>(VT_IS_STRUCT, 0) != 0; - } - int32_t minalign() const { - return GetField<int32_t>(VT_MINALIGN, 0); - } - int32_t bytesize() const { - return GetField<int32_t>(VT_BYTESIZE, 0); - } + } + bool is_struct() const { + return GetField<uint8_t>(VT_IS_STRUCT, 0) != 0; + } + int32_t minalign() const { + return GetField<int32_t>(VT_MINALIGN, 0); + } + int32_t bytesize() const { + return GetField<int32_t>(VT_BYTESIZE, 0); + } const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *attributes() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } + } + const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { + return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffsetRequired(verifier, VT_FIELDS) && - verifier.VerifyVector(fields()) && + VerifyOffsetRequired(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyOffsetRequired(verifier, VT_FIELDS) && + verifier.VerifyVector(fields()) && verifier.VerifyVectorOfTables(fields()) && - VerifyField<uint8_t>(verifier, VT_IS_STRUCT) && - VerifyField<int32_t>(verifier, VT_MINALIGN) && - VerifyField<int32_t>(verifier, VT_BYTESIZE) && - VerifyOffset(verifier, VT_ATTRIBUTES) && - verifier.VerifyVector(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyOffset(verifier, VT_DOCUMENTATION) && - verifier.VerifyVector(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && + VerifyField<uint8_t>(verifier, VT_IS_STRUCT) && + VerifyField<int32_t>(verifier, VT_MINALIGN) && + VerifyField<int32_t>(verifier, VT_BYTESIZE) && + VerifyOffset(verifier, VT_ATTRIBUTES) && + verifier.VerifyVector(attributes()) && + verifier.VerifyVectorOfTables(attributes()) && + VerifyOffset(verifier, VT_DOCUMENTATION) && + verifier.VerifyVector(documentation()) && + verifier.VerifyVectorOfStrings(documentation()) && verifier.EndTable(); } }; @@ -796,52 +796,52 @@ struct ObjectBuilder { typedef Object Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Object::VT_NAME, name); - } + void add_name(flatbuffers::Offset<flatbuffers::String> name) { + fbb_.AddOffset(Object::VT_NAME, name); + } void add_fields(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>>> fields) { - fbb_.AddOffset(Object::VT_FIELDS, fields); - } - void add_is_struct(bool is_struct) { - fbb_.AddElement<uint8_t>(Object::VT_IS_STRUCT, static_cast<uint8_t>(is_struct), 0); - } - void add_minalign(int32_t minalign) { - fbb_.AddElement<int32_t>(Object::VT_MINALIGN, minalign, 0); - } - void add_bytesize(int32_t bytesize) { - fbb_.AddElement<int32_t>(Object::VT_BYTESIZE, bytesize, 0); - } + fbb_.AddOffset(Object::VT_FIELDS, fields); + } + void add_is_struct(bool is_struct) { + fbb_.AddElement<uint8_t>(Object::VT_IS_STRUCT, static_cast<uint8_t>(is_struct), 0); + } + void add_minalign(int32_t minalign) { + fbb_.AddElement<int32_t>(Object::VT_MINALIGN, minalign, 0); + } + void add_bytesize(int32_t bytesize) { + fbb_.AddElement<int32_t>(Object::VT_BYTESIZE, bytesize, 0); + } void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes) { - fbb_.AddOffset(Object::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Object::VT_DOCUMENTATION, documentation); - } - explicit ObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } + fbb_.AddOffset(Object::VT_ATTRIBUTES, attributes); + } + void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { + fbb_.AddOffset(Object::VT_DOCUMENTATION, documentation); + } + explicit ObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } flatbuffers::Offset<Object> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Object>(end); - fbb_.Required(o, Object::VT_NAME); - fbb_.Required(o, Object::VT_FIELDS); + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<Object>(end); + fbb_.Required(o, Object::VT_NAME); + fbb_.Required(o, Object::VT_FIELDS); return o; } }; -inline flatbuffers::Offset<Object> CreateObject( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, +inline flatbuffers::Offset<Object> CreateObject( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> name = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>>> fields = 0, - bool is_struct = false, - int32_t minalign = 0, - int32_t bytesize = 0, + bool is_struct = false, + int32_t minalign = 0, + int32_t bytesize = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { + flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { ObjectBuilder builder_(_fbb); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); + builder_.add_documentation(documentation); + builder_.add_attributes(attributes); builder_.add_bytesize(bytesize); builder_.add_minalign(minalign); builder_.add_fields(fields); @@ -850,298 +850,298 @@ inline flatbuffers::Offset<Object> CreateObject( return builder_.Finish(); } -inline flatbuffers::Offset<Object> CreateObjectDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, +inline flatbuffers::Offset<Object> CreateObjectDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, std::vector<flatbuffers::Offset<reflection::Field>> *fields = nullptr, - bool is_struct = false, - int32_t minalign = 0, - int32_t bytesize = 0, + bool is_struct = false, + int32_t minalign = 0, + int32_t bytesize = 0, std::vector<flatbuffers::Offset<reflection::KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { + const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { auto name__ = name ? _fbb.CreateString(name) : 0; auto fields__ = fields ? _fbb.CreateVectorOfSortedTables<reflection::Field>(fields) : 0; auto attributes__ = attributes ? _fbb.CreateVectorOfSortedTables<reflection::KeyValue>(attributes) : 0; auto documentation__ = documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0; - return reflection::CreateObject( - _fbb, + return reflection::CreateObject( + _fbb, name__, fields__, - is_struct, - minalign, - bytesize, + is_struct, + minalign, + bytesize, attributes__, documentation__); -} - -struct RPCCall FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { +} + +struct RPCCall FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef RPCCallBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_REQUEST = 6, - VT_RESPONSE = 8, - VT_ATTRIBUTES = 10, - VT_DOCUMENTATION = 12 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const RPCCall *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } + VT_NAME = 4, + VT_REQUEST = 6, + VT_RESPONSE = 8, + VT_ATTRIBUTES = 10, + VT_DOCUMENTATION = 12 + }; + const flatbuffers::String *name() const { + return GetPointer<const flatbuffers::String *>(VT_NAME); + } + bool KeyCompareLessThan(const RPCCall *o) const { + return *name() < *o->name(); + } + int KeyCompareWithValue(const char *val) const { + return strcmp(name()->c_str(), val); + } const reflection::Object *request() const { return GetPointer<const reflection::Object *>(VT_REQUEST); - } + } const reflection::Object *response() const { return GetPointer<const reflection::Object *>(VT_RESPONSE); - } + } const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *attributes() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffsetRequired(verifier, VT_REQUEST) && - verifier.VerifyTable(request()) && - VerifyOffsetRequired(verifier, VT_RESPONSE) && - verifier.VerifyTable(response()) && - VerifyOffset(verifier, VT_ATTRIBUTES) && - verifier.VerifyVector(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyOffset(verifier, VT_DOCUMENTATION) && - verifier.VerifyVector(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && - verifier.EndTable(); - } -}; - -struct RPCCallBuilder { + } + const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { + return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffsetRequired(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyOffsetRequired(verifier, VT_REQUEST) && + verifier.VerifyTable(request()) && + VerifyOffsetRequired(verifier, VT_RESPONSE) && + verifier.VerifyTable(response()) && + VerifyOffset(verifier, VT_ATTRIBUTES) && + verifier.VerifyVector(attributes()) && + verifier.VerifyVectorOfTables(attributes()) && + VerifyOffset(verifier, VT_DOCUMENTATION) && + verifier.VerifyVector(documentation()) && + verifier.VerifyVectorOfStrings(documentation()) && + verifier.EndTable(); + } +}; + +struct RPCCallBuilder { typedef RPCCall Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(RPCCall::VT_NAME, name); - } + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset<flatbuffers::String> name) { + fbb_.AddOffset(RPCCall::VT_NAME, name); + } void add_request(flatbuffers::Offset<reflection::Object> request) { - fbb_.AddOffset(RPCCall::VT_REQUEST, request); - } + fbb_.AddOffset(RPCCall::VT_REQUEST, request); + } void add_response(flatbuffers::Offset<reflection::Object> response) { - fbb_.AddOffset(RPCCall::VT_RESPONSE, response); - } + fbb_.AddOffset(RPCCall::VT_RESPONSE, response); + } void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes) { - fbb_.AddOffset(RPCCall::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(RPCCall::VT_DOCUMENTATION, documentation); - } - explicit RPCCallBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset<RPCCall> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<RPCCall>(end); - fbb_.Required(o, RPCCall::VT_NAME); - fbb_.Required(o, RPCCall::VT_REQUEST); - fbb_.Required(o, RPCCall::VT_RESPONSE); - return o; - } -}; - -inline flatbuffers::Offset<RPCCall> CreateRPCCall( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, + fbb_.AddOffset(RPCCall::VT_ATTRIBUTES, attributes); + } + void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { + fbb_.AddOffset(RPCCall::VT_DOCUMENTATION, documentation); + } + explicit RPCCallBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset<RPCCall> Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<RPCCall>(end); + fbb_.Required(o, RPCCall::VT_NAME); + fbb_.Required(o, RPCCall::VT_REQUEST); + fbb_.Required(o, RPCCall::VT_RESPONSE); + return o; + } +}; + +inline flatbuffers::Offset<RPCCall> CreateRPCCall( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> name = 0, flatbuffers::Offset<reflection::Object> request = 0, flatbuffers::Offset<reflection::Object> response = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { - RPCCallBuilder builder_(_fbb); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); - builder_.add_response(response); - builder_.add_request(request); - builder_.add_name(name); - return builder_.Finish(); -} - -inline flatbuffers::Offset<RPCCall> CreateRPCCallDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, + flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { + RPCCallBuilder builder_(_fbb); + builder_.add_documentation(documentation); + builder_.add_attributes(attributes); + builder_.add_response(response); + builder_.add_request(request); + builder_.add_name(name); + return builder_.Finish(); +} + +inline flatbuffers::Offset<RPCCall> CreateRPCCallDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, flatbuffers::Offset<reflection::Object> request = 0, flatbuffers::Offset<reflection::Object> response = 0, std::vector<flatbuffers::Offset<reflection::KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { + const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { auto name__ = name ? _fbb.CreateString(name) : 0; auto attributes__ = attributes ? _fbb.CreateVectorOfSortedTables<reflection::KeyValue>(attributes) : 0; auto documentation__ = documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0; - return reflection::CreateRPCCall( - _fbb, + return reflection::CreateRPCCall( + _fbb, name__, - request, - response, + request, + response, attributes__, documentation__); -} - -struct Service FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { +} + +struct Service FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ServiceBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_CALLS = 6, - VT_ATTRIBUTES = 8, - VT_DOCUMENTATION = 10 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Service *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } + VT_NAME = 4, + VT_CALLS = 6, + VT_ATTRIBUTES = 8, + VT_DOCUMENTATION = 10 + }; + const flatbuffers::String *name() const { + return GetPointer<const flatbuffers::String *>(VT_NAME); + } + bool KeyCompareLessThan(const Service *o) const { + return *name() < *o->name(); + } + int KeyCompareWithValue(const char *val) const { + return strcmp(name()->c_str(), val); + } const flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>> *calls() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>> *>(VT_CALLS); - } + } const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *attributes() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffset(verifier, VT_CALLS) && - verifier.VerifyVector(calls()) && - verifier.VerifyVectorOfTables(calls()) && - VerifyOffset(verifier, VT_ATTRIBUTES) && - verifier.VerifyVector(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyOffset(verifier, VT_DOCUMENTATION) && - verifier.VerifyVector(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && - verifier.EndTable(); - } -}; - -struct ServiceBuilder { + } + const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { + return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffsetRequired(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyOffset(verifier, VT_CALLS) && + verifier.VerifyVector(calls()) && + verifier.VerifyVectorOfTables(calls()) && + VerifyOffset(verifier, VT_ATTRIBUTES) && + verifier.VerifyVector(attributes()) && + verifier.VerifyVectorOfTables(attributes()) && + VerifyOffset(verifier, VT_DOCUMENTATION) && + verifier.VerifyVector(documentation()) && + verifier.VerifyVectorOfStrings(documentation()) && + verifier.EndTable(); + } +}; + +struct ServiceBuilder { typedef Service Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Service::VT_NAME, name); - } + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset<flatbuffers::String> name) { + fbb_.AddOffset(Service::VT_NAME, name); + } void add_calls(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>>> calls) { - fbb_.AddOffset(Service::VT_CALLS, calls); - } + fbb_.AddOffset(Service::VT_CALLS, calls); + } void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes) { - fbb_.AddOffset(Service::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Service::VT_DOCUMENTATION, documentation); - } - explicit ServiceBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset<Service> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Service>(end); - fbb_.Required(o, Service::VT_NAME); - return o; - } -}; - -inline flatbuffers::Offset<Service> CreateService( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, + fbb_.AddOffset(Service::VT_ATTRIBUTES, attributes); + } + void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { + fbb_.AddOffset(Service::VT_DOCUMENTATION, documentation); + } + explicit ServiceBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset<Service> Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<Service>(end); + fbb_.Required(o, Service::VT_NAME); + return o; + } +}; + +inline flatbuffers::Offset<Service> CreateService( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset<flatbuffers::String> name = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>>> calls = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { - ServiceBuilder builder_(_fbb); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); - builder_.add_calls(calls); - builder_.add_name(name); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Service> CreateServiceDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, + flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { + ServiceBuilder builder_(_fbb); + builder_.add_documentation(documentation); + builder_.add_attributes(attributes); + builder_.add_calls(calls); + builder_.add_name(name); + return builder_.Finish(); +} + +inline flatbuffers::Offset<Service> CreateServiceDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, std::vector<flatbuffers::Offset<reflection::RPCCall>> *calls = nullptr, std::vector<flatbuffers::Offset<reflection::KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { + const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { auto name__ = name ? _fbb.CreateString(name) : 0; auto calls__ = calls ? _fbb.CreateVectorOfSortedTables<reflection::RPCCall>(calls) : 0; auto attributes__ = attributes ? _fbb.CreateVectorOfSortedTables<reflection::KeyValue>(attributes) : 0; auto documentation__ = documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0; - return reflection::CreateService( - _fbb, + return reflection::CreateService( + _fbb, name__, calls__, attributes__, documentation__); -} - +} + struct Schema FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SchemaBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_OBJECTS = 4, - VT_ENUMS = 6, - VT_FILE_IDENT = 8, - VT_FILE_EXT = 10, - VT_ROOT_TABLE = 12, + VT_OBJECTS = 4, + VT_ENUMS = 6, + VT_FILE_IDENT = 8, + VT_FILE_EXT = 10, + VT_ROOT_TABLE = 12, VT_SERVICES = 14, VT_ADVANCED_FEATURES = 16 - }; + }; const flatbuffers::Vector<flatbuffers::Offset<reflection::Object>> *objects() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::Object>> *>(VT_OBJECTS); - } + } const flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>> *enums() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>> *>(VT_ENUMS); - } - const flatbuffers::String *file_ident() const { - return GetPointer<const flatbuffers::String *>(VT_FILE_IDENT); - } - const flatbuffers::String *file_ext() const { - return GetPointer<const flatbuffers::String *>(VT_FILE_EXT); - } + } + const flatbuffers::String *file_ident() const { + return GetPointer<const flatbuffers::String *>(VT_FILE_IDENT); + } + const flatbuffers::String *file_ext() const { + return GetPointer<const flatbuffers::String *>(VT_FILE_EXT); + } const reflection::Object *root_table() const { return GetPointer<const reflection::Object *>(VT_ROOT_TABLE); - } + } const flatbuffers::Vector<flatbuffers::Offset<reflection::Service>> *services() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::Service>> *>(VT_SERVICES); - } + } reflection::AdvancedFeatures advanced_features() const { return static_cast<reflection::AdvancedFeatures>(GetField<uint64_t>(VT_ADVANCED_FEATURES, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_OBJECTS) && - verifier.VerifyVector(objects()) && + VerifyOffsetRequired(verifier, VT_OBJECTS) && + verifier.VerifyVector(objects()) && verifier.VerifyVectorOfTables(objects()) && - VerifyOffsetRequired(verifier, VT_ENUMS) && - verifier.VerifyVector(enums()) && + VerifyOffsetRequired(verifier, VT_ENUMS) && + verifier.VerifyVector(enums()) && verifier.VerifyVectorOfTables(enums()) && - VerifyOffset(verifier, VT_FILE_IDENT) && - verifier.VerifyString(file_ident()) && - VerifyOffset(verifier, VT_FILE_EXT) && - verifier.VerifyString(file_ext()) && - VerifyOffset(verifier, VT_ROOT_TABLE) && + VerifyOffset(verifier, VT_FILE_IDENT) && + verifier.VerifyString(file_ident()) && + VerifyOffset(verifier, VT_FILE_EXT) && + verifier.VerifyString(file_ext()) && + VerifyOffset(verifier, VT_ROOT_TABLE) && verifier.VerifyTable(root_table()) && - VerifyOffset(verifier, VT_SERVICES) && - verifier.VerifyVector(services()) && - verifier.VerifyVectorOfTables(services()) && + VerifyOffset(verifier, VT_SERVICES) && + verifier.VerifyVector(services()) && + verifier.VerifyVectorOfTables(services()) && VerifyField<uint64_t>(verifier, VT_ADVANCED_FEATURES) && verifier.EndTable(); } @@ -1152,51 +1152,51 @@ struct SchemaBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_objects(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>>> objects) { - fbb_.AddOffset(Schema::VT_OBJECTS, objects); - } + fbb_.AddOffset(Schema::VT_OBJECTS, objects); + } void add_enums(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>>> enums) { - fbb_.AddOffset(Schema::VT_ENUMS, enums); - } - void add_file_ident(flatbuffers::Offset<flatbuffers::String> file_ident) { - fbb_.AddOffset(Schema::VT_FILE_IDENT, file_ident); - } - void add_file_ext(flatbuffers::Offset<flatbuffers::String> file_ext) { - fbb_.AddOffset(Schema::VT_FILE_EXT, file_ext); - } + fbb_.AddOffset(Schema::VT_ENUMS, enums); + } + void add_file_ident(flatbuffers::Offset<flatbuffers::String> file_ident) { + fbb_.AddOffset(Schema::VT_FILE_IDENT, file_ident); + } + void add_file_ext(flatbuffers::Offset<flatbuffers::String> file_ext) { + fbb_.AddOffset(Schema::VT_FILE_EXT, file_ext); + } void add_root_table(flatbuffers::Offset<reflection::Object> root_table) { - fbb_.AddOffset(Schema::VT_ROOT_TABLE, root_table); - } + fbb_.AddOffset(Schema::VT_ROOT_TABLE, root_table); + } void add_services(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>>> services) { - fbb_.AddOffset(Schema::VT_SERVICES, services); - } + fbb_.AddOffset(Schema::VT_SERVICES, services); + } void add_advanced_features(reflection::AdvancedFeatures advanced_features) { fbb_.AddElement<uint64_t>(Schema::VT_ADVANCED_FEATURES, static_cast<uint64_t>(advanced_features), 0); } - explicit SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } + explicit SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } flatbuffers::Offset<Schema> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Schema>(end); - fbb_.Required(o, Schema::VT_OBJECTS); - fbb_.Required(o, Schema::VT_ENUMS); + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset<Schema>(end); + fbb_.Required(o, Schema::VT_OBJECTS); + fbb_.Required(o, Schema::VT_ENUMS); return o; } }; -inline flatbuffers::Offset<Schema> CreateSchema( - flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset<Schema> CreateSchema( + flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>>> objects = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>>> enums = 0, - flatbuffers::Offset<flatbuffers::String> file_ident = 0, - flatbuffers::Offset<flatbuffers::String> file_ext = 0, + flatbuffers::Offset<flatbuffers::String> file_ident = 0, + flatbuffers::Offset<flatbuffers::String> file_ext = 0, flatbuffers::Offset<reflection::Object> root_table = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>>> services = 0, reflection::AdvancedFeatures advanced_features = static_cast<reflection::AdvancedFeatures>(0)) { SchemaBuilder builder_(_fbb); builder_.add_advanced_features(advanced_features); - builder_.add_services(services); + builder_.add_services(services); builder_.add_root_table(root_table); builder_.add_file_ext(file_ext); builder_.add_file_ident(file_ident); @@ -1205,12 +1205,12 @@ inline flatbuffers::Offset<Schema> CreateSchema( return builder_.Finish(); } -inline flatbuffers::Offset<Schema> CreateSchemaDirect( - flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset<Schema> CreateSchemaDirect( + flatbuffers::FlatBufferBuilder &_fbb, std::vector<flatbuffers::Offset<reflection::Object>> *objects = nullptr, std::vector<flatbuffers::Offset<reflection::Enum>> *enums = nullptr, - const char *file_ident = nullptr, - const char *file_ext = nullptr, + const char *file_ident = nullptr, + const char *file_ext = nullptr, flatbuffers::Offset<reflection::Object> root_table = 0, std::vector<flatbuffers::Offset<reflection::Service>> *services = nullptr, reflection::AdvancedFeatures advanced_features = static_cast<reflection::AdvancedFeatures>(0)) { @@ -1219,60 +1219,60 @@ inline flatbuffers::Offset<Schema> CreateSchemaDirect( auto file_ident__ = file_ident ? _fbb.CreateString(file_ident) : 0; auto file_ext__ = file_ext ? _fbb.CreateString(file_ext) : 0; auto services__ = services ? _fbb.CreateVectorOfSortedTables<reflection::Service>(services) : 0; - return reflection::CreateSchema( - _fbb, + return reflection::CreateSchema( + _fbb, objects__, enums__, file_ident__, file_ext__, - root_table, + root_table, services__, advanced_features); -} - -inline const reflection::Schema *GetSchema(const void *buf) { - return flatbuffers::GetRoot<reflection::Schema>(buf); -} - -inline const reflection::Schema *GetSizePrefixedSchema(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<reflection::Schema>(buf); -} - -inline const char *SchemaIdentifier() { - return "BFBS"; -} - -inline bool SchemaBufferHasIdentifier(const void *buf) { - return flatbuffers::BufferHasIdentifier( - buf, SchemaIdentifier()); -} - -inline bool VerifySchemaBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<reflection::Schema>(SchemaIdentifier()); -} - -inline bool VerifySizePrefixedSchemaBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<reflection::Schema>(SchemaIdentifier()); -} - -inline const char *SchemaExtension() { - return "bfbs"; -} - -inline void FinishSchemaBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<reflection::Schema> root) { - fbb.Finish(root, SchemaIdentifier()); -} - -inline void FinishSizePrefixedSchemaBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<reflection::Schema> root) { - fbb.FinishSizePrefixed(root, SchemaIdentifier()); -} - +} + +inline const reflection::Schema *GetSchema(const void *buf) { + return flatbuffers::GetRoot<reflection::Schema>(buf); +} + +inline const reflection::Schema *GetSizePrefixedSchema(const void *buf) { + return flatbuffers::GetSizePrefixedRoot<reflection::Schema>(buf); +} + +inline const char *SchemaIdentifier() { + return "BFBS"; +} + +inline bool SchemaBufferHasIdentifier(const void *buf) { + return flatbuffers::BufferHasIdentifier( + buf, SchemaIdentifier()); +} + +inline bool VerifySchemaBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer<reflection::Schema>(SchemaIdentifier()); +} + +inline bool VerifySizePrefixedSchemaBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer<reflection::Schema>(SchemaIdentifier()); +} + +inline const char *SchemaExtension() { + return "bfbs"; +} + +inline void FinishSchemaBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset<reflection::Schema> root) { + fbb.Finish(root, SchemaIdentifier()); +} + +inline void FinishSizePrefixedSchemaBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset<reflection::Schema> root) { + fbb.FinishSizePrefixed(root, SchemaIdentifier()); +} + } // namespace reflection #endif // FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/registry.h b/contrib/libs/flatbuffers/include/flatbuffers/registry.h index 30a0016dcb..a313d257f0 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/registry.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/registry.h @@ -1,127 +1,127 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_REGISTRY_H_ -#define FLATBUFFERS_REGISTRY_H_ - +/* + * Copyright 2017 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLATBUFFERS_REGISTRY_H_ +#define FLATBUFFERS_REGISTRY_H_ + #include "idl.h" - -namespace flatbuffers { - -// Convenience class to easily parse or generate text for arbitrary FlatBuffers. -// Simply pre-populate it with all schema filenames that may be in use, and -// This class will look them up using the file_identifier declared in the -// schema. -class Registry { - public: - // Call this for all schemas that may be in use. The identifier has - // a function in the generated code, e.g. MonsterIdentifier(). - void Register(const char *file_identifier, const char *schema_path) { - Schema schema; - schema.path_ = schema_path; - schemas_[file_identifier] = schema; - } - - // Generate text from an arbitrary FlatBuffer by looking up its - // file_identifier in the registry. - bool FlatBufferToText(const uint8_t *flatbuf, size_t len, std::string *dest) { - // Get the identifier out of the buffer. - // If the buffer is truncated, exit. - if (len < sizeof(uoffset_t) + FlatBufferBuilder::kFileIdentifierLength) { - lasterror_ = "buffer truncated"; - return false; - } - std::string ident( - reinterpret_cast<const char *>(flatbuf) + sizeof(uoffset_t), - FlatBufferBuilder::kFileIdentifierLength); - // Load and parse the schema. - Parser parser; - if (!LoadSchema(ident, &parser)) return false; - // Now we're ready to generate text. - if (!GenerateText(parser, flatbuf, dest)) { - lasterror_ = "unable to generate text for FlatBuffer binary"; - return false; - } - return true; - } - - // Converts a binary buffer to text using one of the schemas in the registry, - // use the file_identifier to indicate which. - // If DetachedBuffer::data() is null then parsing failed. - DetachedBuffer TextToFlatBuffer(const char *text, - const char *file_identifier) { - // Load and parse the schema. - Parser parser; - if (!LoadSchema(file_identifier, &parser)) return DetachedBuffer(); - // Parse the text. - if (!parser.Parse(text)) { - lasterror_ = parser.error_; - return DetachedBuffer(); - } - // We have a valid FlatBuffer. Detach it from the builder and return. + +namespace flatbuffers { + +// Convenience class to easily parse or generate text for arbitrary FlatBuffers. +// Simply pre-populate it with all schema filenames that may be in use, and +// This class will look them up using the file_identifier declared in the +// schema. +class Registry { + public: + // Call this for all schemas that may be in use. The identifier has + // a function in the generated code, e.g. MonsterIdentifier(). + void Register(const char *file_identifier, const char *schema_path) { + Schema schema; + schema.path_ = schema_path; + schemas_[file_identifier] = schema; + } + + // Generate text from an arbitrary FlatBuffer by looking up its + // file_identifier in the registry. + bool FlatBufferToText(const uint8_t *flatbuf, size_t len, std::string *dest) { + // Get the identifier out of the buffer. + // If the buffer is truncated, exit. + if (len < sizeof(uoffset_t) + FlatBufferBuilder::kFileIdentifierLength) { + lasterror_ = "buffer truncated"; + return false; + } + std::string ident( + reinterpret_cast<const char *>(flatbuf) + sizeof(uoffset_t), + FlatBufferBuilder::kFileIdentifierLength); + // Load and parse the schema. + Parser parser; + if (!LoadSchema(ident, &parser)) return false; + // Now we're ready to generate text. + if (!GenerateText(parser, flatbuf, dest)) { + lasterror_ = "unable to generate text for FlatBuffer binary"; + return false; + } + return true; + } + + // Converts a binary buffer to text using one of the schemas in the registry, + // use the file_identifier to indicate which. + // If DetachedBuffer::data() is null then parsing failed. + DetachedBuffer TextToFlatBuffer(const char *text, + const char *file_identifier) { + // Load and parse the schema. + Parser parser; + if (!LoadSchema(file_identifier, &parser)) return DetachedBuffer(); + // Parse the text. + if (!parser.Parse(text)) { + lasterror_ = parser.error_; + return DetachedBuffer(); + } + // We have a valid FlatBuffer. Detach it from the builder and return. return parser.builder_.Release(); - } - - // Modify any parsing / output options used by the other functions. - void SetOptions(const IDLOptions &opts) { opts_ = opts; } - - // If schemas used contain include statements, call this function for every - // directory the parser should search them for. - void AddIncludeDirectory(const char *path) { include_paths_.push_back(path); } - - // Returns a human readable error if any of the above functions fail. - const std::string &GetLastError() { return lasterror_; } - - private: - bool LoadSchema(const std::string &ident, Parser *parser) { - // Find the schema, if not, exit. - auto it = schemas_.find(ident); - if (it == schemas_.end()) { - // Don't attach the identifier, since it may not be human readable. - lasterror_ = "identifier for this buffer not in the registry"; - return false; - } - auto &schema = it->second; - // Load the schema from disk. If not, exit. - std::string schematext; - if (!LoadFile(schema.path_.c_str(), false, &schematext)) { - lasterror_ = "could not load schema: " + schema.path_; - return false; - } - // Parse schema. - parser->opts = opts_; - if (!parser->Parse(schematext.c_str(), vector_data(include_paths_), - schema.path_.c_str())) { - lasterror_ = parser->error_; - return false; - } - return true; - } - - struct Schema { - std::string path_; - // TODO(wvo) optionally cache schema file or parsed schema here. - }; - - std::string lasterror_; - IDLOptions opts_; - std::vector<const char *> include_paths_; - std::map<std::string, Schema> schemas_; -}; - -} // namespace flatbuffers - -#endif // FLATBUFFERS_REGISTRY_H_ + } + + // Modify any parsing / output options used by the other functions. + void SetOptions(const IDLOptions &opts) { opts_ = opts; } + + // If schemas used contain include statements, call this function for every + // directory the parser should search them for. + void AddIncludeDirectory(const char *path) { include_paths_.push_back(path); } + + // Returns a human readable error if any of the above functions fail. + const std::string &GetLastError() { return lasterror_; } + + private: + bool LoadSchema(const std::string &ident, Parser *parser) { + // Find the schema, if not, exit. + auto it = schemas_.find(ident); + if (it == schemas_.end()) { + // Don't attach the identifier, since it may not be human readable. + lasterror_ = "identifier for this buffer not in the registry"; + return false; + } + auto &schema = it->second; + // Load the schema from disk. If not, exit. + std::string schematext; + if (!LoadFile(schema.path_.c_str(), false, &schematext)) { + lasterror_ = "could not load schema: " + schema.path_; + return false; + } + // Parse schema. + parser->opts = opts_; + if (!parser->Parse(schematext.c_str(), vector_data(include_paths_), + schema.path_.c_str())) { + lasterror_ = parser->error_; + return false; + } + return true; + } + + struct Schema { + std::string path_; + // TODO(wvo) optionally cache schema file or parsed schema here. + }; + + std::string lasterror_; + IDLOptions opts_; + std::vector<const char *> include_paths_; + std::map<std::string, Schema> schemas_; +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_REGISTRY_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h b/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h index e8e1e59487..d84aecea8e 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h @@ -1,39 +1,39 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_STL_EMULATION_H_ -#define FLATBUFFERS_STL_EMULATION_H_ - -// clang-format off +/* + * Copyright 2017 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLATBUFFERS_STL_EMULATION_H_ +#define FLATBUFFERS_STL_EMULATION_H_ + +// clang-format off #include "base.h" - -#include <string> -#include <type_traits> -#include <vector> -#include <memory> -#include <limits> - -#if defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) - #define FLATBUFFERS_CPP98_STL -#endif // defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) - -#if defined(FLATBUFFERS_CPP98_STL) - #include <cctype> -#endif // defined(FLATBUFFERS_CPP98_STL) - + +#include <string> +#include <type_traits> +#include <vector> +#include <memory> +#include <limits> + +#if defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) + #define FLATBUFFERS_CPP98_STL +#endif // defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) + +#if defined(FLATBUFFERS_CPP98_STL) + #include <cctype> +#endif // defined(FLATBUFFERS_CPP98_STL) + // Detect C++17 compatible compiler. // __cplusplus >= 201703L - a compiler has support of 'static inline' variables. #if defined(FLATBUFFERS_USE_STD_OPTIONAL) \ @@ -62,52 +62,52 @@ #include <array> #endif #endif // defined(FLATBUFFERS_USE_STD_SPAN) - -// This header provides backwards compatibility for C++98 STLs like stlport. -namespace flatbuffers { - -// Retrieve ::back() from a string in a way that is compatible with pre C++11 -// STLs (e.g stlport). -inline char& string_back(std::string &value) { - return value[value.length() - 1]; -} - -inline char string_back(const std::string &value) { - return value[value.length() - 1]; -} - -// Helper method that retrieves ::data() from a vector in a way that is -// compatible with pre C++11 STLs (e.g stlport). -template <typename T> inline T *vector_data(std::vector<T> &vector) { - // In some debug environments, operator[] does bounds checking, so &vector[0] - // can't be used. - return vector.empty() ? nullptr : &vector[0]; -} - -template <typename T> inline const T *vector_data( - const std::vector<T> &vector) { - return vector.empty() ? nullptr : &vector[0]; -} - -template <typename T, typename V> -inline void vector_emplace_back(std::vector<T> *vector, V &&data) { - #if defined(FLATBUFFERS_CPP98_STL) - vector->push_back(data); - #else - vector->emplace_back(std::forward<V>(data)); - #endif // defined(FLATBUFFERS_CPP98_STL) -} - -#ifndef FLATBUFFERS_CPP98_STL - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - template <typename T> - using numeric_limits = std::numeric_limits<T>; - #else - template <typename T> class numeric_limits : - public std::numeric_limits<T> {}; - #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) -#else - template <typename T> class numeric_limits : + +// This header provides backwards compatibility for C++98 STLs like stlport. +namespace flatbuffers { + +// Retrieve ::back() from a string in a way that is compatible with pre C++11 +// STLs (e.g stlport). +inline char& string_back(std::string &value) { + return value[value.length() - 1]; +} + +inline char string_back(const std::string &value) { + return value[value.length() - 1]; +} + +// Helper method that retrieves ::data() from a vector in a way that is +// compatible with pre C++11 STLs (e.g stlport). +template <typename T> inline T *vector_data(std::vector<T> &vector) { + // In some debug environments, operator[] does bounds checking, so &vector[0] + // can't be used. + return vector.empty() ? nullptr : &vector[0]; +} + +template <typename T> inline const T *vector_data( + const std::vector<T> &vector) { + return vector.empty() ? nullptr : &vector[0]; +} + +template <typename T, typename V> +inline void vector_emplace_back(std::vector<T> *vector, V &&data) { + #if defined(FLATBUFFERS_CPP98_STL) + vector->push_back(data); + #else + vector->emplace_back(std::forward<V>(data)); + #endif // defined(FLATBUFFERS_CPP98_STL) +} + +#ifndef FLATBUFFERS_CPP98_STL + #if defined(FLATBUFFERS_TEMPLATES_ALIASES) + template <typename T> + using numeric_limits = std::numeric_limits<T>; + #else + template <typename T> class numeric_limits : + public std::numeric_limits<T> {}; + #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) +#else + template <typename T> class numeric_limits : public std::numeric_limits<T> { public: // Android NDK fix. @@ -115,7 +115,7 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) { return std::numeric_limits<T>::min(); } }; - + template <> class numeric_limits<float> : public std::numeric_limits<float> { public: @@ -128,36 +128,36 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) { static double lowest() { return -DBL_MAX; } }; - template <> class numeric_limits<unsigned long long> { - public: - static unsigned long long min() { return 0ULL; } - static unsigned long long max() { return ~0ULL; } + template <> class numeric_limits<unsigned long long> { + public: + static unsigned long long min() { return 0ULL; } + static unsigned long long max() { return ~0ULL; } static unsigned long long lowest() { return numeric_limits<unsigned long long>::min(); } - }; - - template <> class numeric_limits<long long> { - public: - static long long min() { - return static_cast<long long>(1ULL << ((sizeof(long long) << 3) - 1)); - } - static long long max() { - return static_cast<long long>( - (1ULL << ((sizeof(long long) << 3) - 1)) - 1); - } + }; + + template <> class numeric_limits<long long> { + public: + static long long min() { + return static_cast<long long>(1ULL << ((sizeof(long long) << 3) - 1)); + } + static long long max() { + return static_cast<long long>( + (1ULL << ((sizeof(long long) << 3) - 1)) - 1); + } static long long lowest() { return numeric_limits<long long>::min(); } - }; -#endif // FLATBUFFERS_CPP98_STL - -#if defined(FLATBUFFERS_TEMPLATES_ALIASES) - #ifndef FLATBUFFERS_CPP98_STL - template <typename T> using is_scalar = std::is_scalar<T>; - template <typename T, typename U> using is_same = std::is_same<T,U>; - template <typename T> using is_floating_point = std::is_floating_point<T>; - template <typename T> using is_unsigned = std::is_unsigned<T>; + }; +#endif // FLATBUFFERS_CPP98_STL + +#if defined(FLATBUFFERS_TEMPLATES_ALIASES) + #ifndef FLATBUFFERS_CPP98_STL + template <typename T> using is_scalar = std::is_scalar<T>; + template <typename T, typename U> using is_same = std::is_same<T,U>; + template <typename T> using is_floating_point = std::is_floating_point<T>; + template <typename T> using is_unsigned = std::is_unsigned<T>; template <typename T> using is_enum = std::is_enum<T>; template <typename T> using make_unsigned = std::make_unsigned<T>; template<bool B, class T, class F> @@ -166,13 +166,13 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) { using integral_constant = std::integral_constant<T, v>; template <bool B> using bool_constant = integral_constant<bool, B>; - #else - // Map C++ TR1 templates defined by stlport. - template <typename T> using is_scalar = std::tr1::is_scalar<T>; - template <typename T, typename U> using is_same = std::tr1::is_same<T,U>; - template <typename T> using is_floating_point = - std::tr1::is_floating_point<T>; - template <typename T> using is_unsigned = std::tr1::is_unsigned<T>; + #else + // Map C++ TR1 templates defined by stlport. + template <typename T> using is_scalar = std::tr1::is_scalar<T>; + template <typename T, typename U> using is_same = std::tr1::is_same<T,U>; + template <typename T> using is_floating_point = + std::tr1::is_floating_point<T>; + template <typename T> using is_unsigned = std::tr1::is_unsigned<T>; template <typename T> using is_enum = std::tr1::is_enum<T>; // Android NDK doesn't have std::make_unsigned or std::tr1::make_unsigned. template<typename T> struct make_unsigned { @@ -191,14 +191,14 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) { using integral_constant = std::tr1::integral_constant<T, v>; template <bool B> using bool_constant = integral_constant<bool, B>; - #endif // !FLATBUFFERS_CPP98_STL -#else - // MSVC 2010 doesn't support C++11 aliases. - template <typename T> struct is_scalar : public std::is_scalar<T> {}; - template <typename T, typename U> struct is_same : public std::is_same<T,U> {}; - template <typename T> struct is_floating_point : - public std::is_floating_point<T> {}; - template <typename T> struct is_unsigned : public std::is_unsigned<T> {}; + #endif // !FLATBUFFERS_CPP98_STL +#else + // MSVC 2010 doesn't support C++11 aliases. + template <typename T> struct is_scalar : public std::is_scalar<T> {}; + template <typename T, typename U> struct is_same : public std::is_same<T,U> {}; + template <typename T> struct is_floating_point : + public std::is_floating_point<T> {}; + template <typename T> struct is_unsigned : public std::is_unsigned<T> {}; template <typename T> struct is_enum : public std::is_enum<T> {}; template <typename T> struct make_unsigned : public std::make_unsigned<T> {}; template<bool B, class T, class F> @@ -207,108 +207,108 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) { struct integral_constant : public std::integral_constant<T, v> {}; template <bool B> struct bool_constant : public integral_constant<bool, B> {}; -#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) - -#ifndef FLATBUFFERS_CPP98_STL - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - template <class T> using unique_ptr = std::unique_ptr<T>; - #else - // MSVC 2010 doesn't support C++11 aliases. - // We're manually "aliasing" the class here as we want to bring unique_ptr - // into the flatbuffers namespace. We have unique_ptr in the flatbuffers +#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) + +#ifndef FLATBUFFERS_CPP98_STL + #if defined(FLATBUFFERS_TEMPLATES_ALIASES) + template <class T> using unique_ptr = std::unique_ptr<T>; + #else + // MSVC 2010 doesn't support C++11 aliases. + // We're manually "aliasing" the class here as we want to bring unique_ptr + // into the flatbuffers namespace. We have unique_ptr in the flatbuffers // namespace we have a completely independent implementation (see below) - // for C++98 STL implementations. - template <class T> class unique_ptr : public std::unique_ptr<T> { - public: - unique_ptr() {} - explicit unique_ptr(T* p) : std::unique_ptr<T>(p) {} - unique_ptr(std::unique_ptr<T>&& u) { *this = std::move(u); } - unique_ptr(unique_ptr&& u) { *this = std::move(u); } - unique_ptr& operator=(std::unique_ptr<T>&& u) { - std::unique_ptr<T>::reset(u.release()); - return *this; - } - unique_ptr& operator=(unique_ptr&& u) { - std::unique_ptr<T>::reset(u.release()); - return *this; - } - unique_ptr& operator=(T* p) { - return std::unique_ptr<T>::operator=(p); - } - }; - #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) -#else - // Very limited implementation of unique_ptr. - // This is provided simply to allow the C++ code generated from the default - // settings to function in C++98 environments with no modifications. - template <class T> class unique_ptr { - public: - typedef T element_type; - - unique_ptr() : ptr_(nullptr) {} - explicit unique_ptr(T* p) : ptr_(p) {} - unique_ptr(unique_ptr&& u) : ptr_(nullptr) { reset(u.release()); } - unique_ptr(const unique_ptr& u) : ptr_(nullptr) { - reset(const_cast<unique_ptr*>(&u)->release()); - } - ~unique_ptr() { reset(); } - - unique_ptr& operator=(const unique_ptr& u) { - reset(const_cast<unique_ptr*>(&u)->release()); - return *this; - } - - unique_ptr& operator=(unique_ptr&& u) { - reset(u.release()); - return *this; - } - - unique_ptr& operator=(T* p) { - reset(p); - return *this; - } - - const T& operator*() const { return *ptr_; } - T* operator->() const { return ptr_; } - T* get() const noexcept { return ptr_; } - explicit operator bool() const { return ptr_ != nullptr; } - - // modifiers - T* release() { - T* value = ptr_; - ptr_ = nullptr; - return value; - } - - void reset(T* p = nullptr) { - T* value = ptr_; - ptr_ = p; - if (value) delete value; - } - - void swap(unique_ptr& u) { - T* temp_ptr = ptr_; - ptr_ = u.ptr_; - u.ptr_ = temp_ptr; - } - - private: - T* ptr_; - }; - - template <class T> bool operator==(const unique_ptr<T>& x, - const unique_ptr<T>& y) { - return x.get() == y.get(); - } - - template <class T, class D> bool operator==(const unique_ptr<T>& x, - const D* y) { - return static_cast<D*>(x.get()) == y; - } - - template <class T> bool operator==(const unique_ptr<T>& x, intptr_t y) { - return reinterpret_cast<intptr_t>(x.get()) == y; - } + // for C++98 STL implementations. + template <class T> class unique_ptr : public std::unique_ptr<T> { + public: + unique_ptr() {} + explicit unique_ptr(T* p) : std::unique_ptr<T>(p) {} + unique_ptr(std::unique_ptr<T>&& u) { *this = std::move(u); } + unique_ptr(unique_ptr&& u) { *this = std::move(u); } + unique_ptr& operator=(std::unique_ptr<T>&& u) { + std::unique_ptr<T>::reset(u.release()); + return *this; + } + unique_ptr& operator=(unique_ptr&& u) { + std::unique_ptr<T>::reset(u.release()); + return *this; + } + unique_ptr& operator=(T* p) { + return std::unique_ptr<T>::operator=(p); + } + }; + #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) +#else + // Very limited implementation of unique_ptr. + // This is provided simply to allow the C++ code generated from the default + // settings to function in C++98 environments with no modifications. + template <class T> class unique_ptr { + public: + typedef T element_type; + + unique_ptr() : ptr_(nullptr) {} + explicit unique_ptr(T* p) : ptr_(p) {} + unique_ptr(unique_ptr&& u) : ptr_(nullptr) { reset(u.release()); } + unique_ptr(const unique_ptr& u) : ptr_(nullptr) { + reset(const_cast<unique_ptr*>(&u)->release()); + } + ~unique_ptr() { reset(); } + + unique_ptr& operator=(const unique_ptr& u) { + reset(const_cast<unique_ptr*>(&u)->release()); + return *this; + } + + unique_ptr& operator=(unique_ptr&& u) { + reset(u.release()); + return *this; + } + + unique_ptr& operator=(T* p) { + reset(p); + return *this; + } + + const T& operator*() const { return *ptr_; } + T* operator->() const { return ptr_; } + T* get() const noexcept { return ptr_; } + explicit operator bool() const { return ptr_ != nullptr; } + + // modifiers + T* release() { + T* value = ptr_; + ptr_ = nullptr; + return value; + } + + void reset(T* p = nullptr) { + T* value = ptr_; + ptr_ = p; + if (value) delete value; + } + + void swap(unique_ptr& u) { + T* temp_ptr = ptr_; + ptr_ = u.ptr_; + u.ptr_ = temp_ptr; + } + + private: + T* ptr_; + }; + + template <class T> bool operator==(const unique_ptr<T>& x, + const unique_ptr<T>& y) { + return x.get() == y.get(); + } + + template <class T, class D> bool operator==(const unique_ptr<T>& x, + const D* y) { + return static_cast<D*>(x.get()) == y; + } + + template <class T> bool operator==(const unique_ptr<T>& x, intptr_t y) { + return reinterpret_cast<intptr_t>(x.get()) == y; + } template <class T> bool operator!=(const unique_ptr<T>& x, decltype(nullptr)) { return !!x; @@ -326,8 +326,8 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) { return !x; } -#endif // !FLATBUFFERS_CPP98_STL - +#endif // !FLATBUFFERS_CPP98_STL + #ifdef FLATBUFFERS_USE_STD_OPTIONAL template<class T> using Optional = std::optional<T>; @@ -668,6 +668,6 @@ class span FLATBUFFERS_FINAL_CLASS { #endif // defined(FLATBUFFERS_USE_STD_SPAN) -} // namespace flatbuffers - -#endif // FLATBUFFERS_STL_EMULATION_H_ +} // namespace flatbuffers + +#endif // FLATBUFFERS_STL_EMULATION_H_ diff --git a/contrib/libs/flatbuffers/include/flatbuffers/util.h b/contrib/libs/flatbuffers/include/flatbuffers/util.h index 4493c561c2..0501a6df66 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/util.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/util.h @@ -22,11 +22,11 @@ #include "base.h" #include "stl_emulation.h" -#ifndef FLATBUFFERS_PREFER_PRINTF -# include <sstream> +#ifndef FLATBUFFERS_PREFER_PRINTF +# include <sstream> #else // FLATBUFFERS_PREFER_PRINTF -# include <float.h> -# include <stdio.h> +# include <float.h> +# include <stdio.h> #endif // FLATBUFFERS_PREFER_PRINTF #include <iomanip> @@ -86,54 +86,54 @@ inline char CharToLower(char c) { // @end-locale-independent functions for ASCII character set -#ifdef FLATBUFFERS_PREFER_PRINTF -template<typename T> size_t IntToDigitCount(T t) { - size_t digit_count = 0; - // Count the sign for negative numbers - if (t < 0) digit_count++; - // Count a single 0 left of the dot for fractional numbers - if (-1 < t && t < 1) digit_count++; - // Count digits until fractional part - T eps = std::numeric_limits<float>::epsilon(); - while (t <= (-1 + eps) || (1 - eps) <= t) { - t /= 10; - digit_count++; - } - return digit_count; -} - -template<typename T> size_t NumToStringWidth(T t, int precision = 0) { - size_t string_width = IntToDigitCount(t); - // Count the dot for floating point numbers - if (precision) string_width += (precision + 1); - return string_width; -} - +#ifdef FLATBUFFERS_PREFER_PRINTF +template<typename T> size_t IntToDigitCount(T t) { + size_t digit_count = 0; + // Count the sign for negative numbers + if (t < 0) digit_count++; + // Count a single 0 left of the dot for fractional numbers + if (-1 < t && t < 1) digit_count++; + // Count digits until fractional part + T eps = std::numeric_limits<float>::epsilon(); + while (t <= (-1 + eps) || (1 - eps) <= t) { + t /= 10; + digit_count++; + } + return digit_count; +} + +template<typename T> size_t NumToStringWidth(T t, int precision = 0) { + size_t string_width = IntToDigitCount(t); + // Count the dot for floating point numbers + if (precision) string_width += (precision + 1); + return string_width; +} + template<typename T> std::string NumToStringImplWrapper(T t, const char *fmt, int precision = 0) { - size_t string_width = NumToStringWidth(t, precision); - std::string s(string_width, 0x00); - // Allow snprintf to use std::string trailing null to detect buffer overflow + size_t string_width = NumToStringWidth(t, precision); + std::string s(string_width, 0x00); + // Allow snprintf to use std::string trailing null to detect buffer overflow snprintf(const_cast<char *>(s.data()), (s.size() + 1), fmt, string_width, t); - return s; -} + return s; +} #endif // FLATBUFFERS_PREFER_PRINTF - + // Convert an integer or floating point value to a string. // In contrast to std::stringstream, "char" values are // converted to a string of digits, and we don't use scientific notation. template<typename T> std::string NumToString(T t) { - // clang-format off - - #ifndef FLATBUFFERS_PREFER_PRINTF - std::stringstream ss; - ss << t; - return ss.str(); - #else // FLATBUFFERS_PREFER_PRINTF - auto v = static_cast<long long>(t); - return NumToStringImplWrapper(v, "%.*lld"); - #endif // FLATBUFFERS_PREFER_PRINTF - // clang-format on + // clang-format off + + #ifndef FLATBUFFERS_PREFER_PRINTF + std::stringstream ss; + ss << t; + return ss.str(); + #else // FLATBUFFERS_PREFER_PRINTF + auto v = static_cast<long long>(t); + return NumToStringImplWrapper(v, "%.*lld"); + #endif // FLATBUFFERS_PREFER_PRINTF + // clang-format on } // Avoid char types used as character data. template<> inline std::string NumToString<signed char>(signed char t) { @@ -145,54 +145,54 @@ template<> inline std::string NumToString<unsigned char>(unsigned char t) { template<> inline std::string NumToString<char>(char t) { return NumToString(static_cast<int>(t)); } -#if defined(FLATBUFFERS_CPP98_STL) -template<> inline std::string NumToString<long long>(long long t) { - char buf[21]; // (log((1 << 63) - 1) / log(10)) + 2 - snprintf(buf, sizeof(buf), "%lld", t); - return std::string(buf); -} - -template<> -inline std::string NumToString<unsigned long long>(unsigned long long t) { - char buf[22]; // (log((1 << 63) - 1) / log(10)) + 1 - snprintf(buf, sizeof(buf), "%llu", t); - return std::string(buf); -} -#endif // defined(FLATBUFFERS_CPP98_STL) - +#if defined(FLATBUFFERS_CPP98_STL) +template<> inline std::string NumToString<long long>(long long t) { + char buf[21]; // (log((1 << 63) - 1) / log(10)) + 2 + snprintf(buf, sizeof(buf), "%lld", t); + return std::string(buf); +} + +template<> +inline std::string NumToString<unsigned long long>(unsigned long long t) { + char buf[22]; // (log((1 << 63) - 1) / log(10)) + 1 + snprintf(buf, sizeof(buf), "%llu", t); + return std::string(buf); +} +#endif // defined(FLATBUFFERS_CPP98_STL) + // Special versions for floats/doubles. -template<typename T> std::string FloatToString(T t, int precision) { - // clang-format off - - #ifndef FLATBUFFERS_PREFER_PRINTF - // to_string() prints different numbers of digits for floats depending on - // platform and isn't available on Android, so we use stringstream - std::stringstream ss; - // Use std::fixed to suppress scientific notation. - ss << std::fixed; - // Default precision is 6, we want that to be higher for doubles. - ss << std::setprecision(precision); - ss << t; - auto s = ss.str(); - #else // FLATBUFFERS_PREFER_PRINTF - auto v = static_cast<double>(t); - auto s = NumToStringImplWrapper(v, "%0.*f", precision); - #endif // FLATBUFFERS_PREFER_PRINTF - // clang-format on +template<typename T> std::string FloatToString(T t, int precision) { + // clang-format off + + #ifndef FLATBUFFERS_PREFER_PRINTF + // to_string() prints different numbers of digits for floats depending on + // platform and isn't available on Android, so we use stringstream + std::stringstream ss; + // Use std::fixed to suppress scientific notation. + ss << std::fixed; + // Default precision is 6, we want that to be higher for doubles. + ss << std::setprecision(precision); + ss << t; + auto s = ss.str(); + #else // FLATBUFFERS_PREFER_PRINTF + auto v = static_cast<double>(t); + auto s = NumToStringImplWrapper(v, "%0.*f", precision); + #endif // FLATBUFFERS_PREFER_PRINTF + // clang-format on // Sadly, std::fixed turns "1" into "1.00000", so here we undo that. auto p = s.find_last_not_of('0'); if (p != std::string::npos) { - // Strip trailing zeroes. If it is a whole number, keep one zero. - s.resize(p + (s[p] == '.' ? 2 : 1)); + // Strip trailing zeroes. If it is a whole number, keep one zero. + s.resize(p + (s[p] == '.' ? 2 : 1)); } return s; } - -template<> inline std::string NumToString<double>(double t) { - return FloatToString(t, 12); -} + +template<> inline std::string NumToString<double>(double t) { + return FloatToString(t, 12); +} template<> inline std::string NumToString<float>(float t) { - return FloatToString(t, 6); + return FloatToString(t, 6); } // Convert an integer value to a hexadecimal string. @@ -200,17 +200,17 @@ template<> inline std::string NumToString<float>(float t) { // For example, IntToStringHex(0x23, 8) returns the string "00000023". inline std::string IntToStringHex(int i, int xdigits) { FLATBUFFERS_ASSERT(i >= 0); - // clang-format off - - #ifndef FLATBUFFERS_PREFER_PRINTF - std::stringstream ss; - ss << std::setw(xdigits) << std::setfill('0') << std::hex << std::uppercase - << i; - return ss.str(); - #else // FLATBUFFERS_PREFER_PRINTF - return NumToStringImplWrapper(i, "%.*X", xdigits); - #endif // FLATBUFFERS_PREFER_PRINTF - // clang-format on + // clang-format off + + #ifndef FLATBUFFERS_PREFER_PRINTF + std::stringstream ss; + ss << std::setw(xdigits) << std::setfill('0') << std::hex << std::uppercase + << i; + return ss.str(); + #else // FLATBUFFERS_PREFER_PRINTF + return NumToStringImplWrapper(i, "%.*X", xdigits); + #endif // FLATBUFFERS_PREFER_PRINTF + // clang-format on } // clang-format off @@ -405,26 +405,26 @@ inline uint64_t StringToUInt(const char *s, int base = 10) { return StringToIntegerImpl(&val, s, base) ? val : 0; } -typedef bool (*LoadFileFunction)(const char *filename, bool binary, - std::string *dest); -typedef bool (*FileExistsFunction)(const char *filename); - -LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function); - -FileExistsFunction SetFileExistsFunction( - FileExistsFunction file_exists_function); - +typedef bool (*LoadFileFunction)(const char *filename, bool binary, + std::string *dest); +typedef bool (*FileExistsFunction)(const char *filename); + +LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function); + +FileExistsFunction SetFileExistsFunction( + FileExistsFunction file_exists_function); + // Check if file "name" exists. -bool FileExists(const char *name); - -// Check if "name" exists and it is also a directory. -bool DirExists(const char *name); +bool FileExists(const char *name); +// Check if "name" exists and it is also a directory. +bool DirExists(const char *name); + // Load file "name" into "buf" returning true if successful // false otherwise. If "binary" is false data is read // using ifstream's text mode, otherwise data is read with // no transcoding. -bool LoadFile(const char *name, bool binary, std::string *buf); +bool LoadFile(const char *name, bool binary, std::string *buf); // Save data "buf" of length "len" bytes into a file // "name" returning true if successful, false otherwise. @@ -441,14 +441,14 @@ inline bool SaveFile(const char *name, const std::string &buf, bool binary) { return SaveFile(name, buf.c_str(), buf.size(), binary); } -// Functionality for minimalistic portable path handling. +// Functionality for minimalistic portable path handling. -// The functions below behave correctly regardless of whether posix ('/') or -// Windows ('/' or '\\') separators are used. - -// Any new separators inserted are always posix. +// The functions below behave correctly regardless of whether posix ('/') or +// Windows ('/' or '\\') separators are used. + +// Any new separators inserted are always posix. FLATBUFFERS_CONSTEXPR char kPathSeparator = '/'; - + // Returns the path with the extension, if any, removed. std::string StripExtension(const std::string &filepath); @@ -466,9 +466,9 @@ std::string StripFileName(const std::string &filepath); std::string ConCatPathFileName(const std::string &path, const std::string &filename); -// Replaces any '\\' separators with '/' +// Replaces any '\\' separators with '/' std::string PosixPath(const char *path); - + // This function ensure a directory exists, by recursively // creating dirs for any parts of the path that don't exist yet. void EnsureDirExists(const std::string &filepath); @@ -482,7 +482,7 @@ std::string AbsolutePath(const std::string &filepath); // Convert a unicode code point into a UTF-8 representation by appending it // to a string. Returns the number of bytes generated. inline int ToUTF8(uint32_t ucc, std::string *out) { - FLATBUFFERS_ASSERT(!(ucc & 0x80000000)); // Top bit can't be set. + FLATBUFFERS_ASSERT(!(ucc & 0x80000000)); // Top bit can't be set. // 6 possible encodings: http://en.wikipedia.org/wiki/UTF-8 for (int i = 0; i < 6; i++) { // Max bits this encoding can represent. @@ -492,7 +492,7 @@ inline int ToUTF8(uint32_t ucc, std::string *out) { uint32_t remain_bits = i * 6; // Store first byte: (*out) += static_cast<char>((0xFE << (max_bits - remain_bits)) | - (ucc >> remain_bits)); + (ucc >> remain_bits)); // Store remaining bytes: for (int j = i - 1; j >= 0; j--) { (*out) += static_cast<char>(((ucc >> (j * 6)) & 0x3F) | 0x80); @@ -500,7 +500,7 @@ inline int ToUTF8(uint32_t ucc, std::string *out) { return i + 1; // Return the number of bytes added. } } - FLATBUFFERS_ASSERT(0); // Impossible to arrive here. + FLATBUFFERS_ASSERT(0); // Impossible to arrive here. return -1; } @@ -522,8 +522,8 @@ inline int FromUTF8(const char **in) { if ((static_cast<unsigned char>(**in) << len) & 0x80) return -1; // Bit after leading 1's must be 0. if (!len) return *(*in)++; - // UTF-8 encoded values with a length are between 2 and 4 bytes. - if (len < 2 || len > 4) { return -1; } + // UTF-8 encoded values with a length are between 2 and 4 bytes. + if (len < 2 || len > 4) { return -1; } // Grab initial bits of the code. int ucc = *(*in)++ & ((1 << (7 - len)) - 1); for (int i = 0; i < len - 1; i++) { @@ -531,28 +531,28 @@ inline int FromUTF8(const char **in) { ucc <<= 6; ucc |= *(*in)++ & 0x3F; // Grab 6 more bits of the code. } - // UTF-8 cannot encode values between 0xD800 and 0xDFFF (reserved for - // UTF-16 surrogate pairs). - if (ucc >= 0xD800 && ucc <= 0xDFFF) { return -1; } - // UTF-8 must represent code points in their shortest possible encoding. - switch (len) { - case 2: - // Two bytes of UTF-8 can represent code points from U+0080 to U+07FF. - if (ucc < 0x0080 || ucc > 0x07FF) { return -1; } - break; - case 3: - // Three bytes of UTF-8 can represent code points from U+0800 to U+FFFF. - if (ucc < 0x0800 || ucc > 0xFFFF) { return -1; } - break; - case 4: - // Four bytes of UTF-8 can represent code points from U+10000 to U+10FFFF. - if (ucc < 0x10000 || ucc > 0x10FFFF) { return -1; } - break; - } + // UTF-8 cannot encode values between 0xD800 and 0xDFFF (reserved for + // UTF-16 surrogate pairs). + if (ucc >= 0xD800 && ucc <= 0xDFFF) { return -1; } + // UTF-8 must represent code points in their shortest possible encoding. + switch (len) { + case 2: + // Two bytes of UTF-8 can represent code points from U+0080 to U+07FF. + if (ucc < 0x0080 || ucc > 0x07FF) { return -1; } + break; + case 3: + // Three bytes of UTF-8 can represent code points from U+0800 to U+FFFF. + if (ucc < 0x0800 || ucc > 0xFFFF) { return -1; } + break; + case 4: + // Four bytes of UTF-8 can represent code points from U+10000 to U+10FFFF. + if (ucc < 0x10000 || ucc > 0x10FFFF) { return -1; } + break; + } return ucc; } -#ifndef FLATBUFFERS_PREFER_PRINTF +#ifndef FLATBUFFERS_PREFER_PRINTF // Wraps a string to a maximum length, inserting new lines where necessary. Any // existing whitespace will be collapsed down to a single space. A prefix or // suffix can be provided, which will be inserted before or after a wrapped @@ -581,76 +581,76 @@ inline std::string WordWrap(const std::string in, size_t max_length, } #endif // !FLATBUFFERS_PREFER_PRINTF -inline bool EscapeString(const char *s, size_t length, std::string *_text, - bool allow_non_utf8, bool natural_utf8) { - std::string &text = *_text; - text += "\""; - for (uoffset_t i = 0; i < length; i++) { - char c = s[i]; - switch (c) { - case '\n': text += "\\n"; break; - case '\t': text += "\\t"; break; - case '\r': text += "\\r"; break; - case '\b': text += "\\b"; break; - case '\f': text += "\\f"; break; - case '\"': text += "\\\""; break; - case '\\': text += "\\\\"; break; - default: - if (c >= ' ' && c <= '~') { - text += c; - } else { - // Not printable ASCII data. Let's see if it's valid UTF-8 first: - const char *utf8 = s + i; - int ucc = FromUTF8(&utf8); - if (ucc < 0) { - if (allow_non_utf8) { - text += "\\x"; - text += IntToStringHex(static_cast<uint8_t>(c), 2); - } else { - // There are two cases here: - // - // 1) We reached here by parsing an IDL file. In that case, - // we previously checked for non-UTF-8, so we shouldn't reach - // here. - // - // 2) We reached here by someone calling GenerateText() - // on a previously-serialized flatbuffer. The data might have - // non-UTF-8 Strings, or might be corrupt. - // - // In both cases, we have to give up and inform the caller - // they have no JSON. - return false; - } - } else { - if (natural_utf8) { - // utf8 points to past all utf-8 bytes parsed - text.append(s + i, static_cast<size_t>(utf8 - s - i)); - } else if (ucc <= 0xFFFF) { - // Parses as Unicode within JSON's \uXXXX range, so use that. - text += "\\u"; - text += IntToStringHex(ucc, 4); - } else if (ucc <= 0x10FFFF) { - // Encode Unicode SMP values to a surrogate pair using two \u - // escapes. - uint32_t base = ucc - 0x10000; - auto high_surrogate = (base >> 10) + 0xD800; - auto low_surrogate = (base & 0x03FF) + 0xDC00; - text += "\\u"; - text += IntToStringHex(high_surrogate, 4); - text += "\\u"; - text += IntToStringHex(low_surrogate, 4); - } - // Skip past characters recognized. - i = static_cast<uoffset_t>(utf8 - s - 1); - } - } - break; - } - } - text += "\""; - return true; -} - +inline bool EscapeString(const char *s, size_t length, std::string *_text, + bool allow_non_utf8, bool natural_utf8) { + std::string &text = *_text; + text += "\""; + for (uoffset_t i = 0; i < length; i++) { + char c = s[i]; + switch (c) { + case '\n': text += "\\n"; break; + case '\t': text += "\\t"; break; + case '\r': text += "\\r"; break; + case '\b': text += "\\b"; break; + case '\f': text += "\\f"; break; + case '\"': text += "\\\""; break; + case '\\': text += "\\\\"; break; + default: + if (c >= ' ' && c <= '~') { + text += c; + } else { + // Not printable ASCII data. Let's see if it's valid UTF-8 first: + const char *utf8 = s + i; + int ucc = FromUTF8(&utf8); + if (ucc < 0) { + if (allow_non_utf8) { + text += "\\x"; + text += IntToStringHex(static_cast<uint8_t>(c), 2); + } else { + // There are two cases here: + // + // 1) We reached here by parsing an IDL file. In that case, + // we previously checked for non-UTF-8, so we shouldn't reach + // here. + // + // 2) We reached here by someone calling GenerateText() + // on a previously-serialized flatbuffer. The data might have + // non-UTF-8 Strings, or might be corrupt. + // + // In both cases, we have to give up and inform the caller + // they have no JSON. + return false; + } + } else { + if (natural_utf8) { + // utf8 points to past all utf-8 bytes parsed + text.append(s + i, static_cast<size_t>(utf8 - s - i)); + } else if (ucc <= 0xFFFF) { + // Parses as Unicode within JSON's \uXXXX range, so use that. + text += "\\u"; + text += IntToStringHex(ucc, 4); + } else if (ucc <= 0x10FFFF) { + // Encode Unicode SMP values to a surrogate pair using two \u + // escapes. + uint32_t base = ucc - 0x10000; + auto high_surrogate = (base >> 10) + 0xD800; + auto low_surrogate = (base & 0x03FF) + 0xDC00; + text += "\\u"; + text += IntToStringHex(high_surrogate, 4); + text += "\\u"; + text += IntToStringHex(low_surrogate, 4); + } + // Skip past characters recognized. + i = static_cast<uoffset_t>(utf8 - s - 1); + } + } + break; + } + } + text += "\""; + return true; +} + inline std::string BufferToHexText(const void *buffer, size_t buffer_size, size_t max_length, const std::string &wrapped_line_prefix, diff --git a/contrib/libs/grpc/src/core/lib/gprpp/thd_posix.cc b/contrib/libs/grpc/src/core/lib/gprpp/thd_posix.cc index f6f6af9c26..158978cfac 100644 --- a/contrib/libs/grpc/src/core/lib/gprpp/thd_posix.cc +++ b/contrib/libs/grpc/src/core/lib/gprpp/thd_posix.cc @@ -112,7 +112,7 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface { thd_arg arg = *static_cast<thd_arg*>(v); free(v); if (arg.name != nullptr) { - TThread::SetCurrentThreadName(arg.name); + TThread::SetCurrentThreadName(arg.name); } gpr_mu_lock(&arg.thread->mu_); diff --git a/contrib/libs/libunwind/include/unwind.h b/contrib/libs/libunwind/include/unwind.h index 6949e063dd..d276eeb72c 100644 --- a/contrib/libs/libunwind/include/unwind.h +++ b/contrib/libs/libunwind/include/unwind.h @@ -200,21 +200,21 @@ extern EXCEPTION_DISPOSITION _GCC_specific_handler(EXCEPTION_RECORD *exc, _Unwind_Personality_Fn pers); #endif -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE - -#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE 128 -// NB. How to compute: -// offsetof(__cxa_exception, unwindHeader) + (sizeof(_Unwind_Backtrace_Buffer) + 15) / 16 * 16 - sizeof(_Unwind_Backtrace_Buffer) -// Correctness of this value is static_assert'd in contrib/libs/cxxsupp/libcxxrta/exception.cc -#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET 104 -#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS 0xacadacadull -#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS 0xddddacadull - -typedef struct _Unwind_Backtrace_Buffer { - size_t size; - void* backtrace[_YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE]; -} _Unwind_Backtrace_Buffer; -#endif +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE + +#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE 128 +// NB. How to compute: +// offsetof(__cxa_exception, unwindHeader) + (sizeof(_Unwind_Backtrace_Buffer) + 15) / 16 * 16 - sizeof(_Unwind_Backtrace_Buffer) +// Correctness of this value is static_assert'd in contrib/libs/cxxsupp/libcxxrta/exception.cc +#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET 104 +#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS 0xacadacadull +#define _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS 0xddddacadull + +typedef struct _Unwind_Backtrace_Buffer { + size_t size; + void* backtrace[_YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE]; +} _Unwind_Backtrace_Buffer; +#endif #ifdef __cplusplus } #endif diff --git a/contrib/libs/libunwind/src/UnwindLevel1.c b/contrib/libs/libunwind/src/UnwindLevel1.c index 13ca17cc6a..2480511563 100644 --- a/contrib/libs/libunwind/src/UnwindLevel1.c +++ b/contrib/libs/libunwind/src/UnwindLevel1.c @@ -71,15 +71,15 @@ static _Unwind_Reason_Code unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { __unw_init_local(cursor, uc); -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE - _Unwind_Backtrace_Buffer* backtrace_buffer = - exception_object->exception_class == _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS || - exception_object->exception_class == _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS ? - (_Unwind_Backtrace_Buffer *)( - (char*)exception_object - _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET) - 1 - : NULL; -#endif - +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE + _Unwind_Backtrace_Buffer* backtrace_buffer = + exception_object->exception_class == _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS || + exception_object->exception_class == _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS ? + (_Unwind_Backtrace_Buffer *)( + (char*)exception_object - _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET) - 1 + : NULL; +#endif + // Walk each frame looking for a place to stop. while (true) { // Ask libunwind to get next frame (skip over first which is @@ -99,14 +99,14 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except return _URC_FATAL_PHASE1_ERROR; } -#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE - if (backtrace_buffer && backtrace_buffer->size < _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE) { - unw_word_t pc; - __unw_get_reg(cursor, UNW_REG_IP, &pc); - backtrace_buffer->backtrace[backtrace_buffer->size++] = (void *)pc; - } -#endif - +#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE + if (backtrace_buffer && backtrace_buffer->size < _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE) { + unw_word_t pc; + __unw_get_reg(cursor, UNW_REG_IP, &pc); + backtrace_buffer->backtrace[backtrace_buffer->size++] = (void *)pc; + } +#endif + // See if frame has code to run (has personality routine). unw_proc_info_t frameInfo; unw_word_t sp; diff --git a/contrib/libs/pire/pire/any.h b/contrib/libs/pire/pire/any.h index 4646d25781..cb8f64ff7d 100644 --- a/contrib/libs/pire/pire/any.h +++ b/contrib/libs/pire/pire/any.h @@ -80,7 +80,7 @@ public: throw Pire::Error("type mismatch"); } - void Swap(Any& a) noexcept { + void Swap(Any& a) noexcept { DoSwap(h, a.h); } diff --git a/contrib/libs/pire/pire/stub/stl.h b/contrib/libs/pire/pire/stub/stl.h index 98ebd9f7c6..4bcc32d886 100644 --- a/contrib/libs/pire/pire/stub/stl.h +++ b/contrib/libs/pire/pire/stub/stl.h @@ -22,7 +22,7 @@ #include <util/generic/algorithm.h> #include <util/stream/input.h> #include <util/stream/output.h> -#include <util/string/reverse.h> +#include <util/string/reverse.h> #include <util/string/vector.h> namespace Pire { diff --git a/contrib/libs/poco/Crypto/include/Poco/Crypto/CryptoException.h b/contrib/libs/poco/Crypto/include/Poco/Crypto/CryptoException.h index 8bd5b011c4..6c73133d24 100644 --- a/contrib/libs/poco/Crypto/include/Poco/Crypto/CryptoException.h +++ b/contrib/libs/poco/Crypto/include/Poco/Crypto/CryptoException.h @@ -40,8 +40,8 @@ public: OpenSSLException(const OpenSSLException& exc); ~OpenSSLException() noexcept; OpenSSLException& operator = (const OpenSSLException& exc); - const char* name() const noexcept; - const char* className() const noexcept; + const char* name() const noexcept; + const char* className() const noexcept; Poco::Exception* clone() const; void rethrow() const; diff --git a/contrib/libs/poco/Crypto/src/CryptoException.cpp b/contrib/libs/poco/Crypto/src/CryptoException.cpp index e30940d229..c22ad2ed6b 100644 --- a/contrib/libs/poco/Crypto/src/CryptoException.cpp +++ b/contrib/libs/poco/Crypto/src/CryptoException.cpp @@ -68,13 +68,13 @@ OpenSSLException& OpenSSLException::operator = (const OpenSSLException& exc) } -const char* OpenSSLException::name() const noexcept +const char* OpenSSLException::name() const noexcept { return "OpenSSLException"; } -const char* OpenSSLException::className() const noexcept +const char* OpenSSLException::className() const noexcept { return typeid(*this).name(); } diff --git a/contrib/libs/poco/Foundation/include/Poco/BufferAllocator.h b/contrib/libs/poco/Foundation/include/Poco/BufferAllocator.h index c767fe4ad7..789f2acb6d 100644 --- a/contrib/libs/poco/Foundation/include/Poco/BufferAllocator.h +++ b/contrib/libs/poco/Foundation/include/Poco/BufferAllocator.h @@ -39,7 +39,7 @@ public: return new char_type[static_cast<std::size_t>(size)]; } - static void deallocate(char_type* ptr, std::streamsize /*size*/) noexcept + static void deallocate(char_type* ptr, std::streamsize /*size*/) noexcept { delete [] ptr; } diff --git a/contrib/libs/poco/Foundation/include/Poco/Exception.h b/contrib/libs/poco/Foundation/include/Poco/Exception.h index b2ad47ce89..20d0ab5307 100644 --- a/contrib/libs/poco/Foundation/include/Poco/Exception.h +++ b/contrib/libs/poco/Foundation/include/Poco/Exception.h @@ -49,13 +49,13 @@ public: Exception& operator = (const Exception& exc); /// Assignment operator. - virtual const char* name() const noexcept; + virtual const char* name() const noexcept; /// Returns a static string describing the exception. - virtual const char* className() const noexcept; + virtual const char* className() const noexcept; /// Returns the name of the exception class. - virtual const char* what() const noexcept; + virtual const char* what() const noexcept; /// Returns a static string describing the exception. /// /// Same as name(), but for compatibility with std::exception. @@ -148,8 +148,8 @@ inline int Exception::code() const CLS(const CLS& exc); \ ~CLS() noexcept; \ CLS& operator = (const CLS& exc); \ - const char* name() const noexcept; \ - const char* className() const noexcept; \ + const char* name() const noexcept; \ + const char* className() const noexcept; \ Poco::Exception* clone() const; \ void rethrow() const; \ }; @@ -181,11 +181,11 @@ inline int Exception::code() const BASE::operator = (exc); \ return *this; \ } \ - const char* CLS::name() const noexcept \ + const char* CLS::name() const noexcept \ { \ return NAME; \ } \ - const char* CLS::className() const noexcept \ + const char* CLS::className() const noexcept \ { \ return typeid(*this).name(); \ } \ diff --git a/contrib/libs/poco/Foundation/include/Poco/RefCountedObject.h b/contrib/libs/poco/Foundation/include/Poco/RefCountedObject.h index 55ea76a167..00c32af3ef 100644 --- a/contrib/libs/poco/Foundation/include/Poco/RefCountedObject.h +++ b/contrib/libs/poco/Foundation/include/Poco/RefCountedObject.h @@ -40,7 +40,7 @@ public: void duplicate() const; /// Increments the object's reference count. - void release() const noexcept; + void release() const noexcept; /// Decrements the object's reference count /// and deletes the object if the count /// reaches zero. @@ -75,7 +75,7 @@ inline void RefCountedObject::duplicate() const } -inline void RefCountedObject::release() const noexcept +inline void RefCountedObject::release() const noexcept { try { diff --git a/contrib/libs/poco/Foundation/src/Exception.cpp b/contrib/libs/poco/Foundation/src/Exception.cpp index 1f0fe6fbcb..e75965ddfe 100644 --- a/contrib/libs/poco/Foundation/src/Exception.cpp +++ b/contrib/libs/poco/Foundation/src/Exception.cpp @@ -73,19 +73,19 @@ Exception& Exception::operator = (const Exception& exc) } -const char* Exception::name() const noexcept +const char* Exception::name() const noexcept { return "Exception"; } -const char* Exception::className() const noexcept +const char* Exception::className() const noexcept { return typeid(*this).name(); } -const char* Exception::what() const noexcept +const char* Exception::what() const noexcept { return name(); } diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h index 456526f111..968743777f 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h @@ -70,10 +70,10 @@ public: DOMException& operator = (const DOMException& exc); - const char* name() const noexcept; + const char* name() const noexcept; /// Returns a static string describing the exception. - const char* className() const noexcept; + const char* className() const noexcept; /// Returns the name of the exception class. Poco::Exception* clone() const; diff --git a/contrib/libs/poco/XML/include/Poco/DOM/EventException.h b/contrib/libs/poco/XML/include/Poco/DOM/EventException.h index cb82441058..fa69316422 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/EventException.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/EventException.h @@ -49,10 +49,10 @@ public: EventException& operator = (const EventException& exc); - const char* name() const noexcept; + const char* name() const noexcept; /// Returns a static string describing the exception. - const char* className() const noexcept; + const char* className() const noexcept; /// Returns the name of the exception class. unsigned short code() const; diff --git a/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h b/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h index e1f9cae8e4..c6af682b41 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h @@ -104,10 +104,10 @@ public: SAXParseException& operator = (const SAXParseException& exc); /// Assignment operator. - const char* name() const noexcept; + const char* name() const noexcept; /// Returns a static string describing the exception. - const char* className() const noexcept; + const char* className() const noexcept; /// Returns the name of the exception class. Poco::Exception* clone() const; diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h b/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h index 88e4ff3304..8d5bdaf4f2 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h @@ -35,11 +35,11 @@ public: XMLStreamParserException(const XMLStreamParser&, const std::string& description); virtual ~XMLStreamParserException() noexcept; - const char* name() const noexcept; + const char* name() const noexcept; Poco::UInt64 line() const; Poco::UInt64 column() const; const std::string& description() const; - virtual const char* what() const noexcept; + virtual const char* what() const noexcept; private: void init(); diff --git a/contrib/libs/poco/XML/src/DOMException.cpp b/contrib/libs/poco/XML/src/DOMException.cpp index 546a1e2aae..da7c999055 100644 --- a/contrib/libs/poco/XML/src/DOMException.cpp +++ b/contrib/libs/poco/XML/src/DOMException.cpp @@ -71,13 +71,13 @@ DOMException& DOMException::operator = (const DOMException& exc) } -const char* DOMException::name() const noexcept +const char* DOMException::name() const noexcept { return "DOMException"; } -const char* DOMException::className() const noexcept +const char* DOMException::className() const noexcept { return typeid(*this).name(); } diff --git a/contrib/libs/poco/XML/src/EventException.cpp b/contrib/libs/poco/XML/src/EventException.cpp index d2d07bd1c6..991bdf8a41 100644 --- a/contrib/libs/poco/XML/src/EventException.cpp +++ b/contrib/libs/poco/XML/src/EventException.cpp @@ -44,13 +44,13 @@ EventException& EventException::operator = (const EventException& exc) } -const char* EventException::name() const noexcept +const char* EventException::name() const noexcept { return "EventException"; } -const char* EventException::className() const noexcept +const char* EventException::className() const noexcept { return typeid(*this).name(); } diff --git a/contrib/libs/poco/XML/src/SAXException.cpp b/contrib/libs/poco/XML/src/SAXException.cpp index 112747b08f..cfcdb97653 100644 --- a/contrib/libs/poco/XML/src/SAXException.cpp +++ b/contrib/libs/poco/XML/src/SAXException.cpp @@ -96,13 +96,13 @@ SAXParseException& SAXParseException::operator = (const SAXParseException& exc) } -const char* SAXParseException::name() const noexcept +const char* SAXParseException::name() const noexcept { return "SAXParseException"; } -const char* SAXParseException::className() const noexcept +const char* SAXParseException::className() const noexcept { return typeid(*this).name(); } diff --git a/contrib/libs/poco/XML/src/XMLStreamParserException.cpp b/contrib/libs/poco/XML/src/XMLStreamParserException.cpp index d7b01690ed..93867a395a 100644 --- a/contrib/libs/poco/XML/src/XMLStreamParserException.cpp +++ b/contrib/libs/poco/XML/src/XMLStreamParserException.cpp @@ -55,7 +55,7 @@ void XMLStreamParserException::init() } -const char* XMLStreamParserException::name() const noexcept +const char* XMLStreamParserException::name() const noexcept { return _name.c_str(); } @@ -79,7 +79,7 @@ const std::string& XMLStreamParserException::description() const } -char const* XMLStreamParserException::what() const noexcept +char const* XMLStreamParserException::what() const noexcept { return _what.c_str(); } diff --git a/contrib/libs/protobuf/src/google/protobuf/messagext.cc b/contrib/libs/protobuf/src/google/protobuf/messagext.cc index 1923205598..a47b53558a 100644 --- a/contrib/libs/protobuf/src/google/protobuf/messagext.cc +++ b/contrib/libs/protobuf/src/google/protobuf/messagext.cc @@ -167,11 +167,11 @@ private: }; void TProtoSerializer::Load(IInputStream* input, Message& msg) { - msg.Clear(); - MergeFrom(input, msg); -} - -void TProtoSerializer::MergeFrom(IInputStream* input, Message& msg) { + msg.Clear(); + MergeFrom(input, msg); +} + +void TProtoSerializer::MergeFrom(IInputStream* input, Message& msg) { ui32 size; if (!ReadVarint32(input, size)) ythrow yexception() << "Stream is exhausted"; @@ -180,7 +180,7 @@ void TProtoSerializer::MergeFrom(IInputStream* input, Message& msg) { ::LoadPodArray(input, buf.Data(), size); CodedInputStream decoder(buf.Data(), size); decoder.SetTotalBytesLimit(MaxSizeBytes); - if (!msg.MergeFromCodedStream(&decoder)) + if (!msg.MergeFromCodedStream(&decoder)) ythrow yexception() << "Cannot read protobuf::Message (" << msg.GetTypeName() << ") from input stream"; } diff --git a/contrib/libs/protobuf/src/google/protobuf/messagext.h b/contrib/libs/protobuf/src/google/protobuf/messagext.h index 9176cee1e8..e414c0ecd6 100644 --- a/contrib/libs/protobuf/src/google/protobuf/messagext.h +++ b/contrib/libs/protobuf/src/google/protobuf/messagext.h @@ -108,7 +108,7 @@ class TProtoSerializer { public: static void Save(IOutputStream* output, const Message& msg); static void Load(IInputStream* input, Message& msg); - static void MergeFrom(IInputStream* input, Message& msg); + static void MergeFrom(IInputStream* input, Message& msg); // similar interface for protobuf coded streams static inline bool Save(CodedOutputStream* output, const Message& msg) { diff --git a/contrib/libs/ya.make b/contrib/libs/ya.make index 9c4640fdcf..54a1c0c975 100644 --- a/contrib/libs/ya.make +++ b/contrib/libs/ya.make @@ -70,9 +70,9 @@ RECURSE( ffmpeg-3.4.1 fft flatbuffers - flatbuffers64 - flatbuffers64/flatc - flatbuffers64/samples + flatbuffers64 + flatbuffers64/flatc + flatbuffers64/samples fmath fmt fontconfig diff --git a/contrib/restricted/boost/boost/archive/codecvt_null.hpp b/contrib/restricted/boost/boost/archive/codecvt_null.hpp index 3d9a2dea92..88a56a1926 100644 --- a/contrib/restricted/boost/boost/archive/codecvt_null.hpp +++ b/contrib/restricted/boost/boost/archive/codecvt_null.hpp @@ -52,7 +52,7 @@ class codecvt_null; template<> class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t> { - virtual bool do_always_noconv() const noexcept { + virtual bool do_always_noconv() const noexcept { return true; } public: @@ -86,10 +86,10 @@ class BOOST_WARCHIVE_DECL codecvt_null<wchar_t> : wchar_t * last2, wchar_t * & next2 ) const; - virtual int do_encoding( ) const noexcept{ + virtual int do_encoding( ) const noexcept{ return sizeof(wchar_t) / sizeof(char); } - virtual int do_max_length( ) const noexcept{ + virtual int do_max_length( ) const noexcept{ return do_encoding(); } public: diff --git a/contrib/restricted/boost/boost/archive/iterators/base64_exception.hpp b/contrib/restricted/boost/boost/archive/iterators/base64_exception.hpp index 51d4e8bbf1..8c10bf2f78 100644 --- a/contrib/restricted/boost/boost/archive/iterators/base64_exception.hpp +++ b/contrib/restricted/boost/boost/archive/iterators/base64_exception.hpp @@ -42,7 +42,7 @@ public: base64_exception(exception_code c = other_exception) : code(c) {} - virtual const char *what( ) const noexcept + virtual const char *what( ) const noexcept { const char *msg = "unknown exception code"; switch(code){ diff --git a/contrib/restricted/boost/boost/archive/iterators/dataflow_exception.hpp b/contrib/restricted/boost/boost/archive/iterators/dataflow_exception.hpp index c3138aac7e..791c216e21 100644 --- a/contrib/restricted/boost/boost/archive/iterators/dataflow_exception.hpp +++ b/contrib/restricted/boost/boost/archive/iterators/dataflow_exception.hpp @@ -46,7 +46,7 @@ public: dataflow_exception(exception_code c = other_exception) : code(c) {} - virtual const char *what( ) const noexcept + virtual const char *what( ) const noexcept { const char *msg = "unknown exception code"; switch(code){ diff --git a/contrib/restricted/boost/boost/archive/iterators/xml_unescape_exception.hpp b/contrib/restricted/boost/boost/archive/iterators/xml_unescape_exception.hpp index 623dde24c5..789469a6f7 100644 --- a/contrib/restricted/boost/boost/archive/iterators/xml_unescape_exception.hpp +++ b/contrib/restricted/boost/boost/archive/iterators/xml_unescape_exception.hpp @@ -35,7 +35,7 @@ public: xml_unescape_exception() {} - virtual const char *what( ) const noexcept + virtual const char *what( ) const noexcept { return "xml contained un-recognized escape code"; } diff --git a/contrib/restricted/boost/boost/asio/detail/config.hpp b/contrib/restricted/boost/boost/asio/detail/config.hpp index 6a30d4aa11..c2dbec2794 100644 --- a/contrib/restricted/boost/boost/asio/detail/config.hpp +++ b/contrib/restricted/boost/boost/asio/detail/config.hpp @@ -255,7 +255,7 @@ # define BOOST_ASIO_NOEXCEPT # endif // !defined(BOOST_ASIO_NOEXCEPT) # if !defined(BOOST_ASIO_NOEXCEPT_OR_NOTHROW) -# define BOOST_ASIO_NOEXCEPT_OR_NOTHROW noexcept +# define BOOST_ASIO_NOEXCEPT_OR_NOTHROW noexcept # endif // !defined(BOOST_ASIO_NOEXCEPT_OR_NOTHROW) #endif // !defined(BOOST_ASIO_NOEXCEPT) diff --git a/contrib/restricted/boost/boost/assign/assignment_exception.hpp b/contrib/restricted/boost/boost/assign/assignment_exception.hpp index 7da9a25b92..2c5d73e86e 100644 --- a/contrib/restricted/boost/boost/assign/assignment_exception.hpp +++ b/contrib/restricted/boost/boost/assign/assignment_exception.hpp @@ -29,7 +29,7 @@ namespace boost : what_( _what ) { } - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return what_; } diff --git a/contrib/restricted/boost/boost/chrono/config.hpp b/contrib/restricted/boost/boost/chrono/config.hpp index c9d738f46a..756827260c 100644 --- a/contrib/restricted/boost/boost/chrono/config.hpp +++ b/contrib/restricted/boost/boost/chrono/config.hpp @@ -130,10 +130,10 @@ #endif #if defined( BOOST_NO_CXX11_NUMERIC_LIMITS ) -# define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept +# define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept #else #ifdef BOOST_NO_CXX11_NOEXCEPT -# define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept +# define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept #else # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept #endif diff --git a/contrib/restricted/boost/boost/chrono/process_cpu_clocks.hpp b/contrib/restricted/boost/boost/chrono/process_cpu_clocks.hpp index 6ea90913b7..8f9f9807a1 100644 --- a/contrib/restricted/boost/boost/chrono/process_cpu_clocks.hpp +++ b/contrib/restricted/boost/boost/chrono/process_cpu_clocks.hpp @@ -490,8 +490,8 @@ namespace std { static const bool is_integer = Rep::is_integer; static const bool is_exact = Rep::is_exact; static const int radix = 0; - //~ static Res epsilon() { return 0; } - //~ static Res round_error() { return 0; } + //~ static Res epsilon() { return 0; } + //~ static Res round_error() { return 0; } //~ static const int min_exponent = 0; //~ static const int min_exponent10 = 0; //~ static const int max_exponent = 0; @@ -501,10 +501,10 @@ namespace std { //~ static const bool has_signaling_NaN = false; //~ static const float_denorm_style has_denorm = denorm_absent; //~ static const bool has_denorm_loss = false; - //~ static Res infinity() { return 0; } - //~ static Res quiet_NaN() { return 0; } - //~ static Res signaling_NaN() { return 0; } - //~ static Res denorm_min() { return 0; } + //~ static Res infinity() { return 0; } + //~ static Res quiet_NaN() { return 0; } + //~ static Res signaling_NaN() { return 0; } + //~ static Res denorm_min() { return 0; } //~ static const bool is_iec559 = false; //~ static const bool is_bounded = true; //~ static const bool is_modulo = false; diff --git a/contrib/restricted/boost/boost/compute/exception/context_error.hpp b/contrib/restricted/boost/boost/compute/exception/context_error.hpp index e81f71020d..2c595e7ff6 100644 --- a/contrib/restricted/boost/boost/compute/exception/context_error.hpp +++ b/contrib/restricted/boost/boost/compute/exception/context_error.hpp @@ -37,7 +37,7 @@ public: context_error(const context *context, const char *errinfo, const void *private_info, - size_t private_info_size) noexcept + size_t private_info_size) noexcept : m_context(context), m_errinfo(errinfo), m_private_info(private_info), @@ -46,31 +46,31 @@ public: } /// Destroys the context error object. - ~context_error() + ~context_error() { } /// Returns a string with a description of the error. - const char* what() const noexcept + const char* what() const noexcept { return m_errinfo; } /// Returns a pointer to the context object which generated the error /// notification. - const context* get_context_ptr() const noexcept + const context* get_context_ptr() const noexcept { return m_context; } /// Returns a pointer to the private info memory block. - const void* get_private_info_ptr() const noexcept + const void* get_private_info_ptr() const noexcept { return m_private_info; } /// Returns the size of the private info memory block. - size_t get_private_info_size() const noexcept + size_t get_private_info_size() const noexcept { return m_private_info_size; } diff --git a/contrib/restricted/boost/boost/compute/exception/no_device_found.hpp b/contrib/restricted/boost/boost/compute/exception/no_device_found.hpp index 1a02ab2db3..3442525dde 100644 --- a/contrib/restricted/boost/boost/compute/exception/no_device_found.hpp +++ b/contrib/restricted/boost/boost/compute/exception/no_device_found.hpp @@ -26,17 +26,17 @@ class no_device_found : public std::exception { public: /// Creates a new no_device_found exception object. - no_device_found() noexcept + no_device_found() noexcept { } /// Destroys the no_device_found exception object. - ~no_device_found() + ~no_device_found() { } /// Returns a string containing a human-readable error message. - const char* what() const noexcept + const char* what() const noexcept { return "No OpenCL device found"; } diff --git a/contrib/restricted/boost/boost/compute/exception/opencl_error.hpp b/contrib/restricted/boost/boost/compute/exception/opencl_error.hpp index 2275e14629..acc4996b07 100644 --- a/contrib/restricted/boost/boost/compute/exception/opencl_error.hpp +++ b/contrib/restricted/boost/boost/compute/exception/opencl_error.hpp @@ -31,31 +31,31 @@ class opencl_error : public std::exception { public: /// Creates a new opencl_error exception object for \p error. - explicit opencl_error(cl_int error) noexcept + explicit opencl_error(cl_int error) noexcept : m_error(error), m_error_string(to_string(error)) { } /// Destroys the opencl_error object. - ~opencl_error() + ~opencl_error() { } /// Returns the numeric error code. - cl_int error_code() const noexcept + cl_int error_code() const noexcept { return m_error; } /// Returns a string description of the error. - std::string error_string() const noexcept + std::string error_string() const noexcept { return m_error_string; } /// Returns a C-string description of the error. - const char* what() const noexcept + const char* what() const noexcept { return m_error_string.c_str(); } diff --git a/contrib/restricted/boost/boost/compute/exception/unsupported_extension_error.hpp b/contrib/restricted/boost/boost/compute/exception/unsupported_extension_error.hpp index 9ce9b4efe0..85dd4507ea 100644 --- a/contrib/restricted/boost/boost/compute/exception/unsupported_extension_error.hpp +++ b/contrib/restricted/boost/boost/compute/exception/unsupported_extension_error.hpp @@ -34,7 +34,7 @@ class unsupported_extension_error : public std::exception public: /// Creates a new unsupported extension error exception object indicating /// that \p extension is not supported by the OpenCL platform or device. - explicit unsupported_extension_error(const char *extension) noexcept + explicit unsupported_extension_error(const char *extension) noexcept : m_extension(extension) { std::stringstream msg; @@ -43,19 +43,19 @@ public: } /// Destroys the unsupported extension error object. - ~unsupported_extension_error() + ~unsupported_extension_error() { } /// Returns the name of the unsupported extension. - std::string extension_name() const noexcept + std::string extension_name() const noexcept { return m_extension; } /// Returns a string containing a human-readable error message containing /// the name of the unsupported exception. - const char* what() const noexcept + const char* what() const noexcept { return m_error_string.c_str(); } diff --git a/contrib/restricted/boost/boost/detail/utf8_codecvt_facet.hpp b/contrib/restricted/boost/boost/detail/utf8_codecvt_facet.hpp index 71a4b1bba1..98602d7234 100644 --- a/contrib/restricted/boost/boost/detail/utf8_codecvt_facet.hpp +++ b/contrib/restricted/boost/boost/detail/utf8_codecvt_facet.hpp @@ -185,7 +185,7 @@ protected: std::size_t max_limit ) const #if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - noexcept + noexcept #endif ; @@ -197,7 +197,7 @@ protected: std::size_t max_limit ) const #if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - noexcept + noexcept #endif { return do_length( diff --git a/contrib/restricted/boost/boost/exception/detail/error_info_impl.hpp b/contrib/restricted/boost/boost/exception/detail/error_info_impl.hpp index 404296b6c7..c36030cb2f 100644 --- a/contrib/restricted/boost/boost/exception/detail/error_info_impl.hpp +++ b/contrib/restricted/boost/boost/exception/detail/error_info_impl.hpp @@ -35,7 +35,7 @@ boost virtual error_info_base * clone() const = 0; virtual - ~error_info_base() + ~error_info_base() { } }; @@ -73,7 +73,7 @@ boost } #endif #endif - ~error_info() + ~error_info() { } value_type const & diff --git a/contrib/restricted/boost/boost/exception/detail/exception_ptr.hpp b/contrib/restricted/boost/boost/exception/detail/exception_ptr.hpp index 99424dbefe..8a15de0d98 100644 --- a/contrib/restricted/boost/boost/exception/detail/exception_ptr.hpp +++ b/contrib/restricted/boost/boost/exception/detail/exception_ptr.hpp @@ -105,7 +105,7 @@ boost boost::exception, std::bad_alloc { - ~bad_alloc_() { } + ~bad_alloc_() { } }; struct @@ -113,7 +113,7 @@ boost boost::exception, std::bad_exception { - ~bad_exception_() { } + ~bad_exception_() { } }; template <class Exception> @@ -174,7 +174,7 @@ boost add_original_type(e); } - ~unknown_exception() + ~unknown_exception() { } @@ -220,7 +220,7 @@ boost add_original_type(e1); } - ~current_exception_std_exception_wrapper() + ~current_exception_std_exception_wrapper() { } diff --git a/contrib/restricted/boost/boost/exception/diagnostic_information.hpp b/contrib/restricted/boost/boost/exception/diagnostic_information.hpp index 2ffc1e2dc4..932081c87f 100644 --- a/contrib/restricted/boost/boost/exception/diagnostic_information.hpp +++ b/contrib/restricted/boost/boost/exception/diagnostic_information.hpp @@ -175,7 +175,7 @@ boost inline char const * - diagnostic_information_what( exception const & e, bool verbose=true ) noexcept + diagnostic_information_what( exception const & e, bool verbose=true ) noexcept { char const * w=0; #ifndef BOOST_NO_EXCEPTIONS diff --git a/contrib/restricted/boost/boost/exception/exception.hpp b/contrib/restricted/boost/boost/exception/exception.hpp index 1dfb22a6b6..9b0dfa9217 100644 --- a/contrib/restricted/boost/boost/exception/exception.hpp +++ b/contrib/restricted/boost/boost/exception/exception.hpp @@ -170,7 +170,7 @@ boost protected: - virtual ~error_info_container() + virtual ~error_info_container() { } }; @@ -242,7 +242,7 @@ boost #ifdef __HP_aCC //On HP aCC, this protected copy constructor prevents throwing boost::exception. //On all other platforms, the same effect is achieved by the pure virtual destructor. - exception( exception const & x ) noexcept: + exception( exception const & x ) noexcept: data_(x.data_), throw_function_(x.throw_function_), throw_file_(x.throw_file_), @@ -251,7 +251,7 @@ boost } #endif - virtual ~exception() + virtual ~exception() #ifndef __HP_aCC = 0 //Workaround for HP aCC, =0 incorrectly leads to link errors. #endif @@ -301,7 +301,7 @@ boost inline exception:: - ~exception() + ~exception() { } @@ -355,7 +355,7 @@ boost { } - ~error_info_injector() + ~error_info_injector() { } }; @@ -425,7 +425,7 @@ boost virtual void rethrow() const = 0; virtual - ~clone_base() + ~clone_base() { } }; @@ -481,7 +481,7 @@ boost copy_boost_exception(this,&x); } - ~clone_impl() + ~clone_impl() { } diff --git a/contrib/restricted/boost/boost/exception/info.hpp b/contrib/restricted/boost/boost/exception/info.hpp index 45873a2f27..bb165a7324 100644 --- a/contrib/restricted/boost/boost/exception/info.hpp +++ b/contrib/restricted/boost/boost/exception/info.hpp @@ -62,7 +62,7 @@ boost { } - ~error_info_container_impl() + ~error_info_container_impl() { } diff --git a/contrib/restricted/boost/boost/filesystem/operations.hpp b/contrib/restricted/boost/boost/filesystem/operations.hpp index a4f652fbf8..bc1f6ab6fe 100644 --- a/contrib/restricted/boost/boost/filesystem/operations.hpp +++ b/contrib/restricted/boost/boost/filesystem/operations.hpp @@ -66,8 +66,8 @@ namespace boost // all functions are inline to avoid issues with crossing dll boundaries - // functions previously noexcept are now BOOST_NOEXCEPT_OR_NOTHROW - // functions previously without noexcept are now BOOST_NOEXCEPT + // functions previously noexcept are now BOOST_NOEXCEPT_OR_NOTHROW + // functions previously without noexcept are now BOOST_NOEXCEPT public: // compiler generates copy constructor and copy assignment diff --git a/contrib/restricted/boost/boost/format/exceptions.hpp b/contrib/restricted/boost/boost/format/exceptions.hpp index 5402977f76..800c305319 100644 --- a/contrib/restricted/boost/boost/format/exceptions.hpp +++ b/contrib/restricted/boost/boost/format/exceptions.hpp @@ -30,7 +30,7 @@ namespace boost { { public: format_error() {} - virtual const char *what() const noexcept { + virtual const char *what() const noexcept { return "boost::format_error: " "format generic failure"; } @@ -44,7 +44,7 @@ namespace boost { : pos_(pos), next_(size) {} std::size_t get_pos() const { return pos_; } std::size_t get_next() const { return next_; } - virtual const char *what() const noexcept { + virtual const char *what() const noexcept { return "boost::bad_format_string: format-string is ill-formed"; } }; @@ -57,7 +57,7 @@ namespace boost { : cur_(cur), expected_(expected) {} std::size_t get_cur() const { return cur_; } std::size_t get_expected() const { return expected_; } - virtual const char *what() const noexcept { + virtual const char *what() const noexcept { return "boost::too_few_args: " "format-string referred to more arguments than were passed"; } @@ -71,7 +71,7 @@ namespace boost { : cur_(cur), expected_(expected) {} std::size_t get_cur() const { return cur_; } std::size_t get_expected() const { return expected_; } - virtual const char *what() const noexcept { + virtual const char *what() const noexcept { return "boost::too_many_args: " "format-string referred to fewer arguments than were passed"; } @@ -87,7 +87,7 @@ namespace boost { int get_index() const { return index_; } int get_beg() const { return beg_; } int get_end() const { return end_; } - virtual const char *what() const noexcept { + virtual const char *what() const noexcept { return "boost::out_of_range: " "tried to refer to an argument (or item) number which" " is out of range, according to the format string"; diff --git a/contrib/restricted/boost/boost/geometry/algorithms/centroid.hpp b/contrib/restricted/boost/boost/geometry/algorithms/centroid.hpp index 06e22d5688..70413e6665 100644 --- a/contrib/restricted/boost/boost/geometry/algorithms/centroid.hpp +++ b/contrib/restricted/boost/boost/geometry/algorithms/centroid.hpp @@ -93,7 +93,7 @@ public: \brief Returns the explanatory string. \return Pointer to a null-terminated string with explanatory information. */ - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry Centroid calculation exception"; } diff --git a/contrib/restricted/boost/boost/geometry/algorithms/detail/has_self_intersections.hpp b/contrib/restricted/boost/boost/geometry/algorithms/detail/has_self_intersections.hpp index 6252b85b59..cb6c1e621b 100644 --- a/contrib/restricted/boost/boost/geometry/algorithms/detail/has_self_intersections.hpp +++ b/contrib/restricted/boost/boost/geometry/algorithms/detail/has_self_intersections.hpp @@ -52,7 +52,7 @@ public: inline overlay_invalid_input_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry Overlay invalid input exception"; } diff --git a/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp index 3e1f3a1b9a..2aaff74c94 100644 --- a/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp +++ b/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp @@ -54,10 +54,10 @@ public: message += method; } - virtual ~turn_info_exception() + virtual ~turn_info_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return message.c_str(); } diff --git a/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp b/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp index 2782a8bc2c..16be18f546 100644 --- a/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp +++ b/contrib/restricted/boost/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp @@ -22,10 +22,10 @@ public: inline inconsistent_turns_exception() {} - virtual ~inconsistent_turns_exception() + virtual ~inconsistent_turns_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry Inconsistent Turns exception"; } diff --git a/contrib/restricted/boost/boost/geometry/core/exception.hpp b/contrib/restricted/boost/boost/geometry/core/exception.hpp index a81af0bce2..9e8f6be11f 100644 --- a/contrib/restricted/boost/boost/geometry/core/exception.hpp +++ b/contrib/restricted/boost/boost/geometry/core/exception.hpp @@ -33,7 +33,7 @@ namespace boost { namespace geometry class exception : public std::exception { public: - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry exception"; } @@ -52,7 +52,7 @@ public: inline invalid_input_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry Invalid-Input exception"; } @@ -77,7 +77,7 @@ public: inline empty_input_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry Empty-Input exception"; } @@ -96,7 +96,7 @@ public: inline invalid_output_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return "Boost.Geometry Invalid-Output exception"; } diff --git a/contrib/restricted/boost/boost/geometry/io/wkt/read.hpp b/contrib/restricted/boost/boost/geometry/io/wkt/read.hpp index 28d745a8fa..48b38565e9 100644 --- a/contrib/restricted/boost/boost/geometry/io/wkt/read.hpp +++ b/contrib/restricted/boost/boost/geometry/io/wkt/read.hpp @@ -91,9 +91,9 @@ struct read_wkt_exception : public geometry::exception complete = message + "' in (" + wkt.substr(0, 100) + ")"; } - virtual ~read_wkt_exception() {} + virtual ~read_wkt_exception() {} - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return complete.c_str(); } diff --git a/contrib/restricted/boost/boost/graph/bipartite.hpp b/contrib/restricted/boost/boost/graph/bipartite.hpp index f5459c717f..15a9f64ca2 100644 --- a/contrib/restricted/boost/boost/graph/bipartite.hpp +++ b/contrib/restricted/boost/boost/graph/bipartite.hpp @@ -42,7 +42,7 @@ namespace boost { } - const char* what () const noexcept + const char* what () const noexcept { return "Graph is not bipartite."; } diff --git a/contrib/restricted/boost/boost/graph/graphml.hpp b/contrib/restricted/boost/boost/graph/graphml.hpp index 77505c29ac..74b8bdaa45 100644 --- a/contrib/restricted/boost/boost/graph/graphml.hpp +++ b/contrib/restricted/boost/boost/graph/graphml.hpp @@ -37,8 +37,8 @@ namespace boost struct parse_error: public graph_exception { parse_error(const std::string& err) {error = err; statement = "parse error: " + error;} - virtual ~parse_error() {} - virtual const char* what() const noexcept {return statement.c_str();} + virtual ~parse_error() {} + virtual const char* what() const noexcept {return statement.c_str();} std::string statement; std::string error; }; diff --git a/contrib/restricted/boost/boost/graph/graphviz.hpp b/contrib/restricted/boost/boost/graph/graphviz.hpp index a8caad3538..07196720e5 100644 --- a/contrib/restricted/boost/boost/graph/graphviz.hpp +++ b/contrib/restricted/boost/boost/graph/graphviz.hpp @@ -617,8 +617,8 @@ namespace boost { // Graph reader exceptions ///////////////////////////////////////////////////////////////////////////// struct graph_exception : public std::exception { - virtual ~graph_exception() {} - virtual const char* what() const noexcept = 0; + virtual ~graph_exception() {} + virtual const char* what() const noexcept = 0; }; struct bad_parallel_edge : public graph_exception { @@ -628,8 +628,8 @@ struct bad_parallel_edge : public graph_exception { bad_parallel_edge(const std::string& i, const std::string& j) : from(i), to(j) {} - virtual ~bad_parallel_edge() {} - const char* what() const noexcept { + virtual ~bad_parallel_edge() {} + const char* what() const noexcept { if(statement.empty()) statement = std::string("Failed to add parallel edge: (") @@ -640,8 +640,8 @@ struct bad_parallel_edge : public graph_exception { }; struct directed_graph_error : public graph_exception { - virtual ~directed_graph_error() {} - virtual const char* what() const noexcept { + virtual ~directed_graph_error() {} + virtual const char* what() const noexcept { return "read_graphviz: " "Tried to read a directed graph into an undirected graph."; @@ -649,8 +649,8 @@ struct directed_graph_error : public graph_exception { }; struct undirected_graph_error : public graph_exception { - virtual ~undirected_graph_error() {} - virtual const char* what() const noexcept { + virtual ~undirected_graph_error() {} + virtual const char* what() const noexcept { return "read_graphviz: " "Tried to read an undirected graph into a directed graph."; @@ -661,8 +661,8 @@ struct bad_graphviz_syntax: public graph_exception { std::string errmsg; bad_graphviz_syntax(const std::string& errmsg) : errmsg(errmsg) {} - const char* what() const noexcept {return errmsg.c_str();} - ~bad_graphviz_syntax() {}; + const char* what() const noexcept {return errmsg.c_str();} + ~bad_graphviz_syntax() {}; }; namespace detail { namespace graph { diff --git a/contrib/restricted/boost/boost/graph/loop_erased_random_walk.hpp b/contrib/restricted/boost/boost/graph/loop_erased_random_walk.hpp index f36dc6e9a4..68966e2e00 100644 --- a/contrib/restricted/boost/boost/graph/loop_erased_random_walk.hpp +++ b/contrib/restricted/boost/boost/graph/loop_erased_random_walk.hpp @@ -20,8 +20,8 @@ namespace boost { struct loop_erased_random_walk_stuck : public std::exception { - virtual ~loop_erased_random_walk_stuck() {} - inline virtual const char* what() const noexcept { + virtual ~loop_erased_random_walk_stuck() {} + inline virtual const char* what() const noexcept { return "Loop-erased random walk found a vertex with no out-edges"; } }; diff --git a/contrib/restricted/boost/boost/interprocess/exceptions.hpp b/contrib/restricted/boost/boost/interprocess/exceptions.hpp index eb4ddf2d67..60f26225ea 100644 --- a/contrib/restricted/boost/boost/interprocess/exceptions.hpp +++ b/contrib/restricted/boost/boost/interprocess/exceptions.hpp @@ -60,9 +60,9 @@ class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception catch(...){} } - virtual ~interprocess_exception(){} + virtual ~interprocess_exception(){} - virtual const char * what() const noexcept + virtual const char * what() const noexcept { return m_str.c_str(); } native_error_t get_native_error()const { return m_err.get_native_error(); } @@ -86,7 +86,7 @@ class BOOST_SYMBOL_VISIBLE lock_exception : public interprocess_exception : interprocess_exception(lock_error) {} - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return "boost::interprocess::lock_exception"; } }; @@ -97,7 +97,7 @@ class BOOST_SYMBOL_VISIBLE bad_alloc : public interprocess_exception { public: bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){} - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return "boost::interprocess::bad_alloc"; } }; diff --git a/contrib/restricted/boost/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp b/contrib/restricted/boost/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp index 30866adefe..6e5bc786c0 100644 --- a/contrib/restricted/boost/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp +++ b/contrib/restricted/boost/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp @@ -36,7 +36,7 @@ class bad_weak_ptr { public: - virtual char const * what() const noexcept + virtual char const * what() const noexcept { return "boost::interprocess::bad_weak_ptr"; } }; diff --git a/contrib/restricted/boost/boost/iostreams/detail/codecvt_helper.hpp b/contrib/restricted/boost/boost/iostreams/detail/codecvt_helper.hpp index 79e9544ac0..9f1eacbf8a 100644 --- a/contrib/restricted/boost/boost/iostreams/detail/codecvt_helper.hpp +++ b/contrib/restricted/boost/boost/iostreams/detail/codecvt_helper.hpp @@ -106,15 +106,15 @@ public: return do_unshift(state, first2, last2, next2); } - bool always_noconv() const noexcept { return do_always_noconv(); } + bool always_noconv() const noexcept { return do_always_noconv(); } - int max_length() const noexcept { return do_max_length(); } + int max_length() const noexcept { return do_max_length(); } - int encoding() const noexcept { return do_encoding(); } + int encoding() const noexcept { return do_encoding(); } int length( BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER State& state, const Extern* first1, const Extern* last1, - std::size_t len2 ) const noexcept + std::size_t len2 ) const noexcept { return do_length(state, first1, last1, len2); } @@ -139,15 +139,15 @@ protected: return std::codecvt_base::ok; } - virtual bool do_always_noconv() const noexcept { return true; } + virtual bool do_always_noconv() const noexcept { return true; } - virtual int do_max_length() const noexcept { return 1; } + virtual int do_max_length() const noexcept { return 1; } - virtual int do_encoding() const noexcept { return 1; } + virtual int do_encoding() const noexcept { return 1; } virtual int do_length( BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER State&, const Extern* first1, const Extern* last1, - std::size_t len2 ) const noexcept + std::size_t len2 ) const noexcept { return (std::min)(static_cast<std::size_t>(last1 - first1), len2); } @@ -203,9 +203,9 @@ struct codecvt_helper : std::codecvt<Intern, Extern, State> { #endif { } #ifdef BOOST_IOSTREAMS_NO_CODECVT_MAX_LENGTH - int max_length() const noexcept { return do_max_length(); } + int max_length() const noexcept { return do_max_length(); } protected: - virtual int do_max_length() const noexcept { return 1; } + virtual int do_max_length() const noexcept { return 1; } #endif }; diff --git a/contrib/restricted/boost/boost/limits.hpp b/contrib/restricted/boost/boost/limits.hpp index 261435013a..76a1186bfc 100644 --- a/contrib/restricted/boost/boost/limits.hpp +++ b/contrib/restricted/boost/boost/limits.hpp @@ -59,8 +59,8 @@ namespace std BOOST_STATIC_CONSTANT(bool, is_integer = true); BOOST_STATIC_CONSTANT(bool, is_exact = true); BOOST_STATIC_CONSTANT(int, radix = 2); - static BOOST_LLT epsilon() noexcept { return 0; }; - static BOOST_LLT round_error() noexcept { return 0; }; + static BOOST_LLT epsilon() noexcept { return 0; }; + static BOOST_LLT round_error() noexcept { return 0; }; BOOST_STATIC_CONSTANT(int, min_exponent = 0); BOOST_STATIC_CONSTANT(int, min_exponent10 = 0); @@ -72,10 +72,10 @@ namespace std BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false); BOOST_STATIC_CONSTANT(bool, has_denorm = false); BOOST_STATIC_CONSTANT(bool, has_denorm_loss = false); - static BOOST_LLT infinity() noexcept { return 0; }; - static BOOST_LLT quiet_NaN() noexcept { return 0; }; - static BOOST_LLT signaling_NaN() noexcept { return 0; }; - static BOOST_LLT denorm_min() noexcept { return 0; }; + static BOOST_LLT infinity() noexcept { return 0; }; + static BOOST_LLT quiet_NaN() noexcept { return 0; }; + static BOOST_LLT signaling_NaN() noexcept { return 0; }; + static BOOST_LLT denorm_min() noexcept { return 0; }; BOOST_STATIC_CONSTANT(bool, is_iec559 = false); BOOST_STATIC_CONSTANT(bool, is_bounded = true); @@ -112,8 +112,8 @@ namespace std BOOST_STATIC_CONSTANT(bool, is_integer = true); BOOST_STATIC_CONSTANT(bool, is_exact = true); BOOST_STATIC_CONSTANT(int, radix = 2); - static BOOST_ULLT epsilon() noexcept { return 0; }; - static BOOST_ULLT round_error() noexcept { return 0; }; + static BOOST_ULLT epsilon() noexcept { return 0; }; + static BOOST_ULLT round_error() noexcept { return 0; }; BOOST_STATIC_CONSTANT(int, min_exponent = 0); BOOST_STATIC_CONSTANT(int, min_exponent10 = 0); @@ -125,10 +125,10 @@ namespace std BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false); BOOST_STATIC_CONSTANT(bool, has_denorm = false); BOOST_STATIC_CONSTANT(bool, has_denorm_loss = false); - static BOOST_ULLT infinity() noexcept { return 0; }; - static BOOST_ULLT quiet_NaN() noexcept { return 0; }; - static BOOST_ULLT signaling_NaN() noexcept { return 0; }; - static BOOST_ULLT denorm_min() noexcept { return 0; }; + static BOOST_ULLT infinity() noexcept { return 0; }; + static BOOST_ULLT quiet_NaN() noexcept { return 0; }; + static BOOST_ULLT signaling_NaN() noexcept { return 0; }; + static BOOST_ULLT denorm_min() noexcept { return 0; }; BOOST_STATIC_CONSTANT(bool, is_iec559 = false); BOOST_STATIC_CONSTANT(bool, is_bounded = true); diff --git a/contrib/restricted/boost/boost/locale/generic_codecvt.hpp b/contrib/restricted/boost/boost/locale/generic_codecvt.hpp index f6eb9c374a..bc13adc427 100644 --- a/contrib/restricted/boost/boost/locale/generic_codecvt.hpp +++ b/contrib/restricted/boost/boost/locale/generic_codecvt.hpp @@ -177,15 +177,15 @@ protected: next=from; return std::codecvt_base::ok; } - virtual int do_encoding() const noexcept + virtual int do_encoding() const noexcept { return 0; } - virtual int do_max_length() const noexcept + virtual int do_max_length() const noexcept { return implementation().max_encoding_length(); } - virtual bool do_always_noconv() const noexcept + virtual bool do_always_noconv() const noexcept { return false; } @@ -473,15 +473,15 @@ protected: next=from; return std::codecvt_base::ok; } - virtual int do_encoding() const noexcept + virtual int do_encoding() const noexcept { return 0; } - virtual int do_max_length() const noexcept + virtual int do_max_length() const noexcept { return implementation().max_encoding_length(); } - virtual bool do_always_noconv() const noexcept + virtual bool do_always_noconv() const noexcept { return false; } diff --git a/contrib/restricted/boost/boost/log/exceptions.hpp b/contrib/restricted/boost/boost/log/exceptions.hpp index a3a057a2c2..cf6576524f 100644 --- a/contrib/restricted/boost/boost/log/exceptions.hpp +++ b/contrib/restricted/boost/boost/log/exceptions.hpp @@ -83,12 +83,12 @@ public: /*! * Destructor */ - ~bad_alloc(); + ~bad_alloc(); /*! * Error message accessor. */ - const char* what() const noexcept; + const char* what() const noexcept; #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); @@ -114,7 +114,7 @@ public: /*! * Destructor */ - ~capacity_limit_reached(); + ~capacity_limit_reached(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); @@ -140,7 +140,7 @@ public: /*! * Destructor */ - ~runtime_error(); + ~runtime_error(); }; /*! @@ -161,7 +161,7 @@ public: /*! * Destructor */ - ~missing_value(); + ~missing_value(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -190,7 +190,7 @@ public: /*! * Destructor */ - ~invalid_type(); + ~invalid_type(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -223,7 +223,7 @@ public: /*! * Destructor */ - ~invalid_value(); + ~invalid_value(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -250,7 +250,7 @@ public: /*! * Destructor */ - ~parse_error(); + ~parse_error(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -281,7 +281,7 @@ public: /*! * Destructor */ - ~conversion_error(); + ~conversion_error(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -304,7 +304,7 @@ public: /*! * Destructor */ - ~system_error(); + ~system_error(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, int system_error_code); @@ -331,7 +331,7 @@ public: /*! * Destructor */ - ~logic_error(); + ~logic_error(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); @@ -357,7 +357,7 @@ public: /*! * Destructor */ - ~odr_violation(); + ~odr_violation(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -384,7 +384,7 @@ public: /*! * Destructor */ - ~unexpected_call(); + ~unexpected_call(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -411,7 +411,7 @@ public: /*! * Destructor */ - ~setup_error(); + ~setup_error(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); @@ -438,7 +438,7 @@ public: /*! * Destructor */ - ~limitation_error(); + ~limitation_error(); #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); diff --git a/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_cmath.hpp b/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_cmath.hpp index a687fb6d77..ec5885722c 100644 --- a/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_cmath.hpp +++ b/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_cmath.hpp @@ -191,36 +191,36 @@ // Begin with some forward function declarations. Also implement patches // for compilers that have broken float128 exponential functions. - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LDEXP (boost::math::cstdfloat::detail::float_internal128_t, int) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FREXP (boost::math::cstdfloat::detail::float_internal128_t, int*) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FABS (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FLOOR (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_CEIL (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TRUNC (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_POW (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG10 (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SIN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COS (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TAN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASIN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOS (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATAN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FMOD (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATAN2 (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LGAMMA(boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LDEXP (boost::math::cstdfloat::detail::float_internal128_t, int) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FREXP (boost::math::cstdfloat::detail::float_internal128_t, int*) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FABS (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FLOOR (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_CEIL (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TRUNC (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_POW (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG10 (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SIN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COS (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TAN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASIN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOS (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATAN (boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FMOD (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATAN2 (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LGAMMA(boost::math::cstdfloat::detail::float_internal128_t) noexcept; #if !defined(BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS) - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXP (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SINH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COSH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TANH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASINH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOSH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATANH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXP (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SINH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COSH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TANH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASINH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOSH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATANH (boost::math::cstdfloat::detail::float_internal128_t x) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x) noexcept; #else // BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS @@ -408,13 +408,13 @@ const float_type ex_minus = (float_type(1) / ex_plus); return (ex_plus - ex_minus) / (ex_plus + ex_minus); } - inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASINH(boost::math::cstdfloat::detail::float_internal128_t x) noexcept + inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASINH(boost::math::cstdfloat::detail::float_internal128_t x) noexcept { // Patch the asinh() function since quadmath does not have it. typedef boost::math::cstdfloat::detail::float_internal128_t float_type; return ::BOOST_CSTDFLOAT_FLOAT128_LOG(x + ::BOOST_CSTDFLOAT_FLOAT128_SQRT((x * x) + float_type(1))); } - inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOSH(boost::math::cstdfloat::detail::float_internal128_t x) noexcept + inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOSH(boost::math::cstdfloat::detail::float_internal128_t x) noexcept { // Patch the acosh() function since quadmath does not have it. typedef boost::math::cstdfloat::detail::float_internal128_t float_type; @@ -423,14 +423,14 @@ return ::BOOST_CSTDFLOAT_FLOAT128_LOG(x + (zp * ::BOOST_CSTDFLOAT_FLOAT128_SQRT(zm / zp))); } - inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATANH(boost::math::cstdfloat::detail::float_internal128_t x) noexcept + inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATANH(boost::math::cstdfloat::detail::float_internal128_t x) noexcept { // Patch the atanh() function since quadmath does not have it. typedef boost::math::cstdfloat::detail::float_internal128_t float_type; return ( ::BOOST_CSTDFLOAT_FLOAT128_LOG(float_type(1) + x) - ::BOOST_CSTDFLOAT_FLOAT128_LOG(float_type(1) - x)) / 2; } - inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x) noexcept + inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x) noexcept { // Patch the tgammaq() function for a subset of broken GCC compilers // like GCC 4.7, 4.8 on MinGW. diff --git a/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_iostream.hpp b/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_iostream.hpp index 355783eb5b..064205093f 100644 --- a/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_iostream.hpp +++ b/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_iostream.hpp @@ -35,8 +35,8 @@ #if defined(__GNUC__) // Forward declarations of quadruple-precision string functions. - extern "C" int quadmath_snprintf(char *str, size_t size, const char *format, ...) noexcept; - extern "C" boost::math::cstdfloat::detail::float_internal128_t strtoflt128(const char*, char **) noexcept; + extern "C" int quadmath_snprintf(char *str, size_t size, const char *format, ...) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t strtoflt128(const char*, char **) noexcept; namespace std { diff --git a/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_limits.hpp b/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_limits.hpp index 24e59e5fdb..6603e0f8e2 100644 --- a/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_limits.hpp +++ b/contrib/restricted/boost/boost/math/cstdfloat/cstdfloat_limits.hpp @@ -27,7 +27,7 @@ #endif // Forward declaration of the quadruple-precision square root function. - extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT(boost::math::cstdfloat::detail::float_internal128_t) noexcept; + extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT(boost::math::cstdfloat::detail::float_internal128_t) noexcept; namespace std { diff --git a/contrib/restricted/boost/boost/move/core.hpp b/contrib/restricted/boost/boost/move/core.hpp index 300496d26b..d630c19d52 100644 --- a/contrib/restricted/boost/boost/move/core.hpp +++ b/contrib/restricted/boost/boost/move/core.hpp @@ -82,7 +82,7 @@ >::type { rv(); - ~rv(); + ~rv(); rv(rv const&); void operator=(rv const&); } BOOST_MOVE_ATTRIBUTE_MAY_ALIAS; diff --git a/contrib/restricted/boost/boost/mpi/allocator.hpp b/contrib/restricted/boost/boost/mpi/allocator.hpp index 32514b40a1..87bc529a8c 100644 --- a/contrib/restricted/boost/boost/mpi/allocator.hpp +++ b/contrib/restricted/boost/boost/mpi/allocator.hpp @@ -98,20 +98,20 @@ public: }; /** Default-construct an allocator. */ - allocator() noexcept { } + allocator() noexcept { } /** Copy-construct an allocator. */ - allocator(const allocator&) noexcept { } + allocator(const allocator&) noexcept { } /** * Copy-construct an allocator from another allocator for a * different value type. */ template <typename U> - allocator(const allocator<U>&) noexcept { } + allocator(const allocator<U>&) noexcept { } /** Destroy an allocator. */ - ~allocator() { } + ~allocator() { } /** Returns the address of object @p x. */ pointer address(reference x) const @@ -159,7 +159,7 @@ public: * Returns the maximum number of elements that can be allocated * with @c allocate(). */ - size_type max_size() const noexcept + size_type max_size() const noexcept { return (std::numeric_limits<std::size_t>::max)() / sizeof(T); } @@ -184,7 +184,7 @@ public: * @returns @c true */ template<typename T1, typename T2> -inline bool operator==(const allocator<T1>&, const allocator<T2>&) noexcept +inline bool operator==(const allocator<T1>&, const allocator<T2>&) noexcept { return true; } @@ -196,7 +196,7 @@ inline bool operator==(const allocator<T1>&, const allocator<T2>&) noexcept * @returns @c false */ template<typename T1, typename T2> -inline bool operator!=(const allocator<T1>&, const allocator<T2>&) noexcept +inline bool operator!=(const allocator<T1>&, const allocator<T2>&) noexcept { return false; } diff --git a/contrib/restricted/boost/boost/mpi/exception.hpp b/contrib/restricted/boost/boost/mpi/exception.hpp index 62de0cadde..64bbc66326 100644 --- a/contrib/restricted/boost/boost/mpi/exception.hpp +++ b/contrib/restricted/boost/boost/mpi/exception.hpp @@ -45,12 +45,12 @@ class BOOST_MPI_DECL exception : public std::exception */ exception(const char* routine, int result_code); - virtual ~exception(); + virtual ~exception(); /** * A description of the error that occurred. */ - virtual const char * what () const noexcept + virtual const char * what () const noexcept { return this->message.c_str(); } diff --git a/contrib/restricted/boost/boost/numeric/conversion/converter_policies.hpp b/contrib/restricted/boost/boost/numeric/conversion/converter_policies.hpp index 57a255d451..5e67896b63 100644 --- a/contrib/restricted/boost/boost/numeric/conversion/converter_policies.hpp +++ b/contrib/restricted/boost/boost/numeric/conversion/converter_policies.hpp @@ -136,7 +136,7 @@ class bad_numeric_cast : public std::bad_cast { public: - virtual const char * what() const noexcept + virtual const char * what() const noexcept { return "bad numeric conversion: overflow"; } }; @@ -144,20 +144,20 @@ class negative_overflow : public bad_numeric_cast { public: - virtual const char * what() const noexcept + virtual const char * what() const noexcept { return "bad numeric conversion: negative overflow"; } }; class positive_overflow : public bad_numeric_cast { public: - virtual const char * what() const noexcept + virtual const char * what() const noexcept { return "bad numeric conversion: positive overflow"; } }; struct def_overflow_handler { - void operator() ( range_check_result r ) // + void operator() ( range_check_result r ) // { #ifndef BOOST_NO_EXCEPTIONS if ( r == cNegOverflow ) @@ -175,7 +175,7 @@ struct def_overflow_handler struct silent_overflow_handler { - void operator() ( range_check_result ) {} // noexcept + void operator() ( range_check_result ) {} // noexcept } ; template<class Traits> diff --git a/contrib/restricted/boost/boost/numeric/interval/limits.hpp b/contrib/restricted/boost/boost/numeric/interval/limits.hpp index ded574a87a..e3e3a47a2c 100644 --- a/contrib/restricted/boost/boost/numeric/interval/limits.hpp +++ b/contrib/restricted/boost/boost/numeric/interval/limits.hpp @@ -26,18 +26,18 @@ private: typedef boost::numeric::interval<T, Policies> I; typedef numeric_limits<T> bl; public: - static I min BOOST_PREVENT_MACRO_SUBSTITUTION () noexcept { return I((bl::min)(), (bl::min)()); } - static I max BOOST_PREVENT_MACRO_SUBSTITUTION () noexcept { return I((bl::max)(), (bl::max)()); } - static I epsilon() noexcept { return I(bl::epsilon(), bl::epsilon()); } + static I min BOOST_PREVENT_MACRO_SUBSTITUTION () noexcept { return I((bl::min)(), (bl::min)()); } + static I max BOOST_PREVENT_MACRO_SUBSTITUTION () noexcept { return I((bl::max)(), (bl::max)()); } + static I epsilon() noexcept { return I(bl::epsilon(), bl::epsilon()); } BOOST_STATIC_CONSTANT(float_round_style, round_style = round_indeterminate); BOOST_STATIC_CONSTANT(bool, is_iec559 = false); - static I infinity () noexcept { return I::whole(); } - static I quiet_NaN() noexcept { return I::empty(); } - static I signaling_NaN() noexcept + static I infinity () noexcept { return I::whole(); } + static I quiet_NaN() noexcept { return I::empty(); } + static I signaling_NaN() noexcept { return I(bl::signaling_NaN(), bl::signaling_Nan()); } - static I denorm_min() noexcept + static I denorm_min() noexcept { return I(bl::denorm_min(), bl::denorm_min()); } private: static I round_error(); // hide this on purpose, not yet implemented diff --git a/contrib/restricted/boost/boost/numeric/ublas/exception.hpp b/contrib/restricted/boost/boost/numeric/ublas/exception.hpp index d57d9293a6..920000153c 100644 --- a/contrib/restricted/boost/boost/numeric/ublas/exception.hpp +++ b/contrib/restricted/boost/boost/numeric/ublas/exception.hpp @@ -73,7 +73,7 @@ namespace boost { namespace numeric { namespace ublas { : public std::logic_error { explicit external_logic (const char *s = "external logic") : std::logic_error (s) {} - // virtual const char *what () const noexcept { + // virtual const char *what () const noexcept { // return "exception: external logic"; // } void raise () { diff --git a/contrib/restricted/boost/boost/phoenix/function/lazy_operator.hpp b/contrib/restricted/boost/boost/phoenix/function/lazy_operator.hpp index a33982b506..61c232d1c5 100644 --- a/contrib/restricted/boost/boost/phoenix/function/lazy_operator.hpp +++ b/contrib/restricted/boost/boost/phoenix/function/lazy_operator.hpp @@ -67,7 +67,7 @@ namespace boost { struct lazy_exception : public std::exception { const char* s; lazy_exception( const char* ss ) : s(ss) {} - const char* what() const noexcept { return s; } + const char* what() const noexcept { return s; } }; #endif diff --git a/contrib/restricted/boost/boost/program_options/errors.hpp b/contrib/restricted/boost/boost/program_options/errors.hpp index 9923338ce6..e458aa1cda 100644 --- a/contrib/restricted/boost/boost/program_options/errors.hpp +++ b/contrib/restricted/boost/boost/program_options/errors.hpp @@ -121,7 +121,7 @@ namespace boost { namespace program_options { /** gcc says that throw specification on dtor is loosened * without this line * */ - ~error_with_option_name() {} + ~error_with_option_name() {} //void dump() const @@ -183,7 +183,7 @@ namespace boost { namespace program_options { /** Creates the error_message on the fly * Currently a thin wrapper for substitute_placeholders() */ - virtual const char* what() const noexcept; + virtual const char* what() const noexcept; protected: /** Used to hold the error text returned by what() */ @@ -209,7 +209,7 @@ namespace boost { namespace program_options { multiple_values() : error_with_option_name("option '%canonical_option%' only takes a single argument"){} - ~multiple_values() {} + ~multiple_values() {} }; /** Class thrown when there are several occurrences of an @@ -220,7 +220,7 @@ namespace boost { namespace program_options { multiple_occurrences() : error_with_option_name("option '%canonical_option%' cannot be specified more than once"){} - ~multiple_occurrences() {} + ~multiple_occurrences() {} }; @@ -233,7 +233,7 @@ namespace boost { namespace program_options { { } - ~required_option() {} + ~required_option() {} }; /** Base class of unparsable options, @@ -258,7 +258,7 @@ namespace boost { namespace program_options { /** Does NOT set option name, because no option name makes sense */ virtual void set_option_name(const std::string&) {} - ~error_with_no_option_name() {} + ~error_with_no_option_name() {} }; @@ -270,7 +270,7 @@ namespace boost { namespace program_options { { } - ~unknown_option() {} + ~unknown_option() {} }; @@ -283,9 +283,9 @@ namespace boost { namespace program_options { m_alternatives(xalternatives) {} - ~ambiguous_option() {} + ~ambiguous_option() {} - const std::vector<std::string>& alternatives() const noexcept {return m_alternatives;} + const std::vector<std::string>& alternatives() const noexcept {return m_alternatives;} protected: /** Makes all substitutions using the template */ @@ -320,7 +320,7 @@ namespace boost { namespace program_options { { } - ~invalid_syntax() {} + ~invalid_syntax() {} kind_t kind() const {return m_kind;} @@ -340,7 +340,7 @@ namespace boost { namespace program_options { m_substitutions["invalid_line"] = invalid_line; } - ~invalid_config_file_syntax() {} + ~invalid_config_file_syntax() {} /** Convenience functions for backwards compatibility */ virtual std::string tokens() const {return m_substitutions.find("invalid_line")->second; } @@ -355,7 +355,7 @@ namespace boost { namespace program_options { const std::string& original_token = "", int option_style = 0): invalid_syntax(kind, option_name, original_token, option_style) {} - ~invalid_command_line_syntax() {} + ~invalid_command_line_syntax() {} }; @@ -379,7 +379,7 @@ namespace boost { namespace program_options { { } - ~validation_error() {} + ~validation_error() {} protected: /** Used to convert kind_t to a related error text */ diff --git a/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp b/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp index 4f5de47cab..4b128b1cc6 100644 --- a/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp +++ b/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp @@ -70,17 +70,17 @@ public: ////////////////////////////////////////////////////////////////////// struct dynamic_property_exception : public std::exception { - virtual ~dynamic_property_exception() {} - virtual const char* what() const noexcept = 0; + virtual ~dynamic_property_exception() {} + virtual const char* what() const noexcept = 0; }; struct property_not_found : public dynamic_property_exception { std::string property; mutable std::string statement; property_not_found(const std::string& property) : property(property) {} - virtual ~property_not_found() {} + virtual ~property_not_found() {} - const char* what() const noexcept { + const char* what() const noexcept { if(statement.empty()) statement = std::string("Property not found: ") + property + "."; @@ -93,9 +93,9 @@ struct dynamic_get_failure : public dynamic_property_exception { std::string property; mutable std::string statement; dynamic_get_failure(const std::string& property) : property(property) {} - virtual ~dynamic_get_failure() {} + virtual ~dynamic_get_failure() {} - const char* what() const noexcept { + const char* what() const noexcept { if(statement.empty()) statement = std::string( @@ -107,9 +107,9 @@ struct dynamic_get_failure : public dynamic_property_exception { }; struct dynamic_const_put_error : public dynamic_property_exception { - virtual ~dynamic_const_put_error() {} + virtual ~dynamic_const_put_error() {} - const char* what() const noexcept { + const char* what() const noexcept { return "Attempt to put a value into a const property map: "; } }; diff --git a/contrib/restricted/boost/boost/property_tree/detail/exception_implementation.hpp b/contrib/restricted/boost/boost/property_tree/detail/exception_implementation.hpp index 1d6c48fe1e..cec1ab3f91 100644 --- a/contrib/restricted/boost/boost/property_tree/detail/exception_implementation.hpp +++ b/contrib/restricted/boost/boost/property_tree/detail/exception_implementation.hpp @@ -35,7 +35,7 @@ namespace boost { namespace property_tree { } - inline ptree_error::~ptree_error() + inline ptree_error::~ptree_error() { } @@ -48,7 +48,7 @@ namespace boost { namespace property_tree { } - inline ptree_bad_data::~ptree_bad_data() + inline ptree_bad_data::~ptree_bad_data() { } @@ -68,7 +68,7 @@ namespace boost { namespace property_tree } - inline ptree_bad_path::~ptree_bad_path() + inline ptree_bad_path::~ptree_bad_path() { } diff --git a/contrib/restricted/boost/boost/property_tree/detail/file_parser_error.hpp b/contrib/restricted/boost/boost/property_tree/detail/file_parser_error.hpp index 305ca91d7a..f90e3087d1 100644 --- a/contrib/restricted/boost/boost/property_tree/detail/file_parser_error.hpp +++ b/contrib/restricted/boost/boost/property_tree/detail/file_parser_error.hpp @@ -34,7 +34,7 @@ namespace boost { namespace property_tree { } - ~file_parser_error() + ~file_parser_error() // gcc 3.4.2 complains about lack of throw specifier on compiler // generated dtor { diff --git a/contrib/restricted/boost/boost/property_tree/detail/rapidxml.hpp b/contrib/restricted/boost/boost/property_tree/detail/rapidxml.hpp index ba83695e52..ad2e25823f 100644 --- a/contrib/restricted/boost/boost/property_tree/detail/rapidxml.hpp +++ b/contrib/restricted/boost/boost/property_tree/detail/rapidxml.hpp @@ -58,7 +58,7 @@ namespace boost { namespace property_tree { namespace detail {namespace rapidxml //! Gets human readable description of error. //! \return Pointer to null terminated description of the error. - virtual const char *what() const noexcept + virtual const char *what() const noexcept { return m_what; } diff --git a/contrib/restricted/boost/boost/property_tree/exceptions.hpp b/contrib/restricted/boost/boost/property_tree/exceptions.hpp index 6435bff85a..b160f77efd 100644 --- a/contrib/restricted/boost/boost/property_tree/exceptions.hpp +++ b/contrib/restricted/boost/boost/property_tree/exceptions.hpp @@ -31,7 +31,7 @@ namespace boost { namespace property_tree /// @param what The message to associate with this error. ptree_error(const std::string &what); - ~ptree_error(); + ~ptree_error(); }; @@ -48,7 +48,7 @@ namespace boost { namespace property_tree template<class T> ptree_bad_data(const std::string &what, const T &data); - ~ptree_bad_data(); + ~ptree_bad_data(); /// Retrieve the data associated with this error. This is the source /// value that failed to be translated. You need to explicitly @@ -70,7 +70,7 @@ namespace boost { namespace property_tree template<class T> ptree_bad_path(const std::string &what, const T &path); - ~ptree_bad_path(); + ~ptree_bad_path(); /// Retrieve the invalid path. You need to explicitly specify the /// type of path. diff --git a/contrib/restricted/boost/boost/ptr_container/exception.hpp b/contrib/restricted/boost/boost/ptr_container/exception.hpp index ed845737b5..ae0379bf04 100644 --- a/contrib/restricted/boost/boost/ptr_container/exception.hpp +++ b/contrib/restricted/boost/boost/ptr_container/exception.hpp @@ -27,7 +27,7 @@ namespace boost bad_ptr_container_operation( const char* what ) : what_( what ) { } - virtual const char* what() const noexcept + virtual const char* what() const noexcept { return what_; } diff --git a/contrib/restricted/boost/boost/python/instance_holder.hpp b/contrib/restricted/boost/boost/python/instance_holder.hpp index 2ffb4bf956..0ca4928442 100644 --- a/contrib/restricted/boost/boost/python/instance_holder.hpp +++ b/contrib/restricted/boost/boost/python/instance_holder.hpp @@ -31,7 +31,7 @@ struct BOOST_PYTHON_DECL instance_holder : private noncopyable // that always holds the Python object. virtual void* holds(type_info, bool null_ptr_only) = 0; - void install(PyObject* inst) noexcept; + void install(PyObject* inst) noexcept; // These functions should probably be located elsewhere. @@ -42,7 +42,7 @@ struct BOOST_PYTHON_DECL instance_holder : private noncopyable // Deallocate storage from the heap if it was not carved out of // the given Python object by allocate(), above. - static void deallocate(PyObject*, void* storage) noexcept; + static void deallocate(PyObject*, void* storage) noexcept; private: instance_holder* m_next; }; diff --git a/contrib/restricted/boost/boost/qvm/error.hpp b/contrib/restricted/boost/boost/qvm/error.hpp index 08821dc884..27715a8f13 100644 --- a/contrib/restricted/boost/boost/qvm/error.hpp +++ b/contrib/restricted/boost/boost/qvm/error.hpp @@ -22,12 +22,12 @@ boost virtual std::exception { char const * - what() const noexcept + what() const noexcept { return "Boost QVM error"; } - ~error() + ~error() { } }; diff --git a/contrib/restricted/boost/boost/regex/pattern_except.hpp b/contrib/restricted/boost/boost/regex/pattern_except.hpp index 77854d5b98..25dc5a24c7 100644 --- a/contrib/restricted/boost/boost/regex/pattern_except.hpp +++ b/contrib/restricted/boost/boost/regex/pattern_except.hpp @@ -49,7 +49,7 @@ class BOOST_REGEX_DECL regex_error : public std::runtime_error public: explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0); explicit regex_error(regex_constants::error_type err); - ~regex_error(); + ~regex_error(); regex_constants::error_type code()const { return m_error_code; } std::ptrdiff_t position()const diff --git a/contrib/restricted/boost/boost/regex/v4/basic_regex.hpp b/contrib/restricted/boost/boost/regex/v4/basic_regex.hpp index 89dbe6dff4..263471dcb9 100644 --- a/contrib/restricted/boost/boost/regex/v4/basic_regex.hpp +++ b/contrib/restricted/boost/boost/regex/v4/basic_regex.hpp @@ -502,7 +502,7 @@ public: } // // swap: - void BOOST_REGEX_CALL swap(basic_regex& that)noexcept + void BOOST_REGEX_CALL swap(basic_regex& that)noexcept { m_pimpl.swap(that.m_pimpl); } diff --git a/contrib/restricted/boost/boost/serialization/detail/shared_count_132.hpp b/contrib/restricted/boost/boost/serialization/detail/shared_count_132.hpp index fca9d119cd..2d0d54bc0e 100644 --- a/contrib/restricted/boost/boost/serialization/detail/shared_count_132.hpp +++ b/contrib/restricted/boost/boost/serialization/detail/shared_count_132.hpp @@ -70,7 +70,7 @@ class bad_weak_ptr: public std::exception { public: - virtual char const * what() const noexcept + virtual char const * what() const noexcept { return "boost::bad_weak_ptr"; } diff --git a/contrib/restricted/boost/boost/signals2/expired_slot.hpp b/contrib/restricted/boost/boost/signals2/expired_slot.hpp index 9a6d4da9a1..a84b310ed2 100644 --- a/contrib/restricted/boost/boost/signals2/expired_slot.hpp +++ b/contrib/restricted/boost/boost/signals2/expired_slot.hpp @@ -20,7 +20,7 @@ namespace boost class expired_slot: public bad_weak_ptr { public: - virtual char const * what() const noexcept + virtual char const * what() const noexcept { return "boost::signals2::expired_slot"; } diff --git a/contrib/restricted/boost/boost/signals2/last_value.hpp b/contrib/restricted/boost/boost/signals2/last_value.hpp index 90333c938c..6a15d4c008 100644 --- a/contrib/restricted/boost/boost/signals2/last_value.hpp +++ b/contrib/restricted/boost/boost/signals2/last_value.hpp @@ -25,7 +25,7 @@ namespace boost { class no_slots_error: public std::exception { public: - virtual const char* what() const noexcept {return "boost::signals2::no_slots_error";} + virtual const char* what() const noexcept {return "boost::signals2::no_slots_error";} }; template<typename T> diff --git a/contrib/restricted/boost/boost/smart_ptr/bad_weak_ptr.hpp b/contrib/restricted/boost/boost/smart_ptr/bad_weak_ptr.hpp index 0105ca4cb0..f4b6aaf9c3 100644 --- a/contrib/restricted/boost/boost/smart_ptr/bad_weak_ptr.hpp +++ b/contrib/restricted/boost/boost/smart_ptr/bad_weak_ptr.hpp @@ -47,7 +47,7 @@ class bad_weak_ptr: public std::exception { public: - virtual char const * what() const noexcept + virtual char const * what() const noexcept { return "tr1::bad_weak_ptr"; } diff --git a/contrib/restricted/boost/boost/spirit/home/classic/error_handling/exceptions.hpp b/contrib/restricted/boost/boost/spirit/home/classic/error_handling/exceptions.hpp index bd4dd44483..17b454fc58 100644 --- a/contrib/restricted/boost/boost/spirit/home/classic/error_handling/exceptions.hpp +++ b/contrib/restricted/boost/boost/spirit/home/classic/error_handling/exceptions.hpp @@ -39,7 +39,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN protected: parser_error_base() {} - virtual ~parser_error_base() {} + virtual ~parser_error_base() {} public: @@ -87,10 +87,10 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN } virtual - ~parser_error() {} + ~parser_error() {} virtual const char* - what() const noexcept + what() const noexcept { return "BOOST_SPIRIT_CLASSIC_NS::parser_error"; } diff --git a/contrib/restricted/boost/boost/spirit/home/classic/iterator/multi_pass.hpp b/contrib/restricted/boost/boost/spirit/home/classic/iterator/multi_pass.hpp index 72d1cf2388..6dad8655d1 100644 --- a/contrib/restricted/boost/boost/spirit/home/classic/iterator/multi_pass.hpp +++ b/contrib/restricted/boost/boost/spirit/home/classic/iterator/multi_pass.hpp @@ -150,11 +150,11 @@ class illegal_backtracking : public std::exception { public: - illegal_backtracking() noexcept {} - ~illegal_backtracking() {} + illegal_backtracking() noexcept {} + ~illegal_backtracking() {} virtual const char* - what() const noexcept + what() const noexcept { return "BOOST_SPIRIT_CLASSIC_NS::illegal_backtracking"; } }; diff --git a/contrib/restricted/boost/boost/spirit/home/qi/detail/expectation_failure.hpp b/contrib/restricted/boost/boost/spirit/home/qi/detail/expectation_failure.hpp index ba995c0d8a..08a20c646d 100644 --- a/contrib/restricted/boost/boost/spirit/home/qi/detail/expectation_failure.hpp +++ b/contrib/restricted/boost/boost/spirit/home/qi/detail/expectation_failure.hpp @@ -23,7 +23,7 @@ namespace boost { namespace spirit { namespace qi { : std::runtime_error("boost::spirit::qi::expectation_failure") , first(first_), last(last_), what_(what) {} - ~expectation_failure() {} + ~expectation_failure() {} Iterator first; Iterator last; diff --git a/contrib/restricted/boost/boost/spirit/home/support/detail/hold_any.hpp b/contrib/restricted/boost/boost/spirit/home/support/detail/hold_any.hpp index 52a4d10393..38d23c547c 100644 --- a/contrib/restricted/boost/boost/spirit/home/support/detail/hold_any.hpp +++ b/contrib/restricted/boost/boost/spirit/home/support/detail/hold_any.hpp @@ -49,7 +49,7 @@ namespace boost { namespace spirit : from(src.name()), to(dest.name()) {} - virtual const char* what() const noexcept { return "bad any cast"; } + virtual const char* what() const noexcept { return "bad any cast"; } const char* from; const char* to; diff --git a/contrib/restricted/boost/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp b/contrib/restricted/boost/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp index fff79f358e..e37463130a 100644 --- a/contrib/restricted/boost/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp +++ b/contrib/restricted/boost/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp @@ -23,10 +23,10 @@ namespace boost { namespace spirit { namespace iterator_policies class illegal_backtracking : public std::exception { public: - illegal_backtracking() noexcept {} - ~illegal_backtracking() {} + illegal_backtracking() noexcept {} + ~illegal_backtracking() {} - char const* what() const noexcept + char const* what() const noexcept { return "boost::spirit::multi_pass::illegal_backtracking"; } diff --git a/contrib/restricted/boost/boost/spirit/home/support/utree/utree.hpp b/contrib/restricted/boost/boost/spirit/home/support/utree/utree.hpp index ab4df34eb8..48a5402581 100644 --- a/contrib/restricted/boost/boost/spirit/home/support/utree/utree.hpp +++ b/contrib/restricted/boost/boost/spirit/home/support/utree/utree.hpp @@ -143,9 +143,9 @@ namespace boost { namespace spirit msg = oss.str(); } - virtual ~bad_type_exception() {} + virtual ~bad_type_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return msg.c_str(); } }; @@ -155,9 +155,9 @@ namespace boost { namespace spirit empty_exception(char const* error) : msg(error) {} - virtual ~empty_exception() {} + virtual ~empty_exception() {} - virtual char const* what() const noexcept + virtual char const* what() const noexcept { return msg; } }; diff --git a/contrib/restricted/boost/boost/spirit/home/x3/directive/expect.hpp b/contrib/restricted/boost/boost/spirit/home/x3/directive/expect.hpp index b43c481e8d..90484d3b42 100644 --- a/contrib/restricted/boost/boost/spirit/home/x3/directive/expect.hpp +++ b/contrib/restricted/boost/boost/spirit/home/x3/directive/expect.hpp @@ -25,7 +25,7 @@ namespace boost { namespace spirit { namespace x3 : std::runtime_error("boost::spirit::x3::expectation_failure") , where_(where), which_(which) {} - ~expectation_failure() {} + ~expectation_failure() {} std::string which() const { return which_; } Iterator const& where() const { return where_; } diff --git a/contrib/restricted/boost/boost/thread/exceptions.hpp b/contrib/restricted/boost/boost/thread/exceptions.hpp index 63c1fabac3..8fd99d45a6 100644 --- a/contrib/restricted/boost/boost/thread/exceptions.hpp +++ b/contrib/restricted/boost/boost/thread/exceptions.hpp @@ -56,7 +56,7 @@ namespace boost { } - ~thread_exception() + ~thread_exception() {} @@ -113,7 +113,7 @@ namespace boost { } - ~lock_error() + ~lock_error() {} }; @@ -141,7 +141,7 @@ namespace boost } - ~thread_resource_error() + ~thread_resource_error() {} }; diff --git a/contrib/restricted/boost/boost/wave/cpp_exceptions.hpp b/contrib/restricted/boost/boost/wave/cpp_exceptions.hpp index 19e398a436..2206371749 100644 --- a/contrib/restricted/boost/boost/wave/cpp_exceptions.hpp +++ b/contrib/restricted/boost/boost/wave/cpp_exceptions.hpp @@ -66,7 +66,7 @@ class BOOST_SYMBOL_VISIBLE cpp_exception : public std::exception { public: - cpp_exception(std::size_t line_, std::size_t column_, char const *filename_) noexcept + cpp_exception(std::size_t line_, std::size_t column_, char const *filename_) noexcept : line(line_), column(column_) { unsigned int off = 0; @@ -74,18 +74,18 @@ public: filename[off++] = *filename_++; filename[off] = 0; } - ~cpp_exception() {} + ~cpp_exception() {} - virtual char const *what() const noexcept = 0; // to be overloaded - virtual char const *description() const noexcept = 0; - virtual int get_errorcode() const noexcept = 0; - virtual int get_severity() const noexcept = 0; - virtual char const* get_related_name() const noexcept = 0; - virtual bool is_recoverable() const noexcept = 0; + virtual char const *what() const noexcept = 0; // to be overloaded + virtual char const *description() const noexcept = 0; + virtual int get_errorcode() const noexcept = 0; + virtual int get_severity() const noexcept = 0; + virtual char const* get_related_name() const noexcept = 0; + virtual bool is_recoverable() const noexcept = 0; - std::size_t line_no() const noexcept { return line; } - std::size_t column_no() const noexcept { return column; } - char const *file_name() const noexcept { return filename; } + std::size_t line_no() const noexcept { return line; } + std::size_t column_no() const noexcept { return column; } + char const *file_name() const noexcept { return filename; } protected: char filename[512]; @@ -150,7 +150,7 @@ public: }; preprocess_exception(char const *what_, error_code code, std::size_t line_, - std::size_t column_, char const *filename_) noexcept + std::size_t column_, char const *filename_) noexcept : cpp_exception(line_, column_, filename_), code(code) { @@ -159,29 +159,29 @@ public: buffer[off++] = *what_++; buffer[off] = 0; } - ~preprocess_exception() {} + ~preprocess_exception() {} - virtual char const *what() const noexcept + virtual char const *what() const noexcept { return "boost::wave::preprocess_exception"; } - virtual char const *description() const noexcept + virtual char const *description() const noexcept { return buffer; } - virtual int get_severity() const noexcept + virtual int get_severity() const noexcept { return severity_level(code); } - virtual int get_errorcode() const noexcept + virtual int get_errorcode() const noexcept { return code; } - virtual char const* get_related_name() const noexcept + virtual char const* get_related_name() const noexcept { return "<unknown>"; } - virtual bool is_recoverable() const noexcept + virtual bool is_recoverable() const noexcept { switch (get_errorcode()) { // these are the exceptions thrown during processing not supposed to @@ -371,7 +371,7 @@ class BOOST_SYMBOL_VISIBLE macro_handling_exception : { public: macro_handling_exception(char const *what_, error_code code, std::size_t line_, - std::size_t column_, char const *filename_, char const *macroname) noexcept + std::size_t column_, char const *filename_, char const *macroname) noexcept : preprocess_exception(what_, code, line_, column_, filename_) { unsigned int off = 0; @@ -379,13 +379,13 @@ public: name[off++] = *macroname++; name[off] = 0; } - ~macro_handling_exception() {} + ~macro_handling_exception() {} - virtual char const *what() const noexcept + virtual char const *what() const noexcept { return "boost::wave::macro_handling_exception"; } - char const* get_related_name() const noexcept + char const* get_related_name() const noexcept { return name; } diff --git a/contrib/restricted/boost/boost/wave/cpplexer/cpplexer_exceptions.hpp b/contrib/restricted/boost/boost/wave/cpplexer/cpplexer_exceptions.hpp index e794c1fec7..b232a49f74 100644 --- a/contrib/restricted/boost/boost/wave/cpplexer/cpplexer_exceptions.hpp +++ b/contrib/restricted/boost/boost/wave/cpplexer/cpplexer_exceptions.hpp @@ -132,7 +132,7 @@ class BOOST_SYMBOL_VISIBLE cpplexer_exception : public std::exception { public: - cpplexer_exception(std::size_t line_, std::size_t column_, char const *filename_) noexcept + cpplexer_exception(std::size_t line_, std::size_t column_, char const *filename_) noexcept : line(line_), column(column_) { unsigned int off = 0; @@ -140,17 +140,17 @@ public: filename[off++] = *filename_++; filename[off] = 0; } - ~cpplexer_exception() {} + ~cpplexer_exception() {} - virtual char const *what() const noexcept = 0; // to be overloaded - virtual char const *description() const noexcept = 0; - virtual int get_errorcode() const noexcept = 0; - virtual int get_severity() const noexcept = 0; - virtual bool is_recoverable() const noexcept = 0; + virtual char const *what() const noexcept = 0; // to be overloaded + virtual char const *description() const noexcept = 0; + virtual int get_errorcode() const noexcept = 0; + virtual int get_severity() const noexcept = 0; + virtual bool is_recoverable() const noexcept = 0; - std::size_t line_no() const noexcept { return line; } - std::size_t column_no() const noexcept { return column; } - char const *file_name() const noexcept { return filename; } + std::size_t line_no() const noexcept { return line; } + std::size_t column_no() const noexcept { return column; } + char const *file_name() const noexcept { return filename; } protected: char filename[512]; @@ -175,7 +175,7 @@ public: }; lexing_exception(char const *what_, error_code code, std::size_t line_, - std::size_t column_, char const *filename_) noexcept + std::size_t column_, char const *filename_) noexcept : cpplexer_exception(line_, column_, filename_), level(severity_level(code)), code(code) { @@ -184,25 +184,25 @@ public: buffer[off++] = *what_++; buffer[off] = 0; } - ~lexing_exception() {} + ~lexing_exception() {} - virtual char const *what() const noexcept + virtual char const *what() const noexcept { return "boost::wave::lexing_exception"; } - virtual char const *description() const noexcept + virtual char const *description() const noexcept { return buffer; } - virtual int get_severity() const noexcept + virtual int get_severity() const noexcept { return level; } - virtual int get_errorcode() const noexcept + virtual int get_errorcode() const noexcept { return code; } - virtual bool is_recoverable() const noexcept + virtual bool is_recoverable() const noexcept { switch (get_errorcode()) { case lexing_exception::universal_char_invalid: diff --git a/contrib/restricted/boost/boost/xpressive/basic_regex.hpp b/contrib/restricted/boost/boost/xpressive/basic_regex.hpp index 50a436c8bf..ff173c2a8d 100644 --- a/contrib/restricted/boost/boost/xpressive/basic_regex.hpp +++ b/contrib/restricted/boost/boost/xpressive/basic_regex.hpp @@ -158,7 +158,7 @@ public: /// enclosing regular expression. It is done this way to ensure /// that swap() cannot throw. /// \throw nothrow - void swap(basic_regex<BidiIter> &that) // noexcept + void swap(basic_regex<BidiIter> &that) // noexcept { proto::value(*this).swap(proto::value(that)); } @@ -285,7 +285,7 @@ template<typename BidiIter> regex_constants::syntax_option_type const basic_rege /// that swap() cannot throw. /// \throw nothrow template<typename BidiIter> -inline void swap(basic_regex<BidiIter> &left, basic_regex<BidiIter> &right) // noexcept +inline void swap(basic_regex<BidiIter> &left, basic_regex<BidiIter> &right) // noexcept { left.swap(right); } diff --git a/contrib/restricted/boost/boost/xpressive/detail/core/list.hpp b/contrib/restricted/boost/boost/xpressive/detail/core/list.hpp index 6c23a3655f..fb33f04b42 100644 --- a/contrib/restricted/boost/boost/xpressive/detail/core/list.hpp +++ b/contrib/restricted/boost/boost/xpressive/detail/core/list.hpp @@ -104,7 +104,7 @@ namespace boost { namespace xpressive { namespace detail pop_front(); } - void swap(list &that) // noexcept + void swap(list &that) // noexcept { list temp; temp.splice(temp.begin(), that); // move that to temp diff --git a/contrib/restricted/boost/boost/xpressive/detail/dynamic/parse_charset.hpp b/contrib/restricted/boost/boost/xpressive/detail/dynamic/parse_charset.hpp index bf959b794e..35b8c4de29 100644 --- a/contrib/restricted/boost/boost/xpressive/detail/dynamic/parse_charset.hpp +++ b/contrib/restricted/boost/boost/xpressive/detail/dynamic/parse_charset.hpp @@ -51,7 +51,7 @@ struct escape_value // struct char_overflow_handler { - void operator ()(numeric::range_check_result result) const // + void operator ()(numeric::range_check_result result) const // { if(numeric::cInRange != result) { diff --git a/contrib/restricted/boost/boost/xpressive/detail/utility/tracking_ptr.hpp b/contrib/restricted/boost/boost/xpressive/detail/utility/tracking_ptr.hpp index 398a5e1729..274e1bfd64 100644 --- a/contrib/restricted/boost/boost/xpressive/detail/utility/tracking_ptr.hpp +++ b/contrib/restricted/boost/boost/xpressive/detail/utility/tracking_ptr.hpp @@ -421,7 +421,7 @@ struct tracking_ptr } // NOTE: this does *not* do tracking. Can't provide a non-throwing swap that tracks references - void swap(tracking_ptr<element_type> &that) // noexcept + void swap(tracking_ptr<element_type> &that) // noexcept { this->impl_.swap(that.impl_); } diff --git a/contrib/restricted/boost/boost/xpressive/match_results.hpp b/contrib/restricted/boost/boost/xpressive/match_results.hpp index c51dc2369b..3b5a52d48d 100644 --- a/contrib/restricted/boost/boost/xpressive/match_results.hpp +++ b/contrib/restricted/boost/boost/xpressive/match_results.hpp @@ -102,7 +102,7 @@ struct results_extras // struct char_overflow_handler_ { - void operator ()(numeric::range_check_result result) const // + void operator ()(numeric::range_check_result result) const // { if(numeric::cInRange != result) { @@ -654,7 +654,7 @@ public: /// \post *this contains the sequence of matched sub-expressions that were in that, /// that contains the sequence of matched sub-expressions that were in *this. /// \throw nothrow - void swap(match_results<BidiIter> &that) // noexcept + void swap(match_results<BidiIter> &that) // noexcept { using std::swap; swap(this->regex_id_, that.regex_id_); diff --git a/contrib/restricted/boost/boost/xpressive/regex_error.hpp b/contrib/restricted/boost/boost/xpressive/regex_error.hpp index 727950bee7..98c2058b82 100644 --- a/contrib/restricted/boost/boost/xpressive/regex_error.hpp +++ b/contrib/restricted/boost/boost/xpressive/regex_error.hpp @@ -70,7 +70,7 @@ struct regex_error /// Destructor for class regex_error /// \throw nothrow - virtual ~regex_error() + virtual ~regex_error() {} private: diff --git a/contrib/restricted/boost/libs/exception/src/clone_current_exception_non_intrusive.cpp b/contrib/restricted/boost/libs/exception/src/clone_current_exception_non_intrusive.cpp index 54b056d8d0..e99c91dea3 100644 --- a/contrib/restricted/boost/libs/exception/src/clone_current_exception_non_intrusive.cpp +++ b/contrib/restricted/boost/libs/exception/src/clone_current_exception_non_intrusive.cpp @@ -230,7 +230,7 @@ namespace { } - ~cloned_exception() + ~cloned_exception() { } diff --git a/contrib/restricted/boost/libs/filesystem/src/windows_file_codecvt.hpp b/contrib/restricted/boost/libs/filesystem/src/windows_file_codecvt.hpp index d4ad1b7daf..20f4ab55e2 100644 --- a/contrib/restricted/boost/libs/filesystem/src/windows_file_codecvt.hpp +++ b/contrib/restricted/boost/libs/filesystem/src/windows_file_codecvt.hpp @@ -30,11 +30,11 @@ : std::codecvt<wchar_t, char, std::mbstate_t>(refs) {} protected: - virtual bool do_always_noconv() const noexcept { return false; } + virtual bool do_always_noconv() const noexcept { return false; } // seems safest to assume variable number of characters since we don't // actually know what codepage is active - virtual int do_encoding() const noexcept { return 0; } + virtual int do_encoding() const noexcept { return 0; } virtual std::codecvt_base::result do_in(std::mbstate_t& state, const char* from, const char* from_end, const char*& from_next, @@ -50,7 +50,7 @@ virtual int do_length(std::mbstate_t&, const char* /*from*/, const char* /*from_end*/, std::size_t /*max*/) const { return 0; } - virtual int do_max_length() const noexcept { return 0; } + virtual int do_max_length() const noexcept { return 0; } }; #endif // BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP diff --git a/contrib/restricted/boost/libs/log/src/exceptions.cpp b/contrib/restricted/boost/libs/log/src/exceptions.cpp index 693881b11a..30d13a16e7 100644 --- a/contrib/restricted/boost/libs/log/src/exceptions.cpp +++ b/contrib/restricted/boost/libs/log/src/exceptions.cpp @@ -53,11 +53,11 @@ bad_alloc::bad_alloc(std::string const& descr) : { } -bad_alloc::~bad_alloc() +bad_alloc::~bad_alloc() { } -const char* bad_alloc::what() const noexcept +const char* bad_alloc::what() const noexcept { return m_message.c_str(); } @@ -88,7 +88,7 @@ capacity_limit_reached::capacity_limit_reached(std::string const& descr) : { } -capacity_limit_reached::~capacity_limit_reached() +capacity_limit_reached::~capacity_limit_reached() { } @@ -113,7 +113,7 @@ runtime_error::runtime_error(std::string const& descr) : { } -runtime_error::~runtime_error() +runtime_error::~runtime_error() { } @@ -127,7 +127,7 @@ missing_value::missing_value(std::string const& descr) : { } -missing_value::~missing_value() +missing_value::~missing_value() { } @@ -183,7 +183,7 @@ invalid_type::invalid_type(std::string const& descr) : { } -invalid_type::~invalid_type() +invalid_type::~invalid_type() { } @@ -277,7 +277,7 @@ invalid_value::invalid_value(std::string const& descr) : { } -invalid_value::~invalid_value() +invalid_value::~invalid_value() { } @@ -315,7 +315,7 @@ parse_error::parse_error(std::string const& descr) : { } -parse_error::~parse_error() +parse_error::~parse_error() { } @@ -389,7 +389,7 @@ conversion_error::conversion_error(std::string const& descr) : { } -conversion_error::~conversion_error() +conversion_error::~conversion_error() { } @@ -422,7 +422,7 @@ system_error::system_error(boost::system::error_code code, std::string const& de { } -system_error::~system_error() +system_error::~system_error() { } @@ -463,7 +463,7 @@ logic_error::logic_error(std::string const& descr) : { } -logic_error::~logic_error() +logic_error::~logic_error() { } @@ -493,7 +493,7 @@ odr_violation::odr_violation(std::string const& descr) : { } -odr_violation::~odr_violation() +odr_violation::~odr_violation() { } @@ -531,7 +531,7 @@ unexpected_call::unexpected_call(std::string const& descr) : { } -unexpected_call::~unexpected_call() +unexpected_call::~unexpected_call() { } @@ -569,7 +569,7 @@ setup_error::setup_error(std::string const& descr) : { } -setup_error::~setup_error() +setup_error::~setup_error() { } @@ -607,7 +607,7 @@ limitation_error::limitation_error(std::string const& descr) : { } -limitation_error::~limitation_error() +limitation_error::~limitation_error() { } diff --git a/contrib/restricted/boost/libs/program_options/src/value_semantic.cpp b/contrib/restricted/boost/libs/program_options/src/value_semantic.cpp index 6055f62713..e5fdf10464 100644 --- a/contrib/restricted/boost/libs/program_options/src/value_semantic.cpp +++ b/contrib/restricted/boost/libs/program_options/src/value_semantic.cpp @@ -258,7 +258,7 @@ namespace boost { namespace program_options { } - const char* error_with_option_name::what() const noexcept + const char* error_with_option_name::what() const noexcept { // will substitute tokens each time what is run() substitute_placeholders(m_error_template); diff --git a/contrib/restricted/boost/libs/python/src/object/class.cpp b/contrib/restricted/boost/libs/python/src/object/class.cpp index 8d0daf63d7..652f2ed868 100644 --- a/contrib/restricted/boost/libs/python/src/object/class.cpp +++ b/contrib/restricted/boost/libs/python/src/object/class.cpp @@ -301,7 +301,7 @@ static PyTypeObject class_metatype_object = { // Install the instance data for a C++ object into a Python instance // object. -void instance_holder::install(PyObject* self) noexcept +void instance_holder::install(PyObject* self) noexcept { assert(PyType_IsSubtype(Py_TYPE(Py_TYPE(self)), &class_metatype_object)); m_next = ((objects::instance<>*)self)->objects; @@ -751,7 +751,7 @@ void* instance_holder::allocate(PyObject* self_, std::size_t holder_offset, std: } } -void instance_holder::deallocate(PyObject* self_, void* storage) noexcept +void instance_holder::deallocate(PyObject* self_, void* storage) noexcept { assert(PyType_IsSubtype(Py_TYPE(Py_TYPE(self_)), &class_metatype_object)); objects::instance<>* self = (objects::instance<>*)self_; diff --git a/contrib/restricted/boost/libs/regex/src/regex.cpp b/contrib/restricted/boost/libs/regex/src/regex.cpp index 441f42541f..a18846acdb 100644 --- a/contrib/restricted/boost/libs/regex/src/regex.cpp +++ b/contrib/restricted/boost/libs/regex/src/regex.cpp @@ -70,7 +70,7 @@ regex_error::regex_error(regex_constants::error_type err) { } -regex_error::~regex_error() +regex_error::~regex_error() { } diff --git a/contrib/tools/bison/bison/arcadia_root.h b/contrib/tools/bison/bison/arcadia_root.h index 9c89539def..b5079e96dc 100644 --- a/contrib/tools/bison/bison/arcadia_root.h +++ b/contrib/tools/bison/bison/arcadia_root.h @@ -3,7 +3,7 @@ #define THROWING #ifdef __cplusplus -#define THROWING noexcept +#define THROWING noexcept extern "C" { #endif diff --git a/contrib/tools/bison/gnulib/platform/posix/getopt.h b/contrib/tools/bison/gnulib/platform/posix/getopt.h index 2096ceacfe..aa511eec99 100644 --- a/contrib/tools/bison/gnulib/platform/posix/getopt.h +++ b/contrib/tools/bison/gnulib/platform/posix/getopt.h @@ -119,7 +119,7 @@ # define __GNUC_PREREQ(maj, min) (0) # endif # if defined __cplusplus && __GNUC_PREREQ (2,8) -# define __THROW noexcept +# define __THROW noexcept # else # define __THROW # endif diff --git a/contrib/tools/bison/gnulib/platform/win64/getopt.h b/contrib/tools/bison/gnulib/platform/win64/getopt.h index a80aa65455..e91c103b14 100644 --- a/contrib/tools/bison/gnulib/platform/win64/getopt.h +++ b/contrib/tools/bison/gnulib/platform/win64/getopt.h @@ -119,7 +119,7 @@ # define __GNUC_PREREQ(maj, min) (0) # endif # if defined __cplusplus && __GNUC_PREREQ (2,8) -# define __THROW noexcept +# define __THROW noexcept # else # define __THROW # endif diff --git a/contrib/tools/cython/Cython/Utility/StringTools.c b/contrib/tools/cython/Cython/Utility/StringTools.c index 2fdae812a0..dc4407cbba 100644 --- a/contrib/tools/cython/Cython/Utility/StringTools.c +++ b/contrib/tools/cython/Cython/Utility/StringTools.c @@ -454,7 +454,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_s //@requires: decode_c_bytes static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string( - std::string_view cppstring, Py_ssize_t start, Py_ssize_t stop, + std::string_view cppstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { return __Pyx_decode_c_bytes( diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp index cd96aa0565..de95e3e863 100644 --- a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp +++ b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp @@ -66,7 +66,7 @@ namespace NPlugins { SetCommonFieldVariables(Field_, &Variables_); } - virtual ~TFieldExtGenerator() { + virtual ~TFieldExtGenerator() { } virtual void GenerateAccessorDeclarations(io::Printer* printer) = 0; diff --git a/contrib/tools/ya.make b/contrib/tools/ya.make index 750911c587..f4a26ce31c 100644 --- a/contrib/tools/ya.make +++ b/contrib/tools/ya.make @@ -7,7 +7,7 @@ RECURSE( file2c flame-graph flatc - flatc64 + flatc64 flex flex-old flex-old/fl diff --git a/library/cpp/actors/core/actor_ut.cpp b/library/cpp/actors/core/actor_ut.cpp index e1b765ec72..2f022c2d80 100644 --- a/library/cpp/actors/core/actor_ut.cpp +++ b/library/cpp/actors/core/actor_ut.cpp @@ -188,9 +188,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { TThreadParkPad pad; TAtomic actorsAlive = 0; double elapsedTime = 0; - THolder<IActor> endActor{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&elapsedTime, {}, allocation, Leader)), &pad, &actorsAlive)}; + THolder<IActor> endActor{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&elapsedTime, {}, allocation, Leader)), &pad, &actorsAlive)}; actorSystem.Register(endActor.Release(), mType); @@ -213,9 +213,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { ui32 leaderPoolId = poolsCount == 1 ? 0 : 1; TActorId followerId = actorSystem.Register( new TSendReceiveActor(nullptr, {}, allocation, Follower), TMailboxType::HTSwap, followerPoolId); - THolder<IActor> leader{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&elapsedTime, followerId, allocation, Leader)), &pad, &actorsAlive)}; + THolder<IActor> leader{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&elapsedTime, followerId, allocation, Leader)), &pad, &actorsAlive)}; actorSystem.Register(leader.Release(), TMailboxType::HTSwap, leaderPoolId); pad.Park(); @@ -235,9 +235,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { TActorId followerId = actorSystem.Register( new TSendReceiveActor(nullptr, {}, false, Follower, MailboxNeighbourActors), TMailboxType::HTSwap); - THolder<IActor> leader{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&elapsedTime, followerId, false, Leader, MailboxNeighbourActors)), &pad, &actorsAlive)}; + THolder<IActor> leader{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&elapsedTime, followerId, false, Leader, MailboxNeighbourActors)), &pad, &actorsAlive)}; actorSystem.Register(leader.Release(), TMailboxType::HTSwap); pad.Park(); @@ -262,9 +262,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { ui32 leaderPoolId = 0; TActorId followerId = actorSystem.Register( new TSendReceiveActor(nullptr, {}, true, Follower), TMailboxType::HTSwap, followerPoolId); - THolder<IActor> leader{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&dummy[i], followerId, true, Leader)), &pad, &actorsAlive)}; + THolder<IActor> leader{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&dummy[i], followerId, true, Leader)), &pad, &actorsAlive)}; actorSystem.Register(leader.Release(), TMailboxType::HTSwap, leaderPoolId); } @@ -550,16 +550,16 @@ Y_UNIT_TEST_SUITE(TestDecorator) { TActorSystem actorSystem(setup); actorSystem.Start(); - THolder<IActor> innerActor = MakeHolder<TTestActor>(); + THolder<IActor> innerActor = MakeHolder<TTestActor>(); ui64 pongCounter = 0; - THolder<IActor> pongActor = MakeHolder<TPongDecorator>(std::move(innerActor), &pongCounter); + THolder<IActor> pongActor = MakeHolder<TPongDecorator>(std::move(innerActor), &pongCounter); ui64 pingCounter = 0; - THolder<IActor> pingActor = MakeHolder<TPingDecorator>(std::move(pongActor), &pingCounter); + THolder<IActor> pingActor = MakeHolder<TPingDecorator>(std::move(pongActor), &pingCounter); TThreadParkPad pad; TAtomic actorsAlive = 0; - THolder<IActor> endActor = MakeHolder<TTestEndDecorator>(std::move(pingActor), &pad, &actorsAlive); + THolder<IActor> endActor = MakeHolder<TTestEndDecorator>(std::move(pingActor), &pad, &actorsAlive); actorSystem.Register(endActor.Release(), TMailboxType::HTSwap); pad.Park(); diff --git a/library/cpp/actors/core/actorid.h b/library/cpp/actors/core/actorid.h index d972b1a0ff..4a57bed146 100644 --- a/library/cpp/actors/core/actorid.h +++ b/library/cpp/actors/core/actorid.h @@ -66,40 +66,40 @@ namespace NActors { return Raw.X.X1 != 0 || Raw.X.X2 != 0; } - ui64 LocalId() const noexcept { + ui64 LocalId() const noexcept { return Raw.N.LocalId; } - ui32 Hint() const noexcept { + ui32 Hint() const noexcept { return Raw.N.Hint; } - ui32 NodeId() const noexcept { + ui32 NodeId() const noexcept { return Raw.N.NodeId & NodeIdMask; } - bool IsService() const noexcept { + bool IsService() const noexcept { return (Raw.N.NodeId & ServiceMask); } - TStringBuf ServiceId() const noexcept { + TStringBuf ServiceId() const noexcept { Y_VERIFY_DEBUG(IsService()); return TStringBuf((const char*)Raw.Buf, MaxServiceIDLength); } - static ui32 PoolIndex(ui32 nodeid) noexcept { + static ui32 PoolIndex(ui32 nodeid) noexcept { return ((nodeid & PoolIndexMask) >> PoolIndexShift); } - ui32 PoolID() const noexcept { + ui32 PoolID() const noexcept { return PoolIndex(Raw.N.NodeId); } - ui64 RawX1() const noexcept { + ui64 RawX1() const noexcept { return Raw.X.X1; } - ui64 RawX2() const noexcept { + ui64 RawX2() const noexcept { return Raw.X.X2; } diff --git a/library/cpp/actors/core/executor_pool_basic_ut.cpp b/library/cpp/actors/core/executor_pool_basic_ut.cpp index 76dff693af..71dc9d3b20 100644 --- a/library/cpp/actors/core/executor_pool_basic_ut.cpp +++ b/library/cpp/actors/core/executor_pool_basic_ut.cpp @@ -82,7 +82,7 @@ THolder<TActorSystemSetup> GetActorSystemSetup(TBasicExecutorPool* pool) auto setup = MakeHolder<NActors::TActorSystemSetup>(); setup->NodeId = 1; setup->ExecutorsCount = 1; - setup->Executors.Reset(new TAutoPtr<NActors::IExecutorPool>[1]); + setup->Executors.Reset(new TAutoPtr<NActors::IExecutorPool>[1]); setup->Executors[0] = pool; setup->Scheduler = new TBasicSchedulerThread(NActors::TSchedulerConfig(512, 0)); return setup; diff --git a/library/cpp/actors/core/executor_thread.cpp b/library/cpp/actors/core/executor_thread.cpp index 446b651efd..af8965365f 100644 --- a/library/cpp/actors/core/executor_thread.cpp +++ b/library/cpp/actors/core/executor_thread.cpp @@ -64,7 +64,7 @@ namespace NActors { void TExecutorThread::UnregisterActor(TMailboxHeader* mailbox, ui64 localActorId) { IActor* actor = mailbox->DetachActor(localActorId); Ctx.DecrementActorsAliveByActivity(actor->GetActivityType()); - DyingActors.push_back(THolder(actor)); + DyingActors.push_back(THolder(actor)); } void TExecutorThread::DropUnregistered() { @@ -298,7 +298,7 @@ namespace NActors { #endif if (ThreadName) { - ::SetCurrentThreadName(ThreadName); + ::SetCurrentThreadName(ThreadName); } ExecutorPool->SetRealTimeMode(); diff --git a/library/cpp/actors/core/mailbox.h b/library/cpp/actors/core/mailbox.h index 0bd9c4d314..43a2ffdbf4 100644 --- a/library/cpp/actors/core/mailbox.h +++ b/library/cpp/actors/core/mailbox.h @@ -95,7 +95,7 @@ namespace NActors { bool UnlockFromExecution2(bool wouldReschedule); // proceed with releasing lock bool UnlockAsFree(bool wouldReschedule); // preceed with releasing lock, but mark as free one - bool IsEmpty() const noexcept { + bool IsEmpty() const noexcept { return (ActorPack == TMailboxActorPack::Simple && ActorsInfo.Simple.ActorId == 0); } @@ -123,7 +123,7 @@ namespace NActors { } } - IActor* FindActor(ui64 localActorId) noexcept { + IActor* FindActor(ui64 localActorId) noexcept { switch (ActorPack) { case TMailboxActorPack::Simple: { if (ActorsInfo.Simple.ActorId == localActorId) @@ -150,7 +150,7 @@ namespace NActors { return nullptr; } - void AttachActor(ui64 localActorId, IActor* actor) noexcept { + void AttachActor(ui64 localActorId, IActor* actor) noexcept { switch (ActorPack) { case TMailboxActorPack::Simple: { if (ActorsInfo.Simple.ActorId == 0) { @@ -192,7 +192,7 @@ namespace NActors { } } - IActor* DetachActor(ui64 localActorId) noexcept { + IActor* DetachActor(ui64 localActorId) noexcept { Y_VERIFY_DEBUG(FindActor(localActorId) != nullptr); IActor* actorToDestruct = nullptr; diff --git a/library/cpp/actors/core/mailbox_queue_simple.h b/library/cpp/actors/core/mailbox_queue_simple.h index 2e44c21adb..535c012f19 100644 --- a/library/cpp/actors/core/mailbox_queue_simple.h +++ b/library/cpp/actors/core/mailbox_queue_simple.h @@ -12,7 +12,7 @@ namespace NActors { TTicketLock Lock; public: - ui32 Push(T x) noexcept { + ui32 Push(T x) noexcept { const ui32 spins = Lock.Acquire(); Queue.Push(x); Lock.Release(); diff --git a/library/cpp/actors/core/scheduler_basic.cpp b/library/cpp/actors/core/scheduler_basic.cpp index fba200e16b..59129d568e 100644 --- a/library/cpp/actors/core/scheduler_basic.cpp +++ b/library/cpp/actors/core/scheduler_basic.cpp @@ -53,7 +53,7 @@ namespace NActors { #ifdef BALLOC ThreadDisableBalloc(); #endif - ::SetCurrentThreadName("Scheduler"); + ::SetCurrentThreadName("Scheduler"); ui64 currentMonotonic = RelaxedLoad(CurrentMonotonic); ui64 throttledMonotonic = currentMonotonic; diff --git a/library/cpp/actors/core/scheduler_cookie.cpp b/library/cpp/actors/core/scheduler_cookie.cpp index 0fa6f543a7..faee2a206a 100644 --- a/library/cpp/actors/core/scheduler_cookie.cpp +++ b/library/cpp/actors/core/scheduler_cookie.cpp @@ -10,11 +10,11 @@ namespace NActors { { } - bool IsArmed() noexcept override { + bool IsArmed() noexcept override { return (AtomicGet(Value) == 2); } - bool Detach() noexcept override { + bool Detach() noexcept override { const ui64 x = AtomicDecrement(Value); if (x == 1) return true; @@ -27,7 +27,7 @@ namespace NActors { Y_FAIL(); } - bool DetachEvent() noexcept override { + bool DetachEvent() noexcept override { Y_FAIL(); } }; @@ -45,11 +45,11 @@ namespace NActors { { } - bool IsArmed() noexcept override { + bool IsArmed() noexcept override { return (AtomicGet(Value) == 3); } - bool Detach() noexcept override { + bool Detach() noexcept override { const ui64 x = AtomicDecrement(Value); if (x == 2) return true; @@ -63,7 +63,7 @@ namespace NActors { Y_FAIL(); } - bool DetachEvent() noexcept override { + bool DetachEvent() noexcept override { const ui64 x = AtomicDecrement(Value); if (x == 2) return false; diff --git a/library/cpp/actors/core/scheduler_cookie.h b/library/cpp/actors/core/scheduler_cookie.h index 2c20ca67f3..68f7e1b94d 100644 --- a/library/cpp/actors/core/scheduler_cookie.h +++ b/library/cpp/actors/core/scheduler_cookie.h @@ -10,9 +10,9 @@ namespace NActors { } public: - virtual bool Detach() noexcept = 0; - virtual bool DetachEvent() noexcept = 0; - virtual bool IsArmed() noexcept = 0; + virtual bool Detach() noexcept = 0; + virtual bool DetachEvent() noexcept = 0; + virtual bool IsArmed() noexcept = 0; static ISchedulerCookie* Make2Way(); static ISchedulerCookie* Make3Way(); @@ -36,7 +36,7 @@ namespace NActors { Detach(); } - bool operator==(const TSchedulerCookieHolder& x) const noexcept { + bool operator==(const TSchedulerCookieHolder& x) const noexcept { return (Cookie == x.Cookie); } @@ -55,7 +55,7 @@ namespace NActors { Cookie = cookie; } - bool Detach() noexcept { + bool Detach() noexcept { if (Cookie) { const bool res = Cookie->Detach(); Cookie = nullptr; @@ -65,7 +65,7 @@ namespace NActors { } } - bool DetachEvent() noexcept { + bool DetachEvent() noexcept { if (Cookie) { const bool res = Cookie->DetachEvent(); Cookie = nullptr; diff --git a/library/cpp/actors/http/http_cache.cpp b/library/cpp/actors/http/http_cache.cpp index 27c4eeb6f3..4ea22ffaa7 100644 --- a/library/cpp/actors/http/http_cache.cpp +++ b/library/cpp/actors/http/http_cache.cpp @@ -9,7 +9,7 @@ #include <library/cpp/digest/md5/md5.h> #include <util/digest/multi.h> #include <util/generic/queue.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NHttp { diff --git a/library/cpp/actors/memory_log/memlog.cpp b/library/cpp/actors/memory_log/memlog.cpp index 8e6b46727d..5358e1b0f1 100644 --- a/library/cpp/actors/memory_log/memlog.cpp +++ b/library/cpp/actors/memory_log/memlog.cpp @@ -105,7 +105,7 @@ char* TMemoryLog::LastMarkIsHere = nullptr; std::atomic<bool> TMemoryLog::PrintLastMark(true); -TMemoryLog::TMemoryLog(size_t totalSize, size_t grainSize) +TMemoryLog::TMemoryLog(size_t totalSize, size_t grainSize) : GrainSize(grainSize) , FreeGrains(DEFAULT_TOTAL_SIZE / DEFAULT_GRAIN_SIZE * 2) , Buf(totalSize) diff --git a/library/cpp/actors/testlib/decorator_ut.cpp b/library/cpp/actors/testlib/decorator_ut.cpp index e9a2fa3560..3b297b63e6 100644 --- a/library/cpp/actors/testlib/decorator_ut.cpp +++ b/library/cpp/actors/testlib/decorator_ut.cpp @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { { Write("Start master actor"); for (auto &actor : Actors) { - THolder<IActor> decaratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); + THolder<IActor> decaratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); TActorId id = Register(decaratedActor.Release()); Write("Register test actor"); UNIT_ASSERT(ActorIds.insert(id).second); @@ -232,11 +232,11 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { void Bootstrap() { Write("TFizzBuzzSender::Bootstrap"); - THolder<IActor> actor = MakeHolder<TFooBarReceiver>(SelfId()); - THolder<IActor> decoratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); + THolder<IActor> actor = MakeHolder<TFooBarReceiver>(SelfId()); + THolder<IActor> decoratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); SlaveId = Register(decoratedActor.Release()); for (ui64 idx = 1; idx <= 30; ++idx) { - THolder<TEvWords> ev = MakeHolder<TEvWords>(); + THolder<TEvWords> ev = MakeHolder<TEvWords>(); if (idx % 3 == 0) { ev->Words.push_back("Fizz"); } @@ -295,11 +295,11 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { } THolder<IActor> CreateFizzBuzzSender() { - THolder<IActor> actor = MakeHolder<TFizzBuzzSender>(); - THolder<IActor> foobar = MakeHolder<TFizzBuzzToFooBar>(std::move(actor)); - THolder<IActor> fizzEraser = MakeHolder<TWordEraser>(std::move(foobar), "Fizz"); - THolder<IActor> buzzEraser = MakeHolder<TWordEraser>(std::move(fizzEraser), "Buzz"); - return MakeHolder<TWithoutWordsDroper>(std::move(buzzEraser)); + THolder<IActor> actor = MakeHolder<TFizzBuzzSender>(); + THolder<IActor> foobar = MakeHolder<TFizzBuzzToFooBar>(std::move(actor)); + THolder<IActor> fizzEraser = MakeHolder<TWordEraser>(std::move(foobar), "Fizz"); + THolder<IActor> buzzEraser = MakeHolder<TWordEraser>(std::move(fizzEraser), "Buzz"); + return MakeHolder<TWithoutWordsDroper>(std::move(buzzEraser)); } Y_UNIT_TEST(Basic) { @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { TVector<THolder<IActor>> actors(1); actors[0] = CreateFizzBuzzSender(); //actors[1] = CreateFizzBuzzSender(); - THolder<IActor> testActor = MakeHolder<TTestMasterActor>(std::move(actors), edgeActor); + THolder<IActor> testActor = MakeHolder<TTestMasterActor>(std::move(actors), edgeActor); Write("Start test"); runtime.Register(testActor.Release()); diff --git a/library/cpp/actors/util/queue_oneone_inplace.h b/library/cpp/actors/util/queue_oneone_inplace.h index d7ec8bb21c..a473c500b8 100644 --- a/library/cpp/actors/util/queue_oneone_inplace.h +++ b/library/cpp/actors/util/queue_oneone_inplace.h @@ -53,7 +53,7 @@ public: } struct TPtrCleanDestructor { - static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { + static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { while (T head = x->Pop()) delete head; delete x; @@ -61,7 +61,7 @@ public: }; struct TCleanDestructor { - static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { + static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { while (x->Pop() != nullptr) continue; delete x; @@ -70,7 +70,7 @@ public: struct TPtrCleanInplaceMallocDestructor { template <typename TPtrVal> - static inline void Destroy(TOneOneQueueInplace<TPtrVal*, TSize>* x) noexcept { + static inline void Destroy(TOneOneQueueInplace<TPtrVal*, TSize>* x) noexcept { while (TPtrVal* head = x->Pop()) { head->~TPtrVal(); free(head); @@ -79,7 +79,7 @@ public: } }; - void Push(T x) noexcept { + void Push(T x) noexcept { if (WritePosition != TChunk::EntriesCount) { AtomicStore(&WriteTo->Entries[WritePosition], x); ++WritePosition; diff --git a/library/cpp/actors/util/thread.h b/library/cpp/actors/util/thread.h index d742c8c585..5f7bc27b69 100644 --- a/library/cpp/actors/util/thread.h +++ b/library/cpp/actors/util/thread.h @@ -18,9 +18,9 @@ inline void SetCurrentThreadName(const TString& name, TStringStream linuxName; linuxName << procName << "." << name; - TThread::SetCurrentThreadName(linuxName.Str().data()); + TThread::SetCurrentThreadName(linuxName.Str().data()); #else Y_UNUSED(maxCharsFromProcessName); - TThread::SetCurrentThreadName(name.data()); + TThread::SetCurrentThreadName(name.data()); #endif } diff --git a/library/cpp/actors/util/threadparkpad.cpp b/library/cpp/actors/util/threadparkpad.cpp index 74069ff15b..6d5701e109 100644 --- a/library/cpp/actors/util/threadparkpad.cpp +++ b/library/cpp/actors/util/threadparkpad.cpp @@ -19,25 +19,25 @@ namespace NActors { ~TImpl() { } - bool Park() noexcept { + bool Park() noexcept { __atomic_fetch_sub(&Futex, 1, __ATOMIC_SEQ_CST); while (__atomic_load_n(&Futex, __ATOMIC_ACQUIRE) == -1) SysFutex(&Futex, FUTEX_WAIT_PRIVATE, -1, nullptr, nullptr, 0); return IsInterrupted(); } - void Unpark() noexcept { + void Unpark() noexcept { const int old = __atomic_fetch_add(&Futex, 1, __ATOMIC_SEQ_CST); if (old == -1) SysFutex(&Futex, FUTEX_WAKE_PRIVATE, -1, nullptr, nullptr, 0); } - void Interrupt() noexcept { + void Interrupt() noexcept { __atomic_store_n(&Interrupted, true, __ATOMIC_SEQ_CST); Unpark(); } - bool IsInterrupted() const noexcept { + bool IsInterrupted() const noexcept { return __atomic_load_n(&Interrupted, __ATOMIC_ACQUIRE); } }; @@ -59,26 +59,26 @@ namespace NActors { if (!EvHandle) ythrow TWithBackTrace<yexception>() << "::CreateEvent failed"; } - ~TImpl() { + ~TImpl() { if (EvHandle) ::CloseHandle(EvHandle); } - bool Park() noexcept { + bool Park() noexcept { ::WaitForSingleObject(EvHandle, INFINITE); return AtomicGet(Interrupted); } - void Unpark() noexcept { + void Unpark() noexcept { ::SetEvent(EvHandle); } - void Interrupt() noexcept { + void Interrupt() noexcept { AtomicSet(Interrupted, true); Unpark(); } - bool IsInterrupted() const noexcept { + bool IsInterrupted() const noexcept { return AtomicGet(Interrupted); } }; @@ -98,24 +98,24 @@ namespace NActors { , Ev(TSystemEvent::rAuto) { } - ~TImpl() { + ~TImpl() { } - bool Park() noexcept { + bool Park() noexcept { Ev.Wait(); return AtomicGet(Interrupted); } - void Unpark() noexcept { + void Unpark() noexcept { Ev.Signal(); } - void Interrupt() noexcept { + void Interrupt() noexcept { AtomicSet(Interrupted, true); Unpark(); } - bool IsInterrupted() const noexcept { + bool IsInterrupted() const noexcept { return AtomicGet(Interrupted); } }; @@ -126,22 +126,22 @@ namespace NActors { { } - TThreadParkPad::~TThreadParkPad() { + TThreadParkPad::~TThreadParkPad() { } - bool TThreadParkPad::Park() noexcept { + bool TThreadParkPad::Park() noexcept { return Impl->Park(); } - void TThreadParkPad::Unpark() noexcept { + void TThreadParkPad::Unpark() noexcept { Impl->Unpark(); } - void TThreadParkPad::Interrupt() noexcept { + void TThreadParkPad::Interrupt() noexcept { Impl->Interrupt(); } - bool TThreadParkPad::Interrupted() const noexcept { + bool TThreadParkPad::Interrupted() const noexcept { return Impl->IsInterrupted(); } diff --git a/library/cpp/actors/util/threadparkpad.h b/library/cpp/actors/util/threadparkpad.h index 5b574ccf34..a3f33e601a 100644 --- a/library/cpp/actors/util/threadparkpad.h +++ b/library/cpp/actors/util/threadparkpad.h @@ -10,12 +10,12 @@ namespace NActors { public: TThreadParkPad(); - ~TThreadParkPad(); + ~TThreadParkPad(); - bool Park() noexcept; - void Unpark() noexcept; - void Interrupt() noexcept; - bool Interrupted() const noexcept; + bool Park() noexcept; + void Unpark() noexcept; + void Interrupt() noexcept; + bool Interrupted() const noexcept; }; } diff --git a/library/cpp/actors/util/ticket_lock.h b/library/cpp/actors/util/ticket_lock.h index 3b1fa80393..c6c6aebb32 100644 --- a/library/cpp/actors/util/ticket_lock.h +++ b/library/cpp/actors/util/ticket_lock.h @@ -15,11 +15,11 @@ public: { } - void Release() noexcept { + void Release() noexcept { AtomicUi32Increment(&TicketOut); } - ui32 Acquire() noexcept { + ui32 Acquire() noexcept { ui32 revolves = 0; const ui32 ticket = AtomicUi32Increment(&TicketIn) - 1; while (ticket != AtomicLoad(&TicketOut)) { @@ -30,7 +30,7 @@ public: return revolves; } - bool TryAcquire() noexcept { + bool TryAcquire() noexcept { const ui32 x = AtomicLoad(&TicketOut); if (x == AtomicLoad(&TicketIn) && AtomicUi32Cas(&TicketIn, x + 1, x)) return true; @@ -38,7 +38,7 @@ public: return false; } - bool IsLocked() noexcept { + bool IsLocked() noexcept { const ui32 ticketIn = AtomicLoad(&TicketIn); const ui32 ticketOut = AtomicLoad(&TicketOut); return (ticketIn != ticketOut); diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index 1becc3e5da..623a795bbc 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -145,7 +145,7 @@ public: } inline void Add(const TString& key, IInputStream* src) { - Y_ENSURE(!Dict_.contains(key), "key " << key.data() << " already stored"); + Y_ENSURE(!Dict_.contains(key), "key " << key.data() << " already stored"); TCountingOutput out(Out_); if (UseCompression) { @@ -173,8 +173,8 @@ public: } inline void AddSynonym(const TString& existingKey, const TString& newKey) { - Y_ENSURE(Dict_.contains(existingKey), "key " << existingKey.data() << " not stored yet"); - Y_ENSURE(!Dict_.contains(newKey), "key " << newKey.data() << " already stored"); + Y_ENSURE(Dict_.contains(existingKey), "key " << existingKey.data() << " not stored yet"); + Y_ENSURE(!Dict_.contains(newKey), "key " << newKey.data() << " already stored"); TArchiveRecordDescriptorRef existingDescr = Dict_[existingKey]; TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(existingDescr->Offset(), existingDescr->Length(), newKey)); @@ -312,7 +312,7 @@ public: } inline bool Has(const TStringBuf key) const { - return Dict_.contains(key); + return Dict_.contains(key); } inline TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const { diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 412424889f..2dd31b4879 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -471,13 +471,13 @@ public: }; template <class... TVariantTypes> - int Add(const chunk_id, std::variant<TVariantTypes...>* pData) { - static_assert(std::variant_size_v<std::variant<TVariantTypes...>> < Max<ui32>()); + int Add(const chunk_id, std::variant<TVariantTypes...>* pData) { + static_assert(std::variant_size_v<std::variant<TVariantTypes...>> < Max<ui32>()); ui32 index; if (IsReading()) { Add(1, &index); - TLoadFromTypeFromListHelper<std::variant<TVariantTypes...>>::template Do<TVariantTypes...>( + TLoadFromTypeFromListHelper<std::variant<TVariantTypes...>>::template Do<TVariantTypes...>( *this, index, pData @@ -485,7 +485,7 @@ public: } else { index = pData->index(); // type cast is safe because of static_assert check above Add(1, &index); - std::visit([&](auto& dst) -> void { Add(2, &dst); }, *pData); + std::visit([&](auto& dst) -> void { Add(2, &dst); }, *pData); } return 0; } diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index 37eba5406f..9f6569fbee 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -111,13 +111,13 @@ Y_UNIT_TEST(TestBlob) { Y_UNIT_TEST(TestVariant) { { - using T = std::variant<TString, int>; + using T = std::variant<TString, int>; TestBinSaverSerialization(T(TString(""))); TestBinSaverSerialization(T(0)); } { - using T = std::variant<TString, int, float>; + using T = std::variant<TString, int, float>; TestBinSaverSerialization(T(TString("ask"))); TestBinSaverSerialization(T(12)); diff --git a/library/cpp/bit_io/bitinput_impl.h b/library/cpp/bit_io/bitinput_impl.h index b13fbef101..e5125c2154 100644 --- a/library/cpp/bit_io/bitinput_impl.h +++ b/library/cpp/bit_io/bitinput_impl.h @@ -33,7 +33,7 @@ namespace NBitIO { protected: template <ui32 bits> Y_FORCE_INLINE bool ReadKImpl(ui64& result) { - result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & Mask64(bits); + result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & Mask64(bits); BOffset += bits; if (BOffset < FakeStart) return true; @@ -79,7 +79,7 @@ namespace NBitIO { protected: template <ui64 bits, typename T> Y_FORCE_INLINE static void CopyToResultK(T& result, ui64 r64, ui64 skipbits) { - result = (result & ~(Mask64(bits) << skipbits)) | (r64 << skipbits); + result = (result & ~(Mask64(bits) << skipbits)) | (r64 << skipbits); } template <typename T> @@ -92,8 +92,8 @@ namespace NBitIO { Y_FORCE_INLINE bool ReadWordsImpl(ui64& data) { data = 0; - const ui64 haveMore = NthBit64(bits); - const ui64 mask = Mask64(bits); + const ui64 haveMore = NthBit64(bits); + const ui64 mask = Mask64(bits); ui64 current = 0; ui64 byteNo = 0; diff --git a/library/cpp/bit_io/bitoutput.h b/library/cpp/bit_io/bitoutput.h index 2b886c1f02..24dda13178 100644 --- a/library/cpp/bit_io/bitoutput.h +++ b/library/cpp/bit_io/bitoutput.h @@ -14,10 +14,10 @@ namespace NBitIO { // Almost all code is hard tuned for sequential write performance. // Use tools/bursttrie/benchmarks/bitstreams_benchmark to check your changes. - inline constexpr ui64 BytesUp(ui64 bits) { - return (bits + 7ULL) >> 3ULL; - } - + inline constexpr ui64 BytesUp(ui64 bits) { + return (bits + 7ULL) >> 3ULL; + } + template <typename TStorage> class TBitOutputBase { protected: @@ -36,7 +36,7 @@ namespace NBitIO { } ui64 GetOffset() const { - return Offset + BytesUp(64ULL - FreeBits); + return Offset + BytesUp(64ULL - FreeBits); } ui64 GetBitOffset() const { @@ -83,7 +83,7 @@ namespace NBitIO { ui64 part = data; data >>= bits; - part |= FastZeroIfFalse(data, NthBit64(bits)); + part |= FastZeroIfFalse(data, NthBit64(bits)); Write(part, bits + 1ULL); } while (data); } diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index f3277b8e4b..6cf6cb83d7 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -3,8 +3,8 @@ #include <library/cpp/string_utils/scan/scan.h> #include <library/cpp/string_utils/quote/quote.h> -#include <util/generic/singleton.h> - +#include <util/generic/singleton.h> + TCgiParameters::TCgiParameters(std::initializer_list<std::pair<TString, TString>> il) { for (const auto& item : il) { insert(item); diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index 87d1ab0ad4..b28713606e 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -1,8 +1,8 @@ #pragma once -#include <library/cpp/iterator/iterate_values.h> - -#include <util/generic/iterator_range.h> +#include <library/cpp/iterator/iterate_values.h> + +#include <util/generic/iterator_range.h> #include <util/generic/map.h> #include <util/generic/strbuf.h> #include <util/generic/string.h> @@ -63,8 +63,8 @@ public: TString QuotedPrint(const char* safe = "/") const; Y_PURE_FUNCTION - auto Range(const TStringBuf name) const noexcept { - return IterateValues(MakeIteratorRange(equal_range(name))); + auto Range(const TStringBuf name) const noexcept { + return IterateValues(MakeIteratorRange(equal_range(name))); } Y_PURE_FUNCTION diff --git a/library/cpp/cgiparam/ya.make b/library/cpp/cgiparam/ya.make index fa1a6a13c0..f9859d1631 100644 --- a/library/cpp/cgiparam/ya.make +++ b/library/cpp/cgiparam/ya.make @@ -8,7 +8,7 @@ SRCS( ) PEERDIR( - library/cpp/iterator + library/cpp/iterator library/cpp/string_utils/quote library/cpp/string_utils/scan ) diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index 6097e40131..a3c546ab3f 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -1,15 +1,15 @@ #include "ci_string.h" int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) { - return cp.stricmp(s1.data(), s2.data()); + return cp.stricmp(s1.data(), s2.data()); } int TCiString::compare(const char* p, const TCiString& s2, const CodePage& cp) { - return cp.stricmp(p, s2.data()); + return cp.stricmp(p, s2.data()); } int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { - return cp.stricmp(s1.data(), p); + return cp.stricmp(s1.data(), p); } int TCiString::compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp) { diff --git a/library/cpp/charset/ci_string.h b/library/cpp/charset/ci_string.h index edf24c1b6f..4756379808 100644 --- a/library/cpp/charset/ci_string.h +++ b/library/cpp/charset/ci_string.h @@ -209,7 +209,7 @@ public: static size_t hashVal(const char* pc, size_t len, const CodePage& cp = csYandex); size_t hash() const { - return TCiString::hashVal(data(), length()); + return TCiString::hashVal(data(), length()); } }; diff --git a/library/cpp/charset/ci_string_ut.cpp b/library/cpp/charset/ci_string_ut.cpp index 3d2a53d5fe..c1d979d93a 100644 --- a/library/cpp/charset/ci_string_ut.cpp +++ b/library/cpp/charset/ci_string_ut.cpp @@ -1,13 +1,13 @@ #include "ci_string.h" -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/string_ut.h> class TCaseStringTest: public TTestBase, private TStringTestImpl<TCiString, TTestData<char>> { public: void TestSpecial() { TCiString ss = Data._0123456(); // type 'TCiString' is used as is - size_t hash_val = ComputeHash(ss); + size_t hash_val = ComputeHash(ss); UNIT_ASSERT(hash_val == 1489244); } diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 0431bef31b..a9b64bdd64 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -6,7 +6,7 @@ #include <util/string/cast.h> #include <util/string/subst.h> #include <util/string/util.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <util/system/yassert.h> #include <util/generic/hash.h> #include <util/generic/string.h> @@ -256,8 +256,8 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { if (SingleByteCodepage(enc)) { const CodePage* cp = CodePageByCharset(enc); for (TxChar* s = str; s < e; s++) { - if (Hi8(Lo16(*s)) == 0xF0) - *s = (TxChar)cp->unicode[Lo8(Lo16(*s))]; // NOT mb compliant + if (Hi8(Lo16(*s)) == 0xF0) + *s = (TxChar)cp->unicode[Lo8(Lo16(*s))]; // NOT mb compliant } } else if (enc == CODES_UTF8) { TxChar* s; @@ -276,8 +276,8 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { e = d; } else if (enc == CODES_UNKNOWN) { for (TxChar* s = str; s < e; s++) { - if (Hi8(Lo16(*s)) == 0xF0) - *s = Lo8(Lo16(*s)); + if (Hi8(Lo16(*s)) == 0xF0) + *s = Lo8(Lo16(*s)); } } else { Y_ASSERT(!SingleByteCodepage(enc)); @@ -290,8 +290,8 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { size_t read = 0; size_t written = 0; for (; s < e; ++s) { - if (Hi8(Lo16(*s)) == 0xF0) { - buf.push_back(Lo8(Lo16(*s))); + if (Hi8(Lo16(*s)) == 0xF0) { + buf.push_back(Lo8(Lo16(*s))); } else { if (!buf.empty()) { if (RecodeToUnicode(enc, buf.data(), d, buf.size(), e - d, read, written) == RECODE_OK) { diff --git a/library/cpp/charset/ut/ya.make b/library/cpp/charset/ut/ya.make index 1f9934c712..008f323970 100644 --- a/library/cpp/charset/ut/ya.make +++ b/library/cpp/charset/ut/ya.make @@ -3,7 +3,7 @@ UNITTEST_FOR(library/cpp/charset) OWNER(alzobnin) SRCS( - ci_string_ut.cpp + ci_string_ut.cpp codepage_ut.cpp iconv_ut.cpp wide_ut.cpp diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 78947d51ba..6097773b4b 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -261,10 +261,10 @@ void TConversionTest::TestRecodeIntoString() { TUtf16String copy = sUnicode; // increase ref-counter wres = NDetail::Recode<char>(UTF8Text, sUnicode, CODES_UTF8); UNIT_ASSERT(sUnicode == UnicodeText); // same content -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(sUnicode.data() != wdata); // re-allocated (shared buffer supplied) UNIT_ASSERT(sUnicode.data() == wres.data()); // same buffer -#endif +#endif UNIT_ASSERT(sUnicode.size() == wres.size()); // same content } @@ -372,7 +372,7 @@ void TConversionTest::TestRecode() { UNIT_ASSERT_VALUES_EQUAL(size_t(1), written); UNIT_ASSERT_VALUES_EQUAL(rch2, rch); - if (hash.contains(rch)) { // there are some stupid encodings with duplicate characters + if (hash.contains(rch)) { // there are some stupid encodings with duplicate characters continue; } else { hash.insert(rch); diff --git a/library/cpp/codecs/codecs.h b/library/cpp/codecs/codecs.h index cc5e72b285..6716574b9e 100644 --- a/library/cpp/codecs/codecs.h +++ b/library/cpp/codecs/codecs.h @@ -10,7 +10,7 @@ #include <util/stream/input.h> #include <util/stream/output.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/vector.h> #include <util/system/tls.h> #include <util/ysaveload.h> diff --git a/library/cpp/codecs/codecs_registry.cpp b/library/cpp/codecs/codecs_registry.cpp index 17d07062ab..05caa50d58 100644 --- a/library/cpp/codecs/codecs_registry.cpp +++ b/library/cpp/codecs/codecs_registry.cpp @@ -9,7 +9,7 @@ #include <library/cpp/blockcodecs/codecs.h> #include <util/string/builder.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { TCodecPtr ICodec::GetInstance(TStringBuf name) { @@ -24,7 +24,7 @@ namespace NCodecs { void TCodecRegistry::RegisterFactory(TFactoryPtr fac) { TVector<TString> names = fac->ListNames(); for (const auto& name : names) { - Y_VERIFY(!Registry.contains(name), "already has %s", name.data()); + Y_VERIFY(!Registry.contains(name), "already has %s", name.data()); Registry[name] = fac; } } @@ -37,7 +37,7 @@ namespace NCodecs { } if (TStringBuf::npos == name.find(':')) { - Y_ENSURE_EX(Registry.contains(name), TNoCodecException(name)); + Y_ENSURE_EX(Registry.contains(name), TNoCodecException(name)); return Registry.find(name)->second->MakeCodec(name); } else { TPipelineCodec* pipe = new TPipelineCodec; @@ -190,7 +190,7 @@ namespace NCodecs { } TCodecPtr MakeCodec(TStringBuf name) const override { - if (!Registry.contains(name)) { + if (!Registry.contains(name)) { ythrow TNoCodecException(name); } return Registry.find(name)->second; diff --git a/library/cpp/codecs/codecs_registry.h b/library/cpp/codecs/codecs_registry.h index 53710310d5..3f2e994320 100644 --- a/library/cpp/codecs/codecs_registry.h +++ b/library/cpp/codecs/codecs_registry.h @@ -1,7 +1,7 @@ #pragma once #include "codecs.h" -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { struct TNoCodecException : TCodecException { diff --git a/library/cpp/codecs/comptable_codec.cpp b/library/cpp/codecs/comptable_codec.cpp index 476b8ada80..0fa8104369 100644 --- a/library/cpp/codecs/comptable_codec.cpp +++ b/library/cpp/codecs/comptable_codec.cpp @@ -1,7 +1,7 @@ #include "comptable_codec.h" #include <library/cpp/comptable/comptable.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { class TCompTableCodec::TImpl: public TAtomicRefCount<TImpl> { diff --git a/library/cpp/codecs/delta_codec.h b/library/cpp/codecs/delta_codec.h index 21325825e6..78dbd8f1ee 100644 --- a/library/cpp/codecs/delta_codec.h +++ b/library/cpp/codecs/delta_codec.h @@ -4,8 +4,8 @@ #include <util/generic/array_ref.h> #include <util/generic/typetraits.h> -#include <util/generic/bitops.h> -#include <util/string/cast.h> +#include <util/generic/bitops.h> +#include <util/string/cast.h> namespace NCodecs { template <typename T = ui64, bool UnsignedDelta = true> diff --git a/library/cpp/codecs/float_huffman.cpp b/library/cpp/codecs/float_huffman.cpp index c4a8bd228f..9029877023 100644 --- a/library/cpp/codecs/float_huffman.cpp +++ b/library/cpp/codecs/float_huffman.cpp @@ -1,333 +1,333 @@ #include "float_huffman.h" -#include <util/generic/array_ref.h> -#include <util/generic/bitops.h> -#include <util/generic/cast.h> -#include <util/generic/yexception.h> -#include <util/system/unaligned_mem.h> -#include <util/system/yassert.h> -#include <util/stream/format.h> - -namespace NCodecs::NFloatHuff { - namespace { - struct THuffEntry { - ui32 CodeBase; - ui16 Prefix; - int PrefLength; - int CodeLength; - int TotalLength; - ui32 Mask; - ui64 Offset; - - THuffEntry() = default; - - constexpr THuffEntry(ui32 codeBase, ui16 prefix, int prefLength, int codeLength) - : CodeBase(codeBase) - , Prefix(prefix) - , PrefLength(prefLength) - , CodeLength(codeLength) - , TotalLength(prefLength + codeLength) - , Mask(Mask64(codeLength)) - , Offset(-(ui64(codeBase) << prefLength) + prefix) - {} - - bool Fit(ui32 code) const { - return code >= CodeBase && code < CodeBase + (1ULL << CodeLength); - } - }; - - // NB. There is a typo in the penultimate line (34 instead of 24). It was there from the very - // first commit and we cannot fix it without breaking all the clients. - constexpr THuffEntry entries[16] = { - {0x00000000, 0x01, 1, 0}, // Only +0.0f, 1 bit, prefix [1] - {0x3f800000, 0x0e, 4, 0}, // Only +1.0f, 4 bits, prefix [0111] - {0x3f700000, 0x08, 5, 20}, // [0.9375, 1.0), 25 bits, prefix [00010] - {0x3f000000, 0x00, 5, 20}, // [0.5, 0.5625), 25 bits, prefx [00000] - {0x3f400000, 0x06, 6, 20}, // [0.75, 0.8125), 26 bits, prefix [011000] - {0x3f500000, 0x22, 6, 20}, // [0.8125, 0.875), 26 bits, prefix [010001] - {0x3f200000, 0x02, 6, 20}, // [0.625, 0.6875), 26 bits, prefix [010000] - {0x3f100000, 0x38, 6, 20}, // [0.5625, 0.625), 26 bits, prefix [000111] - {0x3f600000, 0x18, 6, 20}, // [0.875, 0.9375), 26 bits, prefix [000110] - {0x3f300000, 0x30, 6, 20}, // [0.6875, 0.75), 26 bits, prefix [000011] - {0x3e800000, 0x10, 6, 20}, // [0.25, 0.28125), 26 bits, prefix [000010] - {0x3e000000, 0x04, 3, 24}, // [0.125, 0.5), 27 bits, prefix [001] - {0x3d000000, 0x0a, 4, 24}, // [0.03125, 0.125), 28 bits, prefix [0101] - {0x3c000000, 0x12, 5, 24}, // [0.0078125, 0.03125), 29 bits, prefix [01001] - {0x3b000000, 0x26, 6, 34}, // [0.001953125, end of range), 40 bits, prefix [011001] - {0x00000000, 0x16, 5, 32}, // whole range, 37 bits, prefix [01101] +#include <util/generic/array_ref.h> +#include <util/generic/bitops.h> +#include <util/generic/cast.h> +#include <util/generic/yexception.h> +#include <util/system/unaligned_mem.h> +#include <util/system/yassert.h> +#include <util/stream/format.h> + +namespace NCodecs::NFloatHuff { + namespace { + struct THuffEntry { + ui32 CodeBase; + ui16 Prefix; + int PrefLength; + int CodeLength; + int TotalLength; + ui32 Mask; + ui64 Offset; + + THuffEntry() = default; + + constexpr THuffEntry(ui32 codeBase, ui16 prefix, int prefLength, int codeLength) + : CodeBase(codeBase) + , Prefix(prefix) + , PrefLength(prefLength) + , CodeLength(codeLength) + , TotalLength(prefLength + codeLength) + , Mask(Mask64(codeLength)) + , Offset(-(ui64(codeBase) << prefLength) + prefix) + {} + + bool Fit(ui32 code) const { + return code >= CodeBase && code < CodeBase + (1ULL << CodeLength); + } + }; + + // NB. There is a typo in the penultimate line (34 instead of 24). It was there from the very + // first commit and we cannot fix it without breaking all the clients. + constexpr THuffEntry entries[16] = { + {0x00000000, 0x01, 1, 0}, // Only +0.0f, 1 bit, prefix [1] + {0x3f800000, 0x0e, 4, 0}, // Only +1.0f, 4 bits, prefix [0111] + {0x3f700000, 0x08, 5, 20}, // [0.9375, 1.0), 25 bits, prefix [00010] + {0x3f000000, 0x00, 5, 20}, // [0.5, 0.5625), 25 bits, prefx [00000] + {0x3f400000, 0x06, 6, 20}, // [0.75, 0.8125), 26 bits, prefix [011000] + {0x3f500000, 0x22, 6, 20}, // [0.8125, 0.875), 26 bits, prefix [010001] + {0x3f200000, 0x02, 6, 20}, // [0.625, 0.6875), 26 bits, prefix [010000] + {0x3f100000, 0x38, 6, 20}, // [0.5625, 0.625), 26 bits, prefix [000111] + {0x3f600000, 0x18, 6, 20}, // [0.875, 0.9375), 26 bits, prefix [000110] + {0x3f300000, 0x30, 6, 20}, // [0.6875, 0.75), 26 bits, prefix [000011] + {0x3e800000, 0x10, 6, 20}, // [0.25, 0.28125), 26 bits, prefix [000010] + {0x3e000000, 0x04, 3, 24}, // [0.125, 0.5), 27 bits, prefix [001] + {0x3d000000, 0x0a, 4, 24}, // [0.03125, 0.125), 28 bits, prefix [0101] + {0x3c000000, 0x12, 5, 24}, // [0.0078125, 0.03125), 29 bits, prefix [01001] + {0x3b000000, 0x26, 6, 34}, // [0.001953125, end of range), 40 bits, prefix [011001] + {0x00000000, 0x16, 5, 32}, // whole range, 37 bits, prefix [01101] }; [[noreturn]] Y_NO_INLINE void ThrowInvalidOffset(size_t size, size_t byteOffset) { - ythrow yexception() << - "Decompression error: requested decoding 8 bytes past end of input buffer of " << size << " bytes size at position " << byteOffset << ". "; - } - - struct THuffInfo { - constexpr THuffInfo() { - for (size_t i = 0; i < 64; ++i) { - bool init = false; - for (size_t j = 0; j != 16; ++j) { - ui16 prefix = i & Mask64(entries[j].PrefLength); - if (entries[j].Prefix == prefix) { - init = true; - DecodeLookup[i] = entries[j]; - break; - } - } - Y_ASSERT(init); - } - - for (ui32 i = 0; i < (1 << 12); ++i) { - // First two entries (+0.0f and +1.0f) are not present in the lookup, they are handled separately - for (int value = 2; value < 16; ++value) { - if (entries[value].Fit(i << 20)) { - EncodeLookup[i] = value; - break; - } - } - } - } - - std::pair<ui64, int> GetCode(ui32 value) const { - // Zeros are handled separately in the main loop - Y_ASSERT(value != 0); - - if (value == 0x3f800000) { - return {0x0e, 4}; - } - - const auto& entry = entries[EncodeLookup[value >> 20]]; - - return { - (ui64(value) << entry.PrefLength) + entry.Offset, - entry.TotalLength - }; - } - - THuffEntry DecodeLookup[64]; - ui8 EncodeLookup[1 << 12]; - }; - - const THuffInfo huffInfo; - /// End Of Stream - const ui32 EOS = ui32(-1); - } - - TString Encode(TArrayRef<const float> factors) { - TString result; - result.resize((factors.size() + 1) * 40 / 8 + 8, 0); // Max code length is 40 bits - int usedBits = 0; - ui64 buffer = 0; - char* writePtr = result.begin(); - - auto writeBits = [&](ui64 code, int size) { - const auto bitsToTransfer = Min(size, 64 - usedBits); - buffer |= (code << usedBits); - usedBits += bitsToTransfer; - if (usedBits == 64) { - memcpy(writePtr, &buffer, 8); - usedBits = size - bitsToTransfer; - if (bitsToTransfer != 64) { - buffer = code >> bitsToTransfer; - } else { - buffer = 0; - } - writePtr += 8; - } - }; - - for (size_t i = 0; i != factors.size();) { - if (BitCast<ui32>(factors[i]) == 0) { - int zeroCount = 1; - for (;;) { - ++i; - if (i == factors.size() || BitCast<ui32>(factors[i]) != 0) { - break; - } - ++zeroCount; - } - for (; zeroCount >= 64; zeroCount -= 64) { - writeBits(ui64(-1), 64); - } - writeBits(Mask64(zeroCount), zeroCount); - } else { - const auto [code, codeSize] = huffInfo.GetCode(BitCast<ui32>(factors[i])); - writeBits(code, codeSize); - ++i; - } - } - // Write EOS. - // We use precomputed constants instead of the following: - // auto [code, codeSize] = huffInfo.GetCode(EOS); - // writeBits(code, codeSize); - writeBits(211527139302, 40); - memcpy(writePtr, &buffer, 8); - result.resize(writePtr - result.begin() + usedBits / 8 + 8); - - return result; - } - - TDecoder::TDecoder(TStringBuf data) - : State{ - .Workspace = data.size() < 8 ? ThrowInvalidOffset(data.size(), 0), 0 : ReadUnaligned<ui64>(data.data()), - .WorkspaceSize = 64, - .Position = 8, - .Data = data - } - { - FillDecodeBuffer(); - } - - TVector<float> TDecoder::DecodeAll(size_t sizeHint) { - TVector<float> result; - result.reserve(sizeHint); - - while (Begin != End) { - result.insert(result.end(), Begin, End); - FillDecodeBuffer(); - } - return result; - } - - size_t TDecoder::Decode(TArrayRef<float> dest) { - size_t count = 0; - while (count < dest.size()) { - if (dest.size() - count < size_t(End - Begin)) { - const auto size = dest.size() - count; - std::copy(Begin, Begin + size, dest.data() + count); - Begin += size; - return dest.size(); - } else { - std::copy(Begin, End, dest.data() + count); - count += End - Begin; - FillDecodeBuffer(); - if (Begin == End) { - break; - } - } - } - return count; - } - - size_t TDecoder::Skip(size_t count) { - size_t skippedCount = 0; - while (skippedCount < count) { - if (count - skippedCount < size_t(End - Begin)) { - const auto size = count - skippedCount; - Begin += size; - return count; - } else { - skippedCount += End - Begin; - FillDecodeBuffer(); - if (Begin == End) { - break; - } - } - } - return skippedCount; - } - - bool TDecoder::HasMore() const { - return Begin != End; - } - - void TDecoder::FillDecodeBuffer() { - Begin = DecodeBuffer.data(); - End = DecodeBuffer.data(); - - if (HitEos) { - return; - } - - // This helps to keep most of the variables in the registers. - float* end = End; - TState state = State; - - // It is faster to just zero all the memory here in one go - // and then avoid inner loop when writing zeros. There we - // can just increment end pointer. - std::fill(DecodeBuffer.begin(), DecodeBuffer.end(), 0.0f); - - // Make sure that inside the loop we always have space to put 64 zeros and one other - // value. - float* cap = DecodeBuffer.data() + DecodeBuffer.size() - 64 - 1; - - while (end < cap) { - if (state.Workspace % 2 == 1) { - // Decode zeros - // There we can just scan whole state.Workspace for ones because it contains - // zeros outside of the WorkspaceSize bits. - const auto negWorkspace = ~state.Workspace; - const int zeroCount = negWorkspace ? CountTrailingZeroBits(negWorkspace) : 64; - end += zeroCount; - state.SkipBits(zeroCount); - continue; - } - if (state.PeekBits(4) == 0x0e) { - *end++ = 1.0f; - state.SkipBits(4); - continue; - } - const auto& entry = huffInfo.DecodeLookup[state.PeekBits(6)]; - const auto code = ui32((state.NextBitsUnmasked(entry.TotalLength) >> entry.PrefLength) & entry.Mask) + entry.CodeBase; - if (Y_UNLIKELY(code == EOS)) { - HitEos = true; - break; - } - *end++ = BitCast<float>(code); - } - - End = end; - State = state; - } - - ui64 TDecoder::TState::PeekBits(int count) { - if (WorkspaceSize > count) { - return Workspace & Mask64(count); - } else { - if (Y_UNLIKELY(Position + 8 > Data.size())) { - ThrowInvalidOffset(Data.size(), Position); - } - return (Workspace | (ReadUnaligned<ui64>(Data.data() + Position) << WorkspaceSize)) & Mask64(count); - } - } - - ui64 TDecoder::TState::NextBitsUnmasked(int count) { - if (WorkspaceSize > count) { - const auto result = Workspace; - Workspace >>= count; - WorkspaceSize -= count; - return result; - } else { - if (Y_UNLIKELY(Position + 8 > Data.size())) { - ThrowInvalidOffset(Data.size(), Position); - } - ui64 result = Workspace; - Workspace = ReadUnaligned<ui64>(Data.data() + Position); - Position += 8; - result |= Workspace << WorkspaceSize; - Workspace >>= count - WorkspaceSize; - WorkspaceSize += 64 - count; - return result; - } - } - - void TDecoder::TState::SkipBits(int count) { - if (WorkspaceSize > count) { - Workspace >>= count; - WorkspaceSize -= count; - } else { - if (Y_UNLIKELY(Position + 8 > Data.size())) { - ThrowInvalidOffset(Data.size(), Position); - } - Workspace = ReadUnaligned<ui64>(Data.data() + Position); - Position += 8; - Workspace >>= count - WorkspaceSize; - WorkspaceSize += 64 - count; - } - } - - TVector<float> Decode(TStringBuf data, size_t sizeHint) { - return TDecoder(data).DecodeAll(sizeHint); - } -} // namespace NCodecs::NFloatHuff + ythrow yexception() << + "Decompression error: requested decoding 8 bytes past end of input buffer of " << size << " bytes size at position " << byteOffset << ". "; + } + + struct THuffInfo { + constexpr THuffInfo() { + for (size_t i = 0; i < 64; ++i) { + bool init = false; + for (size_t j = 0; j != 16; ++j) { + ui16 prefix = i & Mask64(entries[j].PrefLength); + if (entries[j].Prefix == prefix) { + init = true; + DecodeLookup[i] = entries[j]; + break; + } + } + Y_ASSERT(init); + } + + for (ui32 i = 0; i < (1 << 12); ++i) { + // First two entries (+0.0f and +1.0f) are not present in the lookup, they are handled separately + for (int value = 2; value < 16; ++value) { + if (entries[value].Fit(i << 20)) { + EncodeLookup[i] = value; + break; + } + } + } + } + + std::pair<ui64, int> GetCode(ui32 value) const { + // Zeros are handled separately in the main loop + Y_ASSERT(value != 0); + + if (value == 0x3f800000) { + return {0x0e, 4}; + } + + const auto& entry = entries[EncodeLookup[value >> 20]]; + + return { + (ui64(value) << entry.PrefLength) + entry.Offset, + entry.TotalLength + }; + } + + THuffEntry DecodeLookup[64]; + ui8 EncodeLookup[1 << 12]; + }; + + const THuffInfo huffInfo; + /// End Of Stream + const ui32 EOS = ui32(-1); + } + + TString Encode(TArrayRef<const float> factors) { + TString result; + result.resize((factors.size() + 1) * 40 / 8 + 8, 0); // Max code length is 40 bits + int usedBits = 0; + ui64 buffer = 0; + char* writePtr = result.begin(); + + auto writeBits = [&](ui64 code, int size) { + const auto bitsToTransfer = Min(size, 64 - usedBits); + buffer |= (code << usedBits); + usedBits += bitsToTransfer; + if (usedBits == 64) { + memcpy(writePtr, &buffer, 8); + usedBits = size - bitsToTransfer; + if (bitsToTransfer != 64) { + buffer = code >> bitsToTransfer; + } else { + buffer = 0; + } + writePtr += 8; + } + }; + + for (size_t i = 0; i != factors.size();) { + if (BitCast<ui32>(factors[i]) == 0) { + int zeroCount = 1; + for (;;) { + ++i; + if (i == factors.size() || BitCast<ui32>(factors[i]) != 0) { + break; + } + ++zeroCount; + } + for (; zeroCount >= 64; zeroCount -= 64) { + writeBits(ui64(-1), 64); + } + writeBits(Mask64(zeroCount), zeroCount); + } else { + const auto [code, codeSize] = huffInfo.GetCode(BitCast<ui32>(factors[i])); + writeBits(code, codeSize); + ++i; + } + } + // Write EOS. + // We use precomputed constants instead of the following: + // auto [code, codeSize] = huffInfo.GetCode(EOS); + // writeBits(code, codeSize); + writeBits(211527139302, 40); + memcpy(writePtr, &buffer, 8); + result.resize(writePtr - result.begin() + usedBits / 8 + 8); + + return result; + } + + TDecoder::TDecoder(TStringBuf data) + : State{ + .Workspace = data.size() < 8 ? ThrowInvalidOffset(data.size(), 0), 0 : ReadUnaligned<ui64>(data.data()), + .WorkspaceSize = 64, + .Position = 8, + .Data = data + } + { + FillDecodeBuffer(); + } + + TVector<float> TDecoder::DecodeAll(size_t sizeHint) { + TVector<float> result; + result.reserve(sizeHint); + + while (Begin != End) { + result.insert(result.end(), Begin, End); + FillDecodeBuffer(); + } + return result; + } + + size_t TDecoder::Decode(TArrayRef<float> dest) { + size_t count = 0; + while (count < dest.size()) { + if (dest.size() - count < size_t(End - Begin)) { + const auto size = dest.size() - count; + std::copy(Begin, Begin + size, dest.data() + count); + Begin += size; + return dest.size(); + } else { + std::copy(Begin, End, dest.data() + count); + count += End - Begin; + FillDecodeBuffer(); + if (Begin == End) { + break; + } + } + } + return count; + } + + size_t TDecoder::Skip(size_t count) { + size_t skippedCount = 0; + while (skippedCount < count) { + if (count - skippedCount < size_t(End - Begin)) { + const auto size = count - skippedCount; + Begin += size; + return count; + } else { + skippedCount += End - Begin; + FillDecodeBuffer(); + if (Begin == End) { + break; + } + } + } + return skippedCount; + } + + bool TDecoder::HasMore() const { + return Begin != End; + } + + void TDecoder::FillDecodeBuffer() { + Begin = DecodeBuffer.data(); + End = DecodeBuffer.data(); + + if (HitEos) { + return; + } + + // This helps to keep most of the variables in the registers. + float* end = End; + TState state = State; + + // It is faster to just zero all the memory here in one go + // and then avoid inner loop when writing zeros. There we + // can just increment end pointer. + std::fill(DecodeBuffer.begin(), DecodeBuffer.end(), 0.0f); + + // Make sure that inside the loop we always have space to put 64 zeros and one other + // value. + float* cap = DecodeBuffer.data() + DecodeBuffer.size() - 64 - 1; + + while (end < cap) { + if (state.Workspace % 2 == 1) { + // Decode zeros + // There we can just scan whole state.Workspace for ones because it contains + // zeros outside of the WorkspaceSize bits. + const auto negWorkspace = ~state.Workspace; + const int zeroCount = negWorkspace ? CountTrailingZeroBits(negWorkspace) : 64; + end += zeroCount; + state.SkipBits(zeroCount); + continue; + } + if (state.PeekBits(4) == 0x0e) { + *end++ = 1.0f; + state.SkipBits(4); + continue; + } + const auto& entry = huffInfo.DecodeLookup[state.PeekBits(6)]; + const auto code = ui32((state.NextBitsUnmasked(entry.TotalLength) >> entry.PrefLength) & entry.Mask) + entry.CodeBase; + if (Y_UNLIKELY(code == EOS)) { + HitEos = true; + break; + } + *end++ = BitCast<float>(code); + } + + End = end; + State = state; + } + + ui64 TDecoder::TState::PeekBits(int count) { + if (WorkspaceSize > count) { + return Workspace & Mask64(count); + } else { + if (Y_UNLIKELY(Position + 8 > Data.size())) { + ThrowInvalidOffset(Data.size(), Position); + } + return (Workspace | (ReadUnaligned<ui64>(Data.data() + Position) << WorkspaceSize)) & Mask64(count); + } + } + + ui64 TDecoder::TState::NextBitsUnmasked(int count) { + if (WorkspaceSize > count) { + const auto result = Workspace; + Workspace >>= count; + WorkspaceSize -= count; + return result; + } else { + if (Y_UNLIKELY(Position + 8 > Data.size())) { + ThrowInvalidOffset(Data.size(), Position); + } + ui64 result = Workspace; + Workspace = ReadUnaligned<ui64>(Data.data() + Position); + Position += 8; + result |= Workspace << WorkspaceSize; + Workspace >>= count - WorkspaceSize; + WorkspaceSize += 64 - count; + return result; + } + } + + void TDecoder::TState::SkipBits(int count) { + if (WorkspaceSize > count) { + Workspace >>= count; + WorkspaceSize -= count; + } else { + if (Y_UNLIKELY(Position + 8 > Data.size())) { + ThrowInvalidOffset(Data.size(), Position); + } + Workspace = ReadUnaligned<ui64>(Data.data() + Position); + Position += 8; + Workspace >>= count - WorkspaceSize; + WorkspaceSize += 64 - count; + } + } + + TVector<float> Decode(TStringBuf data, size_t sizeHint) { + return TDecoder(data).DecodeAll(sizeHint); + } +} // namespace NCodecs::NFloatHuff diff --git a/library/cpp/codecs/float_huffman.h b/library/cpp/codecs/float_huffman.h index 786a8eae1d..0fc1573d8e 100644 --- a/library/cpp/codecs/float_huffman.h +++ b/library/cpp/codecs/float_huffman.h @@ -1,50 +1,50 @@ #pragma once -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> #include <util/generic/vector.h> #include <util/generic/strbuf.h> -#include <array> - -namespace NCodecs::NFloatHuff { - TString Encode(TArrayRef<const float> factors); - - class TDecoder { - public: - explicit TDecoder(TStringBuf data); - - TVector<float> DecodeAll(size_t sizeHint = 0); - - // Returns number of decoded floats. May be fewer than requested if the EOS is found. - size_t Decode(TArrayRef<float> dest); - - // Returns the number of skipped values. - size_t Skip(size_t count); - - bool HasMore() const; - - private: - struct TState { - ui64 Workspace = 0; - int WorkspaceSize = 0; - ui64 Position = 0; - TStringBuf Data; - - ui64 NextBitsUnmasked(int count); // The upper 64 - count bits may be arbitrary - ui64 PeekBits(int count); - void SkipBits(int count); - }; - - void FillDecodeBuffer(); - - TState State; - std::array<float, 128> DecodeBuffer; - // The range of already decompressed numbers inside the DecodeBuffer. - // Always kept non-empty until the EOS is encountered. - float* Begin; - float* End; - bool HitEos = false; - }; - - TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); +#include <array> + +namespace NCodecs::NFloatHuff { + TString Encode(TArrayRef<const float> factors); + + class TDecoder { + public: + explicit TDecoder(TStringBuf data); + + TVector<float> DecodeAll(size_t sizeHint = 0); + + // Returns number of decoded floats. May be fewer than requested if the EOS is found. + size_t Decode(TArrayRef<float> dest); + + // Returns the number of skipped values. + size_t Skip(size_t count); + + bool HasMore() const; + + private: + struct TState { + ui64 Workspace = 0; + int WorkspaceSize = 0; + ui64 Position = 0; + TStringBuf Data; + + ui64 NextBitsUnmasked(int count); // The upper 64 - count bits may be arbitrary + ui64 PeekBits(int count); + void SkipBits(int count); + }; + + void FillDecodeBuffer(); + + TState State; + std::array<float, 128> DecodeBuffer; + // The range of already decompressed numbers inside the DecodeBuffer. + // Always kept non-empty until the EOS is encountered. + float* Begin; + float* End; + bool HitEos = false; + }; + + TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); } diff --git a/library/cpp/codecs/float_huffman_bench/main.cpp b/library/cpp/codecs/float_huffman_bench/main.cpp index 1018c17834..c5dd456bbe 100644 --- a/library/cpp/codecs/float_huffman_bench/main.cpp +++ b/library/cpp/codecs/float_huffman_bench/main.cpp @@ -1,145 +1,145 @@ -#include <library/cpp/codecs/float_huffman.h> - -#include <benchmark/benchmark.h> - -#include <util/generic/vector.h> - -const float Factors[] = { - 0.340582, 0.000974026, 0.487168, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0.411765, 0.921569, - 0.00390625, 0.109371, 0, 1, 0, 0, 0, 0, 0.523322, 0, 1, 0, 0, 0, 0, 0.285714, 1, - 0.008253, 1, 0, 0, 0.00993935, 0.450213, 0.000974026, 1, 1, 1, 1, 0, 0, 0.20564, - 0.97561, 0.913896, 1, 1, 0, 1, 0, 0, 0.5, 0, 0, 0, 0.1, 1, 0, 0, 0, 0, 0, 0.450923, - 0, 0.5, 0, 0, 0.20564, 0, 0.5, 0, 0, 0.20564, 0, 0, 0.0313726, 0, 1, 1, 1, 0.363636, - 0.5, 0.686073, 0.45121, 0.00574382, 0.366166, 0.413295, 1, 1, 1, 0, 0, 0, 0, 0.160784, - 0, 0.937255, 0.537255, 0.133333, 0, 0, 0, 0, 0.00392157, 0, 0.333333, 0.027451, 0.0156863, - 1, 0.105882, 1, 0.00220908, 0.000112501, 0.0111262, 0.102384, 0.00140808, 0.123581, - 0.29308, 6.57282e-06, 0.00489498, 2.10209e-05, 0.00140559, 5.907e-06, 0, 0.559322, - 0.559322, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0.794765, 0, - 0.352648, 0.225904, 1, 0.047619, 0.0107276, 0.399461, 0.0304838, 0.292932, 0.00969929, - 0, 0, 0.886904, 0.714693, 0, 0.00223213, 0.000544069, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0.00507403, 0, 0, 0, 0, 0, 0.875, 0, 0, 1, 1, 1, 0, 0.20564, 0, 0.00176048, 0, - 0.000440121, 0, 0, 0, 0.000974026, 0.487168, 0, 0, 0.533333, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 1, 0, 0, 0.723187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0.206882, 0.00483367, 0.792983, 0.00126106, 1, 0.0313726, 0.470588, - 0.254902, 0.188235, 0.188235, 0.388235, 0.164706, 0, 0.870588, 0.843137, 0.635294, - 0.384314, 0.384314, 0.643137, 0, 0, 0, 0, 0, 0, 0, 0, 0.541176, 0, 0.541176, 0, 0, - 0.0532634, 1, 0, 0, 0, 0.015044, 1, 0, 1, 1, 1, 0.47451, 0.329412, 0.964706, 0, 0, - 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.0941176, 0.970588, 0.970588, 0, 0.970588, 0.97561, - 0, 0.0431373, 0.47451, 0.329412, 0.964706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.231373, 0.00392157, 0, 0, 0, 0.054902, 0, 0, - 1, 0, 0, 0.0235294, 0, 1, 0, 0, 0, 0, 0.34902, 0.0352941, 0.925379, 0.623681, 0, - 0.954543, 0, 0, 0.00102756, 0.709804, 0.498039, 0.0901961, 0.631373, 0.847059, 0.270588, - 0.0156863, 0.133333, 0.980392, 1e-12, 1e-12, 1e-12, 1e-12, 0.497159, 0, 0.407487, - 0, 0, 0, 0.00392157, 0.00202156, 0.046875, 0.187159, 0.046875, 0.15625, 0.434232, - 0.15625, 0, 2.95083e-07, 0.20564, 0.20564, 0.97561, 0.913896, 0, 0, 0, 0, 0, 0, 0.00784314, - 0, 0.695525, 1, 0.07205, 0, 0, 0.176471, 0, 0, 0, 1, 1, 0.98, 0.01, 0.01, 0, 0.00690702, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.29078, 0.29078, 1, 0, 0, 0, 0, 0.192157, 0.188235, - 0.0941176, 0, 0.0313726, 0, 0.141176, 0.207843, 0.0901961, 0.00784314, 0.0784314, - 0, 0, 0, 0, 0, 0.203922, 0.0196078, 0.34902, 0.0235294, 0.0980392, 0.164706, 0.133333, - 0.368627, 0, 0.0941176, 0, 1, 0.313726, 0, 0, 0.433582, 0.384508, 0.0532186, 0.0833333, - 0.01609, 0, 1, 0, 0, 0, 0.0666667, 0, 0, 0, 0, 1, 0, 0.564706, 0.501961, 0, 0, 0, - 0, 0, 0.0516447, 0.000173065, 0, 0, 0, 0, 0, 0, 0, 0.996309, 0, 0, 0.00392157, 1, - 0, 0.01, 0, 0, 0, 0, 0, 0.439505, 0.206882, 0.206882, 0.260891, 0, 0.875, 0, 0, 0, - 0, 0, 0.185657, 1, 1, 0, 0, 0, 0.0332647, 0.206106, 0.0688878, 0.239216, 0, 0, 0, - 0, 0.054902, 0, 0.101961, 0.160784, 0.180392, 0, 0.737828, 0, 0, 0.875, 0.0142566, - 0, 0.662745, 1, 0, 0, 0, 0.225806, 0.99992, 0.631373, 0.00392157, 1, 0, 0.143647, - 0.00270085, 1, 0.231482, 0.246735, 0.0428062, 0, 0, 1, 0, 0.186441, 0.0115358, 0, - 0.221762, 0, 0.2, 0, 0.0156863, 0, 0, 0, 0.976471, 0, 0.231373, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0.00392157, 0.00392157, 0.0666667, 0, 0, 0, 0, 0.0117647, 0.580392, 0.98737, - 1, 1, 1, 0, 0, 0, 0.153, 0.847, 0.931373, 0.94697, 0.94697, 0, 0.946294, 0.408118, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0.99992, 0.97561, 0, 0, 0, 0, 0, 0, - 0.274677, 0.153017, 0, 0.642356, 0, 0, 0.1, 0, 0, 0, 0, 0.327944, 0.327944, 0, 0, - 0.815686, 0, 0, 0, 0, 0.206106, 0.439126, 0, 0, 0, 0, 0, 1, 1, 1, 0.00392157, 0.232788, - 0.232465, 0.999899, 0.00309296, 0.0636097, 0.445954, 0.156863, 0, 0, 0, 0, 0, 0, - 0.3796, 0.0784, 0.0651664, 0, 0, 0.254902, 0.266667, 1, 0, 0, 0, 0, 0, 0.596073, - 0.517876, 0.145833, 0.372549, 0, 0.991667, 0.602125, 0.161979, 0, 0, 0, 0, 0.0255146, - 0.947855, 0, 0, 0, 0, 0, 0, 0, 0, 0.847059, 0.679841, 0, 0.156863, 0, 0, 1, 0, 0, - 0, 0, 0.969697, 0, 0, 0.564706, 0, 0, 0, 0, 0, 1, 0.0367282, 0.0395228, 0, 0, 0, - 0, 0, 0.0470588, 0.141176, 0.054902, 0, 0, 0, 0}; - -const ui8 CodedFactors[] = { - 0x24, 0x06, 0x73, 0xB5, 0xC7, 0x55, 0x7F, 0x3A, 0xB4, 0x70, 0xCB, 0xEF, 0xEE, 0xFE, 0xB3, 0x5B, - 0x5A, 0x1A, 0x93, 0x5F, 0x5F, 0x13, 0x00, 0x00, 0x10, 0x00, 0x3D, 0xEF, 0xFF, 0xEE, 0x0F, 0xDC, - 0xF0, 0xAB, 0x3F, 0x37, 0x92, 0x24, 0x5D, 0x5E, 0xDE, 0x1C, 0xF8, 0x12, 0x15, 0x5B, 0x84, 0x51, - 0x82, 0xE6, 0xF6, 0xB8, 0xEA, 0x4F, 0xC7, 0xDD, 0x7D, 0x2E, 0x4D, 0x4A, 0x21, 0xCA, 0xE0, 0xC4, - 0x2E, 0xEA, 0xD3, 0xBD, 0x0F, 0x00, 0x00, 0xE0, 0xDA, 0xCC, 0xCC, 0xEC, 0x9F, 0x61, 0xDF, 0xE6, - 0x01, 0x00, 0x00, 0xCC, 0xA5, 0x49, 0xA9, 0x00, 0x00, 0x00, 0xE6, 0xD2, 0xA4, 0xD4, 0xEA, 0x08, - 0x08, 0xD0, 0xDD, 0xF9, 0xE7, 0xA2, 0x0B, 0x00, 0x00, 0x40, 0xD8, 0x13, 0x7D, 0xFE, 0x13, 0x9C, - 0x9B, 0xA8, 0x36, 0xBC, 0x00, 0x90, 0x43, 0x6F, 0x97, 0x67, 0x9B, 0xD3, 0xEE, 0xFE, 0x84, 0x24, - 0x25, 0x89, 0xC9, 0xBF, 0x3F, 0x58, 0x4C, 0x4C, 0xCA, 0x21, 0x22, 0xBC, 0x39, 0x08, 0x08, 0x08, - 0x40, 0x7E, 0xAA, 0xAA, 0xCA, 0x75, 0x70, 0x70, 0xE9, 0x08, 0x08, 0xE8, 0x9A, 0x8A, 0x8D, 0xED, - 0xA6, 0x8D, 0x31, 0x04, 0x00, 0x96, 0xD0, 0x7D, 0x1D, 0x47, 0xAA, 0x2A, 0xD9, 0x28, 0xAD, 0x6B, - 0xB4, 0x9D, 0x7A, 0xC4, 0xD5, 0xD1, 0x04, 0x8C, 0x7E, 0x56, 0x3A, 0x58, 0x5A, 0x0C, 0x46, 0x6E, - 0x1B, 0x53, 0xC2, 0x0C, 0x14, 0x00, 0xAB, 0x60, 0x05, 0x7B, 0x63, 0x8D, 0x77, 0x70, 0x75, 0xAC, - 0x2F, 0x8D, 0xB1, 0x4D, 0xA0, 0xFB, 0xF2, 0x40, 0xF7, 0xE5, 0x7F, 0xDF, 0xDD, 0xFD, 0xBB, 0x1B, - 0xB8, 0x75, 0x9B, 0x47, 0x8E, 0xB4, 0x0C, 0x9B, 0x3A, 0x73, 0x25, 0x61, 0x18, 0x92, 0xD1, 0xC2, - 0x2F, 0x3C, 0x31, 0x64, 0x96, 0x2A, 0xB9, 0xF9, 0x7C, 0xD9, 0xAF, 0x94, 0xC5, 0xE9, 0x1E, 0x63, - 0x24, 0x0C, 0x03, 0x7F, 0xD8, 0x5B, 0xB3, 0x1D, 0x49, 0x02, 0x00, 0xAB, 0xFD, 0xE9, 0xA0, 0xF3, - 0xBF, 0xC9, 0x40, 0x64, 0x0A, 0xC0, 0xC7, 0x00, 0x00, 0x60, 0x77, 0xCF, 0xA5, 0x49, 0xA9, 0x16, - 0xFD, 0xD7, 0x5C, 0xA7, 0x55, 0x00, 0x36, 0xCF, 0xB9, 0x3D, 0xAE, 0xFA, 0xD3, 0xA1, 0x85, 0x5B, - 0xFE, 0x60, 0x10, 0x11, 0xFF, 0xF7, 0x7D, 0x38, 0x59, 0x24, 0xFF, 0xFF, 0xDF, 0x13, 0x1C, 0x7B, - 0xCA, 0x1C, 0x1E, 0xF3, 0x04, 0xC0, 0x78, 0x07, 0x58, 0x7B, 0xA2, 0x54, 0xAA, 0xE3, 0xEA, 0x08, - 0x08, 0xC0, 0x74, 0x78, 0x78, 0x88, 0x50, 0x50, 0xD8, 0x0A, 0x0C, 0xC4, 0x56, 0x60, 0x20, 0xF6, - 0x1A, 0x1B, 0x33, 0x16, 0x15, 0xA5, 0xB8, 0xED, 0xED, 0x22, 0xF5, 0xF5, 0x09, 0xA1, 0xA2, 0x42, - 0x67, 0x62, 0x62, 0x3A, 0x13, 0x13, 0x0B, 0xA0, 0xA4, 0xF4, 0x0F, 0x06, 0x15, 0x35, 0x18, 0x54, - 0xD4, 0x35, 0x57, 0x45, 0xCB, 0x2F, 0x39, 0xF6, 0xEC, 0xBC, 0xBB, 0x53, 0x5F, 0x5E, 0x9E, 0xB1, - 0xA8, 0xA8, 0x28, 0xDF, 0xDE, 0x3E, 0x00, 0x00, 0x80, 0x5F, 0x75, 0x81, 0x81, 0x51, 0x1D, 0x1E, - 0xA2, 0x3A, 0x3C, 0x8C, 0xEA, 0xF0, 0x10, 0x51, 0x06, 0x67, 0xED, 0x85, 0x85, 0xA1, 0xBE, 0xBC, - 0x3C, 0x63, 0x51, 0x51, 0x51, 0xBE, 0xBD, 0xFD, 0xFF, 0xFD, 0xFE, 0xCE, 0x85, 0x76, 0x36, 0x73, - 0x10, 0x10, 0x10, 0x80, 0xEB, 0x3A, 0x38, 0xD8, 0xBE, 0xD4, 0x05, 0x06, 0xEE, 0x4F, 0x60, 0x59, - 0x59, 0x65, 0x84, 0x84, 0xC0, 0x46, 0xCB, 0x19, 0x7F, 0x4C, 0xFD, 0xC8, 0x9D, 0x8B, 0xB6, 0x31, - 0xAF, 0x86, 0x3A, 0xF0, 0x6D, 0x6D, 0x11, 0xDF, 0xDF, 0x5F, 0x79, 0x71, 0x71, 0x85, 0xD4, 0xD0, - 0x10, 0xB9, 0xB1, 0x11, 0x1A, 0x54, 0x54, 0xE9, 0x08, 0x08, 0x48, 0x39, 0x44, 0x04, 0x84, 0xAF, - 0xAF, 0x96, 0x99, 0x97, 0x71, 0xC5, 0x32, 0xF3, 0x32, 0xAE, 0x58, 0x66, 0x5E, 0xC6, 0x15, 0xCB, - 0xCC, 0xCB, 0xB8, 0x42, 0xD0, 0x45, 0xFF, 0x1C, 0x11, 0x85, 0xBE, 0x39, 0x08, 0x08, 0x08, 0x80, - 0x69, 0xC2, 0x47, 0x00, 0x80, 0x02, 0x00, 0x00, 0x91, 0xD3, 0xF4, 0x47, 0x01, 0x00, 0x80, 0x08, - 0x00, 0x00, 0x42, 0xD4, 0x29, 0x6F, 0x02, 0x00, 0x80, 0xB4, 0xE6, 0x6B, 0x9E, 0x34, 0x5C, 0x9A, - 0x94, 0xE2, 0xD2, 0xA4, 0x14, 0xA2, 0x0C, 0x4E, 0xEC, 0xA2, 0x3E, 0x7F, 0x39, 0x08, 0x08, 0x10, - 0x6E, 0x6F, 0x10, 0xD7, 0x79, 0xC7, 0xC9, 0x09, 0x4D, 0x4B, 0x73, 0x77, 0x84, 0x14, 0xAE, 0x52, - 0xE1, 0x7A, 0x44, 0x2A, 0x5C, 0x8F, 0x34, 0x93, 0xA8, 0xC4, 0x01, 0xF8, 0x3F, 0x3D, 0xC2, 0x29, - 0xE9, 0x11, 0x4E, 0xE9, 0x4F, 0x67, 0x62, 0x22, 0xB6, 0x02, 0x03, 0xA9, 0x2E, 0x30, 0x70, 0x75, - 0x04, 0x04, 0xC8, 0x38, 0x48, 0x08, 0x32, 0x53, 0x53, 0x29, 0x2F, 0x2E, 0xAE, 0x1C, 0x04, 0x04, - 0x50, 0x52, 0x50, 0xD0, 0x4F, 0x77, 0x68, 0x28, 0x99, 0x08, 0x0A, 0x4A, 0x60, 0x59, 0x59, 0xA9, - 0x0B, 0x0C, 0xAC, 0xC7, 0xC8, 0xC8, 0x8C, 0x45, 0x45, 0xA1, 0x1C, 0x22, 0x02, 0x5D, 0x79, 0x79, - 0xAB, 0x2E, 0x30, 0x70, 0xA7, 0x2C, 0x28, 0xE8, 0xB4, 0xF3, 0xEF, 0x26, 0x8F, 0x37, 0xB1, 0xFE, - 0xEE, 0x67, 0xA9, 0xA9, 0xAA, 0xAA, 0x6C, 0x79, 0x1E, 0xEC, 0xD7, 0x46, 0x44, 0xC4, 0xF7, 0xF8, - 0x24, 0x24, 0x00, 0x42, 0x40, 0xF8, 0x5A, 0x96, 0x38, 0x65, 0x91, 0xF1, 0x6A, 0x72, 0xFE, 0x68, - 0xC3, 0xE1, 0x37, 0x07, 0x01, 0x01, 0x01, 0xF0, 0x52, 0xE1, 0x7A, 0xE4, 0xB3, 0xD9, 0x20, 0x9C, - 0xE0, 0xD8, 0x53, 0x04, 0xC7, 0x9E, 0x82, 0x02, 0x27, 0x2B, 0x06, 0x00, 0x00, 0x9F, 0xDE, 0x1C, - 0x3E, 0xEE, 0xD7, 0x48, 0x20, 0x04, 0xD2, 0x35, 0x4C, 0x29, 0x43, 0x45, 0x23, 0x15, 0xEA, 0xE9, - 0x5E, 0xD7, 0xC1, 0xC1, 0xAA, 0x3B, 0x34, 0x34, 0x21, 0x49, 0x49, 0xE8, 0x8A, 0x8B, 0x13, 0x66, - 0x12, 0xE7, 0x31, 0x00, 0x00, 0x90, 0x84, 0x94, 0x69, 0x05, 0xD4, 0xD4, 0xF4, 0x13, 0x36, 0xE7, - 0x0C, 0x09, 0xEB, 0xBF, 0x90, 0x1A, 0x1A, 0xE6, 0x20, 0x20, 0x20, 0x00, 0x9E, 0x33, 0x18, 0x13, - 0xA6, 0x2F, 0x40, 0x0C, 0x00, 0x4E, 0xCF, 0x84, 0x36, 0x6A, 0xA0, 0xF2, 0xA9, 0x63, 0xD5, 0xCB, - 0x9E, 0x64, 0xEA, 0x3E, 0xF2, 0x14, 0xA0, 0x27, 0x29, 0x2B, 0xC6, 0xB2, 0x99, 0x99, 0xA9, 0x74, - 0x04, 0x04, 0x3C, 0x0A, 0xD0, 0xCF, 0x5C, 0x68, 0x67, 0xFB, 0xDF, 0x1C, 0x04, 0x04, 0x04, 0xC0, - 0x1C, 0x04, 0x04, 0x04, 0x40, 0x1B, 0x11, 0x11, 0x5F, 0xEA, 0x02, 0x03, 0xE1, 0x92, 0x94, 0x84, - 0x90, 0x88, 0xD9, 0xDD, 0x4F, 0x04, 0x56, 0x0E, 0xD1, 0x9F, 0x1A, 0x31, 0x3B, 0x37, 0x47, 0xA0, - 0x6C, 0x82, 0x40, 0xD9, 0x24, 0x9A, 0x02, 0x12, 0x62, 0xD3, 0x43, 0xFF, 0xBF, 0x8F, 0x84, 0xF5, - 0x1F, 0x51, 0x06, 0xE7, 0x0F, 0xDD, 0x89, 0x32, 0xFB, 0x60, 0x39, 0x0A, 0x71, 0x71, 0xB4, 0x36, - 0x33, 0x33, 0x3F, 0x8F, 0xD0, 0x4F, 0x79, 0x84, 0x7E, 0xBA, 0xC8, 0x0C, 0x0D, 0x4F, 0xBA, 0x86, - 0x29, 0x82, 0x54, 0x83, 0x7F, 0x77, 0x37, 0x07, 0x01, 0x01, 0x01, 0xA0, 0xFE, 0x97, 0x1B, 0x9D, - 0x16, 0xDC, 0x90, 0x58, 0xFE, 0x9B, 0x42, 0xB3, 0x4A, 0x00, 0x68, 0x73, 0x91, 0x20, 0x2B, 0xA8, - 0xC8, 0x29, 0x0B, 0x0A, 0xF2, 0xD3, 0x5D, 0x4B, 0x58, 0x5D, 0x20, 0x41, 0xD5, 0xBE, 0xAE, 0x70, - 0x88, 0x50, 0x50, 0x20, 0x4A, 0x44, 0xF4, 0x8F, 0xF7, 0x60, 0x22, 0x30, 0x9C, 0x24, 0xFE, 0x54, - 0x55, 0xD0, 0xD7, 0xD7, 0x37, 0x1A, 0xEF, 0x6E, 0xBC, 0x9B, 0x44, 0x39, 0xDD, 0x5D, 0xF2, 0xF2, - 0x7F, 0x20, 0x1A, 0x81, 0x9A, 0xCA, 0xBF, 0xC8, 0x8D, 0x8D, 0xC2, 0x83, 0x82, 0xA7, 0x2C, 0x28, - 0xC8, 0xFE, 0x08, 0xC2, 0x07, 0xC7, 0x27, 0x21, 0xE1, 0xBB, 0x3E, 0xC1, 0x59, 0x68, 0xAA, 0x78, - 0xC8, 0x57, 0x5D, 0x60, 0x20, 0xC6, 0x41, 0x42, 0xE8, 0x3A, 0x38, 0xD8, 0x9B, 0xFF, 0xFF, 0xFF, - 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), Y_ARRAY_SIZE(CodedFactors)); - -void BM_Encode(benchmark::State& state) { - for (const auto _ : state) { - NCodecs::NFloatHuff::Encode(Factors); - } -} - -void BM_Decode(benchmark::State& state) { - for (const auto _ : state) { - NCodecs::NFloatHuff::Decode(CodedFactorsBuf, Y_ARRAY_SIZE(Factors)); - } -} - -BENCHMARK(BM_Encode); -BENCHMARK(BM_Decode); +#include <library/cpp/codecs/float_huffman.h> + +#include <benchmark/benchmark.h> + +#include <util/generic/vector.h> + +const float Factors[] = { + 0.340582, 0.000974026, 0.487168, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0.411765, 0.921569, + 0.00390625, 0.109371, 0, 1, 0, 0, 0, 0, 0.523322, 0, 1, 0, 0, 0, 0, 0.285714, 1, + 0.008253, 1, 0, 0, 0.00993935, 0.450213, 0.000974026, 1, 1, 1, 1, 0, 0, 0.20564, + 0.97561, 0.913896, 1, 1, 0, 1, 0, 0, 0.5, 0, 0, 0, 0.1, 1, 0, 0, 0, 0, 0, 0.450923, + 0, 0.5, 0, 0, 0.20564, 0, 0.5, 0, 0, 0.20564, 0, 0, 0.0313726, 0, 1, 1, 1, 0.363636, + 0.5, 0.686073, 0.45121, 0.00574382, 0.366166, 0.413295, 1, 1, 1, 0, 0, 0, 0, 0.160784, + 0, 0.937255, 0.537255, 0.133333, 0, 0, 0, 0, 0.00392157, 0, 0.333333, 0.027451, 0.0156863, + 1, 0.105882, 1, 0.00220908, 0.000112501, 0.0111262, 0.102384, 0.00140808, 0.123581, + 0.29308, 6.57282e-06, 0.00489498, 2.10209e-05, 0.00140559, 5.907e-06, 0, 0.559322, + 0.559322, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0.794765, 0, + 0.352648, 0.225904, 1, 0.047619, 0.0107276, 0.399461, 0.0304838, 0.292932, 0.00969929, + 0, 0, 0.886904, 0.714693, 0, 0.00223213, 0.000544069, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0.00507403, 0, 0, 0, 0, 0, 0.875, 0, 0, 1, 1, 1, 0, 0.20564, 0, 0.00176048, 0, + 0.000440121, 0, 0, 0, 0.000974026, 0.487168, 0, 0, 0.533333, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 1, 0, 0, 0.723187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0.206882, 0.00483367, 0.792983, 0.00126106, 1, 0.0313726, 0.470588, + 0.254902, 0.188235, 0.188235, 0.388235, 0.164706, 0, 0.870588, 0.843137, 0.635294, + 0.384314, 0.384314, 0.643137, 0, 0, 0, 0, 0, 0, 0, 0, 0.541176, 0, 0.541176, 0, 0, + 0.0532634, 1, 0, 0, 0, 0.015044, 1, 0, 1, 1, 1, 0.47451, 0.329412, 0.964706, 0, 0, + 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.0941176, 0.970588, 0.970588, 0, 0.970588, 0.97561, + 0, 0.0431373, 0.47451, 0.329412, 0.964706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.231373, 0.00392157, 0, 0, 0, 0.054902, 0, 0, + 1, 0, 0, 0.0235294, 0, 1, 0, 0, 0, 0, 0.34902, 0.0352941, 0.925379, 0.623681, 0, + 0.954543, 0, 0, 0.00102756, 0.709804, 0.498039, 0.0901961, 0.631373, 0.847059, 0.270588, + 0.0156863, 0.133333, 0.980392, 1e-12, 1e-12, 1e-12, 1e-12, 0.497159, 0, 0.407487, + 0, 0, 0, 0.00392157, 0.00202156, 0.046875, 0.187159, 0.046875, 0.15625, 0.434232, + 0.15625, 0, 2.95083e-07, 0.20564, 0.20564, 0.97561, 0.913896, 0, 0, 0, 0, 0, 0, 0.00784314, + 0, 0.695525, 1, 0.07205, 0, 0, 0.176471, 0, 0, 0, 1, 1, 0.98, 0.01, 0.01, 0, 0.00690702, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.29078, 0.29078, 1, 0, 0, 0, 0, 0.192157, 0.188235, + 0.0941176, 0, 0.0313726, 0, 0.141176, 0.207843, 0.0901961, 0.00784314, 0.0784314, + 0, 0, 0, 0, 0, 0.203922, 0.0196078, 0.34902, 0.0235294, 0.0980392, 0.164706, 0.133333, + 0.368627, 0, 0.0941176, 0, 1, 0.313726, 0, 0, 0.433582, 0.384508, 0.0532186, 0.0833333, + 0.01609, 0, 1, 0, 0, 0, 0.0666667, 0, 0, 0, 0, 1, 0, 0.564706, 0.501961, 0, 0, 0, + 0, 0, 0.0516447, 0.000173065, 0, 0, 0, 0, 0, 0, 0, 0.996309, 0, 0, 0.00392157, 1, + 0, 0.01, 0, 0, 0, 0, 0, 0.439505, 0.206882, 0.206882, 0.260891, 0, 0.875, 0, 0, 0, + 0, 0, 0.185657, 1, 1, 0, 0, 0, 0.0332647, 0.206106, 0.0688878, 0.239216, 0, 0, 0, + 0, 0.054902, 0, 0.101961, 0.160784, 0.180392, 0, 0.737828, 0, 0, 0.875, 0.0142566, + 0, 0.662745, 1, 0, 0, 0, 0.225806, 0.99992, 0.631373, 0.00392157, 1, 0, 0.143647, + 0.00270085, 1, 0.231482, 0.246735, 0.0428062, 0, 0, 1, 0, 0.186441, 0.0115358, 0, + 0.221762, 0, 0.2, 0, 0.0156863, 0, 0, 0, 0.976471, 0, 0.231373, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0.00392157, 0.00392157, 0.0666667, 0, 0, 0, 0, 0.0117647, 0.580392, 0.98737, + 1, 1, 1, 0, 0, 0, 0.153, 0.847, 0.931373, 0.94697, 0.94697, 0, 0.946294, 0.408118, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0.99992, 0.97561, 0, 0, 0, 0, 0, 0, + 0.274677, 0.153017, 0, 0.642356, 0, 0, 0.1, 0, 0, 0, 0, 0.327944, 0.327944, 0, 0, + 0.815686, 0, 0, 0, 0, 0.206106, 0.439126, 0, 0, 0, 0, 0, 1, 1, 1, 0.00392157, 0.232788, + 0.232465, 0.999899, 0.00309296, 0.0636097, 0.445954, 0.156863, 0, 0, 0, 0, 0, 0, + 0.3796, 0.0784, 0.0651664, 0, 0, 0.254902, 0.266667, 1, 0, 0, 0, 0, 0, 0.596073, + 0.517876, 0.145833, 0.372549, 0, 0.991667, 0.602125, 0.161979, 0, 0, 0, 0, 0.0255146, + 0.947855, 0, 0, 0, 0, 0, 0, 0, 0, 0.847059, 0.679841, 0, 0.156863, 0, 0, 1, 0, 0, + 0, 0, 0.969697, 0, 0, 0.564706, 0, 0, 0, 0, 0, 1, 0.0367282, 0.0395228, 0, 0, 0, + 0, 0, 0.0470588, 0.141176, 0.054902, 0, 0, 0, 0}; + +const ui8 CodedFactors[] = { + 0x24, 0x06, 0x73, 0xB5, 0xC7, 0x55, 0x7F, 0x3A, 0xB4, 0x70, 0xCB, 0xEF, 0xEE, 0xFE, 0xB3, 0x5B, + 0x5A, 0x1A, 0x93, 0x5F, 0x5F, 0x13, 0x00, 0x00, 0x10, 0x00, 0x3D, 0xEF, 0xFF, 0xEE, 0x0F, 0xDC, + 0xF0, 0xAB, 0x3F, 0x37, 0x92, 0x24, 0x5D, 0x5E, 0xDE, 0x1C, 0xF8, 0x12, 0x15, 0x5B, 0x84, 0x51, + 0x82, 0xE6, 0xF6, 0xB8, 0xEA, 0x4F, 0xC7, 0xDD, 0x7D, 0x2E, 0x4D, 0x4A, 0x21, 0xCA, 0xE0, 0xC4, + 0x2E, 0xEA, 0xD3, 0xBD, 0x0F, 0x00, 0x00, 0xE0, 0xDA, 0xCC, 0xCC, 0xEC, 0x9F, 0x61, 0xDF, 0xE6, + 0x01, 0x00, 0x00, 0xCC, 0xA5, 0x49, 0xA9, 0x00, 0x00, 0x00, 0xE6, 0xD2, 0xA4, 0xD4, 0xEA, 0x08, + 0x08, 0xD0, 0xDD, 0xF9, 0xE7, 0xA2, 0x0B, 0x00, 0x00, 0x40, 0xD8, 0x13, 0x7D, 0xFE, 0x13, 0x9C, + 0x9B, 0xA8, 0x36, 0xBC, 0x00, 0x90, 0x43, 0x6F, 0x97, 0x67, 0x9B, 0xD3, 0xEE, 0xFE, 0x84, 0x24, + 0x25, 0x89, 0xC9, 0xBF, 0x3F, 0x58, 0x4C, 0x4C, 0xCA, 0x21, 0x22, 0xBC, 0x39, 0x08, 0x08, 0x08, + 0x40, 0x7E, 0xAA, 0xAA, 0xCA, 0x75, 0x70, 0x70, 0xE9, 0x08, 0x08, 0xE8, 0x9A, 0x8A, 0x8D, 0xED, + 0xA6, 0x8D, 0x31, 0x04, 0x00, 0x96, 0xD0, 0x7D, 0x1D, 0x47, 0xAA, 0x2A, 0xD9, 0x28, 0xAD, 0x6B, + 0xB4, 0x9D, 0x7A, 0xC4, 0xD5, 0xD1, 0x04, 0x8C, 0x7E, 0x56, 0x3A, 0x58, 0x5A, 0x0C, 0x46, 0x6E, + 0x1B, 0x53, 0xC2, 0x0C, 0x14, 0x00, 0xAB, 0x60, 0x05, 0x7B, 0x63, 0x8D, 0x77, 0x70, 0x75, 0xAC, + 0x2F, 0x8D, 0xB1, 0x4D, 0xA0, 0xFB, 0xF2, 0x40, 0xF7, 0xE5, 0x7F, 0xDF, 0xDD, 0xFD, 0xBB, 0x1B, + 0xB8, 0x75, 0x9B, 0x47, 0x8E, 0xB4, 0x0C, 0x9B, 0x3A, 0x73, 0x25, 0x61, 0x18, 0x92, 0xD1, 0xC2, + 0x2F, 0x3C, 0x31, 0x64, 0x96, 0x2A, 0xB9, 0xF9, 0x7C, 0xD9, 0xAF, 0x94, 0xC5, 0xE9, 0x1E, 0x63, + 0x24, 0x0C, 0x03, 0x7F, 0xD8, 0x5B, 0xB3, 0x1D, 0x49, 0x02, 0x00, 0xAB, 0xFD, 0xE9, 0xA0, 0xF3, + 0xBF, 0xC9, 0x40, 0x64, 0x0A, 0xC0, 0xC7, 0x00, 0x00, 0x60, 0x77, 0xCF, 0xA5, 0x49, 0xA9, 0x16, + 0xFD, 0xD7, 0x5C, 0xA7, 0x55, 0x00, 0x36, 0xCF, 0xB9, 0x3D, 0xAE, 0xFA, 0xD3, 0xA1, 0x85, 0x5B, + 0xFE, 0x60, 0x10, 0x11, 0xFF, 0xF7, 0x7D, 0x38, 0x59, 0x24, 0xFF, 0xFF, 0xDF, 0x13, 0x1C, 0x7B, + 0xCA, 0x1C, 0x1E, 0xF3, 0x04, 0xC0, 0x78, 0x07, 0x58, 0x7B, 0xA2, 0x54, 0xAA, 0xE3, 0xEA, 0x08, + 0x08, 0xC0, 0x74, 0x78, 0x78, 0x88, 0x50, 0x50, 0xD8, 0x0A, 0x0C, 0xC4, 0x56, 0x60, 0x20, 0xF6, + 0x1A, 0x1B, 0x33, 0x16, 0x15, 0xA5, 0xB8, 0xED, 0xED, 0x22, 0xF5, 0xF5, 0x09, 0xA1, 0xA2, 0x42, + 0x67, 0x62, 0x62, 0x3A, 0x13, 0x13, 0x0B, 0xA0, 0xA4, 0xF4, 0x0F, 0x06, 0x15, 0x35, 0x18, 0x54, + 0xD4, 0x35, 0x57, 0x45, 0xCB, 0x2F, 0x39, 0xF6, 0xEC, 0xBC, 0xBB, 0x53, 0x5F, 0x5E, 0x9E, 0xB1, + 0xA8, 0xA8, 0x28, 0xDF, 0xDE, 0x3E, 0x00, 0x00, 0x80, 0x5F, 0x75, 0x81, 0x81, 0x51, 0x1D, 0x1E, + 0xA2, 0x3A, 0x3C, 0x8C, 0xEA, 0xF0, 0x10, 0x51, 0x06, 0x67, 0xED, 0x85, 0x85, 0xA1, 0xBE, 0xBC, + 0x3C, 0x63, 0x51, 0x51, 0x51, 0xBE, 0xBD, 0xFD, 0xFF, 0xFD, 0xFE, 0xCE, 0x85, 0x76, 0x36, 0x73, + 0x10, 0x10, 0x10, 0x80, 0xEB, 0x3A, 0x38, 0xD8, 0xBE, 0xD4, 0x05, 0x06, 0xEE, 0x4F, 0x60, 0x59, + 0x59, 0x65, 0x84, 0x84, 0xC0, 0x46, 0xCB, 0x19, 0x7F, 0x4C, 0xFD, 0xC8, 0x9D, 0x8B, 0xB6, 0x31, + 0xAF, 0x86, 0x3A, 0xF0, 0x6D, 0x6D, 0x11, 0xDF, 0xDF, 0x5F, 0x79, 0x71, 0x71, 0x85, 0xD4, 0xD0, + 0x10, 0xB9, 0xB1, 0x11, 0x1A, 0x54, 0x54, 0xE9, 0x08, 0x08, 0x48, 0x39, 0x44, 0x04, 0x84, 0xAF, + 0xAF, 0x96, 0x99, 0x97, 0x71, 0xC5, 0x32, 0xF3, 0x32, 0xAE, 0x58, 0x66, 0x5E, 0xC6, 0x15, 0xCB, + 0xCC, 0xCB, 0xB8, 0x42, 0xD0, 0x45, 0xFF, 0x1C, 0x11, 0x85, 0xBE, 0x39, 0x08, 0x08, 0x08, 0x80, + 0x69, 0xC2, 0x47, 0x00, 0x80, 0x02, 0x00, 0x00, 0x91, 0xD3, 0xF4, 0x47, 0x01, 0x00, 0x80, 0x08, + 0x00, 0x00, 0x42, 0xD4, 0x29, 0x6F, 0x02, 0x00, 0x80, 0xB4, 0xE6, 0x6B, 0x9E, 0x34, 0x5C, 0x9A, + 0x94, 0xE2, 0xD2, 0xA4, 0x14, 0xA2, 0x0C, 0x4E, 0xEC, 0xA2, 0x3E, 0x7F, 0x39, 0x08, 0x08, 0x10, + 0x6E, 0x6F, 0x10, 0xD7, 0x79, 0xC7, 0xC9, 0x09, 0x4D, 0x4B, 0x73, 0x77, 0x84, 0x14, 0xAE, 0x52, + 0xE1, 0x7A, 0x44, 0x2A, 0x5C, 0x8F, 0x34, 0x93, 0xA8, 0xC4, 0x01, 0xF8, 0x3F, 0x3D, 0xC2, 0x29, + 0xE9, 0x11, 0x4E, 0xE9, 0x4F, 0x67, 0x62, 0x22, 0xB6, 0x02, 0x03, 0xA9, 0x2E, 0x30, 0x70, 0x75, + 0x04, 0x04, 0xC8, 0x38, 0x48, 0x08, 0x32, 0x53, 0x53, 0x29, 0x2F, 0x2E, 0xAE, 0x1C, 0x04, 0x04, + 0x50, 0x52, 0x50, 0xD0, 0x4F, 0x77, 0x68, 0x28, 0x99, 0x08, 0x0A, 0x4A, 0x60, 0x59, 0x59, 0xA9, + 0x0B, 0x0C, 0xAC, 0xC7, 0xC8, 0xC8, 0x8C, 0x45, 0x45, 0xA1, 0x1C, 0x22, 0x02, 0x5D, 0x79, 0x79, + 0xAB, 0x2E, 0x30, 0x70, 0xA7, 0x2C, 0x28, 0xE8, 0xB4, 0xF3, 0xEF, 0x26, 0x8F, 0x37, 0xB1, 0xFE, + 0xEE, 0x67, 0xA9, 0xA9, 0xAA, 0xAA, 0x6C, 0x79, 0x1E, 0xEC, 0xD7, 0x46, 0x44, 0xC4, 0xF7, 0xF8, + 0x24, 0x24, 0x00, 0x42, 0x40, 0xF8, 0x5A, 0x96, 0x38, 0x65, 0x91, 0xF1, 0x6A, 0x72, 0xFE, 0x68, + 0xC3, 0xE1, 0x37, 0x07, 0x01, 0x01, 0x01, 0xF0, 0x52, 0xE1, 0x7A, 0xE4, 0xB3, 0xD9, 0x20, 0x9C, + 0xE0, 0xD8, 0x53, 0x04, 0xC7, 0x9E, 0x82, 0x02, 0x27, 0x2B, 0x06, 0x00, 0x00, 0x9F, 0xDE, 0x1C, + 0x3E, 0xEE, 0xD7, 0x48, 0x20, 0x04, 0xD2, 0x35, 0x4C, 0x29, 0x43, 0x45, 0x23, 0x15, 0xEA, 0xE9, + 0x5E, 0xD7, 0xC1, 0xC1, 0xAA, 0x3B, 0x34, 0x34, 0x21, 0x49, 0x49, 0xE8, 0x8A, 0x8B, 0x13, 0x66, + 0x12, 0xE7, 0x31, 0x00, 0x00, 0x90, 0x84, 0x94, 0x69, 0x05, 0xD4, 0xD4, 0xF4, 0x13, 0x36, 0xE7, + 0x0C, 0x09, 0xEB, 0xBF, 0x90, 0x1A, 0x1A, 0xE6, 0x20, 0x20, 0x20, 0x00, 0x9E, 0x33, 0x18, 0x13, + 0xA6, 0x2F, 0x40, 0x0C, 0x00, 0x4E, 0xCF, 0x84, 0x36, 0x6A, 0xA0, 0xF2, 0xA9, 0x63, 0xD5, 0xCB, + 0x9E, 0x64, 0xEA, 0x3E, 0xF2, 0x14, 0xA0, 0x27, 0x29, 0x2B, 0xC6, 0xB2, 0x99, 0x99, 0xA9, 0x74, + 0x04, 0x04, 0x3C, 0x0A, 0xD0, 0xCF, 0x5C, 0x68, 0x67, 0xFB, 0xDF, 0x1C, 0x04, 0x04, 0x04, 0xC0, + 0x1C, 0x04, 0x04, 0x04, 0x40, 0x1B, 0x11, 0x11, 0x5F, 0xEA, 0x02, 0x03, 0xE1, 0x92, 0x94, 0x84, + 0x90, 0x88, 0xD9, 0xDD, 0x4F, 0x04, 0x56, 0x0E, 0xD1, 0x9F, 0x1A, 0x31, 0x3B, 0x37, 0x47, 0xA0, + 0x6C, 0x82, 0x40, 0xD9, 0x24, 0x9A, 0x02, 0x12, 0x62, 0xD3, 0x43, 0xFF, 0xBF, 0x8F, 0x84, 0xF5, + 0x1F, 0x51, 0x06, 0xE7, 0x0F, 0xDD, 0x89, 0x32, 0xFB, 0x60, 0x39, 0x0A, 0x71, 0x71, 0xB4, 0x36, + 0x33, 0x33, 0x3F, 0x8F, 0xD0, 0x4F, 0x79, 0x84, 0x7E, 0xBA, 0xC8, 0x0C, 0x0D, 0x4F, 0xBA, 0x86, + 0x29, 0x82, 0x54, 0x83, 0x7F, 0x77, 0x37, 0x07, 0x01, 0x01, 0x01, 0xA0, 0xFE, 0x97, 0x1B, 0x9D, + 0x16, 0xDC, 0x90, 0x58, 0xFE, 0x9B, 0x42, 0xB3, 0x4A, 0x00, 0x68, 0x73, 0x91, 0x20, 0x2B, 0xA8, + 0xC8, 0x29, 0x0B, 0x0A, 0xF2, 0xD3, 0x5D, 0x4B, 0x58, 0x5D, 0x20, 0x41, 0xD5, 0xBE, 0xAE, 0x70, + 0x88, 0x50, 0x50, 0x20, 0x4A, 0x44, 0xF4, 0x8F, 0xF7, 0x60, 0x22, 0x30, 0x9C, 0x24, 0xFE, 0x54, + 0x55, 0xD0, 0xD7, 0xD7, 0x37, 0x1A, 0xEF, 0x6E, 0xBC, 0x9B, 0x44, 0x39, 0xDD, 0x5D, 0xF2, 0xF2, + 0x7F, 0x20, 0x1A, 0x81, 0x9A, 0xCA, 0xBF, 0xC8, 0x8D, 0x8D, 0xC2, 0x83, 0x82, 0xA7, 0x2C, 0x28, + 0xC8, 0xFE, 0x08, 0xC2, 0x07, 0xC7, 0x27, 0x21, 0xE1, 0xBB, 0x3E, 0xC1, 0x59, 0x68, 0xAA, 0x78, + 0xC8, 0x57, 0x5D, 0x60, 0x20, 0xC6, 0x41, 0x42, 0xE8, 0x3A, 0x38, 0xD8, 0x9B, 0xFF, 0xFF, 0xFF, + 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), Y_ARRAY_SIZE(CodedFactors)); + +void BM_Encode(benchmark::State& state) { + for (const auto _ : state) { + NCodecs::NFloatHuff::Encode(Factors); + } +} + +void BM_Decode(benchmark::State& state) { + for (const auto _ : state) { + NCodecs::NFloatHuff::Decode(CodedFactorsBuf, Y_ARRAY_SIZE(Factors)); + } +} + +BENCHMARK(BM_Encode); +BENCHMARK(BM_Decode); diff --git a/library/cpp/codecs/float_huffman_bench/ya.make b/library/cpp/codecs/float_huffman_bench/ya.make index c8fae6873a..8892fff60e 100644 --- a/library/cpp/codecs/float_huffman_bench/ya.make +++ b/library/cpp/codecs/float_huffman_bench/ya.make @@ -1,13 +1,13 @@ -OWNER(eeight) - -G_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( - library/cpp/codecs -) - -END() +OWNER(eeight) + +G_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/codecs +) + +END() diff --git a/library/cpp/codecs/huffman_codec.h b/library/cpp/codecs/huffman_codec.h index 559545b90d..8b81e665e1 100644 --- a/library/cpp/codecs/huffman_codec.h +++ b/library/cpp/codecs/huffman_codec.h @@ -3,7 +3,7 @@ #include "codecs.h" #include <util/generic/ptr.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { // for types greater than char, pipeline with TFreqCodec. diff --git a/library/cpp/codecs/pfor_codec.h b/library/cpp/codecs/pfor_codec.h index d7d4bb8bf4..26b8fa0c33 100644 --- a/library/cpp/codecs/pfor_codec.h +++ b/library/cpp/codecs/pfor_codec.h @@ -7,7 +7,7 @@ #include <library/cpp/bit_io/bitinput.h> #include <library/cpp/bit_io/bitoutput.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { template <typename T, bool WithDelta = false> diff --git a/library/cpp/codecs/solar_codec.h b/library/cpp/codecs/solar_codec.h index 7158ae7926..d1ded5c208 100644 --- a/library/cpp/codecs/solar_codec.h +++ b/library/cpp/codecs/solar_codec.h @@ -4,7 +4,7 @@ #include <library/cpp/containers/comptrie/comptrie_trie.h> #include <library/cpp/codecs/greedy_dict/gd_builder.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/escape.h> namespace NCodecs { diff --git a/library/cpp/codecs/ut/float_huffman_ut.cpp b/library/cpp/codecs/ut/float_huffman_ut.cpp index 3156fb1f46..91bf9b42b3 100644 --- a/library/cpp/codecs/ut/float_huffman_ut.cpp +++ b/library/cpp/codecs/ut/float_huffman_ut.cpp @@ -167,32 +167,32 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { } Y_UNIT_TEST(TestCompress) { - const auto codedFactors = fh::Encode(Factors); + const auto codedFactors = fh::Encode(Factors); UNIT_ASSERT_VALUES_EQUAL(codedFactors.size(), CodedSize); for (size_t i = 0; i < Min(codedFactors.size(), CodedSize); ++i) - UNIT_ASSERT_VALUES_EQUAL((ui8)codedFactors[i], CodedFactors[i]); + UNIT_ASSERT_VALUES_EQUAL((ui8)codedFactors[i], CodedFactors[i]); //PrintCompressed(codedFactors); } Y_UNIT_TEST(TestSimpleDecompress) { - TVector<float> factors = fh::Decode(CodedFactorsBuf); + TVector<float> factors = fh::Decode(CodedFactorsBuf); UNIT_ASSERT_VALUES_EQUAL(factors.size(), FactorCount); for (size_t i = 0; i < Min(factors.size(), FactorCount); ++i) UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[i]); //PrintDecompressed(factors); } - Y_UNIT_TEST(TestDecompressInParts) { + Y_UNIT_TEST(TestDecompressInParts) { float factors[FactorCount]; FillWithGarbage(factors, FactorCount); - fh::TDecoder decoder(CodedFactorsBuf); + fh::TDecoder decoder(CodedFactorsBuf); const size_t firstPack = 100; // unpack first pack - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); // unpack all the rest - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, FactorCount - firstPack}), FactorCount - firstPack); + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, FactorCount - firstPack}), FactorCount - firstPack); - for (size_t i = 0; i < FactorCount; ++i) + for (size_t i = 0; i < FactorCount; ++i) UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[i]); //PrintDecompressed(factors); } @@ -200,18 +200,18 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { Y_UNIT_TEST(TestSkip) { float factors[FactorCount]; FillWithGarbage(factors, FactorCount); - fh::TDecoder decoder(CodedFactorsBuf); + fh::TDecoder decoder(CodedFactorsBuf); const size_t firstPack = 100; // unpack first pack - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); // skip some factors const size_t skipCount = 60; - UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); + UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); // unpack all, except some factors in the end - const auto toDecode = FactorCount - firstPack - skipCount; - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, toDecode}), toDecode); - UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); - for (size_t i = 0; i < FactorCount - skipCount; ++i) { + const auto toDecode = FactorCount - firstPack - skipCount; + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, toDecode}), toDecode); + UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); + for (size_t i = 0; i < FactorCount - skipCount; ++i) { size_t correctedI = i < firstPack ? i : i + skipCount / 2; UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[correctedI]); } @@ -227,11 +227,11 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { "d4ZfQZrETm3B+OxxB8bbnTPM5+qtbQ92mJ3fHPGj+iH5+8tzcnJuamry1tWUw" "MBD693f07+9+DQQEkIGAgIgPetzN5yEbAGxWpbCNxXK/0JGTKRz2KkIoR7aM"; UNIT_ASSERT_EXCEPTION( - fh::Decode(Base64Decode(brokenBase64Encoded)), + fh::Decode(Base64Decode(brokenBase64Encoded)), yexception); } - - Y_UNIT_TEST(TestDecompressEmpty) { - UNIT_ASSERT_EXCEPTION(fh::Decode({}), yexception); - } + + Y_UNIT_TEST(TestDecompressEmpty) { + UNIT_ASSERT_EXCEPTION(fh::Decode({}), yexception); + } }; diff --git a/library/cpp/codecs/ya.make b/library/cpp/codecs/ya.make index 7e76fb0c9a..174db32828 100644 --- a/library/cpp/codecs/ya.make +++ b/library/cpp/codecs/ya.make @@ -11,7 +11,7 @@ SRCS( codecs_registry.cpp comptable_codec.cpp delta_codec.cpp - float_huffman.cpp + float_huffman.cpp huffman_codec.cpp pfor_codec.cpp solar_codec.cpp diff --git a/library/cpp/containers/bitseq/bititerator.h b/library/cpp/containers/bitseq/bititerator.h index 52dadd3798..2977abdd54 100644 --- a/library/cpp/containers/bitseq/bititerator.h +++ b/library/cpp/containers/bitseq/bititerator.h @@ -2,7 +2,7 @@ #include "traits.h" -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> template <typename T> class TBitIterator { diff --git a/library/cpp/containers/bitseq/bitvector.h b/library/cpp/containers/bitseq/bitvector.h index 3f8fd81ee5..a620f83cb2 100644 --- a/library/cpp/containers/bitseq/bitvector.h +++ b/library/cpp/containers/bitseq/bitvector.h @@ -2,7 +2,7 @@ #include "traits.h" -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <util/generic/vector.h> #include <util/ysaveload.h> diff --git a/library/cpp/containers/bitseq/readonly_bitvector.h b/library/cpp/containers/bitseq/readonly_bitvector.h index 8612739c3f..02f04f9439 100644 --- a/library/cpp/containers/bitseq/readonly_bitvector.h +++ b/library/cpp/containers/bitseq/readonly_bitvector.h @@ -19,12 +19,12 @@ public: { } - explicit TReadonlyBitVector(const TBitVector<T>& vector) - : Size_(vector.Size_) - , Data_(vector.Data_.data()) - { - } - + explicit TReadonlyBitVector(const TBitVector<T>& vector) + : Size_(vector.Size_) + , Data_(vector.Data_.data()) + { + } + bool Test(ui64 pos) const { return TTraits::Test(Data_, pos, Size_); } diff --git a/library/cpp/containers/bitseq/ya.make b/library/cpp/containers/bitseq/ya.make index 7090956c55..ec000d827e 100644 --- a/library/cpp/containers/bitseq/ya.make +++ b/library/cpp/containers/bitseq/ya.make @@ -4,7 +4,7 @@ OWNER(g:util) PEERDIR( util/draft - library/cpp/pop_count + library/cpp/pop_count ) SRCS( diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index cfa35f5ba2..02e998607c 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -85,7 +85,7 @@ public: bool Get(const char* key, T* value) const { ui64 trieValue; if (Trie.Find(key, strlen(key), &trieValue)) { - *value = ReadUnaligned<T>(&trieValue); + *value = ReadUnaligned<T>(&trieValue); return true; } else { return false; @@ -95,7 +95,7 @@ public: T Get(const char* key, T def = T()) const { ui64 trieValue; if (Trie.Find(key, strlen(key), &trieValue)) { - return ReadUnaligned<T>(&trieValue); + return ReadUnaligned<T>(&trieValue); } else { return def; } @@ -126,9 +126,9 @@ public: } void Add(const char* key, const T& value) { - ui64 intValue = 0; - memcpy(&intValue, &value, sizeof(T)); - Builder.Add(key, strlen(key), intValue); + ui64 intValue = 0; + memcpy(&intValue, &value, sizeof(T)); + Builder.Add(key, strlen(key), intValue); #ifndef NDEBUG /* if (!IsSorted) { @@ -140,15 +140,15 @@ public: } void Add(const TString& s, const T& value) { - ui64 intValue = 0; - memcpy(&intValue, &value, sizeof(T)); - Builder.Add(s.data(), s.size(), intValue); + ui64 intValue = 0; + memcpy(&intValue, &value, sizeof(T)); + Builder.Add(s.data(), s.size(), intValue); } bool Get(const char* key, T* value) const { ui64 trieValue; if (Builder.Find(key, strlen(key), &trieValue)) { - *value = ReadUnaligned<T>(&trieValue); + *value = ReadUnaligned<T>(&trieValue); return true; } else { return false; @@ -158,7 +158,7 @@ public: T Get(const char* key, T def = (T)0) const { ui64 trieValue; if (Builder.Find(key, strlen(key), &trieValue)) { - return ReadUnaligned<T>(&trieValue); + return ReadUnaligned<T>(&trieValue); } else { return def; } diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 74bee09b5d..278e36ed0c 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -18,7 +18,7 @@ #include <util/random/fast.h> #include <util/string/hex.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include "comptrie.h" #include "set.h" diff --git a/library/cpp/containers/sorted_vector/sorted_vector.h b/library/cpp/containers/sorted_vector/sorted_vector.h index 123539af9e..93c4bdfb44 100644 --- a/library/cpp/containers/sorted_vector/sorted_vector.h +++ b/library/cpp/containers/sorted_vector/sorted_vector.h @@ -4,7 +4,7 @@ #include <util/generic/hash.h> #include <util/generic/vector.h> #include <util/generic/algorithm.h> -#include <util/generic/mapfindptr.h> +#include <util/generic/mapfindptr.h> #include <util/ysaveload.h> #include <utility> @@ -328,10 +328,10 @@ namespace NSorted { // and then inserts a new one, the existing reference can be broken (due to reallocation). // Please keep this in mind when using this structure. template <typename TKeyType, typename TValueType, class TPredicate = TLess<TKeyType>, class A = std::allocator<TValueType>> - class TSimpleMap: - public TSortedVector<std::pair<TKeyType, TValueType>, TKeyType, TSelect1st, TPredicate, A>, - public TMapOps<TSimpleMap<TKeyType, TValueType, TPredicate, A>> - { + class TSimpleMap: + public TSortedVector<std::pair<TKeyType, TValueType>, TKeyType, TSelect1st, TPredicate, A>, + public TMapOps<TSimpleMap<TKeyType, TValueType, TPredicate, A>> + { private: typedef TSortedVector<std::pair<TKeyType, TValueType>, TKeyType, TSelect1st, TPredicate, A> TBase; @@ -379,22 +379,22 @@ namespace NSorted { Y_FORCE_INLINE TValueType& operator[](const K& key) { return Get(key); } - + template<class K> const TValueType& at(const K& key) const { - const auto i = TBase::Find(key); - if (i == TBase::end()) { - throw std::out_of_range("NSorted::TSimpleMap: missing key"); - } - - return i->second; - } - + const auto i = TBase::Find(key); + if (i == TBase::end()) { + throw std::out_of_range("NSorted::TSimpleMap: missing key"); + } + + return i->second; + } + template<class K> TValueType& at(const K& key) { - return const_cast<TValueType&>( - const_cast<const TSimpleMap<TKeyType, TValueType, TPredicate, A>*>(this)->at(key)); - } + return const_cast<TValueType&>( + const_cast<const TSimpleMap<TKeyType, TValueType, TPredicate, A>*>(this)->at(key)); + } }; // The simplified set (a.k.a TFlatSet, flat_set), which is implemented by the sorted-vector. diff --git a/library/cpp/containers/stack_vector/stack_vec.h b/library/cpp/containers/stack_vector/stack_vec.h index fcc5d9a2a5..4fc3f26d89 100644 --- a/library/cpp/containers/stack_vector/stack_vec.h +++ b/library/cpp/containers/stack_vector/stack_vec.h @@ -3,23 +3,23 @@ #include <util/generic/vector.h> #include <util/ysaveload.h> -#include <type_traits> - +#include <type_traits> + // A vector preallocated on the stack. // After exceeding the preconfigured stack space falls back to the heap. // Publicly inherits TVector, but disallows swap (and hence shrink_to_fit, also operator= is reimplemented via copying). // // Inspired by: http://qt-project.org/doc/qt-4.8/qvarlengtharray.html#details -template <typename T, size_t CountOnStack = 256, bool UseFallbackAlloc = true, class Alloc = std::allocator<T>> +template <typename T, size_t CountOnStack = 256, bool UseFallbackAlloc = true, class Alloc = std::allocator<T>> class TStackVec; template <typename T, class Alloc = std::allocator<T>> -using TSmallVec = TStackVec<T, 16, true, Alloc>; - -template <typename T, size_t CountOnStack = 256> -using TStackOnlyVec = TStackVec<T, CountOnStack, false>; +using TSmallVec = TStackVec<T, 16, true, Alloc>; +template <typename T, size_t CountOnStack = 256> +using TStackOnlyVec = TStackVec<T, CountOnStack, false>; + namespace NPrivate { template <class Alloc, class StackAlloc, typename T, typename U> struct TRebind { @@ -31,10 +31,10 @@ namespace NPrivate { typedef StackAlloc other; }; - template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc = std::allocator<T>> + template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc = std::allocator<T>> class TStackBasedAllocator: public Alloc { public: - typedef TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, Alloc> TSelf; + typedef TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, Alloc> TSelf; using typename Alloc::difference_type; using typename Alloc::size_type; @@ -58,14 +58,14 @@ namespace NPrivate { {} T* allocate(size_type n) { - if (!IsStorageUsed && CountOnStack >= n) { - IsStorageUsed = true; + if (!IsStorageUsed && CountOnStack >= n) { + IsStorageUsed = true; return reinterpret_cast<T*>(&StackBasedStorage[0]); } else { - if constexpr (!UseFallbackAlloc) { - Y_FAIL( - "Stack storage overflow. Capacity: %d, requested: %d", (int)CountOnStack, int(n)); - } + if constexpr (!UseFallbackAlloc) { + Y_FAIL( + "Stack storage overflow. Capacity: %d, requested: %d", (int)CountOnStack, int(n)); + } return FallbackAllocator().allocate(n); } } @@ -73,15 +73,15 @@ namespace NPrivate { void deallocate(T* p, size_type n) { if (p >= reinterpret_cast<T*>(&StackBasedStorage[0]) && p < reinterpret_cast<T*>(&StackBasedStorage[CountOnStack])) { - Y_VERIFY(IsStorageUsed); - IsStorageUsed = false; + Y_VERIFY(IsStorageUsed); + IsStorageUsed = false; } else { FallbackAllocator().deallocate(p, n); } } private: - std::aligned_storage_t<sizeof(T), alignof(T)> StackBasedStorage[CountOnStack]; + std::aligned_storage_t<sizeof(T), alignof(T)> StackBasedStorage[CountOnStack]; bool IsStorageUsed = false; private: @@ -91,8 +91,8 @@ namespace NPrivate { }; } -template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc> -class TStackVec: public TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>> { +template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc> +class TStackVec: public TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>> { private: using TBase = TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>>; using TAllocator = typename TBase::allocator_type; @@ -131,13 +131,13 @@ public: } TStackVec(const TStackVec& src) - : TStackVec(src.begin(), src.end()) + : TStackVec(src.begin(), src.end()) { } template <class A> - TStackVec(const TVector<T, A>& src) - : TStackVec(src.begin(), src.end()) + TStackVec(const TVector<T, A>& src) + : TStackVec(src.begin(), src.end()) { } @@ -150,20 +150,20 @@ public: TStackVec(TIter first, TIter last, const TAllocator& alloc = TAllocator()) : TBase(alloc) { - // NB(eeight) Since we want to call 'reserve' here, we cannot just delegate to TVector ctor. - // The best way to insert values afterwards is to call TVector::insert. However there is a caveat. - // In order to call this ctor of TVector, T needs to be just move-constructible. Insert however - // requires T to be move-assignable. - TBase::reserve(CountOnStack); - if constexpr (std::is_move_assignable_v<T>) { - // Fast path - TBase::insert(TBase::end(), first, last); - } else { - // Slow path. - for (; first != last; ++first) { - TBase::push_back(*first); - } - } + // NB(eeight) Since we want to call 'reserve' here, we cannot just delegate to TVector ctor. + // The best way to insert values afterwards is to call TVector::insert. However there is a caveat. + // In order to call this ctor of TVector, T needs to be just move-constructible. Insert however + // requires T to be move-assignable. + TBase::reserve(CountOnStack); + if constexpr (std::is_move_assignable_v<T>) { + // Fast path + TBase::insert(TBase::end(), first, last); + } else { + // Slow path. + for (; first != last; ++first) { + TBase::push_back(*first); + } + } } public: @@ -188,25 +188,25 @@ public: }; template <typename T, size_t CountOnStack, class Alloc> -class TSerializer<TStackVec<T, CountOnStack, true, Alloc>>: public TVectorSerializer<TStackVec<T, CountOnStack, true, Alloc>> { -}; - -template <typename T, size_t CountOnStack, class Alloc> -class TSerializer<TStackVec<T, CountOnStack, false, Alloc>> { -public: - static void Save(IOutputStream* rh, const TStackVec<T, CountOnStack, false, Alloc>& v) { - if constexpr (CountOnStack < 256) { - ::Save(rh, (ui8)v.size()); - } else { - ::Save(rh, v.size()); - } - ::SaveArray(rh, v.data(), v.size()); - } - - static void Load(IInputStream* rh, TStackVec<T, CountOnStack, false, Alloc>& v) { - std::conditional_t<CountOnStack < 256, ui8, size_t> size; - ::Load(rh, size); - v.resize(size); - ::LoadPodArray(rh, v.data(), v.size()); - } +class TSerializer<TStackVec<T, CountOnStack, true, Alloc>>: public TVectorSerializer<TStackVec<T, CountOnStack, true, Alloc>> { }; + +template <typename T, size_t CountOnStack, class Alloc> +class TSerializer<TStackVec<T, CountOnStack, false, Alloc>> { +public: + static void Save(IOutputStream* rh, const TStackVec<T, CountOnStack, false, Alloc>& v) { + if constexpr (CountOnStack < 256) { + ::Save(rh, (ui8)v.size()); + } else { + ::Save(rh, v.size()); + } + ::SaveArray(rh, v.data(), v.size()); + } + + static void Load(IInputStream* rh, TStackVec<T, CountOnStack, false, Alloc>& v) { + std::conditional_t<CountOnStack < 256, ui8, size_t> size; + ::Load(rh, size); + v.resize(size); + ::LoadPodArray(rh, v.data(), v.size()); + } +}; diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index 19f9677781..89821dd4a8 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -2,13 +2,13 @@ #include <library/cpp/testing/unittest/registar.h> -namespace { - struct TNotCopyAssignable { - const int Value; - }; - - static_assert(std::is_copy_constructible_v<TNotCopyAssignable>); - static_assert(!std::is_copy_assignable_v<TNotCopyAssignable>); +namespace { + struct TNotCopyAssignable { + const int Value; + }; + + static_assert(std::is_copy_constructible_v<TNotCopyAssignable>); + static_assert(!std::is_copy_assignable_v<TNotCopyAssignable>); template <class T, size_t JunkPayloadSize> struct TThickAlloc: public std::allocator<T> { @@ -41,8 +41,8 @@ namespace { return TBase::allocate(n); } }; -} - +} + Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { Y_UNIT_TEST(TestCreateEmpty) { TStackVec<int> ints; @@ -98,34 +98,34 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { UNIT_ASSERT_EQUAL(ints3[i], (int)i); } } - - Y_UNIT_TEST(TestCappedSize) { - TStackVec<int, 8, false> ints; - ints.push_back(1); - ints.push_back(2); - - auto intsCopy = ints; - UNIT_ASSERT_VALUES_EQUAL(intsCopy.capacity(), 8); - - for (int i = 2; i != 8; ++i) { - intsCopy.push_back(i); - } - // Just verify that the program did not crash. - } - - Y_UNIT_TEST(TestCappedSizeWithNotCopyAssignable) { - TStackVec<TNotCopyAssignable, 8, false> values; - values.push_back({1}); - values.push_back({2}); - - auto valuesCopy = values; - UNIT_ASSERT_VALUES_EQUAL(valuesCopy.capacity(), 8); - - for (int i = 2; i != 8; ++i) { - valuesCopy.push_back({i}); - } - // Just verify that the program did not crash. - } + + Y_UNIT_TEST(TestCappedSize) { + TStackVec<int, 8, false> ints; + ints.push_back(1); + ints.push_back(2); + + auto intsCopy = ints; + UNIT_ASSERT_VALUES_EQUAL(intsCopy.capacity(), 8); + + for (int i = 2; i != 8; ++i) { + intsCopy.push_back(i); + } + // Just verify that the program did not crash. + } + + Y_UNIT_TEST(TestCappedSizeWithNotCopyAssignable) { + TStackVec<TNotCopyAssignable, 8, false> values; + values.push_back({1}); + values.push_back({2}); + + auto valuesCopy = values; + UNIT_ASSERT_VALUES_EQUAL(valuesCopy.capacity(), 8); + + for (int i = 2; i != 8; ++i) { + valuesCopy.push_back({i}); + } + // Just verify that the program did not crash. + } Y_UNIT_TEST(TestCustomAllocSize) { constexpr size_t n = 16384; diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index 283a96ecf1..786725a7ed 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -131,7 +131,7 @@ static void ContHelperFunc(TCont* cont, void* arg) { template <typename T, void (T::*M)(TCont*)> static void ContHelperMemberFunc(TCont* c, void* arg) { - ((reinterpret_cast<T*>(arg))->*M)(c); + ((reinterpret_cast<T*>(arg))->*M)(c); } class IUserEvent diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index c7efa105ee..1d4d1da950 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -50,7 +50,7 @@ namespace NPrivate { template <class V> inline void Pointer(const V* v) { - if (v && !Visited.contains((size_t)v)) { + if (v && !Visited.contains((size_t)v)) { Visited.insert((size_t)v); *this << DumpRaw("(") << DumpRaw(TypeName(v).data()) << DumpRaw(")") << Hex((size_t)v) << DumpRaw(" -> ") << *v; Visited.erase((size_t)v); diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index b0e4511299..4433e2dda0 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -2,13 +2,13 @@ #include <util/generic/yexception.h> #include <util/system/defaults.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <util/system/filemap.h> TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) { Map_ = map; i64 len = Map_->Length(); - if (Hi32(len) != 0 && sizeof(size_t) <= sizeof(ui32)) + if (Hi32(len) != 0 && sizeof(size_t) <= sizeof(ui32)) ythrow yexception() << "File '" << dbgName << "' mapping error: " << len << " too large"; Map_->Map(0, static_cast<size_t>(len)); diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index 6c753f68a9..22b591c356 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -39,7 +39,7 @@ RECURSE( iterators_heap parse_utils parse_utils/ut - small_array + small_array solartrie solartrie/indexed_region/ut solartrie/test diff --git a/library/cpp/dns/cache.cpp b/library/cpp/dns/cache.cpp index 05c14e82fc..d98d37cf8f 100644 --- a/library/cpp/dns/cache.cpp +++ b/library/cpp/dns/cache.cpp @@ -38,7 +38,7 @@ namespace { struct THashResolveInfo { inline size_t operator()(const TResolveInfo& ri) const { - return ComputeHash(ri.Host) ^ ri.Port; + return ComputeHash(ri.Host) ^ ri.Port; } }; diff --git a/library/cpp/dns/thread.cpp b/library/cpp/dns/thread.cpp index 8b27d2d527..efec63831c 100644 --- a/library/cpp/dns/thread.cpp +++ b/library/cpp/dns/thread.cpp @@ -3,7 +3,7 @@ #include "magic.h" #include <util/network/socket.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <util/thread/lfqueue.h> #include <util/system/event.h> #include <util/generic/vector.h> @@ -12,7 +12,7 @@ using namespace NDns; namespace { - class TThreadedResolver: public IThreadFactory::IThreadAble, public TNonCopyable { + class TThreadedResolver: public IThreadFactory::IThreadAble, public TNonCopyable { struct TResolveRequest { inline TResolveRequest(const TString& host, ui16 port) : Host(host) @@ -61,7 +61,7 @@ namespace { inline TThreadedResolver() : E_(TSystemEvent::rAuto) { - T_.push_back(SystemThreadFactory()->Run(this)); + T_.push_back(SystemThreadFactory()->Run(this)); } inline ~TThreadedResolver() override { @@ -121,7 +121,7 @@ namespace { private: TLockFreeQueue<TResolveRequest*> Q_; TSystemEvent E_; - typedef TAutoPtr<IThreadFactory::IThread> IThreadRef; + typedef TAutoPtr<IThreadFactory::IThread> IThreadRef; TVector<IThreadRef> T_; }; } diff --git a/library/cpp/getopt/small/completion_generator.cpp b/library/cpp/getopt/small/completion_generator.cpp index ac41988217..7bacd5fffa 100644 --- a/library/cpp/getopt/small/completion_generator.cpp +++ b/library/cpp/getopt/small/completion_generator.cpp @@ -48,7 +48,7 @@ namespace NLastGetopt { L << "local prefix_orig=\"$PREFIX\""; L << "local suffix_orig=\"$SUFFIX\""; L; - std::visit(TOverloaded{ + std::visit(TOverloaded{ [&out, &manager](const TModChooser* modChooser) { GenerateModesCompletion(out, *modChooser, manager); }, @@ -390,7 +390,7 @@ namespace NLastGetopt { L << "local need_space=\"1\""; L << "local IFS=$' \\t\\n'"; L; - std::visit(TOverloaded{ + std::visit(TOverloaded{ [&out, &manager](const TModChooser* modChooser) { GenerateModesCompletion(out, *modChooser, manager, 1); }, diff --git a/library/cpp/getopt/small/completion_generator.h b/library/cpp/getopt/small/completion_generator.h index 4241bb7d6c..8c21d6fa36 100644 --- a/library/cpp/getopt/small/completion_generator.h +++ b/library/cpp/getopt/small/completion_generator.h @@ -19,7 +19,7 @@ namespace NLastGetopt { virtual void Generate(TStringBuf command, IOutputStream& stream) = 0; protected: - std::variant<const TModChooser*, const TOpts*> Options_; + std::variant<const TModChooser*, const TOpts*> Options_; }; class TZshCompletionGenerator: public TCompletionGenerator { diff --git a/library/cpp/getopt/small/last_getopt_handlers.h b/library/cpp/getopt/small/last_getopt_handlers.h index d35456ef34..961298127f 100644 --- a/library/cpp/getopt/small/last_getopt_handlers.h +++ b/library/cpp/getopt/small/last_getopt_handlers.h @@ -3,7 +3,7 @@ #include "last_getopt_support.h" #include <util/string/split.h> -#include <util/system/compiler.h> +#include <util/system/compiler.h> namespace NLastGetopt { /// Handler to split option value by delimiter into a target container. diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h index a8dd5adca9..707b7cc279 100644 --- a/library/cpp/getopt/small/last_getopt_opt.h +++ b/library/cpp/getopt/small/last_getopt_opt.h @@ -8,7 +8,7 @@ #include <util/generic/string.h> #include <util/generic/maybe.h> #include <util/generic/vector.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <stdarg.h> diff --git a/library/cpp/getopt/small/last_getopt_opts.cpp b/library/cpp/getopt/small/last_getopt_opts.cpp index 03c432849f..698cc8bee7 100644 --- a/library/cpp/getopt/small/last_getopt_opts.cpp +++ b/library/cpp/getopt/small/last_getopt_opts.cpp @@ -260,7 +260,7 @@ namespace NLastGetopt { } TStringBuf TOpts::GetFreeArgTitle(size_t pos) const { - if (FreeArgSpecs_.contains(pos)) { + if (FreeArgSpecs_.contains(pos)) { return FreeArgSpecs_.at(pos).GetTitle(DefaultFreeArgTitle_); } return DefaultFreeArgTitle_; diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index 7668b12a03..477723a7d8 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -341,7 +341,7 @@ namespace NLastGetopt { const TOpt* opt = (*it).Get(); if (nullptr == opt) continue; - if (OptsSeen_.contains(opt)) + if (OptsSeen_.contains(opt)) continue; if (opt->IsRequired()) { diff --git a/library/cpp/grpc/client/grpc_client_low.h b/library/cpp/grpc/client/grpc_client_low.h index ab0a0627be..c0a5a2d86e 100644 --- a/library/cpp/grpc/client/grpc_client_low.h +++ b/library/cpp/grpc/client/grpc_client_low.h @@ -2,7 +2,7 @@ #include "grpc_common.h" -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <grpc++/grpc++.h> #include <grpc++/support/async_stream.h> #include <grpc++/support/async_unary_call.h> @@ -1371,7 +1371,7 @@ public: void AddWorkerThreadForTest(); private: - using IThreadRef = std::unique_ptr<IThreadFactory::IThread>; + using IThreadRef = std::unique_ptr<IThreadFactory::IThread>; using CompletionQueueRef = std::unique_ptr<grpc::CompletionQueue>; void Init(size_t numWorkerThread); diff --git a/library/cpp/grpc/server/grpc_server.h b/library/cpp/grpc/server/grpc_server.h index d6814a90a0..39b32260b9 100644 --- a/library/cpp/grpc/server/grpc_server.h +++ b/library/cpp/grpc/server/grpc_server.h @@ -13,7 +13,7 @@ #include <util/generic/hash_set.h> #include <util/system/types.h> #include <util/system/mutex.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <grpc++/grpc++.h> @@ -342,7 +342,7 @@ public: TString GetHost() const; private: - using IThreadRef = TAutoPtr<IThreadFactory::IThread>; + using IThreadRef = TAutoPtr<IThreadFactory::IThread>; const TServerOptions Options_; std::unique_ptr<grpc::Server> Server_; diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.h b/library/cpp/histogram/adaptive/adaptive_histogram.h index fa8f48433f..6e1f00ff4c 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.h +++ b/library/cpp/histogram/adaptive/adaptive_histogram.h @@ -54,40 +54,40 @@ namespace NKiwiAggr { TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = nullptr); TAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = CalcWeightQuality); - ~TAdaptiveHistogram() override { + ~TAdaptiveHistogram() override { } TQualityFunction GetQualityFunc(); void Clear() override; - void Add(double value, double weight) override; - void Add(const THistoRec& histoRec) override; + void Add(double value, double weight) override; + void Add(const THistoRec& histoRec) override; - void Merge(const THistogram& histo, double multiplier) final; - void Merge(const TVector<THistogram>& histogramsToMerge) final; - void Merge(TVector<IHistogramPtr> histogramsToMerge) final; + void Merge(const THistogram& histo, double multiplier) final; + void Merge(const TVector<THistogram>& histogramsToMerge) final; + void Merge(TVector<IHistogramPtr> histogramsToMerge) final; - void Multiply(double factor) final; + void Multiply(double factor) final; - void FromProto(const THistogram& histo) final; - void ToProto(THistogram& histo) final; + void FromProto(const THistogram& histo) final; + void ToProto(THistogram& histo) final; - void SetId(ui64 id) final; - ui64 GetId() final; - bool Empty() final; - double GetMinValue() final; - double GetMaxValue() final; - double GetSum() final; - double GetSumInRange(double leftBound, double rightBound) final; - double GetSumAboveBound(double bound) final; - double GetSumBelowBound(double bound) final; - double CalcUpperBound(double sum) final; - double CalcLowerBound(double sum) final; - double CalcUpperBoundSafe(double sum) final; - double CalcLowerBoundSafe(double sum) final; + void SetId(ui64 id) final; + ui64 GetId() final; + bool Empty() final; + double GetMinValue() final; + double GetMaxValue() final; + double GetSum() final; + double GetSumInRange(double leftBound, double rightBound) final; + double GetSumAboveBound(double bound) final; + double GetSumBelowBound(double bound) final; + double CalcUpperBound(double sum) final; + double CalcLowerBound(double sum) final; + double CalcUpperBoundSafe(double sum) final; + double CalcLowerBoundSafe(double sum) final; - void PrecomputePartialSums() final; + void PrecomputePartialSums() final; private: void FromIHistogram(IHistogram* histo); @@ -120,7 +120,7 @@ namespace NKiwiAggr { { } - ~TDefinedAdaptiveHistogram() override { + ~TDefinedAdaptiveHistogram() override { } }; diff --git a/library/cpp/histogram/hdr/histogram.cpp b/library/cpp/histogram/hdr/histogram.cpp index a213d5d8fd..82e7ed07e1 100644 --- a/library/cpp/histogram/hdr/histogram.cpp +++ b/library/cpp/histogram/hdr/histogram.cpp @@ -1,6 +1,6 @@ #include "histogram.h" -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/yexception.h> #include <contrib/libs/hdr_histogram/src/hdr_histogram.h> @@ -24,7 +24,7 @@ namespace NHdr { IAllocator::TBlock mem = allocator->Allocate(histogramSize); struct hdr_histogram* histogram = - reinterpret_cast<struct hdr_histogram*>(mem.Data); + reinterpret_cast<struct hdr_histogram*>(mem.Data); // memset will ensure that all of the function pointers are null memset(histogram, 0, histogramSize); diff --git a/library/cpp/http/io/compression.h b/library/cpp/http/io/compression.h index f16c4a18eb..3287c6f34c 100644 --- a/library/cpp/http/io/compression.h +++ b/library/cpp/http/io/compression.h @@ -2,7 +2,7 @@ #include "stream.h" -#include <util/generic/deque.h> +#include <util/generic/deque.h> #include <util/generic/hash.h> class TCompressionCodecFactory { @@ -44,7 +44,7 @@ private: TEncoderConstructor Encoder; }; - TDeque<TString> Strings_; + TDeque<TString> Strings_; THashMap<TStringBuf, TCodec> Codecs_; TVector<TStringBuf> BestCodecs_; }; diff --git a/library/cpp/http/misc/parsed_request.cpp b/library/cpp/http/misc/parsed_request.cpp index e332a24e91..7f322ce0ea 100644 --- a/library/cpp/http/misc/parsed_request.cpp +++ b/library/cpp/http/misc/parsed_request.cpp @@ -2,7 +2,7 @@ #include <util/string/strip.h> #include <util/generic/yexception.h> -#include <util/string/cast.h> +#include <util/string/cast.h> static inline TStringBuf StripLeft(const TStringBuf& s) noexcept { const char* b = s.begin(); diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 128583bdd7..48498e6b8b 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -17,7 +17,7 @@ #include <util/system/mutex.h> #include <util/system/pipe.h> #include <util/system/thread.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <cerrno> #include <cstring> diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index b292d38f27..517fcf9eb2 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -3,14 +3,14 @@ #include "conn.h" #include "options.h" -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <library/cpp/http/io/stream.h> #include <util/memory/blob.h> #include <util/generic/ptr.h> #include <util/generic/vector.h> #include <util/system/atomic.h> -class IThreadFactory; +class IThreadFactory; class TClientRequest; class TClientConnection; @@ -62,7 +62,7 @@ public: }; typedef THttpServerOptions TOptions; - typedef TSimpleSharedPtr<IThreadPool> TMtpQueueRef; + typedef TSimpleSharedPtr<IThreadPool> TMtpQueueRef; THttpServer(ICallBack* cb, const TOptions& options = TOptions(), IThreadFactory* pool = nullptr); THttpServer(ICallBack* cb, TMtpQueueRef mainWorkers, TMtpQueueRef failWorkers, const TOptions& options = TOptions()); diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index cc62bb988e..1199007496 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { bool Expect100Continue = false; }; - class TFailingMtpQueue: public TSimpleThreadPool { + class TFailingMtpQueue: public TSimpleThreadPool { private: bool FailOnAdd_ = false; @@ -297,16 +297,16 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { void SetFailOnAdd(bool fail = true) { FailOnAdd_ = fail; } - [[nodiscard]] bool Add(IObjectInQueue* pObj) override { + [[nodiscard]] bool Add(IObjectInQueue* pObj) override { if (FailOnAdd_) { return false; } - return TSimpleThreadPool::Add(pObj); + return TSimpleThreadPool::Add(pObj); } TFailingMtpQueue() = default; - TFailingMtpQueue(IThreadFactory* pool) - : TSimpleThreadPool(pool) + TFailingMtpQueue(IThreadFactory* pool) + : TSimpleThreadPool(pool) { } }; @@ -434,9 +434,9 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { THttpServer::TOptions options(port); options.EnableKeepAlive(true); options.EnableCompression(true); - using TFailingServerMtpQueue = TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; - THttpServer::TMtpQueueRef mainWorkers = new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); - THttpServer::TMtpQueueRef failWorkers = new TThreadPool(SystemThreadFactory()); + using TFailingServerMtpQueue = TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; + THttpServer::TMtpQueueRef mainWorkers = new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); + THttpServer::TMtpQueueRef failWorkers = new TThreadPool(SystemThreadFactory()); THttpServer server(&serverImpl, mainWorkers, failWorkers, options); UNIT_ASSERT(server.Start()); @@ -703,7 +703,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { for (bool keepAlive : trueFalse) { server.ResetCounters(); - TVector<TAutoPtr<IThreadFactory::IThread>> threads; + TVector<TAutoPtr<IThreadFactory::IThread>> threads; server.Busy(3); server.BusyThread(); @@ -715,7 +715,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { r->KeepAliveConnection = keepAlive; r->Execute(); }; - threads.push_back(SystemThreadFactory()->Run(func)); + threads.push_back(SystemThreadFactory()->Run(func)); } server.FreeThread(); // all threads get connection & go to processing diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp index 52d64c91ce..b94a2f4482 100644 --- a/library/cpp/http/server/response.cpp +++ b/library/cpp/http/server/response.cpp @@ -2,7 +2,7 @@ #include <util/stream/output.h> #include <util/stream/mem.h> -#include <util/string/cast.h> +#include <util/string/cast.h> THttpResponse& THttpResponse::AddMultipleHeaders(const THttpHeaders& headers) { for (THttpHeaders::TConstIterator i = headers.Begin(); i != headers.End(); ++i) { diff --git a/library/cpp/iterator/mapped.h b/library/cpp/iterator/mapped.h index 6c5e763184..97c730b66d 100644 --- a/library/cpp/iterator/mapped.h +++ b/library/cpp/iterator/mapped.h @@ -6,7 +6,7 @@ #include <iterator> -namespace NIteratorPrivate { +namespace NIteratorPrivate { template <class TIterator> constexpr bool HasRandomAccess() { return std::is_same_v<typename std::iterator_traits<TIterator>::iterator_category, @@ -26,7 +26,7 @@ public: using value_type = TValue; using reference = TValue&; using pointer = std::remove_reference_t<TValue>*; - using iterator_category = std::conditional_t<NIteratorPrivate::HasRandomAccess<TIterator>(), + using iterator_category = std::conditional_t<NIteratorPrivate::HasRandomAccess<TIterator>(), std::random_access_iterator_tag, std::input_iterator_tag>; TMappedIterator(TIterator it, TMapper mapper) @@ -122,10 +122,10 @@ public: return {std::end(*Container.Ptr()), {*Mapper.Ptr()}}; } - bool empty() const { - return std::begin(*Container.Ptr()) == std::end(*Container.Ptr()); - } - + bool empty() const { + return std::begin(*Container.Ptr()) == std::end(*Container.Ptr()); + } + protected: mutable TContainerStorage Container; mutable TMapperStorage Mapper; @@ -154,7 +154,7 @@ public: using TBase::begin; using TBase::end; - using TBase::empty; + using TBase::empty; size_type size() const { return std::end(*this->Container.Ptr()) - std::begin(*this->Container.Ptr()); @@ -185,7 +185,7 @@ auto MakeMappedRange(TIterator begin, TIterator end, TMapper mapper) { template <class TContainer, class TMapper> auto MakeMappedRange(TContainer&& container, TMapper&& mapper) { - if constexpr (NIteratorPrivate::HasRandomAccess<decltype(std::begin(container))>()) { + if constexpr (NIteratorPrivate::HasRandomAccess<decltype(std::begin(container))>()) { return TRandomAccessMappedRange<TContainer, TMapper>(std::forward<TContainer>(container), std::forward<TMapper>(mapper)); } else { return TInputMappedRange<TContainer, TMapper>(std::forward<TContainer>(container), std::forward<TMapper>(mapper)); diff --git a/library/cpp/json/easy_parse/json_easy_parser.cpp b/library/cpp/json/easy_parse/json_easy_parser.cpp index 3c781f544b..0d4e1c52ff 100644 --- a/library/cpp/json/easy_parse/json_easy_parser.cpp +++ b/library/cpp/json/easy_parse/json_easy_parser.cpp @@ -1,6 +1,6 @@ #include "json_easy_parser.h" #include <library/cpp/json/json_reader.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/split.h> #include <util/string/strip.h> @@ -13,7 +13,7 @@ namespace NJson { TVector<const char*> parts; Split(path.begin(), '/', &parts); for (size_t n = 0; n < parts.size(); ++n) { - TString part = Strip(parts[n]); + TString part = Strip(parts[n]); if (!part.empty()) { if (part[0] != '[') { res->push_back(TPathElem(NImpl::MAP)); diff --git a/library/cpp/json/json_reader.cpp b/library/cpp/json/json_reader.cpp index 072c8deafe..9cabc3efe0 100644 --- a/library/cpp/json/json_reader.cpp +++ b/library/cpp/json/json_reader.cpp @@ -423,12 +423,12 @@ namespace NJson { } TJsonValue ReadJsonFastTree(TStringBuf in, bool notClosedBracketIsError) { - TJsonValue value; - // There is no way to report an error apart from throwing an exception when we return result by value. + TJsonValue value; + // There is no way to report an error apart from throwing an exception when we return result by value. ReadJsonFastTree(in, &value, /* throwOnError = */ true, notClosedBracketIsError); - return value; - } - + return value; + } + namespace { struct TJsonCallbacksWrapper { TJsonCallbacks& Impl; diff --git a/library/cpp/json/ut/json_reader_fast_ut.cpp b/library/cpp/json/ut/json_reader_fast_ut.cpp index 60dffc91c7..647804b998 100644 --- a/library/cpp/json/ut/json_reader_fast_ut.cpp +++ b/library/cpp/json/ut/json_reader_fast_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/printf.h> namespace NJson { diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index c61e8d1dc4..6010b4e4d1 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -921,7 +921,7 @@ namespace NJson { } bool TJsonValue::Has(const TStringBuf& key) const noexcept { - return Type == JSON_MAP && Value.Map->contains(key); + return Type == JSON_MAP && Value.Map->contains(key); } bool TJsonValue::Has(size_t key) const noexcept { diff --git a/library/cpp/logger/filter_creator.cpp b/library/cpp/logger/filter_creator.cpp index fd5618087b..bb7d98d083 100644 --- a/library/cpp/logger/filter_creator.cpp +++ b/library/cpp/logger/filter_creator.cpp @@ -7,7 +7,7 @@ TFilteredBackendCreator::TFilteredBackendCreator(THolder<ILogBackendCreator> sla {} THolder<TLogBackend> TFilteredBackendCreator::DoCreateLogBackend() const { - return MakeHolder<TFilteredLogBackend>(Slave->CreateLogBackend(), Priority); + return MakeHolder<TFilteredLogBackend>(Slave->CreateLogBackend(), Priority); } bool TFilteredBackendCreator::Init(const IInitContext& ctx) { diff --git a/library/cpp/logger/global/common.cpp b/library/cpp/logger/global/common.cpp index 4fb05c19b4..41138d8105 100644 --- a/library/cpp/logger/global/common.cpp +++ b/library/cpp/logger/global/common.cpp @@ -1,26 +1,26 @@ #include "common.h" -#include <util/generic/yexception.h> - +#include <util/generic/yexception.h> + namespace NLoggingImpl { TString GetLocalTimeSSimple() { struct tm tm; return Strftime("%b%d_%H%M%S", Now().LocalTime(&tm)); } - - TString PrepareToOpenLog(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) { - Y_ENSURE(logLevel >= 0 && logLevel <= (int)LOG_MAX_PRIORITY, "Incorrect log level"); - - if (rotation && TFsPath(logType).Exists()) { - TString newPath = Sprintf("%s_%s_%" PRIu64, logType.data(), NLoggingImpl::GetLocalTimeSSimple().data(), static_cast<ui64>(Now().MicroSeconds())); - TFsPath(logType).RenameTo(newPath); - } + + TString PrepareToOpenLog(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) { + Y_ENSURE(logLevel >= 0 && logLevel <= (int)LOG_MAX_PRIORITY, "Incorrect log level"); + + if (rotation && TFsPath(logType).Exists()) { + TString newPath = Sprintf("%s_%s_%" PRIu64, logType.data(), NLoggingImpl::GetLocalTimeSSimple().data(), static_cast<ui64>(Now().MicroSeconds())); + TFsPath(logType).RenameTo(newPath); + } if (startAsDaemon && (logType == "console"sv || logType == "cout"sv || logType == "cerr"sv)) { - logType = "null"; - } - - return logType; - } + logType = "null"; + } + + return logType; + } } bool TLogFilter::CheckLoggingContext(TLog& log, const TLogRecordContext& context) { diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 7dcf650dec..56fa92f0b6 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -68,12 +68,12 @@ namespace NLoggingImpl { TString GetLocalTimeSSimple(); - // Returns correct log type to use + // Returns correct log type to use TString PrepareToOpenLog(TString logType, int logLevel, bool rotation, bool startAsDaemon); template <class TLoggerType> void InitLogImpl(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) { - TLoggerOperator<TLoggerType>::Set(new TLoggerType(PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), (ELogPriority)logLevel)); + TLoggerOperator<TLoggerType>::Set(new TLoggerType(PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), (ELogPriority)logLevel)); } } diff --git a/library/cpp/logger/global/global.cpp b/library/cpp/logger/global/global.cpp index 9fbd10f666..32303ef60e 100644 --- a/library/cpp/logger/global/global.cpp +++ b/library/cpp/logger/global/global.cpp @@ -8,14 +8,14 @@ static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter TLoggerFormatterOperator::Set(formatter.Release()); } -void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) { - DoInitGlobalLog( - MakeHolder<TGlobalLog>( - CreateLogBackend( - NLoggingImpl::PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), - (ELogPriority)logLevel, - threaded)), - std::move(formatter)); +void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) { + DoInitGlobalLog( + MakeHolder<TGlobalLog>( + CreateLogBackend( + NLoggingImpl::PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), + (ELogPriority)logLevel, + threaded)), + std::move(formatter)); } void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter) { diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index cbe71b16ea..b1193ed403 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -6,7 +6,7 @@ // ATTENTION! MUST CALL DoInitGlobalLog BEFORE USAGE bool GlobalLogInitialized(); -void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false); +void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false); void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {}); inline void InitGlobalLog2Null() { diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index e1d70cc3d2..0c17874294 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -19,7 +19,7 @@ THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priorit } THolder<TLogBackend> CreateFilteredOwningThreadedLogBackend(const TString& fname, ELogPriority priority, size_t queueLen) { - return MakeHolder<TFilteredLogBackend>(CreateOwningThreadedLogBackend(fname, queueLen), priority); + return MakeHolder<TFilteredLogBackend>(CreateOwningThreadedLogBackend(fname, queueLen), priority); } THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString& fname, size_t queueLen) { diff --git a/library/cpp/logger/thread.cpp b/library/cpp/logger/thread.cpp index 0ccf9e374b..124b36adde 100644 --- a/library/cpp/logger/thread.cpp +++ b/library/cpp/logger/thread.cpp @@ -1,7 +1,7 @@ #include "thread.h" #include "record.h" -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/system/event.h> #include <util/memory/addstorage.h> #include <util/generic/ptr.h> diff --git a/library/cpp/lwtrace/custom_action.cpp b/library/cpp/lwtrace/custom_action.cpp index a379b34ec0..e8a2741c6a 100644 --- a/library/cpp/lwtrace/custom_action.cpp +++ b/library/cpp/lwtrace/custom_action.cpp @@ -14,7 +14,7 @@ TCustomActionExecutor* TCustomActionFactory::Create(TProbe* probe, const TCustom } void TCustomActionFactory::Register(const TString& name, const TCustomActionFactory::TCallback& callback) { - if (Callbacks.contains(name)) { + if (Callbacks.contains(name)) { ythrow yexception() << "duplicate custom action '" << name << "'"; } Callbacks[name] = callback; diff --git a/library/cpp/lwtrace/mon/analytics/json_output.h b/library/cpp/lwtrace/mon/analytics/json_output.h index 189f9802d3..1d867c3d05 100644 --- a/library/cpp/lwtrace/mon/analytics/json_output.h +++ b/library/cpp/lwtrace/mon/analytics/json_output.h @@ -19,13 +19,13 @@ inline TString ToJsonFlot(const TTable& in, const TString& xno, const TVector<TS TString xn; THashSet<TString> xopts; ParseNameAndOpts(xno, xn, xopts); - bool xstack = xopts.contains("stack"); + bool xstack = xopts.contains("stack"); for (const TString& yno : ynos) { TString yn; THashSet<TString> yopts; ParseNameAndOpts(yno, yn, yopts); - bool ystackOpt = yopts.contains("stack"); + bool ystackOpt = yopts.contains("stack"); ss << (first? "": ",\n ") << "{ " << opts << (opts? ", ": "") << "\"label\": \"" << yn << "\", \"data\": [ "; bool first2 = true; diff --git a/library/cpp/lwtrace/mon/analytics/transform.h b/library/cpp/lwtrace/mon/analytics/transform.h index f7dc9adb5b..32a175a63e 100644 --- a/library/cpp/lwtrace/mon/analytics/transform.h +++ b/library/cpp/lwtrace/mon/analytics/transform.h @@ -98,12 +98,12 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl if (i >= 0 && i < buckets) { out[i][yn + "_cnt"] = out[i].GetOrDefault(yn + "_cnt") + 1; out[i][yn + "_sum"] = out[i].GetOrDefault(yn + "_sum") + y; - if (out[i].contains(yn + "_min")) { + if (out[i].contains(yn + "_min")) { out[i][yn + "_min"] = Min(y, out[i].GetOrDefault(yn + "_min")); } else { out[i][yn + "_min"] = y; } - if (out[i].contains(yn + "_max")) { + if (out[i].contains(yn + "_max")) { out[i][yn + "_max"] = Max(y, out[i].GetOrDefault(yn + "_max")); } else { out[i][yn + "_max"] = y; diff --git a/library/cpp/lwtrace/mon/analytics/util.h b/library/cpp/lwtrace/mon/analytics/util.h index e07d06cc43..777694781c 100644 --- a/library/cpp/lwtrace/mon/analytics/util.h +++ b/library/cpp/lwtrace/mon/analytics/util.h @@ -56,7 +56,7 @@ inline double MinValue(const TString& nameAndOpts, const TTable& table) TString name; THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); - bool stack = opts.contains("stack"); + bool stack = opts.contains("stack"); if (stack) { return 0.0; } else { @@ -73,7 +73,7 @@ inline double MaxValue(const TString& nameAndOpts, const TTable& table) TString name; THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); - bool stack = opts.contains("stack"); + bool stack = opts.contains("stack"); if (stack) { return AccumulateIfExist(name, table, 0.0, [] (double x, double y) { return x + y; diff --git a/library/cpp/lwtrace/mon/mon_lwtrace.cpp b/library/cpp/lwtrace/mon/mon_lwtrace.cpp index a61ee9ce22..c2c9853813 100644 --- a/library/cpp/lwtrace/mon/mon_lwtrace.cpp +++ b/library/cpp/lwtrace/mon/mon_lwtrace.cpp @@ -819,9 +819,9 @@ private: #if defined(_linux_) TStringStream linuxName; linuxName << TStringBuf(GetExecPath()).RNextTok('/') << "." << name; - TThread::SetCurrentThreadName(linuxName.Str().data()); + TThread::SetCurrentThreadName(linuxName.Str().data()); #else - TThread::SetCurrentThreadName(name.data()); + TThread::SetCurrentThreadName(name.data()); #endif static_cast<TTraceCleaner*>(_this)->Exec(); return nullptr; @@ -1394,7 +1394,7 @@ void RequireMultipleSelection(TStringStream& ss, const TCgiParameters& e, const for (const TString& subvalue : Subvalues(e, param)) { DropdownSelector<Erasable, true>(ss, e, param, subvalue, "", variants); } - if (selectedValues.contains("")) { + if (selectedValues.contains("")) { throw TPageGen<TSelectorsContainer>(ss.Str()); } else { BtnHref<Button|ExtraSmall>(ss, "+", MakeUrlAddSub(e, param, "")); @@ -1435,7 +1435,7 @@ void OptionalMultipleSelection(TStringStream& ss, const TCgiParameters& e, const for (const TString& subvalue : Subvalues(e, param)) { DropdownSelector<Erasable, true>(ss, e, param, subvalue, "", variants); } - if (selectedValues.contains("")) { + if (selectedValues.contains("")) { throw TPageGen<TSelectorsContainer>(ss.Str()); } else { BtnHref<Button|ExtraSmall>(ss, selectedValues.empty()? text: "+", MakeUrlAddSub(e, param, "")); @@ -2116,7 +2116,7 @@ public: bool IsFiltered(const TString& paramName) const { - return FilteredParamValues.contains(paramName); + return FilteredParamValues.contains(paramName); } private: @@ -3550,7 +3550,7 @@ private: const NLWTrace::TSignature* sgn = &probe->Event.Signature; for (size_t pi = 0; pi < sgn->ParamCount; pi++) { TString param = sgn->ParamNames[pi]; - if (TrackIds.contains(param) || IsFiltered(param)) { + if (TrackIds.contains(param) || IsFiltered(param)) { continue; } os << "<li><a href=\"" diff --git a/library/cpp/lwtrace/signature.h b/library/cpp/lwtrace/signature.h index 868bd9bcf2..bf545ee070 100644 --- a/library/cpp/lwtrace/signature.h +++ b/library/cpp/lwtrace/signature.h @@ -4,7 +4,7 @@ #include <library/cpp/lwtrace/protos/lwtrace.pb.h> -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/string.h> #include <util/generic/typetraits.h> #include <util/string/builder.h> @@ -80,12 +80,12 @@ namespace NLWTrace { template <class T> const T& Get() const { - return *reinterpret_cast<const T*>(Data); + return *reinterpret_cast<const T*>(Data); } template <class T> T& Get() { - return *reinterpret_cast<T*>(Data); + return *reinterpret_cast<T*>(Data); } template <class T> diff --git a/library/cpp/lwtrace/trace.cpp b/library/cpp/lwtrace/trace.cpp index 3c974c85a0..f3de2098cd 100644 --- a/library/cpp/lwtrace/trace.cpp +++ b/library/cpp/lwtrace/trace.cpp @@ -46,7 +46,7 @@ namespace NLWTrace { void TProbeRegistry::AddProbeNoLock(const TBoxPtr& box) { TProbe* probe = box->GetProbe(); - if (Probes.contains(probe)) { + if (Probes.contains(probe)) { return; // silently skip probe double registration } TIds::key_type key(probe->Event.GetProvider(), probe->Event.Name); @@ -1005,7 +1005,7 @@ namespace NLWTrace { bool TManager::HasTrace(const TString& id) const { TGuard<TMutex> g(Mtx); - return Traces.contains(id); + return Traces.contains(id); } const TSession* TManager::GetTrace(const TString& id) const { diff --git a/library/cpp/messagebus/actor/executor.cpp b/library/cpp/messagebus/actor/executor.cpp index 7a2227a458..5b38e87495 100644 --- a/library/cpp/messagebus/actor/executor.cpp +++ b/library/cpp/messagebus/actor/executor.cpp @@ -322,7 +322,7 @@ void TExecutor::RunWorker() { Y_VERIFY(!ThreadCurrentExecutor, "state check"); ThreadCurrentExecutor = this; - SetCurrentThreadName("wrkr"); + SetCurrentThreadName("wrkr"); for (;;) { TAutoPtr<IWorkItem> wi = DequeueWork(); diff --git a/library/cpp/messagebus/actor/thread_extra.cpp b/library/cpp/messagebus/actor/thread_extra.cpp index 048480f255..ad59d7113a 100644 --- a/library/cpp/messagebus/actor/thread_extra.cpp +++ b/library/cpp/messagebus/actor/thread_extra.cpp @@ -19,12 +19,12 @@ namespace { #endif } -void SetCurrentThreadName(const char* name) { +void SetCurrentThreadName(const char* name) { #ifdef _linux_ TStringStream linuxName; linuxName << GetExecName() << "." << name; - TThread::SetCurrentThreadName(linuxName.Str().data()); + TThread::SetCurrentThreadName(linuxName.Str().data()); #else - TThread::SetCurrentThreadName(name); + TThread::SetCurrentThreadName(name); #endif } diff --git a/library/cpp/messagebus/actor/thread_extra.h b/library/cpp/messagebus/actor/thread_extra.h index b5aa151618..5e8e271beb 100644 --- a/library/cpp/messagebus/actor/thread_extra.h +++ b/library/cpp/messagebus/actor/thread_extra.h @@ -24,7 +24,7 @@ namespace NTSAN { } -void SetCurrentThreadName(const char* name); +void SetCurrentThreadName(const char* name); namespace NThreadExtra { namespace NPrivate { diff --git a/library/cpp/messagebus/config/netaddr.h b/library/cpp/messagebus/config/netaddr.h index b79c0cc355..892f841abc 100644 --- a/library/cpp/messagebus/config/netaddr.h +++ b/library/cpp/messagebus/config/netaddr.h @@ -1,7 +1,7 @@ #pragma once #include <util/digest/numeric.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/ptr.h> #include <util/generic/strbuf.h> #include <util/generic/vector.h> @@ -73,13 +73,13 @@ namespace NBus { switch (s->sa_family) { case AF_INET: - return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa->sin_addr), sizeof(sa->sin_addr))), IntHashImpl(sa->sin_port)); + return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa->sin_addr), sizeof(sa->sin_addr))), IntHashImpl(sa->sin_port)); case AF_INET6: - return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa6->sin6_addr), sizeof(sa6->sin6_addr))), IntHashImpl(sa6->sin6_port)); + return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa6->sin6_addr), sizeof(sa6->sin6_addr))), IntHashImpl(sa6->sin6_port)); } - return ComputeHash(TStringBuf(reinterpret_cast<const char*>(s), a.Len())); + return ComputeHash(TStringBuf(reinterpret_cast<const char*>(s), a.Len())); } }; diff --git a/library/cpp/messagebus/event_loop.cpp b/library/cpp/messagebus/event_loop.cpp index f685135bed..71f6f45d96 100644 --- a/library/cpp/messagebus/event_loop.cpp +++ b/library/cpp/messagebus/event_loop.cpp @@ -281,7 +281,7 @@ void TEventLoop::TImpl::Run() { Y_VERIFY(res, "Invalid mbus event loop state"); if (!!Name) { - SetCurrentThreadName(Name); + SetCurrentThreadName(Name); } while (AtomicGet(StopSignal) == 0) { diff --git a/library/cpp/messagebus/socket_addr.h b/library/cpp/messagebus/socket_addr.h index 959eafe689..7b28c8ce82 100644 --- a/library/cpp/messagebus/socket_addr.h +++ b/library/cpp/messagebus/socket_addr.h @@ -2,7 +2,7 @@ #include "hash.h" -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/utility.h> #include <util/network/address.h> #include <util/network/init.h> @@ -101,7 +101,7 @@ namespace NBus { template <> struct THash<NBus::NPrivate::TBusIpAddr> { inline size_t operator()(const NBus::NPrivate::TBusIpAddr& a) const { - return ComputeHash(TStringBuf((const char*)&a, sizeof(a))); + return ComputeHash(TStringBuf((const char*)&a, sizeof(a))); } }; diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp index 8489319278..c3a084d5b6 100644 --- a/library/cpp/messagebus/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/test/perftest/perftest.cpp @@ -260,7 +260,7 @@ public: /// dispatch of requests is done here void Work() { - SetCurrentThreadName("FastClient::Work"); + SetCurrentThreadName("FastClient::Work"); while (!TheExit) { TBusClientConnection* connection; @@ -524,7 +524,7 @@ void stopsignal(int /*sig*/) { // -c <node:port,node:port> - start client void TTestStats::PeriodicallyPrint() { - SetCurrentThreadName("print-stats"); + SetCurrentThreadName("print-stats"); for (;;) { StopEvent.WaitT(TDuration::Seconds(1)); diff --git a/library/cpp/monlib/counters/counters_ut.cpp b/library/cpp/monlib/counters/counters_ut.cpp index 2845efb97b..8e3cfb936f 100644 --- a/library/cpp/monlib/counters/counters_ut.cpp +++ b/library/cpp/monlib/counters/counters_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/set.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> using namespace NMonitoring; @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TDeprecatedCountersTest) { } }; - TThreadPool q; + TThreadPool q; q.Start(THREADS_COUNT); for (ui32 i = 0; i < THREADS_COUNT; i++) { q.SafeAddFunc(adder); diff --git a/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp b/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp index 53683cb39c..8d9d468232 100644 --- a/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp +++ b/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp @@ -97,7 +97,7 @@ void AssertSimpleMessage(const NProto::TMultiSamplesList& samples, TString pathP UNIT_ASSERT_EQUAL(s.PointsSize(), 1); const auto labelVal = s.GetLabels(0).GetValue(); - UNIT_ASSERT(expectedValues.contains(labelVal)); + UNIT_ASSERT(expectedValues.contains(labelVal)); if (labelVal == pathPrefix + "Foo") { UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::GAUGE); diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index 929efbf816..bbd3dabda1 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -203,13 +203,13 @@ namespace NMonitoring { const TMtHttpServer& Parent; }; - TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool) + TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool) : THttpServer(this, options, pool) , Handler(std::move(handler)) { } - TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool) + TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool) : THttpServer(this, /* mainWorkers = */pool, /* failWorkers = */pool, options) , Handler(std::move(handler)) { diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 2f66dddaf8..270f42ef66 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -60,8 +60,8 @@ namespace NMonitoring { class TMtHttpServer: public THttpServer, private THttpServer::ICallBack { public: - TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool = nullptr); - TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool); + TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool = nullptr); + TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool); /** * This will cause the server start to accept incoming connections. diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index 96cc11bcfd..a5508e0afe 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -134,7 +134,7 @@ namespace NObjectFactory { template<class... Args> static THolder<TProduct> MakeHolder(Args&&... args) { - return THolder<TProduct>(Construct(std::forward<Args>(args)...)); + return THolder<TProduct>(Construct(std::forward<Args>(args)...)); } static bool Has(const TKey& key) { diff --git a/library/cpp/packedtypes/longs_ut.cpp b/library/cpp/packedtypes/longs_ut.cpp index 8b06c934d2..c2ee49b9e1 100644 --- a/library/cpp/packedtypes/longs_ut.cpp +++ b/library/cpp/packedtypes/longs_ut.cpp @@ -5,7 +5,7 @@ #include <library/cpp/digest/old_crc/crc.h> #include <util/string/util.h> #include <util/stream/output.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> Y_UNIT_TEST_SUITE(TLongsTest) { Y_UNIT_TEST(TestLongs) { @@ -15,14 +15,14 @@ Y_UNIT_TEST_SUITE(TLongsTest) { TString s; s += Sprintf("x16=0x%x\n", (int)x16); - s += Sprintf("LO_8(x16)=0x%x HI_8(x16)=0x%x\n\n", (int)Lo8(x16), (int)Hi8(x16)); + s += Sprintf("LO_8(x16)=0x%x HI_8(x16)=0x%x\n\n", (int)Lo8(x16), (int)Hi8(x16)); char buf[100]; memset(buf, 0, 100); char* p = buf; int l = out_long(x64, buf); s += Sprintf("x64=0x%" PRIi64 "\n", x64); - s += Sprintf("LO_32(x64)=0x%" PRIu32 " HI_32(x64)=0x%" PRIu32 "\n", (ui32)Lo32(x64), (ui32)Hi32(x64)); + s += Sprintf("LO_32(x64)=0x%" PRIu32 " HI_32(x64)=0x%" PRIu32 "\n", (ui32)Lo32(x64), (ui32)Hi32(x64)); s += Sprintf("buf=%s, l=%d: ", buf, l); for (int i = 0; i < l; i++) { s += Sprintf("0x%02x ", buf[i]); diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index 88cff26ae2..95d6dfdd47 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -65,7 +65,7 @@ struct TZCMemoryInput_traits { } }; -void Y_FORCE_INLINE PackUI32(IOutputStream& out, ui32 v) { +void Y_FORCE_INLINE PackUI32(IOutputStream& out, ui32 v) { char buf[sizeof(ui32)]; char* bufPtr = buf; size_t size; diff --git a/library/cpp/packedtypes/packedfloat.h b/library/cpp/packedtypes/packedfloat.h index f178912ed3..2d9f04064c 100644 --- a/library/cpp/packedtypes/packedfloat.h +++ b/library/cpp/packedtypes/packedfloat.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/ylimits.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <cmath> #include <cfloat> @@ -34,12 +34,12 @@ namespace NPackedFloat { self& operator=(float t) { assert(SIGNED == 1 || SIGNED == 0 && t >= 0.); - val = BitCast<ui32>(t) >> (15 + SIGNED); + val = BitCast<ui32>(t) >> (15 + SIGNED); return *this; } operator float() const { - return BitCast<float>((ui32)val << (15 + SIGNED)); + return BitCast<float>((ui32)val << (15 + SIGNED)); } static self New(float v) { @@ -81,15 +81,15 @@ namespace NPackedFloat { self& operator=(float t) { assert(SIGNED == 1 || SIGNED == 0 && t >= 0.); - ui16 hi16 = Hi16(t); + ui16 hi16 = Hi16(t); - ui8 sign = SIGNED ? Hi8(hi16) & 0x80 : 0; + ui8 sign = SIGNED ? Hi8(hi16) & 0x80 : 0; - hi16 <<= 1; + hi16 <<= 1; - ui8 fexp = Hi8(hi16); + ui8 fexp = Hi8(hi16); ui8 exp; - ui8 frac = (Lo8(hi16) & 0xf0) >> 4; + ui8 frac = (Lo8(hi16) & 0xf0) >> 4; if (fexp <= FMinExp) { exp = 0; @@ -106,25 +106,25 @@ namespace NPackedFloat { } operator float() const { - ui32 v = 0; + ui32 v = 0; - v |= SIGNED ? (val & 0x80) << 24 : 0; + v |= SIGNED ? (val & 0x80) << 24 : 0; ui8 frac = val & 0x0f; ui8 exp = val & MaxExp; if (exp) { - v |= ((exp >> 4) + FMinExp) << 23 | frac << 19; + v |= ((exp >> 4) + FMinExp) << 23 | frac << 19; } else if (DENORM && val & 0x0f) { while (!(frac & 0x10)) { frac <<= 1; ++exp; } - v |= (FMinExp - exp + 1) << 23 | (frac & 0x0f) << 19; + v |= (FMinExp - exp + 1) << 23 | (frac & 0x0f) << 19; } else - v |= 0; + v |= 0; - return BitCast<float>(v); + return BitCast<float>(v); } static self New(float v) { diff --git a/library/cpp/pop_count/benchmark/main.cpp b/library/cpp/pop_count/benchmark/main.cpp index 41ea3c91cc..272a1c1fe2 100644 --- a/library/cpp/pop_count/benchmark/main.cpp +++ b/library/cpp/pop_count/benchmark/main.cpp @@ -2,7 +2,7 @@ #include <util/datetime/cputimer.h> #include <util/system/type_name.h> -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <library/cpp/testing/benchmark/bench.h> template <class F, class I> diff --git a/library/cpp/pop_count/benchmark/ya.make b/library/cpp/pop_count/benchmark/ya.make index 7fb54a519a..ba34ef196c 100644 --- a/library/cpp/pop_count/benchmark/ya.make +++ b/library/cpp/pop_count/benchmark/ya.make @@ -4,7 +4,7 @@ Y_BENCHMARK() PEERDIR( util/draft - library/cpp/pop_count + library/cpp/pop_count ) SRCS( diff --git a/library/cpp/pop_count/popcount.h b/library/cpp/pop_count/popcount.h index 3d67737ed2..71ea2721e6 100644 --- a/library/cpp/pop_count/popcount.h +++ b/library/cpp/pop_count/popcount.h @@ -1,9 +1,9 @@ #pragma once #include <util/generic/typelist.h> -#include <util/system/cpu_id.h> +#include <util/system/cpu_id.h> #include <util/system/defaults.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <util/system/platform.h> #if defined(_MSC_VER) @@ -38,7 +38,7 @@ static inline ui32 PopCountImpl(ui32 n) { return __popcnt(n); #else #if defined(_x86_64_) - if (NX86::CachedHavePOPCNT()) { + if (NX86::CachedHavePOPCNT()) { ui32 r; __asm__("popcnt %1, %0;" @@ -61,7 +61,7 @@ static inline ui32 PopCountImpl(ui32 n) { #endif #endif - return PopCountImpl((ui16)Lo16(n)) + PopCountImpl((ui16)Hi16(n)); + return PopCountImpl((ui16)Lo16(n)) + PopCountImpl((ui16)Hi16(n)); #endif } @@ -70,7 +70,7 @@ static inline ui32 PopCountImpl(ui64 n) { return __popcnt64(n); #else #if defined(_x86_64_) - if (NX86::CachedHavePOPCNT()) { + if (NX86::CachedHavePOPCNT()) { ui64 r; __asm__("popcnt %1, %0;" @@ -93,7 +93,7 @@ static inline ui32 PopCountImpl(ui64 n) { #endif #endif - return PopCountImpl((ui32)Lo32(n)) + PopCountImpl((ui32)Hi32(n)); + return PopCountImpl((ui32)Lo32(n)) + PopCountImpl((ui32)Hi32(n)); #endif } diff --git a/library/cpp/pop_count/ut/ya.make b/library/cpp/pop_count/ut/ya.make index f0e6c014e5..02678db1c2 100644 --- a/library/cpp/pop_count/ut/ya.make +++ b/library/cpp/pop_count/ut/ya.make @@ -1,4 +1,4 @@ -UNITTEST_FOR(library/cpp/pop_count) +UNITTEST_FOR(library/cpp/pop_count) OWNER(g:util) diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 640c10f5a5..aa185c28d1 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -400,7 +400,7 @@ namespace NProtobufJson { knownFields[GetFieldName(*field, config)] = 1; } for (const auto& f : json.GetMap()) { - Y_ENSURE(knownFields.contains(f.first), "unknown field " << f.first); + Y_ENSURE(knownFields.contains(f.first), "unknown field " << f.first); } } } diff --git a/library/cpp/protobuf/json/string_transform.cpp b/library/cpp/protobuf/json/string_transform.cpp index 7c42daa677..818928ce91 100644 --- a/library/cpp/protobuf/json/string_transform.cpp +++ b/library/cpp/protobuf/json/string_transform.cpp @@ -3,7 +3,7 @@ #include <google/protobuf/stubs/strutil.h> #include <library/cpp/string_utils/base64/base64.h> - + namespace NProtobufJson { void TCEscapeTransform::Transform(TString& str) const { str = google::protobuf::CEscape(str); @@ -54,11 +54,11 @@ namespace NProtobufJson { return result; } - void TBase64EncodeBytesTransform::TransformBytes(TString &str) const { - str = Base64Encode(str); - } - - void TBase64DecodeBytesTransform::TransformBytes(TString &str) const { - str = Base64Decode(str); - } + void TBase64EncodeBytesTransform::TransformBytes(TString &str) const { + str = Base64Encode(str); + } + + void TBase64DecodeBytesTransform::TransformBytes(TString &str) const { + str = Base64Decode(str); + } } diff --git a/library/cpp/protobuf/json/string_transform.h b/library/cpp/protobuf/json/string_transform.h index e4b296bc01..0603e2f8c3 100644 --- a/library/cpp/protobuf/json/string_transform.h +++ b/library/cpp/protobuf/json/string_transform.h @@ -83,29 +83,29 @@ namespace NProtobufJson { TString Unescape(const TString& str) const; }; - class TBase64EncodeBytesTransform: public NProtobufJson::IStringTransform { - public: - int GetType() const override { - return 0; - } - - void Transform(TString&) const override { - // Do not transform strings - } - - void TransformBytes(TString &str) const override; - }; - - class TBase64DecodeBytesTransform: public NProtobufJson::IStringTransform { - public: - int GetType() const override { - return 0; - } - - void Transform(TString&) const override { - // Do not transform strings - } - - void TransformBytes(TString &str) const override; - }; + class TBase64EncodeBytesTransform: public NProtobufJson::IStringTransform { + public: + int GetType() const override { + return 0; + } + + void Transform(TString&) const override { + // Do not transform strings + } + + void TransformBytes(TString &str) const override; + }; + + class TBase64DecodeBytesTransform: public NProtobufJson::IStringTransform { + public: + int GetType() const override { + return 0; + } + + void Transform(TString&) const override { + // Do not transform strings + } + + void TransformBytes(TString &str) const override; + }; } diff --git a/library/cpp/random_provider/random_provider.cpp b/library/cpp/random_provider/random_provider.cpp index 64cb48b8b7..1f04e36834 100644 --- a/library/cpp/random_provider/random_provider.cpp +++ b/library/cpp/random_provider/random_provider.cpp @@ -1,7 +1,7 @@ #include "random_provider.h" #include <util/random/mersenne.h> #include <util/random/random.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> namespace { void SetV4(TGUID& g) { @@ -47,7 +47,7 @@ public: TGUID GenGuid() noexcept override { TGUID ret; - WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); + WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); ret.dw[2] = (ui32)Gen.GenRand(); ret.dw[3] = ++GuidCount; return ret; @@ -55,8 +55,8 @@ public: TGUID GenUuid4() noexcept override { TGUID ret; - WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); - WriteUnaligned<ui64>(ret.dw + 2, Gen.GenRand()); + WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); + WriteUnaligned<ui64>(ret.dw + 2, Gen.GenRand()); SetV4(ret); return ret; } diff --git a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp index 9caa53f2e7..2781cff8c2 100644 --- a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp +++ b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp @@ -67,8 +67,8 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { "fooBaR", callback); UNIT_ASSERT_EQUAL(foundIds.size(), 2); - UNIT_ASSERT(foundIds.contains(42)); - UNIT_ASSERT(foundIds.contains(241)); + UNIT_ASSERT(foundIds.contains(42)); + UNIT_ASSERT(foundIds.contains(241)); } // https://ml.yandex-team.ru/thread/2370000002965712422/ diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 5184e801cc..9d03f5e0ce 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -69,7 +69,7 @@ private: } else { result = "NM"; } - StripInPlace(result); + StripInPlace(result); UNIT_ASSERT_VALUES_EQUAL(result, regTest.Result); } } diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index 94bba4064b..d0803878fb 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -63,7 +63,7 @@ namespace NRegExp { ucs4[outWritten] = 0; lexer.Assign(ucs4.begin(), - ucs4.begin() + std::char_traits<wchar32>::length(ucs4.data())); + ucs4.begin() + std::char_traits<wchar32>::length(ucs4.data())); } if (opts.CaseInsensitive) { diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index 66001c4769..92878eff46 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -22,7 +22,7 @@ namespace { struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> { void Store(const TStringBuf key, const TStringBuf data) override { - if (contains(key)) { + if (contains(key)) { const TStringBuf value = (*this)[key]->second; if (value != data) { size_t vsize = GetCodec()->DecompressedLength(value); diff --git a/library/cpp/scheme/domscheme_traits.h b/library/cpp/scheme/domscheme_traits.h index a11c4dd444..18e1798fd9 100644 --- a/library/cpp/scheme/domscheme_traits.h +++ b/library/cpp/scheme/domscheme_traits.h @@ -1,7 +1,7 @@ #pragma once #include "scheme.h" -#include <util/string/cast.h> +#include <util/string/cast.h> struct TSchemeTraits { using TValue = NSc::TValue; diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp index 3efd116d4f..3eb2e6c46e 100644 --- a/library/cpp/scheme/scheme.cpp +++ b/library/cpp/scheme/scheme.cpp @@ -2,7 +2,7 @@ #include "scimpl_private.h" #include <util/generic/algorithm.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NSc { TStringBufs& TValue::DictKeys(TStringBufs& vs, bool sorted) const { @@ -251,10 +251,10 @@ namespace NSc { } if (coreA.IsString()) { - std::string_view strA = coreA.String; - std::string_view strB = coreB.String; + std::string_view strA = coreA.String; + std::string_view strB = coreB.String; - if (strA != strB) { + if (strA != strB) { return false; } } else if (coreA.IsArray()) { @@ -507,7 +507,7 @@ namespace NSc { namespace NPrivate { int CompareStr(const NSc::TValue& a, TStringBuf b) { - return a.GetString().compare(b); + return a.GetString().compare(b); } int CompareInt(const NSc::TValue& a, i64 r) { diff --git a/library/cpp/scheme/scimpl.h b/library/cpp/scheme/scimpl.h index 4f68f16290..5ab13a1955 100644 --- a/library/cpp/scheme/scimpl.h +++ b/library/cpp/scheme/scimpl.h @@ -552,7 +552,7 @@ namespace NSc { } bool TValue::Has(TStringBuf s) const { - return GetDict().contains(s); + return GetDict().contains(s); } TValue& TValue::GetOrAddUnsafe(size_t idx) { diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp index 55a971d9e4..2a06e29f22 100644 --- a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp +++ b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp @@ -102,23 +102,23 @@ namespace NSc::NUt { TRef TVMAction::GetRef(ui32 arg) const noexcept { - return std::get<TRef>(Arg[arg]); + return std::get<TRef>(Arg[arg]); } TSrc TVMAction::GetSrc(ui32 arg) const noexcept { - return std::get<TSrc>(Arg[arg]); + return std::get<TSrc>(Arg[arg]); } TDst TVMAction::GetDst(ui32 arg) const noexcept { - return std::get<TDst>(Arg[arg]); + return std::get<TDst>(Arg[arg]); } ui32 TVMAction::GetPos(ui32 arg) const noexcept { - return std::get<TPos>(Arg[arg]).Pos; + return std::get<TPos>(Arg[arg]).Pos; } ui32 TVMAction::GetIdx(ui32 arg) const noexcept { - return std::get<TIdx>(Arg[arg]).Idx; + return std::get<TIdx>(Arg[arg]).Idx; } TStringBuf TVMAction::GetKey(ui32 arg) const noexcept { @@ -134,7 +134,7 @@ namespace NSc::NUt { } TStringBuf TVMAction::GetPath(ui32 arg) const noexcept { - return std::get<TPath>(Arg[arg]).Path; + return std::get<TPath>(Arg[arg]).Path; } @@ -143,7 +143,7 @@ namespace NSc::NUt { : Out(out) {} - bool operator()(const std::monostate&) const { + bool operator()(const std::monostate&) const { return true; } //TIdx, TPos, TRef, TSrc, TDst, TPath @@ -159,7 +159,7 @@ namespace NSc::NUt { TStringBuilder out; out << Type; for (const auto& arg : Arg) { - if (std::visit(TActionPrinter(out.Out), arg)) { + if (std::visit(TActionPrinter(out.Out), arg)) { break; } } diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h index 9a0ddf7351..7db4ddeda3 100644 --- a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h +++ b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h @@ -98,11 +98,11 @@ namespace NSc::NUt { return std::move(Memory[pos]); } - [[nodiscard]] + [[nodiscard]] bool TryPushBack(); template <class T> - [[nodiscard]] + [[nodiscard]] bool TryPushBack(T&& t) { if (MayAddMoreMemory()) { Memory.emplace_back(std::forward<T>(t)); @@ -112,11 +112,11 @@ namespace NSc::NUt { } } - [[nodiscard]] + [[nodiscard]] bool TryPushFront(); template <class T> - [[nodiscard]] + [[nodiscard]] bool TryPushFront(T&& t) { if (MayAddMoreMemory()) { Pos += 1; @@ -127,16 +127,16 @@ namespace NSc::NUt { } } - [[nodiscard]] + [[nodiscard]] bool TryPopBack(); - [[nodiscard]] + [[nodiscard]] bool TryPopFront(); TString ToString() const; private: - [[nodiscard]] + [[nodiscard]] bool MayAddMoreMemory() const noexcept { return Memory.size() < MaxMemory; } @@ -223,7 +223,7 @@ namespace NSc::NUt { TString ToString() const; }; - using TArg = std::variant<std::monostate, TIdx, TPos, TRef, TSrc, TDst, TPath>; + using TArg = std::variant<std::monostate, TIdx, TPos, TRef, TSrc, TDst, TPath>; struct TVMAction { using EType = EVMAction; @@ -269,7 +269,7 @@ namespace NSc::NUt { ui32 CurrArg = 0; }; - [[nodiscard]] + [[nodiscard]] inline ui32 GetCountWidth(ui32 cnt) { return MostSignificantBit(cnt - 1) + 1; } diff --git a/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp b/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp index ce3786a671..b464bef666 100644 --- a/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp +++ b/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp @@ -32,14 +32,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParsePos(st)); } - [[nodiscard]] + [[nodiscard]] ui32 DoTestParsePosSuccess(TVMState& st) { const auto pos = ParsePos(st); UNIT_ASSERT(pos); return pos->Pos; } - [[nodiscard]] + [[nodiscard]] ui32 DoTestParsePosSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParsePosSuccess(st); @@ -81,14 +81,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParseRef(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseRefSuccess(TVMState& st) { const auto ref = ParseRef(st); UNIT_ASSERT(ref); return std::make_pair(ref->Pos, ref->Type); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseRefSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParseRefSuccess(st); @@ -118,14 +118,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParseSrc(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseSrcSuccess(TVMState& st) { const auto src = ParseSrc(st); UNIT_ASSERT(src); return std::make_pair(src->Pos, src->Type); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseSrcSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParseSrcSuccess(st); @@ -153,14 +153,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParseDst(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseDstSuccess(TVMState& st) { const auto dst = ParseDst(st); UNIT_ASSERT(dst); return std::make_pair(dst->Pos, dst->Type); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseDstSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParseDstSuccess(st); @@ -201,14 +201,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParsePath(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParsePathSuccess(TVMState& st) { const auto path = ParsePath(st); UNIT_ASSERT(path); return path->Path; } - [[nodiscard]] + [[nodiscard]] auto DoTestParsePathSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParsePathSuccess(st); diff --git a/library/cpp/scheme/ut_utils/scheme_ut_utils.h b/library/cpp/scheme/ut_utils/scheme_ut_utils.h index eb3ea15b2a..58876a9b14 100644 --- a/library/cpp/scheme/ut_utils/scheme_ut_utils.h +++ b/library/cpp/scheme/ut_utils/scheme_ut_utils.h @@ -5,7 +5,7 @@ #include <library/cpp/json/json_value.h> #include <library/cpp/json/json_writer.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NSc { namespace NUt { diff --git a/library/cpp/string_utils/scan/ya.make b/library/cpp/string_utils/scan/ya.make index 2faae86b09..9b05c04db1 100644 --- a/library/cpp/string_utils/scan/ya.make +++ b/library/cpp/string_utils/scan/ya.make @@ -1,11 +1,11 @@ -OWNER( - g:util -) - -LIBRARY() - -SRCS( - scan.cpp -) - -END() +OWNER( + g:util +) + +LIBRARY() + +SRCS( + scan.cpp +) + +END() diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 85f4ac5d69..5e4ce24fb0 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -36,8 +36,8 @@ namespace { template <typename TChar1, typename TChar2> int Compare1Case2(const TChar1* s1, const TChar2* s2, size_t n) { for (size_t i = 0; i < n; ++i) { - if ((TChar1)ToLower(s1[i]) != s2[i]) - return (TChar1)ToLower(s1[i]) < s2[i] ? -1 : 1; + if ((TChar1)ToLower(s1[i]) != s2[i]) + return (TChar1)ToLower(s1[i]) < s2[i] ? -1 : 1; } return 0; } diff --git a/library/cpp/terminate_handler/terminate_handler.cpp b/library/cpp/terminate_handler/terminate_handler.cpp index d7e8fbed95..dbc5fb43ed 100644 --- a/library/cpp/terminate_handler/terminate_handler.cpp +++ b/library/cpp/terminate_handler/terminate_handler.cpp @@ -1,36 +1,36 @@ -#include <cstdlib> +#include <cstdlib> #include <exception> #include <util/stream/output.h> #include <util/system/backtrace.h> #include <util/generic/yexception.h> -namespace { - // Avoid infinite recursion if std::terminate is triggered anew by the - // FancyTerminateHandler. - thread_local int TerminateCount = 0; +namespace { + // Avoid infinite recursion if std::terminate is triggered anew by the + // FancyTerminateHandler. + thread_local int TerminateCount = 0; - void FancyTerminateHandler() { - switch (++TerminateCount) { - case 1: - break; - case 2: - Cerr << "FancyTerminateHandler called recursively" << Endl; + void FancyTerminateHandler() { + switch (++TerminateCount) { + case 1: + break; + case 2: + Cerr << "FancyTerminateHandler called recursively" << Endl; [[fallthrough]]; - default: - abort(); + default: + abort(); break; - } + } - if (std::current_exception()) { - Cerr << "Uncaught exception: " << CurrentExceptionMessage() << '\n'; - } else { - Cerr << "Terminate for unknown reason (no current exception)\n"; - } - PrintBackTrace(); - Cerr.Flush(); + if (std::current_exception()) { + Cerr << "Uncaught exception: " << CurrentExceptionMessage() << '\n'; + } else { + Cerr << "Terminate for unknown reason (no current exception)\n"; + } + PrintBackTrace(); + Cerr.Flush(); abort(); } - [[maybe_unused]] auto _ = std::set_terminate(&FancyTerminateHandler); + [[maybe_unused]] auto _ = std::set_terminate(&FancyTerminateHandler); } diff --git a/library/cpp/terminate_handler/ya.make b/library/cpp/terminate_handler/ya.make index 70a9712fed..b419b23718 100644 --- a/library/cpp/terminate_handler/ya.make +++ b/library/cpp/terminate_handler/ya.make @@ -1,12 +1,12 @@ LIBRARY() -OWNER( - ilnurkh - eeight -) +OWNER( + ilnurkh + eeight +) SRCS( - GLOBAL terminate_handler.cpp + GLOBAL terminate_handler.cpp segv_handler.cpp ) diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp index ddd8b05ffc..dd5c932542 100644 --- a/library/cpp/testing/benchmark/examples/main.cpp +++ b/library/cpp/testing/benchmark/examples/main.cpp @@ -193,7 +193,7 @@ Y_CPU_BENCHMARK(FunctionCallCost_TwoArg, iface) { * │ ↓ je 25 * │ xor %edi,%edi * │ xor %esi,%esi - * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char + * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char * │ nop * 100.00 │20:┌─→dec %rbx * │ └──jne 20 diff --git a/library/cpp/testing/gtest_extensions/pretty_printers.h b/library/cpp/testing/gtest_extensions/pretty_printers.h index 14d8284446..ea2b850bb1 100644 --- a/library/cpp/testing/gtest_extensions/pretty_printers.h +++ b/library/cpp/testing/gtest_extensions/pretty_printers.h @@ -71,7 +71,7 @@ inline void PrintTo(TNothing /* value */, std::ostream* stream) { *stream << "nothing"; } -inline void PrintTo(std::monostate /* value */, std::ostream* stream) { +inline void PrintTo(std::monostate /* value */, std::ostream* stream) { *stream << "monostate"; } diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index 3679b768ed..f2b51de0b4 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -10,7 +10,7 @@ #include <util/system/guard.h> #include <util/system/tls.h> #include <util/system/error.h> -#include <util/string/cast.h> +#include <util/string/cast.h> bool NUnitTest::ShouldColorizeDiff = true; bool NUnitTest::ContinueOnFail = false; diff --git a/library/cpp/threading/equeue/equeue.cpp b/library/cpp/threading/equeue/equeue.cpp index 54a848e912..4a708ef3ad 100644 --- a/library/cpp/threading/equeue/equeue.cpp +++ b/library/cpp/threading/equeue/equeue.cpp @@ -71,10 +71,10 @@ void TElasticQueue::Start(size_t threadCount, size_t maxQueueSize) { SlaveQueue_->Start(threadCount, maxQueueSize); } -void TElasticQueue::Stop() noexcept { +void TElasticQueue::Stop() noexcept { return SlaveQueue_->Stop(); } -size_t TElasticQueue::Size() const noexcept { +size_t TElasticQueue::Size() const noexcept { return SlaveQueue_->Size(); } diff --git a/library/cpp/threading/equeue/equeue.h b/library/cpp/threading/equeue/equeue.h index 40dd342585..ff735399e6 100644 --- a/library/cpp/threading/equeue/equeue.h +++ b/library/cpp/threading/equeue/equeue.h @@ -1,11 +1,11 @@ #pragma once -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/system/atomic.h> #include <util/generic/ptr.h> //actual queue limit will be (maxQueueSize - numBusyThreads) or 0 -class TElasticQueue: public IThreadPool { +class TElasticQueue: public IThreadPool { public: explicit TElasticQueue(THolder<IThreadPool> slaveQueue); @@ -21,7 +21,7 @@ private: bool TryIncCounter(); private: - THolder<IThreadPool> SlaveQueue_; + THolder<IThreadPool> SlaveQueue_; size_t MaxQueueSize_ = 0; TAtomic ObjectCount_ = 0; TAtomic GuardCount_ = 0; diff --git a/library/cpp/threading/equeue/equeue_ut.cpp b/library/cpp/threading/equeue/equeue_ut.cpp index 9cf2aced44..d08a94848b 100644 --- a/library/cpp/threading/equeue/equeue_ut.cpp +++ b/library/cpp/threading/equeue/equeue_ut.cpp @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { Counters.Reset(); TryCounter = 0; - struct TSender: public IThreadFactory::IThreadAble { + struct TSender: public IThreadFactory::IThreadAble { void DoExecute() override { while ((size_t)AtomicIncrement(TryCounter) <= N) { if (!TryAdd()) { @@ -108,9 +108,9 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { { TQueueSetup setup; - TVector< TAutoPtr<IThreadFactory::IThread> > senders; + TVector< TAutoPtr<IThreadFactory::IThread> > senders; for (size_t i = 0; i < ThreadCount; ++i) { - senders.push_back(::SystemThreadFactory()->Run(&sender)); + senders.push_back(::SystemThreadFactory()->Run(&sender)); } for (size_t i = 0; i < senders.size(); ++i) { diff --git a/library/cpp/threading/future/async.h b/library/cpp/threading/future/async.h index 8543fdd5c6..a7e84cc29b 100644 --- a/library/cpp/threading/future/async.h +++ b/library/cpp/threading/future/async.h @@ -3,7 +3,7 @@ #include "future.h" #include <util/generic/function.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> namespace NThreading { /** @@ -18,7 +18,7 @@ namespace NThreading { * unittest. */ template <typename Func> - TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) { + TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) { auto promise = NewPromise<TFutureType<TFunctionResult<Func>>>(); auto lambda = [promise, func = std::forward<Func>(func)]() mutable { NImpl::SetValue(promise, func); diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp index a3699744e4..6901ed2621 100644 --- a/library/cpp/threading/future/async_ut.cpp +++ b/library/cpp/threading/future/async_ut.cpp @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(Async) { } Y_UNIT_TEST(WorksWithIMtpQueue) { - auto queue = MakeHolder<TThreadPool>(); + auto queue = MakeHolder<TThreadPool>(); queue->Start(1); auto future = NThreading::Async([]() { return 5; }, *queue); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(Async) { Y_UNIT_TEST(ProperlyDeducesFutureType) { // Compileability test - auto queue = CreateThreadPool(1); + auto queue = CreateThreadPool(1); NThreading::TFuture<void> f1 = NThreading::Async([]() {}, *queue); NThreading::TFuture<int> f2 = NThreading::Async([]() { return 5; }, *queue); diff --git a/library/cpp/threading/future/legacy_future.h b/library/cpp/threading/future/legacy_future.h index 6f1eabad73..5240f92992 100644 --- a/library/cpp/threading/future/legacy_future.h +++ b/library/cpp/threading/future/legacy_future.h @@ -3,13 +3,13 @@ #include "fwd.h" #include "future.h" -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <functional> namespace NThreading { template <typename TR, bool IgnoreException> - class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable { + class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable { public: typedef TR(TFunctionSignature)(); using TFunctionObjectType = std::function<TFunctionSignature>; @@ -18,10 +18,10 @@ namespace NThreading { private: TFunctionObjectType Func_; TPromise<TResult> Result_; - THolder<IThreadFactory::IThread> Thread_; + THolder<IThreadFactory::IThread> Thread_; public: - inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory()) + inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory()) : Func_(func) , Result_(NewPromise<TResult>()) , Thread_(pool->Run(this)) diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp index ff63db1725..873c913d82 100644 --- a/library/cpp/threading/future/legacy_future_ut.cpp +++ b/library/cpp/threading/future/legacy_future_ut.cpp @@ -43,7 +43,7 @@ namespace NThreading { TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3))); UNIT_ASSERT_VALUES_EQUAL(4, f11.Get()); - TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory()); + TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory()); UNIT_ASSERT_VALUES_EQUAL(4, f12.Get()); TSampleClass c(5); @@ -51,17 +51,17 @@ namespace NThreading { TLegacyFuture<int> f21(std::bind(&TSampleClass::Calc, std::ref(c))); UNIT_ASSERT_VALUES_EQUAL(6, f21.Get()); - TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory()); + TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory()); UNIT_ASSERT_VALUES_EQUAL(6, f22.Get()); } - struct TSomeThreadPool: public IThreadFactory {}; + struct TSomeThreadPool: public IThreadFactory {}; Y_UNIT_TEST(TestFunction) { std::function<int()> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get()); - UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get()); + UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get()); if (false) { TSomeThreadPool* q = nullptr; diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h index 2753d5446c..a80b65a933 100644 --- a/library/cpp/threading/future/wait/wait-inl.h +++ b/library/cpp/threading/future/wait/wait-inl.h @@ -6,31 +6,31 @@ namespace NThreading { namespace NImpl { - template <typename TContainer> - TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) { - TVector<TFuture<void>> voidFutures; - voidFutures.reserve(futures.size()); + template <typename TContainer> + TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) { + TVector<TFuture<void>> voidFutures; + voidFutures.reserve(futures.size()); - for (const auto& future: futures) { - voidFutures.push_back(future.IgnoreResult()); + for (const auto& future: futures) { + voidFutures.push_back(future.IgnoreResult()); } - return voidFutures; + return voidFutures; } } template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) { - return WaitAll(NImpl::ToVoidFutures(futures)); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) { + return WaitAll(NImpl::ToVoidFutures(futures)); } template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) { - return WaitExceptionOrAll(NImpl::ToVoidFutures(futures)); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) { + return WaitExceptionOrAll(NImpl::ToVoidFutures(futures)); } template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) { - return WaitAny(NImpl::ToVoidFutures(futures)); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) { + return WaitAny(NImpl::ToVoidFutures(futures)); } } diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp index a173833a7f..cc33f3189c 100644 --- a/library/cpp/threading/future/wait/wait.cpp +++ b/library/cpp/threading/future/wait/wait.cpp @@ -1,17 +1,17 @@ -#include "wait.h" +#include "wait.h" #include "wait_group.h" #include "wait_policy.h" namespace NThreading { - namespace { + namespace { template <class WaitPolicy> - TFuture<void> WaitGeneric(const TFuture<void>& f1) { + TFuture<void> WaitGeneric(const TFuture<void>& f1) { return f1; } template <class WaitPolicy> - TFuture<void> WaitGeneric(const TFuture<void>& f1, const TFuture<void>& f2) { + TFuture<void> WaitGeneric(const TFuture<void>& f1, const TFuture<void>& f2) { TWaitGroup<WaitPolicy> wg; wg.Add(f1).Add(f2); @@ -19,13 +19,13 @@ namespace NThreading { return std::move(wg).Finish(); } - template <class WaitPolicy> - TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) { + template <class WaitPolicy> + TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) { if (futures.empty()) { return MakeFuture(); } if (futures.size() == 1) { - return futures.front(); + return futures.front(); } TWaitGroup<WaitPolicy> wg; @@ -39,44 +39,44 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - TFuture<void> WaitAll(const TFuture<void>& f1) { - return WaitGeneric<TWaitPolicy::TAll>(f1); + TFuture<void> WaitAll(const TFuture<void>& f1) { + return WaitGeneric<TWaitPolicy::TAll>(f1); } - TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) { - return WaitGeneric<TWaitPolicy::TAll>(f1, f2); + TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) { + return WaitGeneric<TWaitPolicy::TAll>(f1, f2); } - TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) { - return WaitGeneric<TWaitPolicy::TAll>(futures); + TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) { + return WaitGeneric<TWaitPolicy::TAll>(futures); } //////////////////////////////////////////////////////////////////////////////// - TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) { - return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1); + TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) { + return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1); } - TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2) { - return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1, f2); + TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2) { + return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1, f2); } - TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) { - return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures); + TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) { + return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures); } //////////////////////////////////////////////////////////////////////////////// - TFuture<void> WaitAny(const TFuture<void>& f1) { - return WaitGeneric<TWaitPolicy::TAny>(f1); + TFuture<void> WaitAny(const TFuture<void>& f1) { + return WaitGeneric<TWaitPolicy::TAny>(f1); } - TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2) { - return WaitGeneric<TWaitPolicy::TAny>(f1, f2); + TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2) { + return WaitGeneric<TWaitPolicy::TAny>(f1, f2); } - TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures) { - return WaitGeneric<TWaitPolicy::TAny>(futures); + TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures) { + return WaitGeneric<TWaitPolicy::TAny>(futures); } } diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h index 6ff7d57baa..ade4c9a3ad 100644 --- a/library/cpp/threading/future/wait/wait.h +++ b/library/cpp/threading/future/wait/wait.h @@ -5,35 +5,35 @@ #include <library/cpp/threading/future/core/future.h> #include <library/cpp/threading/future/wait/wait_group.h> -#include <util/generic/array_ref.h> - +#include <util/generic/array_ref.h> + namespace NThreading { - namespace NImpl { - template <class TContainer> - using EnableGenericWait = std::enable_if_t< - !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>, - TFuture<void>>; - } + namespace NImpl { + template <class TContainer> + using EnableGenericWait = std::enable_if_t< + !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>, + TFuture<void>>; + } // waits for all futures [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1); [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2); - [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures); + [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures); template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures); // waits for the first exception or for all futures [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1); [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2); - [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures); + [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures); template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures); // waits for any future [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1); [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2); - [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures); + [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures); template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures); } #define INCLUDE_FUTURE_INL_H diff --git a/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp b/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp index e82063d959..bf5b734411 100644 --- a/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp +++ b/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/random/random.h> #include <util/system/atomic.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> class TRWMutexTest: public TTestBase { UNIT_TEST_SUITE(TRWMutexTest); @@ -116,7 +116,7 @@ private: #undef RUN_CYCLE private: TSharedData Data_; - TThreadPool Q_; + TThreadPool Q_; }; UNIT_TEST_SUITE_REGISTRATION(TRWMutexTest) diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 1d3fbb4bf4..528f35a74d 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -166,7 +166,7 @@ void* NPar::TLocalExecutor::TImpl::HostWorkerThread(void* p) { static const int FAST_ITERATIONS = 200; auto* const ctx = (TImpl*)p; - TThread::SetCurrentThreadName("ParLocalExecutor"); + TThread::SetCurrentThreadName("ParLocalExecutor"); ctx->WorkerThreadId = AtomicAdd(ctx->ThreadId, 1); for (bool cont = true; cont;) { TSingleJob job; diff --git a/library/cpp/threading/poor_man_openmp/thread_helper.h b/library/cpp/threading/poor_man_openmp/thread_helper.h index 0ecee0590b..d1744f217d 100644 --- a/library/cpp/threading/poor_man_openmp/thread_helper.h +++ b/library/cpp/threading/poor_man_openmp/thread_helper.h @@ -1,6 +1,6 @@ #pragma once -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/generic/utility.h> #include <util/generic/yexception.h> #include <util/system/info.h> @@ -17,7 +17,7 @@ public: TMtpQueueHelper() { SetThreadCount(NSystemInfo::CachedNumberOfCpus()); } - IThreadPool* Get() { + IThreadPool* Get() { return q.Get(); } size_t GetThreadCount() { @@ -25,14 +25,14 @@ public: } void SetThreadCount(size_t threads) { ThreadCount = threads; - q = CreateThreadPool(ThreadCount); + q = CreateThreadPool(ThreadCount); } static TMtpQueueHelper& Instance(); private: size_t ThreadCount; - TAutoPtr<IThreadPool> q; + TAutoPtr<IThreadPool> q; }; namespace NYmp { @@ -49,7 +49,7 @@ namespace NYmp { chunkSize = Max<size_t>(chunkSize, 1); size_t threadCount = TMtpQueueHelper::Instance().GetThreadCount(); - IThreadPool* queue = TMtpQueueHelper::Instance().Get(); + IThreadPool* queue = TMtpQueueHelper::Instance().Get(); TCondVar cv; TMutex mutex; TAtomic counter = threadCount; diff --git a/library/cpp/threading/skip_list/perf/main.cpp b/library/cpp/threading/skip_list/perf/main.cpp index 4ad52049e7..8194a660cb 100644 --- a/library/cpp/threading/skip_list/perf/main.cpp +++ b/library/cpp/threading/skip_list/perf/main.cpp @@ -198,7 +198,7 @@ namespace { } for (size_t i = 0; i < tests.size(); ++i) { - if (!AllTests.contains(tests[i])) { + if (!AllTests.contains(tests[i])) { LogError() << "unknown test name: " << tests[i] << Endl; return false; } diff --git a/library/cpp/threading/task_scheduler/task_scheduler.cpp b/library/cpp/threading/task_scheduler/task_scheduler.cpp index 174dde4bf7..d428a0f8a3 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler.cpp @@ -21,7 +21,7 @@ public: TString DebugState = "?"; TString DebugId = ""; private: - void* ThreadProc() noexcept override { + void* ThreadProc() noexcept override { Scheduler_.WorkerFunc(this); return nullptr; } diff --git a/library/cpp/timezone_conversion/civil.cpp b/library/cpp/timezone_conversion/civil.cpp index 5986318b9a..8b3fea5494 100644 --- a/library/cpp/timezone_conversion/civil.cpp +++ b/library/cpp/timezone_conversion/civil.cpp @@ -70,7 +70,7 @@ namespace NDatetime { return GetFixedTimeZone(offset); } TTimeZone result; - if (!cctz::load_time_zone(static_cast<std::string>(name), &result)) { + if (!cctz::load_time_zone(static_cast<std::string>(name), &result)) { ythrow TInvalidTimezone() << "Failed to load time zone " << name << ", " << result.name(); } return result; diff --git a/library/cpp/timezone_conversion/civil.h b/library/cpp/timezone_conversion/civil.h index 0e95b807ed..4030dd3305 100644 --- a/library/cpp/timezone_conversion/civil.h +++ b/library/cpp/timezone_conversion/civil.h @@ -213,7 +213,7 @@ namespace NDatetime { */ template <typename TP> TString Format(TStringBuf fmt, const TP& tp, const TTimeZone& tz) { - return TString(cctz::format(static_cast<std::string>(fmt), TTimePoint(cctz::convert(tp, tz)), tz)); + return TString(cctz::format(static_cast<std::string>(fmt), TTimePoint(cctz::convert(tp, tz)), tz)); } /** Returns the weekday by day. diff --git a/library/cpp/tld/tld.cpp b/library/cpp/tld/tld.cpp index e31f3f0322..61d3f0e4ef 100644 --- a/library/cpp/tld/tld.cpp +++ b/library/cpp/tld/tld.cpp @@ -38,11 +38,11 @@ namespace NTld { } bool IsTld(const TStringBuf& s) { - return Default<TTLDHash>().contains(s); + return Default<TTLDHash>().contains(s); } bool IsVeryGoodTld(const TStringBuf& s) { - return Default<TVeryGoodTld>().contains(s); + return Default<TVeryGoodTld>().contains(s); } } diff --git a/library/cpp/tvmauth/client/misc/src_checker.h b/library/cpp/tvmauth/client/misc/src_checker.h index 25e8e72602..b2de25dd94 100644 --- a/library/cpp/tvmauth/client/misc/src_checker.h +++ b/library/cpp/tvmauth/client/misc/src_checker.h @@ -28,7 +28,7 @@ namespace NTvmAuth { return ticket; } - TServiceTicketImplPtr impl = THolder(NInternal::TCanningKnife::GetS(ticket)); + TServiceTicketImplPtr impl = THolder(NInternal::TCanningKnife::GetS(ticket)); impl->SetStatus(ETicketStatus::NoRoles); return TCheckedServiceTicket(std::move(impl)); } diff --git a/library/cpp/unicode/normalization/custom_encoder.cpp b/library/cpp/unicode/normalization/custom_encoder.cpp index c6f186405f..2e8ca0c575 100644 --- a/library/cpp/unicode/normalization/custom_encoder.cpp +++ b/library/cpp/unicode/normalization/custom_encoder.cpp @@ -64,7 +64,7 @@ void TCustomEncoder::Create(const CodePage* target, bool extended) { Y_ASSERT(decomp_p != nullptr); dw = decomp_p[0]; - if (std::char_traits<wchar32>::length(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'(')) + if (std::char_traits<wchar32>::length(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'(')) dw = decomp_p[1]; } if (Code(dw) != 0 && isGoodDecomp(w, dw)) diff --git a/library/cpp/unicode/punycode/punycode.cpp b/library/cpp/unicode/punycode/punycode.cpp index 800d1f19fe..a16b360d56 100644 --- a/library/cpp/unicode/punycode/punycode.cpp +++ b/library/cpp/unicode/punycode/punycode.cpp @@ -106,7 +106,7 @@ TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { CheckIdnaResult(rc); TUtf16String decoded; - AppendUtf32ToWide(out.Data, std::char_traits<ui32>::length(out.Data), decoded); + AppendUtf32ToWide(out.Data, std::char_traits<ui32>::length(out.Data), decoded); return decoded; } diff --git a/library/cpp/uri/other.cpp b/library/cpp/uri/other.cpp index b23a5b68a9..687c31df7b 100644 --- a/library/cpp/uri/other.cpp +++ b/library/cpp/uri/other.cpp @@ -35,12 +35,12 @@ void UnTrspChars(const char* s, char* d) { void InvertDomain(char* begin, char* end) { // skip schema if it is present - const auto dotPos = TStringBuf{begin, end}.find('.'); - if (dotPos == TStringBuf::npos) + const auto dotPos = TStringBuf{begin, end}.find('.'); + if (dotPos == TStringBuf::npos) return; // no need to invert anything - const auto schemaendPos = TStringBuf{begin, end}.find("://", 3); - if (schemaendPos < dotPos) - begin += schemaendPos + 3; + const auto schemaendPos = TStringBuf{begin, end}.find("://", 3); + if (schemaendPos < dotPos) + begin += schemaendPos + 3; char* sl = (char*)memchr(begin, '/', end - begin); char* cl = (char*)memchr(begin, ':', sl ? sl - begin : end - begin); end = cl ? cl : (sl ? sl : end); diff --git a/library/cpp/xml/document/xml-textreader_ut.cpp b/library/cpp/xml/document/xml-textreader_ut.cpp index 6232dfe47e..aea1b249b6 100644 --- a/library/cpp/xml/document/xml-textreader_ut.cpp +++ b/library/cpp/xml/document/xml-textreader_ut.cpp @@ -159,20 +159,20 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EQUAL(data.size(), 3); - UNIT_ASSERT(data.contains(225)); + UNIT_ASSERT(data.contains(225)); const TCountry& russia = data.at(225); UNIT_ASSERT_EQUAL(russia.Name, "Россия"); UNIT_ASSERT_EQUAL(russia.Cities.size(), 2); UNIT_ASSERT_EQUAL(russia.Cities[0], "Москва"); UNIT_ASSERT_EQUAL(russia.Cities[1], "Санкт-Петербург"); - UNIT_ASSERT(data.contains(149)); + UNIT_ASSERT(data.contains(149)); const TCountry& belarus = data.at(149); UNIT_ASSERT_EQUAL(belarus.Name, "Беларусь"); UNIT_ASSERT_EQUAL(belarus.Cities.size(), 1); UNIT_ASSERT_EQUAL(belarus.Cities[0], "Минск"); - UNIT_ASSERT(data.contains(187)); + UNIT_ASSERT(data.contains(187)); const TCountry& ukraine = data.at(187); UNIT_ASSERT_EQUAL(ukraine.Name, "Украина"); UNIT_ASSERT_EQUAL(ukraine.Cities.size(), 1); diff --git a/library/cpp/ya.make b/library/cpp/ya.make index 8c1193b007..a66c9ebf25 100644 --- a/library/cpp/ya.make +++ b/library/cpp/ya.make @@ -41,7 +41,7 @@ RECURSE( clustered_hnsw clustered_hnsw/ut codecs - codecs/float_huffman_bench + codecs/float_huffman_bench codecs/greedy_dict/ut codecs/static/tools codecs/static/tools/tests @@ -86,8 +86,8 @@ RECURSE( dot_product dot_product/bench dot_product/ut - dwarf_backtrace - dwarf_backtrace/registry + dwarf_backtrace + dwarf_backtrace/registry edit_distance edit_distance/ut enumbitset @@ -120,8 +120,8 @@ RECURSE( file_checker/test file_checker/test/tests file_checker/ut - flatbuffers64_introspection - flatbuffers64_introspection/example + flatbuffers64_introspection + flatbuffers64_introspection/example float16 float16/ut framing @@ -274,9 +274,9 @@ RECURSE( packers/ut par perceptron - pop_count - pop_count/benchmark - pop_count/ut + pop_count + pop_count/benchmark + pop_count/ut presort presort/ut prob_counter @@ -321,9 +321,9 @@ RECURSE( scheme/ut_utils scores scores/ut - select_in_word - select_in_word/bench - select_in_word/ut + select_in_word + select_in_word/bench + select_in_word/ut semver semver/ut shingles diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp index b39e070718..a7daf0f2f6 100644 --- a/library/cpp/yson/node/node.cpp +++ b/library/cpp/yson/node/node.cpp @@ -4,8 +4,8 @@ #include <library/cpp/yson/writer.h> -#include <util/generic/overloaded.h> - +#include <util/generic/overloaded.h> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -279,17 +279,17 @@ size_t TNode::Size() const TNode::EType TNode::GetType() const { - return std::visit(TOverloaded{ - [](const TUndefined&) { return Undefined; }, - [](const TString&) { return String; }, - [](i64) { return Int64; }, - [](ui64) { return Uint64; }, - [](double) { return Double; }, - [](bool) { return Bool; }, - [](const TListType&) { return List; }, - [](const TMapType&) { return Map; }, - [](const TNull&) { return Null; } - }, Value_); + return std::visit(TOverloaded{ + [](const TUndefined&) { return Undefined; }, + [](const TString&) { return String; }, + [](i64) { return Int64; }, + [](ui64) { return Uint64; }, + [](double) { return Double; }, + [](bool) { return Bool; }, + [](const TListType&) { return List; }, + [](const TMapType&) { return Map; }, + [](const TNull&) { return Null; } + }, Value_); } const TString& TNode::AsString() const diff --git a/library/cpp/yt/string/string.cpp b/library/cpp/yt/string/string.cpp index 7440ac3fdd..98f3f217e4 100644 --- a/library/cpp/yt/string/string.cpp +++ b/library/cpp/yt/string/string.cpp @@ -3,7 +3,7 @@ #include <library/cpp/yt/assert/assert.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/string/ascii.h> @@ -220,7 +220,7 @@ size_t TCaseInsensitiveStringHasher::operator()(TStringBuf arg) const for (size_t index = 0; index < arg.length(); ++index) { buffer[index] = AsciiToLower(arg[index]); } - return ComputeHash(TStringBuf(buffer, arg.length())); + return ComputeHash(TStringBuf(buffer, arg.length())); }; const size_t SmallSize = 256; if (arg.length() <= SmallSize) { diff --git a/tools/archiver/main.cpp b/tools/archiver/main.cpp index 6cda54c1ea..d883638492 100644 --- a/tools/archiver/main.cpp +++ b/tools/archiver/main.cpp @@ -58,10 +58,10 @@ namespace { { } - ~THexOutput() override { + ~THexOutput() override { } - inline IOutputStream* Slave() const noexcept { + inline IOutputStream* Slave() const noexcept { return Slave_; } @@ -125,7 +125,7 @@ namespace { *Out_ << Base_ << ":\n"; } - ~TYasmOutput() override { + ~TYasmOutput() override { } void DoFinish() override { @@ -170,7 +170,7 @@ namespace { *Slave() << "static_assert(sizeof(unsigned int) == 4, \"ups, unsupported platform\");\n\nextern \"C\" {\nextern const unsigned char " << B << "[] = {\n"; } - ~TCOutput() override { + ~TCOutput() override { } void DoFinish() override { @@ -188,7 +188,7 @@ namespace { *O << "static_assert(sizeof(unsigned int) == 4, \"ups, unsupported platform\");\n\nextern \"C\" {\nextern const unsigned char " << B << "[] = \n"; } - ~TCStringOutput() override { + ~TCStringOutput() override { } void DoWrite(const void* data, size_t len) override { @@ -298,7 +298,7 @@ static inline TAutoPtr<IOutputStream> OpenOutput(const TString& url) { } } -static inline bool IsDelim(char ch) noexcept { +static inline bool IsDelim(char ch) noexcept { return ch == '/' || ch == '\\'; } diff --git a/tools/fix_elf/patch.h b/tools/fix_elf/patch.h index c3dcd24224..1ecb5b13c9 100644 --- a/tools/fix_elf/patch.h +++ b/tools/fix_elf/patch.h @@ -28,11 +28,11 @@ public: } } - Elf64_Ehdr* GetHeader() const noexcept { + Elf64_Ehdr* GetHeader() const noexcept { return reinterpret_cast<Elf64_Ehdr*>(Begin); } - char* GetPtr(size_t offset = 0) const noexcept { + char* GetPtr(size_t offset = 0) const noexcept { return Begin + offset; } @@ -52,7 +52,7 @@ public: return r; } - size_t GetSectionCount() const noexcept { + size_t GetSectionCount() const noexcept { size_t count = GetHeader()->e_shnum; if (count == 0) { count = GetSection(0)->sh_size; @@ -61,15 +61,15 @@ public: return count; } - Elf64_Shdr* GetSectionBegin() const noexcept { + Elf64_Shdr* GetSectionBegin() const noexcept { return reinterpret_cast<Elf64_Shdr*>(Begin + GetHeader()->e_shoff); } - Elf64_Shdr* GetSectionEnd() const noexcept { + Elf64_Shdr* GetSectionEnd() const noexcept { return reinterpret_cast<Elf64_Shdr*>(Begin + GetHeader()->e_shoff) + GetSectionCount(); } - Elf64_Shdr* GetSection(size_t i) const noexcept { + Elf64_Shdr* GetSection(size_t i) const noexcept { return GetSectionBegin() + i; } @@ -94,36 +94,36 @@ public: { } - bool IsNull() const noexcept { + bool IsNull() const noexcept { return !This; } - char* GetPtr(size_t offset = 0) const noexcept { + char* GetPtr(size_t offset = 0) const noexcept { return Elf->GetPtr(This->sh_offset) + offset; } - TStringBuf GetStr(size_t offset) const noexcept { + TStringBuf GetStr(size_t offset) const noexcept { return GetPtr(offset); } - TStringBuf GetName() const noexcept { + TStringBuf GetName() const noexcept { return TSection{Elf, Elf->GetSectionsNameSection()}.GetPtr(This->sh_name); } - size_t GetLink() const noexcept { + size_t GetLink() const noexcept { return This->sh_link; } - size_t GetSize() const noexcept { + size_t GetSize() const noexcept { return This->sh_size; } - size_t GetEntryCount() const noexcept { + size_t GetEntryCount() const noexcept { return GetSize() / This->sh_entsize; } template<typename TTo = char> - TTo* GetEntry(size_t i) const noexcept { + TTo* GetEntry(size_t i) const noexcept { return reinterpret_cast<TTo*>(GetPtr(i * This->sh_entsize)); } @@ -139,7 +139,7 @@ public: { } - Elf64_Verneed* GetFirstVerneed() const noexcept { + Elf64_Verneed* GetFirstVerneed() const noexcept { if (!GetSize()) { return nullptr; } @@ -147,7 +147,7 @@ public: return reinterpret_cast<Elf64_Verneed*>(GetPtr()); } - Elf64_Verneed* GetNextVerneed(Elf64_Verneed* v) const noexcept { + Elf64_Verneed* GetNextVerneed(Elf64_Verneed* v) const noexcept { if (!v->vn_next) { return nullptr; } @@ -155,7 +155,7 @@ public: return Offset<Elf64_Verneed*>(v, v->vn_next); } - Elf64_Vernaux* GetFirstVernaux(Elf64_Verneed* v) const noexcept { + Elf64_Vernaux* GetFirstVernaux(Elf64_Verneed* v) const noexcept { if (!v->vn_cnt) { return nullptr; } @@ -163,7 +163,7 @@ public: return Offset<Elf64_Vernaux*>(v, v->vn_aux); } - Elf64_Vernaux* GetNextVernaux(Elf64_Vernaux* v) const noexcept { + Elf64_Vernaux* GetNextVernaux(Elf64_Vernaux* v) const noexcept { if (!v->vna_next) { return nullptr; } diff --git a/util/charset/wide.cpp b/util/charset/wide.cpp index a287438ddd..ddf898c1a0 100644 --- a/util/charset/wide.cpp +++ b/util/charset/wide.cpp @@ -1,6 +1,6 @@ #include "wide.h" -#include <util/generic/mem_copy.h> +#include <util/generic/mem_copy.h> #include <util/string/strip.h> namespace { diff --git a/util/charset/wide.h b/util/charset/wide.h index 04e6928aab..3de0b14ca7 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -3,7 +3,7 @@ #include "recode_result.h" #include "unidata.h" #include "utf8.h" -#include "wide_specific.h" +#include "wide_specific.h" #include <util/generic/algorithm.h> #include <util/generic/string.h> diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index d8f3233e73..579d75a52d 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/string/reverse.h> - +#include <util/string/reverse.h> + #include <algorithm> namespace { @@ -613,9 +613,9 @@ public: s = w; Collapse(s); UNIT_ASSERT(s == w); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == w.c_str()); // Collapse() does not change the string at all -#endif +#endif } s = ASCIIToWide(" 123 456 "); Collapse(s); @@ -641,9 +641,9 @@ public: s = w; Collapse(s); UNIT_ASSERT(s == w); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == w.c_str()); // Collapse() does not change the string at all -#endif +#endif } s = ASCIIToWide(" "); Collapse(s); @@ -774,21 +774,21 @@ public: s = w; Strip(s); UNIT_ASSERT(s == w); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all -#endif +#endif s = w; StripLeft(s); UNIT_ASSERT(s == w); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all -#endif +#endif s = w; StripRight(s); UNIT_ASSERT(s == w); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all -#endif +#endif } void TestIsSpace() { @@ -865,7 +865,7 @@ public: wchar16 upperCase[n]; std::copy(wideCyrillicAlphabet, wideCyrillicAlphabet + n, upperCase); ToLower(upperCase, n); - UNIT_ASSERT(TWtringBuf(upperCase, n) == TWtringBuf(wideCyrillicAlphabet + n, n)); + UNIT_ASSERT(TWtringBuf(upperCase, n) == TWtringBuf(wideCyrillicAlphabet + n, n)); } void TestToUpper() { @@ -873,7 +873,7 @@ public: wchar16 lowerCase[n]; std::copy(wideCyrillicAlphabet + n, wideCyrillicAlphabet + n * 2, lowerCase); ToUpper(lowerCase, n); - UNIT_ASSERT(TWtringBuf(lowerCase, n) == TWtringBuf(wideCyrillicAlphabet, n)); + UNIT_ASSERT(TWtringBuf(lowerCase, n) == TWtringBuf(wideCyrillicAlphabet, n)); } void TestWideString() { @@ -912,7 +912,7 @@ public: const TUtf16String reversed = UTF32ToWide(buffer.data(), buffer.size()); temp = original; - ReverseInPlace(temp); + ReverseInPlace(temp); UNIT_ASSERT(temp == reversed); } @@ -1099,9 +1099,9 @@ public: UNIT_ASSERT(!ToLower(s)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == lower); @@ -1120,9 +1120,9 @@ public: UNIT_ASSERT(!ToLower(s)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == lower); @@ -1140,9 +1140,9 @@ public: UNIT_ASSERT(!ToLower(s, 100500)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToLowerRet(copy, 100500) == lower); UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500) == lower); @@ -1154,9 +1154,9 @@ public: UNIT_ASSERT(!ToLower(s, 100500, 1111)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToLowerRet(copy, 100500, 1111) == lower); UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500, 1111) == lower); @@ -1187,9 +1187,9 @@ public: UNIT_ASSERT(!ToLower(s)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == lower); @@ -1208,9 +1208,9 @@ public: UNIT_ASSERT(!ToLower(s)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == lower); @@ -1257,9 +1257,9 @@ public: UNIT_ASSERT(!ToLower(s, 2)); UNIT_ASSERT(s == lower); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToLowerRet(copy, 2) == lower); UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower); @@ -1282,9 +1282,9 @@ public: UNIT_ASSERT(!ToLower(s, 3, 1)); UNIT_ASSERT(s == copy); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToLowerRet(copy, 3, 1) == lower); UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 1) == lower); @@ -1296,9 +1296,9 @@ public: UNIT_ASSERT(!ToLower(s, 3, 100500)); UNIT_ASSERT(s == copy); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToLowerRet(copy, 3, 100500) == lower); UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 100500) == lower); @@ -1314,9 +1314,9 @@ public: UNIT_ASSERT(!ToUpper(s)); UNIT_ASSERT(s == upper); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == upper); @@ -1335,9 +1335,9 @@ public: UNIT_ASSERT(!ToUpper(s)); UNIT_ASSERT(s == upper); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == upper); @@ -1356,9 +1356,9 @@ public: UNIT_ASSERT(!ToUpper(s, 100500)); UNIT_ASSERT(s == upper); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == upper); @@ -1376,9 +1376,9 @@ public: UNIT_ASSERT(!ToUpper(s, 100500, 1111)); UNIT_ASSERT(s == upper); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToUpperRet(copy, 100500, 1111) == upper); UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500, 1111) == upper); @@ -1409,9 +1409,9 @@ public: UNIT_ASSERT(!ToUpper(s)); UNIT_ASSERT(s == copy); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == upper); @@ -1531,9 +1531,9 @@ public: UNIT_ASSERT(!ToTitle(s)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == title); @@ -1552,9 +1552,9 @@ public: UNIT_ASSERT(!ToTitle(s)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == title); @@ -1572,9 +1572,9 @@ public: UNIT_ASSERT(!ToTitle(s, 100500)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToTitleRet(copy) == title); UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); @@ -1586,9 +1586,9 @@ public: UNIT_ASSERT(!ToTitle(s, 100500, 1111)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToTitleRet(copy) == title); UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); @@ -1619,9 +1619,9 @@ public: UNIT_ASSERT(!ToTitle(s)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == title); @@ -1658,9 +1658,9 @@ public: UNIT_ASSERT(!ToTitle(s)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); UNIT_ASSERT(writableCopy == title); @@ -1707,9 +1707,9 @@ public: UNIT_ASSERT(!ToTitle(s, 2)); UNIT_ASSERT(s == title); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.data() == copy.data()); -#endif +#endif UNIT_ASSERT(ToTitleRet(copy, 2) == title); UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title); diff --git a/util/charset/ya.make b/util/charset/ya.make index 26d38cb10b..de467c7f6a 100644 --- a/util/charset/ya.make +++ b/util/charset/ya.make @@ -5,10 +5,10 @@ SUBSCRIBER(g:util-subscribers) NO_UTIL() -IF (TSTRING_IS_STD_STRING) - CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) -ENDIF() - +IF (TSTRING_IS_STD_STRING) + CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) +ENDIF() + JOIN_SRCS( all_charset.cpp generated/unidata.cpp diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp index f64393860a..0926df8312 100644 --- a/util/draft/holder_vector_ut.cpp +++ b/util/draft/holder_vector_ut.cpp @@ -25,8 +25,8 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { ints.PushBack(new int(1)); UNIT_ASSERT_VALUES_EQUAL(*ints[0], 0); UNIT_ASSERT_VALUES_EQUAL(*ints[1], 1); - ints.Reset(0, MakeHolder<int>(2)); - ints.Reset(1, MakeHolder<int>(3)); + ints.Reset(0, MakeHolder<int>(2)); + ints.Reset(1, MakeHolder<int>(3)); UNIT_ASSERT_VALUES_EQUAL(*ints[0], 2); UNIT_ASSERT_VALUES_EQUAL(*ints[1], 3); } @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { THolderVector<int> ints; ints.Resize(1); UNIT_ASSERT_EQUAL(ints[0], (int*)nullptr); - ints.Reset(0, MakeHolder<int>(1)); + ints.Reset(0, MakeHolder<int>(1)); UNIT_ASSERT_UNEQUAL(ints[0], (int*)nullptr); UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1); } diff --git a/util/draft/ip.h b/util/draft/ip.h index eb947cd2cd..6647cc6348 100644 --- a/util/draft/ip.h +++ b/util/draft/ip.h @@ -91,7 +91,7 @@ inline void Out<TIp6>(IOutputStream& os, const TIp6& a) { os << Ip6ToString(a); } -using TIp4Or6 = std::variant<TIp4, TIp6>; +using TIp4Or6 = std::variant<TIp4, TIp6>; static inline TIp4Or6 Ip4Or6FromString(const char* ipStr) { const char* c = ipStr; @@ -107,10 +107,10 @@ static inline TIp4Or6 Ip4Or6FromString(const char* ipStr) { } static inline TString Ip4Or6ToString(const TIp4Or6& ip) { - if (std::holds_alternative<TIp6>(ip)) { - return Ip6ToString(std::get<TIp6>(ip)); + if (std::holds_alternative<TIp6>(ip)) { + return Ip6ToString(std::get<TIp6>(ip)); } else { - return IpToString(std::get<TIp4>(ip)); + return IpToString(std::get<TIp4>(ip)); } } diff --git a/util/draft/ya.make b/util/draft/ya.make index e00674b682..4756a982eb 100644 --- a/util/draft/ya.make +++ b/util/draft/ya.make @@ -5,10 +5,10 @@ SUBSCRIBER(g:util-subscribers) NO_UTIL() -IF (TSTRING_IS_STD_STRING) - CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) -ENDIF() - +IF (TSTRING_IS_STD_STRING) + CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) +ENDIF() + SRCS( date.cpp datetime.cpp diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index ffc9b09f96..b081c5e0f6 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -601,17 +601,17 @@ int ResolvePath(const char* rel, const char* abs, char res[/*MAXPATHLEN*/], bool return 0; } -TString ResolvePath(const char* rel, const char* abs, bool isdir) { +TString ResolvePath(const char* rel, const char* abs, bool isdir) { char buf[PATH_MAX]; - if (ResolvePath(rel, abs, buf, isdir)) - ythrow yexception() << "cannot resolve path: \"" << rel << "\""; + if (ResolvePath(rel, abs, buf, isdir)) + ythrow yexception() << "cannot resolve path: \"" << rel << "\""; return buf; } -TString ResolvePath(const char* path, bool isDir) { - return ResolvePath(path, nullptr, isDir); -} - +TString ResolvePath(const char* path, bool isDir) { + return ResolvePath(path, nullptr, isDir); +} + TString StripFileComponent(const TString& fileName) { TString dir = IsDir(fileName) ? fileName : GetDirName(fileName); if (!dir.empty() && dir.back() != GetDirectorySeparator()) { diff --git a/util/folder/dirut.h b/util/folder/dirut.h index 2537027b12..3e40048362 100644 --- a/util/folder/dirut.h +++ b/util/folder/dirut.h @@ -76,7 +76,7 @@ TString GetSystemTempDir(); int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix); int ResolvePath(const char* rel, const char* abs, char res[/*FILENAME_MAX*/], bool isdir = false); -TString ResolvePath(const char* rel, const char* abs, bool isdir = false); +TString ResolvePath(const char* rel, const char* abs, bool isdir = false); TString ResolvePath(const char* path, bool isDir = false); TString ResolveDir(const char* path); diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d68..13df9269cb 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -3,7 +3,7 @@ #include "pathsplit.h" #include <util/generic/yexception.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/system/compiler.h> #include <util/system/file.h> #include <util/system/fs.h> diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp index 6fdf8f753c..cb4a2cc4ba 100644 --- a/util/folder/tempdir.cpp +++ b/util/folder/tempdir.cpp @@ -6,11 +6,11 @@ #include <util/system/maxlen.h> TTempDir::TTempDir() - : TTempDir(nullptr, TCreationToken{}) -{ -} - -TTempDir::TTempDir(const char* prefix, TCreationToken) + : TTempDir(nullptr, TCreationToken{}) +{ +} + +TTempDir::TTempDir(const char* prefix, TCreationToken) : TempDir() , Remove(true) { @@ -29,10 +29,10 @@ TTempDir::TTempDir(const TString& tempDir) MakeDirIfNotExist(TempDir.c_str()); } -TTempDir TTempDir::NewTempDir(const TString& root) { - return {root.c_str(), TCreationToken{}}; -} - +TTempDir TTempDir::NewTempDir(const TString& root) { + return {root.c_str(), TCreationToken{}}; +} + void TTempDir::DoNotRemove() { Remove = false; } diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h index ff458f83b9..6acea134eb 100644 --- a/util/folder/tempdir.h +++ b/util/folder/tempdir.h @@ -6,17 +6,17 @@ class TTempDir { public: - /// Create new directory in system tmp folder. + /// Create new directory in system tmp folder. TTempDir(); - - /// Create new directory with this fixed name. If it already exists, clear it. + + /// Create new directory with this fixed name. If it already exists, clear it. TTempDir(const TString& tempDir); - + ~TTempDir(); - /// Create new directory in given folder. - static TTempDir NewTempDir(const TString& root); - + /// Create new directory in given folder. + static TTempDir NewTempDir(const TString& root); + const TString& operator()() const { return Name(); } @@ -32,12 +32,12 @@ public: void DoNotRemove(); private: - struct TCreationToken {}; - - // Prevent people from confusing this ctor with the public one - // by requiring additional fake argument. - TTempDir(const char* prefix, TCreationToken); - + struct TCreationToken {}; + + // Prevent people from confusing this ctor with the public one + // by requiring additional fake argument. + TTempDir(const char* prefix, TCreationToken); + TFsPath TempDir; bool Remove; }; diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 2db15fc59b..9e31bf18d3 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -449,11 +449,11 @@ void SetBits(T& value, T bits) { value &= ~(maxValue << Offset); value |= bits << Offset; } - -inline constexpr ui64 NthBit64(int bit) { - return ui64(1) << bit; -} - -inline constexpr ui64 Mask64(int bits) { - return NthBit64(bits) - 1; -} + +inline constexpr ui64 NthBit64(int bit) { + return ui64(1) << bit; +} + +inline constexpr ui64 Mask64(int bits) { + return NthBit64(bits) - 1; +} diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp index b92697e1d0..d0ba5fab85 100644 --- a/util/generic/buffer.cpp +++ b/util/generic/buffer.cpp @@ -1,6 +1,6 @@ -#include "buffer.h" -#include "mem_copy.h" -#include "string.h" +#include "buffer.h" +#include "mem_copy.h" +#include "string.h" #include "ymath.h" #include <util/system/sys_alloc.h> diff --git a/util/generic/cast.h b/util/generic/cast.h index 0d4a41f385..10278b6b62 100644 --- a/util/generic/cast.h +++ b/util/generic/cast.h @@ -5,7 +5,7 @@ #include <util/system/compat.h> #include <util/system/type_name.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #include <util/system/yassert.h> #include <cstdlib> @@ -158,19 +158,19 @@ template <typename T> constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept { return static_cast<std::underlying_type_t<T>>(enum_); } - -// std::bit_cast from c++20 -template <class TTarget, class TSource> -TTarget BitCast(const TSource& source) { - static_assert(sizeof(TSource) == sizeof(TTarget), "Size mismatch"); - static_assert(std::is_trivially_copyable<TSource>::value, "TSource is not trivially copyable"); - static_assert(std::is_trivial<TTarget>::value, "TTarget is not trivial"); - - // Support volatile qualifiers. - // ReadUnaligned does not work with volatile pointers, so cast away - // volatileness beforehand. - using TNonvolatileSource = std::remove_volatile_t<TSource>; - using TNonvolatileTarget = std::remove_volatile_t<TTarget>; - - return ReadUnaligned<TNonvolatileTarget>(&const_cast<const TNonvolatileSource&>(source)); -} + +// std::bit_cast from c++20 +template <class TTarget, class TSource> +TTarget BitCast(const TSource& source) { + static_assert(sizeof(TSource) == sizeof(TTarget), "Size mismatch"); + static_assert(std::is_trivially_copyable<TSource>::value, "TSource is not trivially copyable"); + static_assert(std::is_trivial<TTarget>::value, "TTarget is not trivial"); + + // Support volatile qualifiers. + // ReadUnaligned does not work with volatile pointers, so cast away + // volatileness beforehand. + using TNonvolatileSource = std::remove_volatile_t<TSource>; + using TNonvolatileTarget = std::remove_volatile_t<TTarget>; + + return ReadUnaligned<TNonvolatileTarget>(&const_cast<const TNonvolatileSource&>(source)); +} diff --git a/util/generic/cast_ut.cpp b/util/generic/cast_ut.cpp index 718a8de79d..1f73066ccd 100644 --- a/util/generic/cast_ut.cpp +++ b/util/generic/cast_ut.cpp @@ -8,7 +8,7 @@ class TGenericCastsTest: public TTestBase { UNIT_TEST(TestIntegralCast) UNIT_TEST(TestEnumCast) UNIT_TEST(TestToUnderlying) - UNIT_TEST(TestBitCast) + UNIT_TEST(TestBitCast) UNIT_TEST_SUITE_END(); private: @@ -81,32 +81,32 @@ private: UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1)); UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1)); } - - void TestBitCast() { - // Change sign of float - { + + void TestBitCast() { + // Change sign of float + { const float floatValue = 17.33f; - ui32 ui32Value = BitCast<ui32>(floatValue); - ui32Value ^= (ui32)1 << 31; - UNIT_ASSERT_VALUES_EQUAL(-floatValue, BitCast<float>(ui32Value)); - } - - // Unpack ui64 into a struct - { - const ui64 value = 0x1122334455667788; - struct TStruct { - ui32 a; - ui16 b; - ui8 c; - ui8 d; - }; - auto structValue = BitCast<TStruct>(value); - UNIT_ASSERT_VALUES_EQUAL(structValue.a, 0x55667788); - UNIT_ASSERT_VALUES_EQUAL(structValue.b, 0x3344); - UNIT_ASSERT_VALUES_EQUAL(structValue.c, 0x22); - UNIT_ASSERT_VALUES_EQUAL(structValue.d, 0x11); - } - } + ui32 ui32Value = BitCast<ui32>(floatValue); + ui32Value ^= (ui32)1 << 31; + UNIT_ASSERT_VALUES_EQUAL(-floatValue, BitCast<float>(ui32Value)); + } + + // Unpack ui64 into a struct + { + const ui64 value = 0x1122334455667788; + struct TStruct { + ui32 a; + ui16 b; + ui8 c; + ui8 d; + }; + auto structValue = BitCast<TStruct>(value); + UNIT_ASSERT_VALUES_EQUAL(structValue.a, 0x55667788); + UNIT_ASSERT_VALUES_EQUAL(structValue.b, 0x3344); + UNIT_ASSERT_VALUES_EQUAL(structValue.c, 0x22); + UNIT_ASSERT_VALUES_EQUAL(structValue.d, 0x11); + } + } }; UNIT_TEST_SUITE_REGISTRATION(TGenericCastsTest); diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp index 8b907457bc..c56cfade60 100644 --- a/util/generic/guid.cpp +++ b/util/generic/guid.cpp @@ -42,7 +42,7 @@ TGUID TGUID::Create() { } void CreateGuid(TGUID* res) { - ui64* dw = reinterpret_cast<ui64*>(res->dw); + ui64* dw = reinterpret_cast<ui64*>(res->dw); WriteUnaligned<ui64>(&dw[0], RandomNumber<ui64>()); WriteUnaligned<ui64>(&dw[1], RandomNumber<ui64>()); diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..320691f0c9 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -1623,18 +1623,18 @@ public: } template <class TheKey> - bool contains(const TheKey& key) const { - return rep.find(key) != rep.end(); - } - bool contains(const key_type& key) const { - return rep.find(key) != rep.end(); - } - - template <class TheKey> - bool contains(const TheKey& key, insert_ctx& ins) { - return rep.find_i(key, ins) != rep.end(); - } - + bool contains(const TheKey& key) const { + return rep.find(key) != rep.end(); + } + bool contains(const key_type& key) const { + return rep.find(key) != rep.end(); + } + + template <class TheKey> + bool contains(const TheKey& key, insert_ctx& ins) { + return rep.find_i(key, ins) != rep.end(); + } + template <class TKey> T& operator[](const TKey& key) { insert_ctx ctx = nullptr; @@ -1935,10 +1935,10 @@ public: } template <class TheKey> - bool contains(const TheKey& key) const { - return rep.find(key) != rep.end(); - } - + bool contains(const TheKey& key) const { + return rep.find(key) != rep.end(); + } + template <class TKey> size_type count(const TKey& key) const { return rep.count(key); @@ -2021,9 +2021,9 @@ template <class Key, class T, class HF, class EqKey, class Alloc> inline bool operator!=(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) { return !(hm1 == hm2); } - -// Cannot name it just 'Hash' because it clashes with too many class members in the code. -template <class T> -size_t ComputeHash(const T& value) { - return THash<T>{}(value); -} + +// Cannot name it just 'Hash' because it clashes with too many class members in the code. +template <class T> +size_t ComputeHash(const T& value) { + return THash<T>{}(value); +} diff --git a/util/generic/hash.pxd b/util/generic/hash.pxd index 385c10d805..828c5e04ef 100644 --- a/util/generic/hash.pxd +++ b/util/generic/hash.pxd @@ -47,7 +47,7 @@ cdef extern from "util/generic/hash.h" nogil: void erase(iterator, iterator) except + size_t erase(T&) iterator find(T&) - bint contains(T&) + bint contains(T&) const_iterator const_find "find"(T&) pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index e8088cf23b..f7cb6839c8 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -200,14 +200,14 @@ public: } template <class TheKey> - bool contains(const TheKey& key) const { - return rep.find(key) != rep.end(); - } - template <class TheKey> - bool contains(const TheKey& key, insert_ctx& ins) { - return rep.find_i(key, ins) != rep.end(); - } - + bool contains(const TheKey& key) const { + return rep.find(key) != rep.end(); + } + template <class TheKey> + bool contains(const TheKey& key, insert_ctx& ins) { + return rep.find_i(key, ins) != rep.end(); + } + template <class TKey> size_type count(const TKey& key) const { return rep.count(key); @@ -266,7 +266,7 @@ inline bool operator==(const THashSet<Value, HashFcn, EqualKey, Alloc>& hs1, con return false; } for (const auto& it : hs1) { - if (!hs2.contains(it)) { + if (!hs2.contains(it)) { return false; } } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..5804a53dca 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -177,9 +177,9 @@ void THashTest::TestHMap1() { m['x'] = "10"; // Correct mistake. UNIT_ASSERT(!strcmp(m['x'].c_str(), "10")); - UNIT_ASSERT(!m.contains('z')); + UNIT_ASSERT(!m.contains('z')); UNIT_ASSERT(!strcmp(m['z'].c_str(), "")); - UNIT_ASSERT(m.contains('z')); + UNIT_ASSERT(m.contains('z')); UNIT_ASSERT(m.count('z') == 1); auto p = m.insert(std::pair<const char, TString>('c', TString("100"))); @@ -377,34 +377,34 @@ void THashTest::TestHSetConstructorsAndAssignments() { UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - UNIT_ASSERT(c1.contains(100)); - UNIT_ASSERT(c2.contains(200)); + UNIT_ASSERT(c1.contains(100)); + UNIT_ASSERT(c2.contains(200)); container c3(std::move(c1)); UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - UNIT_ASSERT(c3.contains(100)); + UNIT_ASSERT(c3.contains(100)); c2.insert(300); c3 = c2; UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - UNIT_ASSERT(c3.contains(300)); + UNIT_ASSERT(c3.contains(300)); c2.insert(400); c3 = std::move(c2); UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - UNIT_ASSERT(c3.contains(400)); + UNIT_ASSERT(c3.contains(400)); container c4 = {1, 2, 3}; UNIT_ASSERT_VALUES_EQUAL(c4.size(), 3); - UNIT_ASSERT(c4.contains(1)); - UNIT_ASSERT(c4.contains(2)); - UNIT_ASSERT(c4.contains(3)); + UNIT_ASSERT(c4.contains(1)); + UNIT_ASSERT(c4.contains(2)); + UNIT_ASSERT(c4.contains(3)); } void THashTest::TestHSetSize() { @@ -1010,31 +1010,31 @@ void THashTest::TestHMMapEmplaceDirect() { void THashTest::TestHSetEmplace() { using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>; hash_t hash; - UNIT_ASSERT(!hash.contains(0)); + UNIT_ASSERT(!hash.contains(0)); hash.emplace(0); - UNIT_ASSERT(hash.contains(0)); - UNIT_ASSERT(!hash.contains(1)); + UNIT_ASSERT(hash.contains(0)); + UNIT_ASSERT(!hash.contains(1)); } void THashTest::TestHSetEmplaceNoresize() { using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>; hash_t hash; hash.reserve(1); - UNIT_ASSERT(!hash.contains(0)); + UNIT_ASSERT(!hash.contains(0)); hash.emplace_noresize(0); - UNIT_ASSERT(hash.contains(0)); - UNIT_ASSERT(!hash.contains(1)); + UNIT_ASSERT(hash.contains(0)); + UNIT_ASSERT(!hash.contains(1)); } void THashTest::TestHSetEmplaceDirect() { using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>; hash_t hash; - UNIT_ASSERT(!hash.contains(0)); + UNIT_ASSERT(!hash.contains(0)); hash_t::insert_ctx ins; hash.find(0, ins); hash.emplace_direct(ins, 1); - UNIT_ASSERT(hash.contains(0)); - UNIT_ASSERT(!hash.contains(1)); + UNIT_ASSERT(hash.contains(0)); + UNIT_ASSERT(!hash.contains(1)); } void THashTest::TestNonCopyable() { @@ -1100,8 +1100,8 @@ void THashTest::TestReleaseNodes() { set.insert(i); } UNIT_ASSERT_VALUES_EQUAL(counters.Allocations, 7); - UNIT_ASSERT(set.contains(10)); - UNIT_ASSERT(!set.contains(0)); + UNIT_ASSERT(set.contains(10)); + UNIT_ASSERT(!set.contains(0)); set.basic_clear(); UNIT_ASSERT_VALUES_EQUAL(counters.Deallocations, 3); diff --git a/util/generic/hash_ut.pyx b/util/generic/hash_ut.pyx index ecf6dac2e6..3eb50fc950 100644 --- a/util/generic/hash_ut.pyx +++ b/util/generic/hash_ut.pyx @@ -24,8 +24,8 @@ class TestHash(unittest.TestCase): self.assertEqual(2, c1.size()) self.assertEqual(2, c2.size()) self.assertEqual(1, c1.at("one")) - self.assertTrue(c1.contains("two")) - self.assertTrue(c2.contains("one")) + self.assertTrue(c1.contains("two")) + self.assertTrue(c2.contains("one")) self.assertEqual(2, c2.at("two")) c2["three"] = 3 c1 = c2 diff --git a/util/generic/map.h b/util/generic/map.h index b5001b56c0..8a1533755d 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -22,9 +22,9 @@ public: return !this->empty(); } - inline bool contains(const K& key) const { - return this->find(key) != this->end(); - } + inline bool contains(const K& key) const { + return this->find(key) != this->end(); + } }; template <class K, class V, class Less, class A> @@ -38,7 +38,7 @@ public: return !this->empty(); } - inline bool contains(const K& key) const { - return this->find(key) != this->end(); - } + inline bool contains(const K& key) const { + return this->find(key) != this->end(); + } }; diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..3fb0f800f4 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -468,7 +468,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { {"two", -2}, {"three", 3}, }; - UNIT_ASSERT(mm.contains("two")); + UNIT_ASSERT(mm.contains("two")); TMultiMap<TString, int> expected; expected.emplace("one", 1); expected.emplace("two", 2); @@ -485,12 +485,12 @@ Y_UNIT_TEST_SUITE(TYMapTest) { TMapInPool m(&pool); m.emplace(0, 1); - UNIT_ASSERT(m.contains(0)); + UNIT_ASSERT(m.contains(0)); UNIT_ASSERT_VALUES_EQUAL(1, m[0]); TMapInPool movedM = std::move(m); - UNIT_ASSERT(movedM.contains(0)); + UNIT_ASSERT(movedM.contains(0)); UNIT_ASSERT_VALUES_EQUAL(1, movedM[0]); } } diff --git a/util/generic/overloaded.h b/util/generic/overloaded.h index 96a97e44bc..c531f74fd8 100644 --- a/util/generic/overloaded.h +++ b/util/generic/overloaded.h @@ -3,9 +3,9 @@ /** * Construct an ad-hoc object with an overloaded `operator()`. * - * Typically used with lambdas to construct type-matching visitors for e.g. std::variant: + * Typically used with lambdas to construct type-matching visitors for e.g. std::variant: * ``` - * std::variant<int, void*, TString> var; + * std::variant<int, void*, TString> var; * Visit(TOverloaded{ * [](int val) { Cerr << "int: " << val; }, * [](void* val) { Cerr << "ptr: " << val; }, @@ -22,7 +22,7 @@ * For example, the following code will compile and run by casting all values to * double: * ``` - * std::variant<int, double, char> var; + * std::variant<int, double, char> var; * Visit(TOverloaded{ * [](double val) { Cerr << "dbl: " << val; }, * }, var); @@ -31,7 +31,7 @@ * If cases may be ambigous or specific type-matching logic is required, * a verbose `if constexpr`-based version would be preferred: * ``` - * std::variant<int, double, char> var; + * std::variant<int, double, char> var; * Visit([](auto&& val) { * using T = std::decay_t<decltype(val)>; * if constexpr (std::is_same_v<T, int>) { diff --git a/util/generic/overloaded_ut.cpp b/util/generic/overloaded_ut.cpp index f3d73895ad..57c3f284a6 100644 --- a/util/generic/overloaded_ut.cpp +++ b/util/generic/overloaded_ut.cpp @@ -28,13 +28,13 @@ Y_UNIT_TEST_SUITE(TOverloadedTest) { } Y_UNIT_TEST(VariantTest) { - std::variant<int, double, TType1> v = 5; + std::variant<int, double, TType1> v = 5; int res = 0; - std::visit(TOverloaded{ - [&](int val) { res = val; }, - [&](double) { res = -1; }, - [&](TType1) { res = -1; }}, - v); + std::visit(TOverloaded{ + [&](int val) { res = val; }, + [&](double) { res = -1; }, + [&](TType1) { res = -1; }}, + v); UNIT_ASSERT_VALUES_EQUAL(res, 5); } @@ -52,16 +52,16 @@ Y_UNIT_TEST_SUITE(TOverloadedTest) { } Y_UNIT_TEST(ImplicitConversionsTest) { - using TTestVariant = std::variant<int, double, char>; + using TTestVariant = std::variant<int, double, char>; // Purposefully exhibit inexact overload matched with implicit type // conversions // All cases implicitly cast to int auto matchAsInt = [](TTestVariant var) { - return std::visit(TOverloaded{ - [](int val) { return val; }, - }, var); + return std::visit(TOverloaded{ + [](int val) { return val; }, + }, var); }; UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{17.77}), 17); @@ -70,9 +70,9 @@ Y_UNIT_TEST_SUITE(TOverloadedTest) { // All cases implicitly cast to double auto matchAsDouble = [](TTestVariant var) { - return std::visit(TOverloaded{ - [](double val) { return val; }, - }, var); + return std::visit(TOverloaded{ + [](double val) { return val; }, + }, var); }; UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{17.77}), 17.77); diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec5..f38a3e44ca 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -12,9 +12,9 @@ #include <util/system/yassert.h> #include <util/system/defaults.h> -template <class T, class U> -using TGuardConversion = typename std::enable_if_t<std::is_convertible<U*, T*>::value>; - +template <class T, class U> +using TGuardConversion = typename std::enable_if_t<std::is_convertible<U*, T*>::value>; + template <class T> inline void AssertTypeComplete() { // If compiler triggers this error from destructor of your class with @@ -242,7 +242,7 @@ public: { } - explicit THolder(T* t) noexcept + explicit THolder(T* t) noexcept : T_(t) { } @@ -252,7 +252,7 @@ public: { } - template <class U, class = TGuardConversion<T, U>> + template <class U, class = TGuardConversion<T, U>> inline THolder(TAutoPtr<U, D> t) noexcept : T_(t.Release()) { @@ -263,7 +263,7 @@ public: { } - template <class U, class = TGuardConversion<T, U>> + template <class U, class = TGuardConversion<T, U>> inline THolder(THolder<U, D>&& that) noexcept : T_(that.Release()) { @@ -346,7 +346,7 @@ private: template <typename T, typename... Args> [[nodiscard]] THolder<T> MakeHolder(Args&&... args) { - return THolder<T>(new T(std::forward<Args>(args)...)); + return THolder<T>(new T(std::forward<Args>(args)...)); } /* @@ -475,12 +475,12 @@ public: template <class T, class Ops> class TIntrusivePtr: public TPointerBase<TIntrusivePtr<T, Ops>, T> { - template <class U, class O> - friend class TIntrusivePtr; - - template <class U, class O> - friend class TIntrusiveConstPtr; + template <class U, class O> + friend class TIntrusivePtr; + template <class U, class O> + friend class TIntrusiveConstPtr; + public: struct TNoIncrement { }; @@ -517,20 +517,20 @@ public: // void Func(TIntrusivePtr<B>); // ... // Func(TIntrusivePtr<A>(new A)); // <--- compiler can't decide which version of Func to use - template <class U, class = TGuardConversion<T, U>> - inline TIntrusivePtr(const TIntrusivePtr<U>& p) noexcept + template <class U, class = TGuardConversion<T, U>> + inline TIntrusivePtr(const TIntrusivePtr<U>& p) noexcept : T_(p.Get()) { Ref(); } - template <class U, class = TGuardConversion<T, U>> - inline TIntrusivePtr(TIntrusivePtr<U>&& p) noexcept - : T_(p.T_) - { - p.T_ = nullptr; - } - + template <class U, class = TGuardConversion<T, U>> + inline TIntrusivePtr(TIntrusivePtr<U>&& p) noexcept + : T_(p.T_) + { + p.T_ = nullptr; + } + inline TIntrusivePtr(TIntrusivePtr&& p) noexcept : T_(nullptr) { @@ -637,26 +637,26 @@ public: Swap(p); } - inline TIntrusiveConstPtr(TIntrusivePtr<T> p) noexcept - : T_(p.T_) + inline TIntrusiveConstPtr(TIntrusivePtr<T> p) noexcept + : T_(p.T_) { - p.T_ = nullptr; + p.T_ = nullptr; } - template <class U, class = TGuardConversion<T, U>> - inline TIntrusiveConstPtr(const TIntrusiveConstPtr<U>& p) noexcept + template <class U, class = TGuardConversion<T, U>> + inline TIntrusiveConstPtr(const TIntrusiveConstPtr<U>& p) noexcept : T_(p.T_) { Ref(); } - template <class U, class = TGuardConversion<T, U>> - inline TIntrusiveConstPtr(TIntrusiveConstPtr<U>&& p) noexcept - : T_(p.T_) - { - p.T_ = nullptr; - } - + template <class U, class = TGuardConversion<T, U>> + inline TIntrusiveConstPtr(TIntrusiveConstPtr<U>&& p) noexcept + : T_(p.T_) + { + p.T_ = nullptr; + } + inline TIntrusiveConstPtr& operator=(TIntrusiveConstPtr p) noexcept { p.Swap(*this); @@ -816,7 +816,7 @@ public: { } - template <class TT, class = TGuardConversion<T, TT>> + template <class TT, class = TGuardConversion<T, TT>> inline TSharedPtr(THolder<TT>&& t) { Init(t); } @@ -839,7 +839,7 @@ public: Swap(t); } - template <class TT, class = TGuardConversion<T, TT>> + template <class TT, class = TGuardConversion<T, TT>> inline TSharedPtr(const TSharedPtr<TT, C, D>& t) noexcept : T_(t.T_) , C_(t.C_) @@ -847,15 +847,15 @@ public: Ref(); } - template <class TT, class = TGuardConversion<T, TT>> - inline TSharedPtr(TSharedPtr<TT, C, D>&& t) noexcept - : T_(t.T_) - , C_(t.C_) - { - t.T_ = nullptr; - t.C_ = nullptr; - } - + template <class TT, class = TGuardConversion<T, TT>> + inline TSharedPtr(TSharedPtr<TT, C, D>&& t) noexcept + : T_(t.T_) + , C_(t.C_) + { + t.T_ = nullptr; + t.C_ = nullptr; + } + inline TSharedPtr& operator=(TSharedPtr t) noexcept { t.Swap(*this); diff --git a/util/generic/serialized_enum.h b/util/generic/serialized_enum.h index 79df2bac22..74228a0609 100644 --- a/util/generic/serialized_enum.h +++ b/util/generic/serialized_enum.h @@ -375,7 +375,7 @@ namespace NEnumSerializationRuntime { } bool contains(const TEnumType key) const { - return Ref.contains(this->CastToRepresentationType(key)); + return Ref.contains(this->CastToRepresentationType(key)); } TIterator find(const TEnumType key) const { diff --git a/util/generic/set.h b/util/generic/set.h index 4c437ca26f..3573ee9f8e 100644 --- a/util/generic/set.h +++ b/util/generic/set.h @@ -20,9 +20,9 @@ public: } template <class TheKey> - inline bool contains(const TheKey& key) const { - return this->find(key) != this->end(); - } + inline bool contains(const TheKey& key) const { + return this->find(key) != this->end(); + } }; template <class K, class L, class A> @@ -34,9 +34,9 @@ public: inline explicit operator bool() const noexcept { return !this->empty(); } - - template <class TheKey> - inline bool contains(const TheKey& key) const { - return this->find(key) != this->end(); - } + + template <class TheKey> + inline bool contains(const TheKey& key) const { + return this->find(key) != this->end(); + } }; diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp index d2769d327f..3308651a51 100644 --- a/util/generic/set_ut.cpp +++ b/util/generic/set_ut.cpp @@ -73,20 +73,20 @@ Y_UNIT_TEST_SUITE(YSetTest) { Y_UNIT_TEST(TestHas) { TSet<int> s; - UNIT_ASSERT(!s.contains(0)); + UNIT_ASSERT(!s.contains(0)); TSet<int> const& crs = s; - UNIT_ASSERT(!crs.contains(0)); + UNIT_ASSERT(!crs.contains(0)); s.insert(1); s.insert(42); s.insert(100); s.insert(2); - UNIT_ASSERT(s.contains(1)); - UNIT_ASSERT(s.contains(2)); - UNIT_ASSERT(s.contains(42)); - UNIT_ASSERT(s.contains(100)); + UNIT_ASSERT(s.contains(1)); + UNIT_ASSERT(s.contains(2)); + UNIT_ASSERT(s.contains(42)); + UNIT_ASSERT(s.contains(100)); } Y_UNIT_TEST(TestBounds) { @@ -203,28 +203,28 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT_VALUES_EQUAL(2, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c2.size()); - UNIT_ASSERT(c1.contains(100)); - UNIT_ASSERT(c2.contains(200)); + UNIT_ASSERT(c1.contains(100)); + UNIT_ASSERT(c2.contains(200)); container c3(std::move(c1)); UNIT_ASSERT_VALUES_EQUAL(0, c1.size()); UNIT_ASSERT_VALUES_EQUAL(2, c3.size()); - UNIT_ASSERT(c3.contains(100)); + UNIT_ASSERT(c3.contains(100)); c2.insert(300); c3 = c2; UNIT_ASSERT_VALUES_EQUAL(3, c2.size()); UNIT_ASSERT_VALUES_EQUAL(3, c3.size()); - UNIT_ASSERT(c3.contains(300)); + UNIT_ASSERT(c3.contains(300)); c2.insert(400); c3 = std::move(c2); UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); - UNIT_ASSERT(c3.contains(400)); + UNIT_ASSERT(c3.contains(400)); } { diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537..425755cfbc 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -37,7 +37,7 @@ namespace NStringPrivate { template <typename TDerived, typename TCharType, typename TTraitsType = std::char_traits<TCharType>> class TStringBase { using TStringView = std::basic_string_view<TCharType>; - using TStringViewWithTraits = std::basic_string_view<TCharType, TTraitsType>; + using TStringViewWithTraits = std::basic_string_view<TCharType, TTraitsType>; public: using TChar = TCharType; @@ -115,11 +115,11 @@ public: template <class TCharTraits> inline constexpr operator std::basic_string_view<TCharType, TCharTraits>() const { - return std::basic_string_view<TCharType, TCharTraits>(data(), size()); + return std::basic_string_view<TCharType, TCharTraits>(data(), size()); } template <class TCharTraits, class Allocator> - inline explicit operator std::basic_string<TCharType, TCharTraits, Allocator>() const { + inline explicit operator std::basic_string<TCharType, TCharTraits, Allocator>() const { return std::basic_string<TCharType, TCharTraits, Allocator>(Ptr(), Len()); } @@ -219,17 +219,17 @@ private: public: // ~~~ Comparison ~~~ : FAMILY0(int, compare) static int compare(const TSelf& s1, const TSelf& s2) noexcept { - return s1.AsStringView().compare(s2.AsStringView()); + return s1.AsStringView().compare(s2.AsStringView()); } static int compare(const TCharType* p, const TSelf& s2) noexcept { - TCharType null{0}; - return TStringViewWithTraits(p ? p : &null).compare(s2.AsStringView()); + TCharType null{0}; + return TStringViewWithTraits(p ? p : &null).compare(s2.AsStringView()); } static int compare(const TSelf& s1, const TCharType* p) noexcept { - TCharType null{0}; - return s1.AsStringView().compare(p ? p : &null); + TCharType null{0}; + return s1.AsStringView().compare(p ? p : &null); } static int compare(const TStringView s1, const TStringView s2) noexcept { @@ -258,7 +258,7 @@ public: } static bool equal(const TSelf& s1, const TSelf& s2) noexcept { - return s1.AsStringView() == s2.AsStringView(); + return s1.AsStringView() == s2.AsStringView(); } static bool equal(const TSelf& s1, const TCharType* p) noexcept { @@ -266,7 +266,7 @@ public: return s1.Len() == 0; } - return s1.AsStringView() == p; + return s1.AsStringView() == p; } static bool equal(const TCharType* p, const TSelf& s2) noexcept { @@ -274,7 +274,7 @@ public: } static bool equal(const TStringView s1, const TStringView s2) noexcept { - return TStringViewWithTraits{s1.data(), s1.size()} == TStringViewWithTraits{s2.data(), s2.size()}; + return TStringViewWithTraits{s1.data(), s1.size()} == TStringViewWithTraits{s2.data(), s2.size()}; } template <class T> @@ -295,11 +295,11 @@ public: } static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept { - return withLen <= whatLen && TStringViewWithTraits(what, withLen) == TStringViewWithTraits(with, withLen); + return withLen <= whatLen && TStringViewWithTraits(what, withLen) == TStringViewWithTraits(with, withLen); } static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept { - return withLen <= whatLen && TStringViewWithTraits(what + whatLen - withLen, withLen) == TStringViewWithTraits(with, withLen); + return withLen <= whatLen && TStringViewWithTraits(what + whatLen - withLen, withLen) == TStringViewWithTraits(with, withLen); } inline bool StartsWith(const TCharType* s, size_t n) const noexcept { @@ -311,7 +311,7 @@ public: } inline bool StartsWith(TCharType ch) const noexcept { - return !empty() && TTraits::eq(*Ptr(), ch); + return !empty() && TTraits::eq(*Ptr(), ch); } inline bool EndsWith(const TCharType* s, size_t n) const noexcept { @@ -323,7 +323,7 @@ public: } inline bool EndsWith(TCharType ch) const noexcept { - return !empty() && TTraits::eq(Ptr()[Len() - 1], ch); + return !empty() && TTraits::eq(Ptr()[Len() - 1], ch); } template <typename TDerived2, typename TTraits2> @@ -449,30 +449,30 @@ public: * @return Position of the substring inside this string, or `npos` if not found. */ inline size_t find(const TStringView s, size_t pos = 0) const noexcept { - return find(s.data(), pos, s.size()); + return find(s.data(), pos, s.size()); } inline size_t find(const TCharType* s, size_t pos, size_t count) const noexcept { - return AsStringView().find(s, pos, count); + return AsStringView().find(s, pos, count); } inline size_t find(TCharType c, size_t pos = 0) const noexcept { - return AsStringView().find(c, pos); + return AsStringView().find(c, pos); } inline size_t rfind(TCharType c) const noexcept { - return AsStringView().rfind(c); + return AsStringView().rfind(c); } inline size_t rfind(TCharType c, size_t pos) const noexcept { - if (pos == 0) { - return npos; + if (pos == 0) { + return npos; } - return AsStringView().rfind(c, pos - 1); + return AsStringView().rfind(c, pos - 1); } inline size_t rfind(const TStringView str, size_t pos = npos) const { - return AsStringView().rfind(str.data(), pos, str.size()); + return AsStringView().rfind(str.data(), pos, str.size()); } //~~~~Contains~~~~ @@ -505,7 +505,7 @@ public: } inline size_t find_first_of(const TStringView set, size_t pos) const noexcept { - return AsStringView().find_first_of(set.data(), pos, set.size()); + return AsStringView().find_first_of(set.data(), pos, set.size()); } inline size_t find_first_not_of(TCharType c) const noexcept { @@ -521,7 +521,7 @@ public: } inline size_t find_first_not_of(const TStringView set, size_t pos) const noexcept { - return AsStringView().find_first_not_of(set.data(), pos, set.size()); + return AsStringView().find_first_not_of(set.data(), pos, set.size()); } inline size_t find_last_of(TCharType c, size_t pos = npos) const noexcept { @@ -533,11 +533,11 @@ public: } inline size_t find_last_of(const TCharType* set, size_t pos, size_t n) const noexcept { - return AsStringView().find_last_of(set, pos, n); + return AsStringView().find_last_of(set, pos, n); } inline size_t find_last_not_of(TCharType c, size_t pos = npos) const noexcept { - return AsStringView().find_last_not_of(c, pos); + return AsStringView().find_last_not_of(c, pos); } inline size_t find_last_not_of(const TStringView set, size_t pos = npos) const noexcept { @@ -545,7 +545,7 @@ public: } inline size_t find_last_not_of(const TCharType* set, size_t pos, size_t n) const noexcept { - return AsStringView().find_last_not_of(set, pos, n); + return AsStringView().find_last_not_of(set, pos, n); } inline size_t copy(TCharType* pc, size_t n, size_t pos) const { @@ -581,8 +581,8 @@ public: private: using GenericFinder = const TCharType* (*)(const TCharType*, size_t, const TCharType*, size_t); - TStringViewWithTraits AsStringView() const { - return static_cast<TStringViewWithTraits>(*this); + TStringViewWithTraits AsStringView() const { + return static_cast<TStringViewWithTraits>(*this); } constexpr inline const TCharType* Ptr() const noexcept { diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..e69704a79b 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -18,7 +18,7 @@ #include "singleton.h" #include "strbase.h" #include "strbuf.h" -#include "string_hash.h" +#include "string_hash.h" #if defined(address_sanitizer_enabled) || defined(thread_sanitizer_enabled) #include "hide_ptr.h" @@ -153,7 +153,7 @@ private: TStringType& S_; size_t Pos_; }; -#endif +#endif template <typename TCharType, typename TTraits> class TBasicString: public TStringBase<TBasicString<TCharType, TTraits>, TCharType, TTraits> { @@ -161,14 +161,14 @@ public: // TODO: Move to private section using TBase = TStringBase<TBasicString, TCharType, TTraits>; using TStringType = std::basic_string<TCharType, TTraits>; -#ifdef TSTRING_IS_STD_STRING +#ifdef TSTRING_IS_STD_STRING using TStorage = TStringType; using reference = typename TStorage::reference; -#else +#else using TStdStr = TStdString<TStringType>; using TStorage = TIntrusivePtr<TStdStr, TStringPtrOps<TStdStr>>; using reference = TBasicCharRef<TBasicString>; -#endif +#endif using char_type = TCharType; // TODO: DROP using value_type = TCharType; using traits_type = TTraits; @@ -188,16 +188,16 @@ public: size_t Size; }; - static size_t max_size() noexcept { + static size_t max_size() noexcept { static size_t res = TStringType().max_size(); return res; } protected: -#ifdef TSTRING_IS_STD_STRING - TStorage Storage_; -#else +#ifdef TSTRING_IS_STD_STRING + TStorage Storage_; +#else TStorage S_; template <typename... A> @@ -259,11 +259,11 @@ public: inline reference operator[](size_t pos) noexcept { Y_ASSERT(pos <= length()); -#ifdef TSTRING_IS_STD_STRING - return Storage_[pos]; -#else +#ifdef TSTRING_IS_STD_STRING + return Storage_[pos]; +#else return reference(*this, pos); -#endif +#endif } using TBase::back; @@ -271,15 +271,15 @@ public: inline reference back() noexcept { Y_ASSERT(!this->empty()); -#ifdef TSTRING_IS_STD_STRING - return Storage_.back(); -#else +#ifdef TSTRING_IS_STD_STRING + return Storage_.back(); +#else if (Y_UNLIKELY(this->empty())) { return reference(*this, 0); } return reference(*this, length() - 1); -#endif +#endif } using TBase::front; @@ -287,11 +287,11 @@ public: inline reference front() noexcept { Y_ASSERT(!this->empty()); -#ifdef TSTRING_IS_STD_STRING - return Storage_.front(); -#else +#ifdef TSTRING_IS_STD_STRING + return Storage_.front(); +#else return reference(*this, 0); -#endif +#endif } inline size_t length() const noexcept { @@ -333,80 +333,80 @@ public: using TBase::rend; //!< const_reverse_iterator TStringBase::rend() const inline size_t capacity() const noexcept { -#ifdef TSTRING_IS_STD_STRING - return Storage_.capacity(); -#else +#ifdef TSTRING_IS_STD_STRING + return Storage_.capacity(); +#else if (S_->IsNull()) { return 0; } return S_->capacity(); -#endif +#endif } TCharType* Detach() { -#ifdef TSTRING_IS_STD_STRING - return Storage_.data(); -#else +#ifdef TSTRING_IS_STD_STRING + return Storage_.data(); +#else if (Y_UNLIKELY(!IsDetached())) { Clone(); } return (TCharType*)S_->data(); -#endif +#endif } bool IsDetached() const { -#ifdef TSTRING_IS_STD_STRING - return true; -#else +#ifdef TSTRING_IS_STD_STRING + return true; +#else return 1 == RefCount(); -#endif +#endif } // ~~~ Size and capacity ~~~ TBasicString& resize(size_t n, TCharType c = ' ') { // remove or append MutRef().resize(n, c); - - return *this; + + return *this; } // ~~~ Constructor ~~~ : FAMILY0(,TBasicString) TBasicString() noexcept -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING : S_(Construct()) -#endif +#endif { } inline explicit TBasicString(::NDetail::TReserveTag rt) -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING : S_(Construct()) -#endif +#endif { reserve(rt.Capacity); } inline TBasicString(const TBasicString& s) -#ifdef TSTRING_IS_STD_STRING - : Storage_(s.Storage_) -#else +#ifdef TSTRING_IS_STD_STRING + : Storage_(s.Storage_) +#else : S_(s.S_) -#endif +#endif { } inline TBasicString(TBasicString&& s) noexcept -#ifdef TSTRING_IS_STD_STRING - : Storage_(std::move(s.Storage_)) -#else +#ifdef TSTRING_IS_STD_STRING + : Storage_(std::move(s.Storage_)) +#else : S_(Construct()) -#endif +#endif { #ifdef TSTRING_IS_STD_STRING #else s.swap(*this); -#endif +#endif } template <typename T, typename A> @@ -426,41 +426,41 @@ public: } TBasicString(const TBasicString& s, size_t pos, size_t n) Y_NOEXCEPT -#ifdef TSTRING_IS_STD_STRING - : Storage_(s.Storage_, pos, n) +#ifdef TSTRING_IS_STD_STRING + : Storage_(s.Storage_, pos, n) #else : S_(n ? Construct(s, pos, n) : Construct()) -#endif - { +#endif + { } - TBasicString(const TCharType* pc) + TBasicString(const TCharType* pc) : TBasicString(pc, TBase::StrLen(pc)) - { + { } // TODO thegeorg@: uncomment and fix clients // TBasicString(std::nullptr_t) = delete; - TBasicString(const TCharType* pc, size_t n) -#ifdef TSTRING_IS_STD_STRING - : Storage_(pc, n) + TBasicString(const TCharType* pc, size_t n) +#ifdef TSTRING_IS_STD_STRING + : Storage_(pc, n) #else : S_(n ? Construct(pc, n) : Construct()) -#endif - { +#endif + { } TBasicString(std::nullptr_t, size_t) = delete; - TBasicString(const TCharType* pc, size_t pos, size_t n) + TBasicString(const TCharType* pc, size_t pos, size_t n) : TBasicString(pc + pos, n) - { + { } #ifdef TSTRING_IS_STD_STRING explicit TBasicString(TExplicitType<TCharType> c) { - Storage_.push_back(c); + Storage_.push_back(c); } -#else +#else explicit TBasicString(TExplicitType<TCharType> c) : TBasicString(&c.Value(), 1) { @@ -469,15 +469,15 @@ public: : TBasicString(&c, 1) { } -#endif +#endif - TBasicString(size_t n, TCharType c) -#ifdef TSTRING_IS_STD_STRING - : Storage_(n, c) + TBasicString(size_t n, TCharType c) +#ifdef TSTRING_IS_STD_STRING + : Storage_(n, c) #else : S_(Construct(n, c)) -#endif - { +#endif + { } /** @@ -489,13 +489,13 @@ public: TBasicString(TUninitialized uninitialized) { #if !defined(TSTRING_IS_STD_STRING) S_ = Construct(); -#endif +#endif ReserveAndResize(uninitialized.Size); } - TBasicString(const TCharType* b, const TCharType* e) + TBasicString(const TCharType* b, const TCharType* e) : TBasicString(b, e - b) - { + { } explicit TBasicString(const TBasicStringBuf<TCharType, TTraits> s) @@ -504,14 +504,14 @@ public: } template <typename Traits> - explicit inline TBasicString(const std::basic_string_view<TCharType, Traits>& s) + explicit inline TBasicString(const std::basic_string_view<TCharType, Traits>& s) : TBasicString(s.data(), s.size()) - { + { } /** - * WARN: - * Certain invocations of this method will result in link-time error. + * WARN: + * Certain invocations of this method will result in link-time error. * You are free to implement corresponding methods in string.cpp if you need them. */ static TBasicString FromAscii(const ::TStringBuf& s) { @@ -562,9 +562,9 @@ private: public: inline void clear() noexcept { -#ifdef TSTRING_IS_STD_STRING - Storage_.clear(); -#else +#ifdef TSTRING_IS_STD_STRING + Storage_.clear(); +#else if (IsDetached()) { S_->clear(); @@ -572,7 +572,7 @@ public: } Construct().Swap(S_); -#endif +#endif } template <typename... R> @@ -655,8 +655,8 @@ public: } /** - * WARN: - * Certain invocations of this method will result in link-time error. + * WARN: + * Certain invocations of this method will result in link-time error. * You are free to implement corresponding methods in string.cpp if you need them. */ auto AssignAscii(const ::TStringBuf& s) { @@ -720,20 +720,20 @@ public: inline TBasicString& append(const TBasicString& s) { MutRef().append(s.ConstRef()); - - return *this; + + return *this; } inline TBasicString& append(const TBasicString& s, size_t pos, size_t n) { MutRef().append(s.ConstRef(), pos, n); - - return *this; + + return *this; } inline TBasicString& append(const TCharType* pc) Y_NOEXCEPT { MutRef().append(pc); - - return *this; + + return *this; } inline TBasicString& append(TCharType c) { @@ -744,14 +744,14 @@ public: inline TBasicString& append(const TCharType* first, const TCharType* last) { MutRef().append(first, last); - - return *this; + + return *this; } inline TBasicString& append(const TCharType* pc, size_t len) { MutRef().append(pc, len); - - return *this; + + return *this; } inline void ReserveAndResize(size_t len) { @@ -786,12 +786,12 @@ public: } TBasicString& append(const TCharType* pc, size_t pos, size_t n, size_t pc_len = TBase::npos) { - return append(pc + pos, Min(n, pc_len - pos)); + return append(pc + pos, Min(n, pc_len - pos)); } /** - * WARN: - * Certain invocations of this method will result in link-time error. + * WARN: + * Certain invocations of this method will result in link-time error. * You are free to implement corresponding methods in string.cpp if you need them. */ TBasicString& AppendAscii(const ::TStringBuf& s); @@ -836,8 +836,8 @@ public: operator const TStringType&() const noexcept { return this->ConstRef(); - } - + } + operator TStringType&() { return this->MutRef(); } @@ -879,7 +879,7 @@ public: s2.prepend(s1); return std::move(s2); } -#endif +#endif s1 += s2; return std::move(s1); } @@ -948,32 +948,32 @@ public: // ~~~ Prepending ~~~ : FAMILY0(TBasicString&, prepend); TBasicString& prepend(const TBasicString& s) { MutRef().insert(0, s.ConstRef()); - - return *this; + + return *this; } TBasicString& prepend(const TBasicString& s, size_t pos, size_t n) { MutRef().insert(0, s.ConstRef(), pos, n); - - return *this; + + return *this; } TBasicString& prepend(const TCharType* pc) { MutRef().insert(0, pc); - - return *this; + + return *this; } TBasicString& prepend(size_t n, TCharType c) { MutRef().insert(size_t(0), n, c); - - return *this; + + return *this; } TBasicString& prepend(TCharType c) { MutRef().insert(size_t(0), 1, c); - - return *this; + + return *this; } TBasicString& prepend(const TBasicStringBuf<TCharType, TTraits> s, size_t spos = 0, size_t sn = TBase::npos) { @@ -983,42 +983,42 @@ public: // ~~~ Insertion ~~~ : FAMILY1(TBasicString&, insert, size_t pos); TBasicString& insert(size_t pos, const TBasicString& s) { MutRef().insert(pos, s.ConstRef()); - - return *this; + + return *this; } TBasicString& insert(size_t pos, const TBasicString& s, size_t pos1, size_t n1) { MutRef().insert(pos, s.ConstRef(), pos1, n1); - - return *this; + + return *this; } TBasicString& insert(size_t pos, const TCharType* pc) { MutRef().insert(pos, pc); - - return *this; + + return *this; } TBasicString& insert(size_t pos, const TCharType* pc, size_t len) { MutRef().insert(pos, pc, len); - - return *this; + + return *this; } TBasicString& insert(const_iterator pos, const_iterator b, const_iterator e) { -#ifdef TSTRING_IS_STD_STRING - Storage_.insert(Storage_.begin() + this->off(pos), b, e); - - return *this; -#else +#ifdef TSTRING_IS_STD_STRING + Storage_.insert(Storage_.begin() + this->off(pos), b, e); + + return *this; +#else return insert(this->off(pos), b, e - b); -#endif +#endif } TBasicString& insert(size_t pos, size_t n, TCharType c) { MutRef().insert(pos, n, c); - - return *this; + + return *this; } TBasicString& insert(const_iterator pos, size_t len, TCharType ch) { @@ -1031,8 +1031,8 @@ public: TBasicString& insert(size_t pos, const TBasicStringBuf<TCharType, TTraits> s, size_t spos = 0, size_t sn = TBase::npos) { MutRef().insert(pos, s, spos, sn); - - return *this; + + return *this; } // ~~~ Removing ~~~ @@ -1040,8 +1040,8 @@ public: if (pos < length()) { MutRef().erase(pos, n); } - - return *this; + + return *this; } TBasicString& remove(size_t pos = 0) Y_NOEXCEPT { @@ -1054,8 +1054,8 @@ public: TBasicString& erase(size_t pos = 0, size_t n = TBase::npos) Y_NOEXCEPT { MutRef().erase(pos, n); - - return *this; + + return *this; } TBasicString& erase(const_iterator b, const_iterator e) Y_NOEXCEPT { @@ -1068,10 +1068,10 @@ public: TBasicString& pop_back() Y_NOEXCEPT { Y_ASSERT(!this->empty()); - + MutRef().pop_back(); - return *this; + return *this; } // ~~~ replacement ~~~ : FAMILY2(TBasicString&, replace, size_t pos, size_t n); @@ -1118,11 +1118,11 @@ public: } void swap(TBasicString& s) noexcept { -#ifdef TSTRING_IS_STD_STRING - std::swap(Storage_, s.Storage_); -#else +#ifdef TSTRING_IS_STD_STRING + std::swap(Storage_, s.Storage_); +#else S_.Swap(s.S_); -#endif +#endif } /** @@ -1166,15 +1166,15 @@ public: bool changed = false; for (size_t i = pos; i != pos + n; ++i) { -#ifdef TSTRING_IS_STD_STRING - auto c = f(i, Storage_[i]); - - if (c != Storage_[i]) { - changed = true; - - Storage_[i] = c; - } -#else +#ifdef TSTRING_IS_STD_STRING + auto c = f(i, Storage_[i]); + + if (c != Storage_[i]) { + changed = true; + + Storage_[i] = c; + } +#else auto c = f(i, data()[i]); if (c != data()[i]) { if (!changed) { @@ -1184,7 +1184,7 @@ public: begin()[i] = c; } -#endif +#endif } return changed; @@ -1221,7 +1221,7 @@ namespace std { using argument_type = TString; using result_type = size_t; inline result_type operator()(argument_type const& s) const noexcept { - return NHashPrivate::ComputeStringHash(s.data(), s.size()); + return NHashPrivate::ComputeStringHash(s.data(), s.size()); } }; } diff --git a/util/generic/string_hash.h b/util/generic/string_hash.h index b949c7a2d9..23f1798c68 100644 --- a/util/generic/string_hash.h +++ b/util/generic/string_hash.h @@ -1,21 +1,21 @@ -#pragma once - -#include <cstddef> - -// reduce code bloat and cycled includes, declare functions here -#if defined(_64_) && !defined(NO_CITYHASH) -ui64 CityHash64(const char* buf, size_t len) noexcept; -#else -size_t MurmurHashSizeT(const char* buf, size_t len) noexcept; -#endif - -namespace NHashPrivate { - template <typename C> - size_t ComputeStringHash(const C* ptr, size_t size) noexcept { -#if defined(_64_) && !defined(NO_CITYHASH) +#pragma once + +#include <cstddef> + +// reduce code bloat and cycled includes, declare functions here +#if defined(_64_) && !defined(NO_CITYHASH) +ui64 CityHash64(const char* buf, size_t len) noexcept; +#else +size_t MurmurHashSizeT(const char* buf, size_t len) noexcept; +#endif + +namespace NHashPrivate { + template <typename C> + size_t ComputeStringHash(const C* ptr, size_t size) noexcept { +#if defined(_64_) && !defined(NO_CITYHASH) return CityHash64((const char*)ptr, size * sizeof(C)); -#else +#else return MurmurHashSizeT((const char*)ptr, size * sizeof(C)); -#endif - } -} +#endif + } +} diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index ac82e9091d..c5f3531fa6 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -1,24 +1,24 @@ #include "deque.h" -#include "strbuf.h" -#include "string_ut.h" +#include "strbuf.h" +#include "string_ut.h" #include "vector.h" #include "yexception.h" #include <util/charset/wide.h> #include <util/str_stl.h> -#include <util/stream/output.h> -#include <util/string/subst.h> +#include <util/stream/output.h> +#include <util/string/subst.h> #include <string> #include <sstream> #include <algorithm> #include <stdexcept> -#ifdef TSTRING_IS_STD_STRING -static_assert(sizeof(TString) == sizeof(std::string), "expect sizeof(TString) == sizeof(std::string)"); -#else +#ifdef TSTRING_IS_STD_STRING +static_assert(sizeof(TString) == sizeof(std::string), "expect sizeof(TString) == sizeof(std::string)"); +#else static_assert(sizeof(TString) == sizeof(const char*), "expect sizeof(TString) == sizeof(const char*)"); -#endif +#endif class TStringTestZero: public TTestBase { UNIT_TEST_SUITE(TStringTestZero); @@ -50,7 +50,7 @@ public: TString copy = s; copy.replace(copy.size() - 1, 1, "z"); UNIT_ASSERT(s != copy); - copy.replace(copy.size() - 1, 1, "\0", 0, 1); + copy.replace(copy.size() - 1, 1, "\0", 0, 1); UNIT_ASSERT(s == copy); TString prefix(data, 5); @@ -70,9 +70,9 @@ UNIT_TEST_SUITE_REGISTRATION(TStringTestZero); template <typename TStringType, typename TTestData> class TStringStdTestImpl { - using TChar = typename TStringType::char_type; - using TTraits = typename TStringType::traits_type; - using TView = std::basic_string_view<TChar, TTraits>; + using TChar = typename TStringType::char_type; + using TTraits = typename TStringType::traits_type; + using TView = std::basic_string_view<TChar, TTraits>; TTestData Data_; @@ -121,7 +121,7 @@ protected: s.reserve(10); #ifdef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.capacity() >= 64); + UNIT_ASSERT(s.capacity() >= 64); #else UNIT_ASSERT(s.capacity() >= 256 && s.data() == data); #endif @@ -147,7 +147,7 @@ protected: UNIT_ASSERT(s.capacity() >= 64 && s.capacity() < 128 && s.data() != data); UNIT_ASSERT(s.IsDetached()); #endif -#endif +#endif } void short_string() { @@ -511,7 +511,7 @@ protected: void copy() { TStringType s(Data_.foo()); - TChar dest[4]; + TChar dest[4]; dest[0] = dest[1] = dest[2] = dest[3] = 1; s.copy(dest, 4); int pos = 0; @@ -712,7 +712,7 @@ protected: UNIT_ASSERT(str == Data.This_This_is_test_StringT_for_StringT_calls()); #if !defined(STLPORT) || defined(_STLP_MEMBER_TEMPLATES) - deque<TChar> cdeque; + deque<TChar> cdeque; cdeque.push_back(*Data.I()); str.replace(str.begin(), str.begin() + 11, cdeque.begin(), cdeque.end()); UNIT_ASSERT(str == Data.Is_test_StringT_for_StringT_calls()); @@ -727,9 +727,9 @@ public: UNIT_TEST(TestMaxSize); UNIT_TEST(TestConstructors); UNIT_TEST(TestReplace); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestRefCount); -#endif +#endif UNIT_TEST(TestFind); UNIT_TEST(TestContains); UNIT_TEST(TestOperators); @@ -741,9 +741,9 @@ public: UNIT_TEST(TestCopy); UNIT_TEST(TestStrCpy); UNIT_TEST(TestPrefixSuffix); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestCharRef); -#endif +#endif UNIT_TEST(TestBack) UNIT_TEST(TestFront) UNIT_TEST(TestIterators); @@ -788,9 +788,9 @@ public: UNIT_TEST_SUITE(TWideStringTest); UNIT_TEST(TestConstructors); UNIT_TEST(TestReplace); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestRefCount); -#endif +#endif UNIT_TEST(TestFind); UNIT_TEST(TestContains); UNIT_TEST(TestOperators); @@ -803,9 +803,9 @@ public: UNIT_TEST(TestCopy); UNIT_TEST(TestStrCpy); UNIT_TEST(TestPrefixSuffix); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestCharRef); -#endif +#endif UNIT_TEST(TestBack); UNIT_TEST(TestFront) UNIT_TEST(TestDecodingMethods); @@ -912,9 +912,9 @@ public: UNIT_TEST_SUITE(TUtf32StringTest); UNIT_TEST(TestConstructors); UNIT_TEST(TestReplace); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestRefCount); -#endif +#endif UNIT_TEST(TestFind); UNIT_TEST(TestContains); UNIT_TEST(TestOperators); @@ -927,9 +927,9 @@ public: UNIT_TEST(TestCopy); UNIT_TEST(TestStrCpy); UNIT_TEST(TestPrefixSuffix); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestCharRef); -#endif +#endif UNIT_TEST(TestBack); UNIT_TEST(TestFront) UNIT_TEST(TestDecodingMethods); diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdeb..1f5255d4fe 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -1,513 +1,513 @@ -#pragma once - +#pragma once + #include "string.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/string/reverse.h> - -template <typename CharT, size_t N> -struct TCharBuffer { - CharT Data[N]; - //! copies characters from string to the internal buffer without any conversion - //! @param s a string that must contain only characters less than 0x7F - explicit TCharBuffer(const char* s) { - // copy all symbols including null terminated symbol - for (size_t i = 0; i < N; ++i) { - Data[i] = s[i]; - } - } - const CharT* GetData() const { - return Data; - } -}; - -template <> -struct TCharBuffer<char, 0> { - const char* Data; - //! stores pointer to string - explicit TCharBuffer(const char* s) - : Data(s) - { - } - const char* GetData() const { - return Data; - } -}; - -#define DECLARE_AND_RETURN_BUFFER(s) \ - static TCharBuffer<CharT, sizeof(s)> buf(s); \ - return buf.GetData(); - -//! @attention this class can process characters less than 0x7F only (the low half of ASCII table) -template <typename CharT> -struct TTestData { - // words - const CharT* str1() { - DECLARE_AND_RETURN_BUFFER("str1"); - } - const CharT* str2() { - DECLARE_AND_RETURN_BUFFER("str2"); - } - const CharT* str__________________________________________________1() { - DECLARE_AND_RETURN_BUFFER("str 1"); - } - const CharT* str__________________________________________________2() { - DECLARE_AND_RETURN_BUFFER("str 2"); - } - const CharT* one() { - DECLARE_AND_RETURN_BUFFER("one"); - } - const CharT* two() { - DECLARE_AND_RETURN_BUFFER("two"); - } - const CharT* three() { - DECLARE_AND_RETURN_BUFFER("three"); - } - const CharT* thrii() { - DECLARE_AND_RETURN_BUFFER("thrii"); - } - const CharT* four() { - DECLARE_AND_RETURN_BUFFER("four"); - } - const CharT* enotw_() { - DECLARE_AND_RETURN_BUFFER("enotw "); - } - const CharT* foo() { - DECLARE_AND_RETURN_BUFFER("foo"); - } - const CharT* abcdef() { - DECLARE_AND_RETURN_BUFFER("abcdef"); - } - const CharT* abcdefg() { - DECLARE_AND_RETURN_BUFFER("abcdefg"); - } - const CharT* aba() { - DECLARE_AND_RETURN_BUFFER("aba"); - } - const CharT* hr() { - DECLARE_AND_RETURN_BUFFER("hr"); - } - const CharT* hrt() { - DECLARE_AND_RETURN_BUFFER("hrt"); - } - const CharT* thr() { - DECLARE_AND_RETURN_BUFFER("thr"); - } - const CharT* tw() { - DECLARE_AND_RETURN_BUFFER("tw"); - } - const CharT* ow() { - DECLARE_AND_RETURN_BUFFER("ow"); - } - const CharT* opq() { - DECLARE_AND_RETURN_BUFFER("opq"); - } - const CharT* xyz() { - DECLARE_AND_RETURN_BUFFER("xyz"); - } - const CharT* abc() { - DECLARE_AND_RETURN_BUFFER("abc"); - } - const CharT* abcd() { - DECLARE_AND_RETURN_BUFFER("abcd"); - } - const CharT* abcde() { - DECLARE_AND_RETURN_BUFFER("abcde"); - } - const CharT* abcc() { - DECLARE_AND_RETURN_BUFFER("abcc"); - } - const CharT* abce() { - DECLARE_AND_RETURN_BUFFER("abce"); - } - const CharT* qwe() { - DECLARE_AND_RETURN_BUFFER("qwe"); - } - const CharT* cd() { - DECLARE_AND_RETURN_BUFFER("cd"); - } - const CharT* cde() { - DECLARE_AND_RETURN_BUFFER("cde"); - } - const CharT* cdef() { - DECLARE_AND_RETURN_BUFFER("cdef"); - } - const CharT* cdefgh() { - DECLARE_AND_RETURN_BUFFER("cdefgh"); - } - const CharT* ehortw_() { - DECLARE_AND_RETURN_BUFFER("ehortw "); - } - const CharT* fg() { - DECLARE_AND_RETURN_BUFFER("fg"); - } - const CharT* abcdefgh() { - DECLARE_AND_RETURN_BUFFER("abcdefgh"); - } - - // phrases - const CharT* Hello_World() { - DECLARE_AND_RETURN_BUFFER("Hello World"); - } - const CharT* This_is_test_string_for_string_calls() { - DECLARE_AND_RETURN_BUFFER("This is test string for string calls"); - } - const CharT* This_is_teis_test_string_st_string_for_string_calls() { - DECLARE_AND_RETURN_BUFFER("This is teis test string st string for string calls"); - } - const CharT* This_is_test_stis_test_string_for_stringring_for_string_calls() { - DECLARE_AND_RETURN_BUFFER("This is test stis test string for stringring for string calls"); - } - const CharT* allsThis_is_test_string_for_string_calls() { - DECLARE_AND_RETURN_BUFFER("allsThis is test string for string calls"); - } - const CharT* ng_for_string_callsThis_is_test_string_for_string_calls() { - DECLARE_AND_RETURN_BUFFER("ng for string callsThis is test string for string calls"); - } - const CharT* one_two_three_one_two_three() { - DECLARE_AND_RETURN_BUFFER("one two three one two three"); - } - const CharT* test_string_for_assign() { - DECLARE_AND_RETURN_BUFFER("test string for assign"); - } - const CharT* other_test_string() { - DECLARE_AND_RETURN_BUFFER("other test string"); - } - const CharT* This_This_is_tefor_string_calls() { - DECLARE_AND_RETURN_BUFFER("This This is tefor string calls"); - } - const CharT* This_This_is_test_string_for_string_calls() { - DECLARE_AND_RETURN_BUFFER("This This is test string for string calls"); - } - - const CharT* _0123456x() { - DECLARE_AND_RETURN_BUFFER("0123456x"); - } - const CharT* _0123456xy() { - DECLARE_AND_RETURN_BUFFER("0123456xy"); - } - const CharT* _0123456xyz() { - DECLARE_AND_RETURN_BUFFER("0123456xyz"); - } - const CharT* _0123456xyzZ() { - DECLARE_AND_RETURN_BUFFER("0123456xyzZ"); - } - const CharT* _0123456xyzZ0() { - DECLARE_AND_RETURN_BUFFER("0123456xyzZ0"); - } - const CharT* abc0123456xyz() { - DECLARE_AND_RETURN_BUFFER("abc0123456xyz"); - } - const CharT* BCabc0123456xyz() { - DECLARE_AND_RETURN_BUFFER("BCabc0123456xyz"); - } - const CharT* qweBCabc0123456xyz() { - DECLARE_AND_RETURN_BUFFER("qweBCabc0123456xyz"); - } - const CharT* _1qweBCabc0123456xyz() { - DECLARE_AND_RETURN_BUFFER("1qweBCabc0123456xyz"); - } - const CharT* _01abc23456() { - DECLARE_AND_RETURN_BUFFER("01abc23456"); - } - const CharT* _01ABCabc23456() { - DECLARE_AND_RETURN_BUFFER("01ABCabc23456"); - } - const CharT* ABC() { - DECLARE_AND_RETURN_BUFFER("ABC"); - } - const CharT* ABCD() { - DECLARE_AND_RETURN_BUFFER("ABCD"); - } - const CharT* QWE() { - DECLARE_AND_RETURN_BUFFER("QWE"); - } - const CharT* XYZ() { - DECLARE_AND_RETURN_BUFFER("XYZ"); - } - const CharT* W01ABCabc23456() { - DECLARE_AND_RETURN_BUFFER("W01ABCabc23456"); - } - const CharT* abcd456() { - DECLARE_AND_RETURN_BUFFER("abcd456"); - } - const CharT* abcdABCD() { - DECLARE_AND_RETURN_BUFFER("abcdABCD"); - } - const CharT* abcdABC123() { - DECLARE_AND_RETURN_BUFFER("abcdABC123"); - } - const CharT* z123z123() { - DECLARE_AND_RETURN_BUFFER("z123z123"); - } - const CharT* ASDF1234QWER() { - DECLARE_AND_RETURN_BUFFER("ASDF1234QWER"); - } - const CharT* asdf1234qwer() { - DECLARE_AND_RETURN_BUFFER("asdf1234qwer"); - } - const CharT* asDF1234qWEr() { - DECLARE_AND_RETURN_BUFFER("asDF1234qWEr"); - } - const CharT* AsDF1234qWEr() { - DECLARE_AND_RETURN_BUFFER("AsDF1234qWEr"); - } - const CharT* Asdf1234qwer() { - DECLARE_AND_RETURN_BUFFER("Asdf1234qwer"); - } - const CharT* Asdf1234qwerWWWW() { - DECLARE_AND_RETURN_BUFFER("Asdf1234qwerWWWW"); - } - const CharT* Asdf() { - DECLARE_AND_RETURN_BUFFER("Asdf"); - } - const CharT* orig() { - DECLARE_AND_RETURN_BUFFER("orig"); - } - const CharT* fdfdsfds() { - DECLARE_AND_RETURN_BUFFER("fdfdsfds"); - } - - // numbers - const CharT* _0() { - DECLARE_AND_RETURN_BUFFER("0"); - } - const CharT* _00() { - DECLARE_AND_RETURN_BUFFER("00"); - } - const CharT* _0000000000() { - DECLARE_AND_RETURN_BUFFER("0000000000"); - } - const CharT* _00000() { - DECLARE_AND_RETURN_BUFFER("00000"); - } - const CharT* _0123() { - DECLARE_AND_RETURN_BUFFER("0123"); - } - const CharT* _01230123() { - DECLARE_AND_RETURN_BUFFER("01230123"); - } - const CharT* _01234() { - DECLARE_AND_RETURN_BUFFER("01234"); - } - const CharT* _0123401234() { - DECLARE_AND_RETURN_BUFFER("0123401234"); - } - const CharT* _012345() { - DECLARE_AND_RETURN_BUFFER("012345"); - } - const CharT* _0123456() { - DECLARE_AND_RETURN_BUFFER("0123456"); - } - const CharT* _1() { - DECLARE_AND_RETURN_BUFFER("1"); - } - const CharT* _11() { - DECLARE_AND_RETURN_BUFFER("11"); - } - const CharT* _1100000() { - DECLARE_AND_RETURN_BUFFER("1100000"); - } - const CharT* _110000034() { - DECLARE_AND_RETURN_BUFFER("110000034"); - } - const CharT* _12() { - DECLARE_AND_RETURN_BUFFER("12"); - } - const CharT* _123() { - DECLARE_AND_RETURN_BUFFER("123"); - } - const CharT* _1233321() { - DECLARE_AND_RETURN_BUFFER("1233321"); - } - const CharT* _1221() { - DECLARE_AND_RETURN_BUFFER("1221"); - } - const CharT* _1234123456() { - DECLARE_AND_RETURN_BUFFER("1234123456"); - } - const CharT* _12334444321() { - DECLARE_AND_RETURN_BUFFER("12334444321"); - } - const CharT* _123344544321() { - DECLARE_AND_RETURN_BUFFER("123344544321"); - } - const CharT* _1234567890123456789012345678901234567890() { - DECLARE_AND_RETURN_BUFFER("1234567890123456789012345678901234567890"); - } - const CharT* _1234() { - DECLARE_AND_RETURN_BUFFER("1234"); - } - const CharT* _12345() { - DECLARE_AND_RETURN_BUFFER("12345"); - } - const CharT* _123456() { - DECLARE_AND_RETURN_BUFFER("123456"); - } - const CharT* _1234567() { - DECLARE_AND_RETURN_BUFFER("1234567"); - } - const CharT* _1234561234() { - DECLARE_AND_RETURN_BUFFER("1234561234"); - } - const CharT* _12356() { - DECLARE_AND_RETURN_BUFFER("12356"); - } - const CharT* _1345656() { - DECLARE_AND_RETURN_BUFFER("1345656"); - } - const CharT* _15656() { - DECLARE_AND_RETURN_BUFFER("15656"); - } - const CharT* _17856() { - DECLARE_AND_RETURN_BUFFER("17856"); - } - const CharT* _1783456() { - DECLARE_AND_RETURN_BUFFER("1783456"); - } - const CharT* _2() { - DECLARE_AND_RETURN_BUFFER("2"); - } - const CharT* _2123456() { - DECLARE_AND_RETURN_BUFFER("2123456"); - } - const CharT* _23() { - DECLARE_AND_RETURN_BUFFER("23"); - } - const CharT* _2345() { - DECLARE_AND_RETURN_BUFFER("2345"); - } - const CharT* _3() { - DECLARE_AND_RETURN_BUFFER("3"); - } - const CharT* _345() { - DECLARE_AND_RETURN_BUFFER("345"); - } - const CharT* _3456() { - DECLARE_AND_RETURN_BUFFER("3456"); - } - const CharT* _333333() { - DECLARE_AND_RETURN_BUFFER("333333"); - } - const CharT* _389() { - DECLARE_AND_RETURN_BUFFER("389"); - } - const CharT* _4294967295() { - DECLARE_AND_RETURN_BUFFER("4294967295"); - } - const CharT* _4444() { - DECLARE_AND_RETURN_BUFFER("4444"); - } - const CharT* _5() { - DECLARE_AND_RETURN_BUFFER("5"); - } - const CharT* _6() { - DECLARE_AND_RETURN_BUFFER("6"); - } - const CharT* _6543210() { - DECLARE_AND_RETURN_BUFFER("6543210"); - } - const CharT* _7() { - DECLARE_AND_RETURN_BUFFER("7"); - } - const CharT* _78() { - DECLARE_AND_RETURN_BUFFER("78"); - } - const CharT* _2004_01_01() { - DECLARE_AND_RETURN_BUFFER("2004-01-01"); - } - const CharT* _1234562004_01_01() { - DECLARE_AND_RETURN_BUFFER("1234562004-01-01"); - } - const CharT* _0123456_12345() { - DECLARE_AND_RETURN_BUFFER("0123456_12345"); - } - - // letters - const CharT* a() { - DECLARE_AND_RETURN_BUFFER("a"); - } - const CharT* b() { - DECLARE_AND_RETURN_BUFFER("b"); - } - const CharT* c() { - DECLARE_AND_RETURN_BUFFER("c"); - } - const CharT* d() { - DECLARE_AND_RETURN_BUFFER("d"); - } - const CharT* e() { - DECLARE_AND_RETURN_BUFFER("e"); - } - const CharT* f() { - DECLARE_AND_RETURN_BUFFER("f"); - } - const CharT* h() { - DECLARE_AND_RETURN_BUFFER("h"); - } - const CharT* o() { - DECLARE_AND_RETURN_BUFFER("o"); - } - const CharT* p() { - DECLARE_AND_RETURN_BUFFER("p"); - } - const CharT* q() { - DECLARE_AND_RETURN_BUFFER("q"); - } - const CharT* r() { - DECLARE_AND_RETURN_BUFFER("r"); - } - const CharT* s() { - DECLARE_AND_RETURN_BUFFER("s"); - } - const CharT* t() { - DECLARE_AND_RETURN_BUFFER("t"); - } - const CharT* w() { - DECLARE_AND_RETURN_BUFFER("w"); - } - const CharT* x() { - DECLARE_AND_RETURN_BUFFER("x"); - } - const CharT* y() { - DECLARE_AND_RETURN_BUFFER("y"); - } - const CharT* z() { - DECLARE_AND_RETURN_BUFFER("z"); - } - const CharT* H() { - DECLARE_AND_RETURN_BUFFER("H"); - } - const CharT* I() { - DECLARE_AND_RETURN_BUFFER("I"); - } - const CharT* W() { - DECLARE_AND_RETURN_BUFFER("W"); - } - - const CharT* Space() { - DECLARE_AND_RETURN_BUFFER(" "); - } - const CharT* Empty() { - DECLARE_AND_RETURN_BUFFER(""); - } - - size_t HashOf_0123456() { - return 0; - } -}; - -template <> -size_t TTestData<char>::HashOf_0123456() { - return 1229863857ul; -} - -template <> -size_t TTestData<wchar16>::HashOf_0123456() { - return 2775195331ul; -} - +#include <util/string/reverse.h> + +template <typename CharT, size_t N> +struct TCharBuffer { + CharT Data[N]; + //! copies characters from string to the internal buffer without any conversion + //! @param s a string that must contain only characters less than 0x7F + explicit TCharBuffer(const char* s) { + // copy all symbols including null terminated symbol + for (size_t i = 0; i < N; ++i) { + Data[i] = s[i]; + } + } + const CharT* GetData() const { + return Data; + } +}; + +template <> +struct TCharBuffer<char, 0> { + const char* Data; + //! stores pointer to string + explicit TCharBuffer(const char* s) + : Data(s) + { + } + const char* GetData() const { + return Data; + } +}; + +#define DECLARE_AND_RETURN_BUFFER(s) \ + static TCharBuffer<CharT, sizeof(s)> buf(s); \ + return buf.GetData(); + +//! @attention this class can process characters less than 0x7F only (the low half of ASCII table) +template <typename CharT> +struct TTestData { + // words + const CharT* str1() { + DECLARE_AND_RETURN_BUFFER("str1"); + } + const CharT* str2() { + DECLARE_AND_RETURN_BUFFER("str2"); + } + const CharT* str__________________________________________________1() { + DECLARE_AND_RETURN_BUFFER("str 1"); + } + const CharT* str__________________________________________________2() { + DECLARE_AND_RETURN_BUFFER("str 2"); + } + const CharT* one() { + DECLARE_AND_RETURN_BUFFER("one"); + } + const CharT* two() { + DECLARE_AND_RETURN_BUFFER("two"); + } + const CharT* three() { + DECLARE_AND_RETURN_BUFFER("three"); + } + const CharT* thrii() { + DECLARE_AND_RETURN_BUFFER("thrii"); + } + const CharT* four() { + DECLARE_AND_RETURN_BUFFER("four"); + } + const CharT* enotw_() { + DECLARE_AND_RETURN_BUFFER("enotw "); + } + const CharT* foo() { + DECLARE_AND_RETURN_BUFFER("foo"); + } + const CharT* abcdef() { + DECLARE_AND_RETURN_BUFFER("abcdef"); + } + const CharT* abcdefg() { + DECLARE_AND_RETURN_BUFFER("abcdefg"); + } + const CharT* aba() { + DECLARE_AND_RETURN_BUFFER("aba"); + } + const CharT* hr() { + DECLARE_AND_RETURN_BUFFER("hr"); + } + const CharT* hrt() { + DECLARE_AND_RETURN_BUFFER("hrt"); + } + const CharT* thr() { + DECLARE_AND_RETURN_BUFFER("thr"); + } + const CharT* tw() { + DECLARE_AND_RETURN_BUFFER("tw"); + } + const CharT* ow() { + DECLARE_AND_RETURN_BUFFER("ow"); + } + const CharT* opq() { + DECLARE_AND_RETURN_BUFFER("opq"); + } + const CharT* xyz() { + DECLARE_AND_RETURN_BUFFER("xyz"); + } + const CharT* abc() { + DECLARE_AND_RETURN_BUFFER("abc"); + } + const CharT* abcd() { + DECLARE_AND_RETURN_BUFFER("abcd"); + } + const CharT* abcde() { + DECLARE_AND_RETURN_BUFFER("abcde"); + } + const CharT* abcc() { + DECLARE_AND_RETURN_BUFFER("abcc"); + } + const CharT* abce() { + DECLARE_AND_RETURN_BUFFER("abce"); + } + const CharT* qwe() { + DECLARE_AND_RETURN_BUFFER("qwe"); + } + const CharT* cd() { + DECLARE_AND_RETURN_BUFFER("cd"); + } + const CharT* cde() { + DECLARE_AND_RETURN_BUFFER("cde"); + } + const CharT* cdef() { + DECLARE_AND_RETURN_BUFFER("cdef"); + } + const CharT* cdefgh() { + DECLARE_AND_RETURN_BUFFER("cdefgh"); + } + const CharT* ehortw_() { + DECLARE_AND_RETURN_BUFFER("ehortw "); + } + const CharT* fg() { + DECLARE_AND_RETURN_BUFFER("fg"); + } + const CharT* abcdefgh() { + DECLARE_AND_RETURN_BUFFER("abcdefgh"); + } + + // phrases + const CharT* Hello_World() { + DECLARE_AND_RETURN_BUFFER("Hello World"); + } + const CharT* This_is_test_string_for_string_calls() { + DECLARE_AND_RETURN_BUFFER("This is test string for string calls"); + } + const CharT* This_is_teis_test_string_st_string_for_string_calls() { + DECLARE_AND_RETURN_BUFFER("This is teis test string st string for string calls"); + } + const CharT* This_is_test_stis_test_string_for_stringring_for_string_calls() { + DECLARE_AND_RETURN_BUFFER("This is test stis test string for stringring for string calls"); + } + const CharT* allsThis_is_test_string_for_string_calls() { + DECLARE_AND_RETURN_BUFFER("allsThis is test string for string calls"); + } + const CharT* ng_for_string_callsThis_is_test_string_for_string_calls() { + DECLARE_AND_RETURN_BUFFER("ng for string callsThis is test string for string calls"); + } + const CharT* one_two_three_one_two_three() { + DECLARE_AND_RETURN_BUFFER("one two three one two three"); + } + const CharT* test_string_for_assign() { + DECLARE_AND_RETURN_BUFFER("test string for assign"); + } + const CharT* other_test_string() { + DECLARE_AND_RETURN_BUFFER("other test string"); + } + const CharT* This_This_is_tefor_string_calls() { + DECLARE_AND_RETURN_BUFFER("This This is tefor string calls"); + } + const CharT* This_This_is_test_string_for_string_calls() { + DECLARE_AND_RETURN_BUFFER("This This is test string for string calls"); + } + + const CharT* _0123456x() { + DECLARE_AND_RETURN_BUFFER("0123456x"); + } + const CharT* _0123456xy() { + DECLARE_AND_RETURN_BUFFER("0123456xy"); + } + const CharT* _0123456xyz() { + DECLARE_AND_RETURN_BUFFER("0123456xyz"); + } + const CharT* _0123456xyzZ() { + DECLARE_AND_RETURN_BUFFER("0123456xyzZ"); + } + const CharT* _0123456xyzZ0() { + DECLARE_AND_RETURN_BUFFER("0123456xyzZ0"); + } + const CharT* abc0123456xyz() { + DECLARE_AND_RETURN_BUFFER("abc0123456xyz"); + } + const CharT* BCabc0123456xyz() { + DECLARE_AND_RETURN_BUFFER("BCabc0123456xyz"); + } + const CharT* qweBCabc0123456xyz() { + DECLARE_AND_RETURN_BUFFER("qweBCabc0123456xyz"); + } + const CharT* _1qweBCabc0123456xyz() { + DECLARE_AND_RETURN_BUFFER("1qweBCabc0123456xyz"); + } + const CharT* _01abc23456() { + DECLARE_AND_RETURN_BUFFER("01abc23456"); + } + const CharT* _01ABCabc23456() { + DECLARE_AND_RETURN_BUFFER("01ABCabc23456"); + } + const CharT* ABC() { + DECLARE_AND_RETURN_BUFFER("ABC"); + } + const CharT* ABCD() { + DECLARE_AND_RETURN_BUFFER("ABCD"); + } + const CharT* QWE() { + DECLARE_AND_RETURN_BUFFER("QWE"); + } + const CharT* XYZ() { + DECLARE_AND_RETURN_BUFFER("XYZ"); + } + const CharT* W01ABCabc23456() { + DECLARE_AND_RETURN_BUFFER("W01ABCabc23456"); + } + const CharT* abcd456() { + DECLARE_AND_RETURN_BUFFER("abcd456"); + } + const CharT* abcdABCD() { + DECLARE_AND_RETURN_BUFFER("abcdABCD"); + } + const CharT* abcdABC123() { + DECLARE_AND_RETURN_BUFFER("abcdABC123"); + } + const CharT* z123z123() { + DECLARE_AND_RETURN_BUFFER("z123z123"); + } + const CharT* ASDF1234QWER() { + DECLARE_AND_RETURN_BUFFER("ASDF1234QWER"); + } + const CharT* asdf1234qwer() { + DECLARE_AND_RETURN_BUFFER("asdf1234qwer"); + } + const CharT* asDF1234qWEr() { + DECLARE_AND_RETURN_BUFFER("asDF1234qWEr"); + } + const CharT* AsDF1234qWEr() { + DECLARE_AND_RETURN_BUFFER("AsDF1234qWEr"); + } + const CharT* Asdf1234qwer() { + DECLARE_AND_RETURN_BUFFER("Asdf1234qwer"); + } + const CharT* Asdf1234qwerWWWW() { + DECLARE_AND_RETURN_BUFFER("Asdf1234qwerWWWW"); + } + const CharT* Asdf() { + DECLARE_AND_RETURN_BUFFER("Asdf"); + } + const CharT* orig() { + DECLARE_AND_RETURN_BUFFER("orig"); + } + const CharT* fdfdsfds() { + DECLARE_AND_RETURN_BUFFER("fdfdsfds"); + } + + // numbers + const CharT* _0() { + DECLARE_AND_RETURN_BUFFER("0"); + } + const CharT* _00() { + DECLARE_AND_RETURN_BUFFER("00"); + } + const CharT* _0000000000() { + DECLARE_AND_RETURN_BUFFER("0000000000"); + } + const CharT* _00000() { + DECLARE_AND_RETURN_BUFFER("00000"); + } + const CharT* _0123() { + DECLARE_AND_RETURN_BUFFER("0123"); + } + const CharT* _01230123() { + DECLARE_AND_RETURN_BUFFER("01230123"); + } + const CharT* _01234() { + DECLARE_AND_RETURN_BUFFER("01234"); + } + const CharT* _0123401234() { + DECLARE_AND_RETURN_BUFFER("0123401234"); + } + const CharT* _012345() { + DECLARE_AND_RETURN_BUFFER("012345"); + } + const CharT* _0123456() { + DECLARE_AND_RETURN_BUFFER("0123456"); + } + const CharT* _1() { + DECLARE_AND_RETURN_BUFFER("1"); + } + const CharT* _11() { + DECLARE_AND_RETURN_BUFFER("11"); + } + const CharT* _1100000() { + DECLARE_AND_RETURN_BUFFER("1100000"); + } + const CharT* _110000034() { + DECLARE_AND_RETURN_BUFFER("110000034"); + } + const CharT* _12() { + DECLARE_AND_RETURN_BUFFER("12"); + } + const CharT* _123() { + DECLARE_AND_RETURN_BUFFER("123"); + } + const CharT* _1233321() { + DECLARE_AND_RETURN_BUFFER("1233321"); + } + const CharT* _1221() { + DECLARE_AND_RETURN_BUFFER("1221"); + } + const CharT* _1234123456() { + DECLARE_AND_RETURN_BUFFER("1234123456"); + } + const CharT* _12334444321() { + DECLARE_AND_RETURN_BUFFER("12334444321"); + } + const CharT* _123344544321() { + DECLARE_AND_RETURN_BUFFER("123344544321"); + } + const CharT* _1234567890123456789012345678901234567890() { + DECLARE_AND_RETURN_BUFFER("1234567890123456789012345678901234567890"); + } + const CharT* _1234() { + DECLARE_AND_RETURN_BUFFER("1234"); + } + const CharT* _12345() { + DECLARE_AND_RETURN_BUFFER("12345"); + } + const CharT* _123456() { + DECLARE_AND_RETURN_BUFFER("123456"); + } + const CharT* _1234567() { + DECLARE_AND_RETURN_BUFFER("1234567"); + } + const CharT* _1234561234() { + DECLARE_AND_RETURN_BUFFER("1234561234"); + } + const CharT* _12356() { + DECLARE_AND_RETURN_BUFFER("12356"); + } + const CharT* _1345656() { + DECLARE_AND_RETURN_BUFFER("1345656"); + } + const CharT* _15656() { + DECLARE_AND_RETURN_BUFFER("15656"); + } + const CharT* _17856() { + DECLARE_AND_RETURN_BUFFER("17856"); + } + const CharT* _1783456() { + DECLARE_AND_RETURN_BUFFER("1783456"); + } + const CharT* _2() { + DECLARE_AND_RETURN_BUFFER("2"); + } + const CharT* _2123456() { + DECLARE_AND_RETURN_BUFFER("2123456"); + } + const CharT* _23() { + DECLARE_AND_RETURN_BUFFER("23"); + } + const CharT* _2345() { + DECLARE_AND_RETURN_BUFFER("2345"); + } + const CharT* _3() { + DECLARE_AND_RETURN_BUFFER("3"); + } + const CharT* _345() { + DECLARE_AND_RETURN_BUFFER("345"); + } + const CharT* _3456() { + DECLARE_AND_RETURN_BUFFER("3456"); + } + const CharT* _333333() { + DECLARE_AND_RETURN_BUFFER("333333"); + } + const CharT* _389() { + DECLARE_AND_RETURN_BUFFER("389"); + } + const CharT* _4294967295() { + DECLARE_AND_RETURN_BUFFER("4294967295"); + } + const CharT* _4444() { + DECLARE_AND_RETURN_BUFFER("4444"); + } + const CharT* _5() { + DECLARE_AND_RETURN_BUFFER("5"); + } + const CharT* _6() { + DECLARE_AND_RETURN_BUFFER("6"); + } + const CharT* _6543210() { + DECLARE_AND_RETURN_BUFFER("6543210"); + } + const CharT* _7() { + DECLARE_AND_RETURN_BUFFER("7"); + } + const CharT* _78() { + DECLARE_AND_RETURN_BUFFER("78"); + } + const CharT* _2004_01_01() { + DECLARE_AND_RETURN_BUFFER("2004-01-01"); + } + const CharT* _1234562004_01_01() { + DECLARE_AND_RETURN_BUFFER("1234562004-01-01"); + } + const CharT* _0123456_12345() { + DECLARE_AND_RETURN_BUFFER("0123456_12345"); + } + + // letters + const CharT* a() { + DECLARE_AND_RETURN_BUFFER("a"); + } + const CharT* b() { + DECLARE_AND_RETURN_BUFFER("b"); + } + const CharT* c() { + DECLARE_AND_RETURN_BUFFER("c"); + } + const CharT* d() { + DECLARE_AND_RETURN_BUFFER("d"); + } + const CharT* e() { + DECLARE_AND_RETURN_BUFFER("e"); + } + const CharT* f() { + DECLARE_AND_RETURN_BUFFER("f"); + } + const CharT* h() { + DECLARE_AND_RETURN_BUFFER("h"); + } + const CharT* o() { + DECLARE_AND_RETURN_BUFFER("o"); + } + const CharT* p() { + DECLARE_AND_RETURN_BUFFER("p"); + } + const CharT* q() { + DECLARE_AND_RETURN_BUFFER("q"); + } + const CharT* r() { + DECLARE_AND_RETURN_BUFFER("r"); + } + const CharT* s() { + DECLARE_AND_RETURN_BUFFER("s"); + } + const CharT* t() { + DECLARE_AND_RETURN_BUFFER("t"); + } + const CharT* w() { + DECLARE_AND_RETURN_BUFFER("w"); + } + const CharT* x() { + DECLARE_AND_RETURN_BUFFER("x"); + } + const CharT* y() { + DECLARE_AND_RETURN_BUFFER("y"); + } + const CharT* z() { + DECLARE_AND_RETURN_BUFFER("z"); + } + const CharT* H() { + DECLARE_AND_RETURN_BUFFER("H"); + } + const CharT* I() { + DECLARE_AND_RETURN_BUFFER("I"); + } + const CharT* W() { + DECLARE_AND_RETURN_BUFFER("W"); + } + + const CharT* Space() { + DECLARE_AND_RETURN_BUFFER(" "); + } + const CharT* Empty() { + DECLARE_AND_RETURN_BUFFER(""); + } + + size_t HashOf_0123456() { + return 0; + } +}; + +template <> +size_t TTestData<char>::HashOf_0123456() { + return 1229863857ul; +} + +template <> +size_t TTestData<wchar16>::HashOf_0123456() { + return 2775195331ul; +} + template <class TStringType, typename TTestData> class TStringTestImpl { protected: @@ -518,7 +518,7 @@ protected: public: void TestMaxSize() { - const size_t badMaxVal = TStringType{}.max_size() + 1; + const size_t badMaxVal = TStringType{}.max_size() + 1; TStringType s; UNIT_CHECK_GENERATED_EXCEPTION(s.reserve(badMaxVal), std::length_error); @@ -541,10 +541,10 @@ public: UNIT_ASSERT_VALUES_EQUAL(fromChar.size(), 1u); UNIT_ASSERT_VALUES_EQUAL(fromChar[0], char_type('a')); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING TStringType s3 = TStringType::Uninitialized(10); UNIT_ASSERT(s3.size() == 10); -#endif +#endif TStringType s4(Data._0123456(), 1, 3); UNIT_ASSERT(s4 == Data._123()); @@ -556,9 +556,9 @@ public: UNIT_ASSERT(s6 == Data._0123456()); TStringType s7(s6); UNIT_ASSERT(s7 == s6); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s7.c_str() == s6.c_str()); -#endif +#endif TStringType s8(s7, 1, 3); UNIT_ASSERT(s8 == Data._123()); @@ -568,7 +568,7 @@ public: TStringType s10(Reserve(100)); UNIT_ASSERT(s10.empty()); - UNIT_ASSERT(s10.capacity() >= 100); + UNIT_ASSERT(s10.capacity() >= 100); } void TestReplace() { @@ -579,11 +579,11 @@ public: s.append(Data.x()); UNIT_ASSERT(s == Data._0123456x()); -#ifdef TSTRING_IS_STD_STRING - s.append(Data.xyz() + 1, 1); -#else +#ifdef TSTRING_IS_STD_STRING + s.append(Data.xyz() + 1, 1); +#else s.append(Data.xyz(), 1, 1); -#endif +#endif UNIT_ASSERT(s == Data._0123456xy()); s.append(TStringType(Data.z())); @@ -650,7 +650,7 @@ public: UNIT_ASSERT(s[s.size()] == 0); } -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING void TestRefCount() { using TStr = TStringType; @@ -672,7 +672,7 @@ public: UNIT_ASSERT_EQUAL(s2.RefCount() == 1, true); UNIT_ASSERT_EQUAL(s1.c_str() == s2.c_str(), false); } -#endif +#endif // Find family @@ -797,11 +797,11 @@ public: UNIT_ASSERT(s > Data.abc0123456xyz()); UNIT_ASSERT(s == Data.abcd()); - using TCIStringBuf = TBasicStringBuf<char_type, traits_type>; - - UNIT_ASSERT(s > TCIStringBuf(Data.abc0123456xyz())); - UNIT_ASSERT(TCIStringBuf(Data.abc0123456xyz()) < s); - UNIT_ASSERT(s == TCIStringBuf(Data.abcd())); + using TCIStringBuf = TBasicStringBuf<char_type, traits_type>; + + UNIT_ASSERT(s > TCIStringBuf(Data.abc0123456xyz())); + UNIT_ASSERT(TCIStringBuf(Data.abc0123456xyz()) < s); + UNIT_ASSERT(s == TCIStringBuf(Data.abcd())); } void TestMulOperators() { @@ -836,7 +836,7 @@ public: UNIT_ASSERT(s2 == s); // reverse() - ReverseInPlace(s2); + ReverseInPlace(s2); UNIT_ASSERT(s2 == Data._6543210()); // to_upper() @@ -894,7 +894,7 @@ public: // hash() TStringType sS = s2; // type 'TStringType' is used as is - ComputeHash(sS); /*size_t hash_val = sS.hash(); + ComputeHash(sS); /*size_t hash_val = sS.hash(); try { //UNIT_ASSERT(hash_val == Data.HashOf_0123456()); @@ -998,7 +998,7 @@ public: UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true); } -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING void TestCharRef() { const char_type abc[] = {'a', 'b', 'c', 0}; const char_type bbc[] = {'b', 'b', 'c', 0}; @@ -1045,7 +1045,7 @@ public: UNIT_ASSERT_VALUES_EQUAL(s1, red_eared); } } -#endif +#endif void TestBack() { const char_type chars[] = {'f', 'o', 'o', 0}; diff --git a/util/generic/variant.h b/util/generic/variant.h index 749fc75090..080f0a6e7e 100644 --- a/util/generic/variant.h +++ b/util/generic/variant.h @@ -1,23 +1,23 @@ #pragma once -#include "hash.h" +#include "hash.h" -#include <variant> +#include <variant> template <class... Ts> -struct THash<std::variant<Ts...>> { +struct THash<std::variant<Ts...>> { public: - size_t operator()(const std::variant<Ts...>& v) const noexcept { - return CombineHashes( - IntHash(v.index()), - v.valueless_by_exception() ? 0 : std::visit([](const auto& value) { return ComputeHash(value); }, v)); + size_t operator()(const std::variant<Ts...>& v) const noexcept { + return CombineHashes( + IntHash(v.index()), + v.valueless_by_exception() ? 0 : std::visit([](const auto& value) { return ComputeHash(value); }, v)); } }; template <> -struct THash<std::monostate> { +struct THash<std::monostate> { public: - constexpr size_t operator()(std::monostate) const noexcept { + constexpr size_t operator()(std::monostate) const noexcept { return 1; } }; diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp index 1158a8ca42..568bd0708a 100644 --- a/util/memory/pool_ut.cpp +++ b/util/memory/pool_ut.cpp @@ -158,9 +158,9 @@ private: { TMemoryPool pool(123, TMemoryPool::TExpGrow::Instance(), &alloc); - THolder<TConstructorTest, TDestructor> data1{pool.New<TConstructorTest>()}; - THolder<TConstructorTest, TDestructor> data2{pool.New<TConstructorTest>(42)}; - THolder<TConstructorTest, TDestructor> data3{pool.New<TConstructorTest>("hello", "world")}; + THolder<TConstructorTest, TDestructor> data1{pool.New<TConstructorTest>()}; + THolder<TConstructorTest, TDestructor> data2{pool.New<TConstructorTest>(42)}; + THolder<TConstructorTest, TDestructor> data3{pool.New<TConstructorTest>("hello", "world")}; UNIT_ASSERT_VALUES_EQUAL(data1->ConstructorType, 1); UNIT_ASSERT_VALUES_EQUAL(data2->ConstructorType, 2); UNIT_ASSERT_VALUES_EQUAL(data3->ConstructorType, 4); diff --git a/util/network/ip_ut.cpp b/util/network/ip_ut.cpp index 6716c6a699..5641029a13 100644 --- a/util/network/ip_ut.cpp +++ b/util/network/ip_ut.cpp @@ -58,6 +58,6 @@ void TSysIpTest::TestIpToString() { const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"}; for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) { - UNIT_ASSERT(IpToString(*reinterpret_cast<TIpHost*>(&(ipArr[i]))) == ipStr[i]); + UNIT_ASSERT(IpToString(*reinterpret_cast<TIpHost*>(&(ipArr[i]))) == ipStr[i]); } } diff --git a/util/network/nonblock.cpp b/util/network/nonblock.cpp index e515c27cc5..ee2a9474ef 100644 --- a/util/network/nonblock.cpp +++ b/util/network/nonblock.cpp @@ -22,7 +22,7 @@ namespace { { #if defined(_unix_) && defined(SOCK_NONBLOCK) { - Accept4 = reinterpret_cast<TAccept4>(dlsym(RTLD_DEFAULT, "accept4")); + Accept4 = reinterpret_cast<TAccept4>(dlsym(RTLD_DEFAULT, "accept4")); #if defined(_musl_) //musl always statically linked diff --git a/util/str_stl.h b/util/str_stl.h index f1e137181d..9ca29e658e 100644 --- a/util/str_stl.h +++ b/util/str_stl.h @@ -3,7 +3,7 @@ #include <util/memory/alloc.h> #include <util/digest/numeric.h> #include <util/generic/string.h> -#include <util/generic/string_hash.h> +#include <util/generic/string_hash.h> #include <util/generic/strbuf.h> #include <util/generic/typetraits.h> @@ -52,7 +52,7 @@ namespace NHashPrivate { using is_transparent = void; inline size_t operator()(const TBasicStringBuf<C> s) const noexcept { - return NHashPrivate::ComputeStringHash(s.data(), s.size()); + return NHashPrivate::ComputeStringHash(s.data(), s.size()); } }; } diff --git a/util/stream/output.cpp b/util/stream/output.cpp index db81b81b70..48853c84c8 100644 --- a/util/stream/output.cpp +++ b/util/stream/output.cpp @@ -209,7 +209,7 @@ void Out<typename std::vector<bool>::reference>(IOutputStream& o, const std::vec } #endif -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING template <> void Out<TBasicCharRef<TString>>(IOutputStream& o, const TBasicCharRef<TString>& c) { o << static_cast<char>(c); @@ -224,7 +224,7 @@ template <> void Out<TBasicCharRef<TUtf32String>>(IOutputStream& o, const TBasicCharRef<TUtf32String>& c) { o << static_cast<wchar32>(c); } -#endif +#endif template <> void Out<const void*>(IOutputStream& o, const void* t) { diff --git a/util/string/ascii.h b/util/string/ascii.h index 10344384d3..68c3a963f9 100644 --- a/util/string/ascii.h +++ b/util/string/ascii.h @@ -31,12 +31,12 @@ namespace NPrivate { using type = T; }; -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING template <class String> struct TDereference<TBasicCharRef<String>> { using type = typename String::value_type; }; -#endif +#endif template <class T> using TDereferenced = typename TDereference<T>::type; @@ -52,12 +52,12 @@ namespace NPrivate { return c >= static_cast<T>(0) && c <= static_cast<T>(127); } -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING template <class String> bool RangeOk(const TBasicCharRef<String>& c) { return RangeOk(static_cast<typename String::value_type>(c)); } -#endif +#endif } constexpr bool IsAscii(const int c) noexcept { diff --git a/util/string/cast.h b/util/string/cast.h index 90e925c194..d4f6a876d8 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -343,15 +343,15 @@ template <class TInt, int base, class TStringType> inline TInt IntFromString(const TStringType& str) { return IntFromString<TInt, base>(str.data(), str.size()); } - -static inline TString ToString(const TStringBuf str) { - return TString(str); -} - -static inline TUtf16String ToWtring(const TWtringBuf wtr) { - return TUtf16String(wtr); -} - -static inline TUtf32String ToUtf32String(const TUtf32StringBuf wtr) { - return TUtf32String(wtr); -} + +static inline TString ToString(const TStringBuf str) { + return TString(str); +} + +static inline TUtf16String ToWtring(const TWtringBuf wtr) { + return TUtf16String(wtr); +} + +static inline TUtf32String ToUtf32String(const TUtf32StringBuf wtr) { + return TUtf32String(wtr); +} diff --git a/util/string/escape.cpp b/util/string/escape.cpp index cd09a7dbd0..ea35b5fb15 100644 --- a/util/string/escape.cpp +++ b/util/string/escape.cpp @@ -283,12 +283,12 @@ static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) { } case 'U': - if (CountHex<8>(p + 1, pe) != 8) { + if (CountHex<8>(p + 1, pe) != 8) { res.append(*p); - } else { + } else { AppendUnicode(res, IntFromString<ui32, 16>(p + 1, 8)); - p += 8; - } + p += 8; + } break; case 'x': if (ui32 v = CountHex<2>(p + 1, pe)) { @@ -319,8 +319,8 @@ static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) { ++p; } else { - const auto r = std::basic_string_view<TChar>(p, pe - p).find('\\'); - const auto n = r != std::string::npos ? p + r : pe; + const auto r = std::basic_string_view<TChar>(p, pe - p).find('\\'); + const auto n = r != std::string::npos ? p + r : pe; res.append(p, n); p = n; @@ -338,17 +338,17 @@ TBasicString<TChar>& UnescapeCImpl(const TChar* p, size_t sz, TBasicString<TChar template <class TChar> TChar* UnescapeC(const TChar* str, size_t len, TChar* buf) { struct TUnboundedString { - void append(TChar ch) noexcept { + void append(TChar ch) noexcept { *P++ = ch; } - void append(const TChar* b, const TChar* e) noexcept { + void append(const TChar* b, const TChar* e) noexcept { while (b != e) { append(*b++); } } - void AppendNoAlias(const TChar* s, size_t l) noexcept { + void AppendNoAlias(const TChar* s, size_t l) noexcept { append(s, s + l); } diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp index cd38ecffd3..c79c2833a8 100644 --- a/util/string/escape_ut.cpp +++ b/util/string/escape_ut.cpp @@ -140,9 +140,9 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) { UNIT_ASSERT_VALUES_EQUAL(x.Source, TStringBuf(buf, end)); } } - - Y_UNIT_TEST(TestCapitalUEscapes) { - UNIT_ASSERT_VALUES_EQUAL(UnescapeC("\\U00000020"), " "); - UNIT_ASSERT_VALUES_EQUAL(UnescapeC("\\Uxxx"), "Uxxx"); - } + + Y_UNIT_TEST(TestCapitalUEscapes) { + UNIT_ASSERT_VALUES_EQUAL(UnescapeC("\\U00000020"), " "); + UNIT_ASSERT_VALUES_EQUAL(UnescapeC("\\Uxxx"), "Uxxx"); + } } diff --git a/util/string/fuzzing/collapse/main.cpp b/util/string/fuzzing/collapse/main.cpp index e7b09f0f55..e26ec54f79 100644 --- a/util/string/fuzzing/collapse/main.cpp +++ b/util/string/fuzzing/collapse/main.cpp @@ -6,7 +6,7 @@ extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { Collapse(w); TString s((const char*)data, size); - CollapseInPlace(s); + CollapseInPlace(s); return 0; // Non-zero return values are reserved for future use. } diff --git a/util/string/join.h b/util/string/join.h index b166fad1f3..b848bea1d3 100644 --- a/util/string/join.h +++ b/util/string/join.h @@ -2,7 +2,7 @@ #include <util/generic/string.h> #include <util/generic/typetraits.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include "cast.h" /* diff --git a/util/string/reverse.cpp b/util/string/reverse.cpp index 167cd11f49..3d67e95b04 100644 --- a/util/string/reverse.cpp +++ b/util/string/reverse.cpp @@ -1,33 +1,33 @@ -#include "reverse.h" - -#include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/charset/wide_specific.h> - -#include <algorithm> - -void ReverseInPlace(TString& string) { - auto* begin = string.begin(); - std::reverse(begin, begin + string.size()); -} - -void ReverseInPlace(TUtf16String& string) { - auto* begin = string.begin(); - const auto len = string.size(); - auto* end = begin + string.size(); - - TVector<wchar16> buffer(len); - wchar16* rbegin = buffer.data() + len; - for (wchar16* p = begin; p < end;) { - const size_t symbolSize = W16SymbolSize(p, end); - rbegin -= symbolSize; - std::copy(p, p + symbolSize, rbegin); - p += symbolSize; - } - std::copy(buffer.begin(), buffer.end(), begin); -} - -void ReverseInPlace(TUtf32String& string) { - auto* begin = string.begin(); - std::reverse(begin, begin + string.size()); -} +#include "reverse.h" + +#include <util/generic/string.h> +#include <util/generic/vector.h> +#include <util/charset/wide_specific.h> + +#include <algorithm> + +void ReverseInPlace(TString& string) { + auto* begin = string.begin(); + std::reverse(begin, begin + string.size()); +} + +void ReverseInPlace(TUtf16String& string) { + auto* begin = string.begin(); + const auto len = string.size(); + auto* end = begin + string.size(); + + TVector<wchar16> buffer(len); + wchar16* rbegin = buffer.data() + len; + for (wchar16* p = begin; p < end;) { + const size_t symbolSize = W16SymbolSize(p, end); + rbegin -= symbolSize; + std::copy(p, p + symbolSize, rbegin); + p += symbolSize; + } + std::copy(buffer.begin(), buffer.end(), begin); +} + +void ReverseInPlace(TUtf32String& string) { + auto* begin = string.begin(); + std::reverse(begin, begin + string.size()); +} diff --git a/util/string/reverse.h b/util/string/reverse.h index 80f8b00887..6adf17f08b 100644 --- a/util/string/reverse.h +++ b/util/string/reverse.h @@ -1,16 +1,16 @@ -#pragma once - -#include <util/generic/fwd.h> - -void ReverseInPlace(TString& string); - -/** NB. UTF-16 is variable-length encoding because of the surrogate pairs. - * This function takes this into account and treats a surrogate pair as a single symbol. - * Ex. if [C D] is a surrogate pair, - * A B [C D] E - * will become - * E [C D] B A - */ -void ReverseInPlace(TUtf16String& string); - -void ReverseInPlace(TUtf32String& string); +#pragma once + +#include <util/generic/fwd.h> + +void ReverseInPlace(TString& string); + +/** NB. UTF-16 is variable-length encoding because of the surrogate pairs. + * This function takes this into account and treats a surrogate pair as a single symbol. + * Ex. if [C D] is a surrogate pair, + * A B [C D] E + * will become + * E [C D] B A + */ +void ReverseInPlace(TUtf16String& string); + +void ReverseInPlace(TUtf32String& string); diff --git a/util/string/split.h b/util/string/split.h index bc46d9e64c..951b3cc7d4 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -21,7 +21,7 @@ // NOTE: Check StringSplitter below to get more convenient split string interface. -namespace NStringSplitPrivate { +namespace NStringSplitPrivate { template <class T, class I, class = void> struct TIsConsumer: std::false_type {}; @@ -36,21 +36,21 @@ namespace NStringSplitPrivate { template <class T, class I> constexpr bool TIsConsumerV = TIsConsumer<T, I>::value; - template <class T> - T* Find(T* str, std::common_type_t<T> ch) { - for (; *str; ++str) { - if (*str == ch) { - return str; - } - } - - return nullptr; - } - + template <class T> + T* Find(T* str, std::common_type_t<T> ch) { + for (; *str; ++str) { + if (*str == ch) { + return str; + } + } + + return nullptr; + } + } template <class I, class TDelim, class TConsumer> -std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>> +std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>> SplitString(I b, I e, const TDelim& d, TConsumer&& c) { I l, i; @@ -61,7 +61,7 @@ SplitString(I b, I e, const TDelim& d, TConsumer&& c) { } template <class I, class TDelim, class TConsumer> -std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>> +std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>> SplitString(I b, const TDelim& d, TConsumer&& c) { I l, i; @@ -73,7 +73,7 @@ SplitString(I b, const TDelim& d, TConsumer&& c) { template <class I1, class I2> static inline I1* FastStrChr(I1* str, I2 f) noexcept { - I1* ret = NStringSplitPrivate::Find(str, f); + I1* ret = NStringSplitPrivate::Find(str, f); if (!ret) { ret = str + std::char_traits<I1>::length(str); @@ -84,21 +84,21 @@ static inline I1* FastStrChr(I1* str, I2 f) noexcept { template <class I> static inline I* FastStrStr(I* str, I* f, size_t l) noexcept { - std::basic_string_view<I> strView(str); - const auto ret = strView.find(*f); - - if (ret != std::string::npos) { - std::basic_string_view<I> fView(f, l); - strView = strView.substr(ret); - for (; strView.size() >= l; strView = strView.substr(1)) { - if (strView.substr(0, l) == fView) { - break; - } - } - - return strView.size() >= l ? strView.data() : strView.data() + strView.size(); - } else { - return strView.data() + strView.size(); + std::basic_string_view<I> strView(str); + const auto ret = strView.find(*f); + + if (ret != std::string::npos) { + std::basic_string_view<I> fView(f, l); + strView = strView.substr(ret); + for (; strView.size() >= l; strView = strView.substr(1)) { + if (strView.substr(0, l) == fView) { + break; + } + } + + return strView.size() >= l ? strView.data() : strView.data() + strView.size(); + } else { + return strView.data() + strView.size(); } } @@ -117,12 +117,12 @@ struct TStringDelimiter { } inline Char* Find(Char*& b, Char* e) const noexcept { - const auto ret = std::basic_string_view<Char>(b, e - b).find(Delim, 0, Len); + const auto ret = std::basic_string_view<Char>(b, e - b).find(Delim, 0, Len); - if (ret != std::string::npos) { - const auto result = b + ret; - b = result + Len; - return result; + if (ret != std::string::npos) { + const auto result = b + ret; + b = result + Len; + return result; } return (b = e); @@ -131,7 +131,7 @@ struct TStringDelimiter { inline Char* Find(Char*& b) const noexcept { Char* ret = FastStrStr(b, Delim, Len); - b = *ret ? ret + Len : ret; + b = *ret ? ret + Len : ret; return ret; } @@ -148,12 +148,12 @@ struct TCharDelimiter { } inline Char* Find(Char*& b, Char* e) const noexcept { - const auto ret = std::basic_string_view<Char>(b, e - b).find(Ch); + const auto ret = std::basic_string_view<Char>(b, e - b).find(Ch); - if (ret != std::string::npos) { - const auto result = b + ret; - b = result + 1; - return result; + if (ret != std::string::npos) { + const auto result = b + ret; + b = result + 1; + return result; } return (b = e); @@ -205,16 +205,16 @@ struct TFindFirstOf { inline Char* FindFirstOf(Char* b, Char* e) const noexcept { Char* ret = b; for (; ret != e; ++ret) { - if (NStringSplitPrivate::Find(Set, *ret)) + if (NStringSplitPrivate::Find(Set, *ret)) break; } return ret; } inline Char* FindFirstOf(Char* b) const noexcept { - const std::basic_string_view<Char> bView(b); - const auto ret = bView.find_first_of(Set); - return ret != std::string::npos ? b + ret : b + bView.size(); + const std::basic_string_view<Char> bView(b); + const auto ret = bView.find_first_of(Set); + return ret != std::string::npos ? b + ret : b + bView.size(); } Char* Set; @@ -489,7 +489,7 @@ void Split(TStringBuf s, D delim, P1& p1, P2& p2, Other&... other) { * \endcode */ -namespace NStringSplitPrivate { +namespace NStringSplitPrivate { Y_HAS_MEMBER(push_back, PushBack); Y_HAS_MEMBER(insert, Insert); Y_HAS_MEMBER(data, Data); @@ -1042,30 +1042,30 @@ namespace NStringSplitPrivate { template <class Iterator> auto StringSplitter(Iterator begin, Iterator end) { - return ::NStringSplitPrivate::MakeStringSplitter(TIteratorRange<Iterator>(begin, end)); + return ::NStringSplitPrivate::MakeStringSplitter(TIteratorRange<Iterator>(begin, end)); } template <class Char> auto StringSplitter(const Char* begin, const Char* end) { - return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, end)); + return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, end)); } template <class Char> auto StringSplitter(const Char* begin, size_t len) { - return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, len)); + return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, len)); } template <class Char> auto StringSplitter(const Char* str) { - return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(str)); + return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(str)); } template <class String, std::enable_if_t<!std::is_pointer<std::remove_reference_t<String>>::value, int> = 0> auto StringSplitter(String& s) { - return ::NStringSplitPrivate::MakeStringSplitter(::NStringSplitPrivate::TStringBufOf<String>(s.data(), s.size())); + return ::NStringSplitPrivate::MakeStringSplitter(::NStringSplitPrivate::TStringBufOf<String>(s.data(), s.size())); } template <class String, std::enable_if_t<!std::is_pointer<std::remove_reference_t<String>>::value, int> = 0> auto StringSplitter(String&& s) { - return ::NStringSplitPrivate::MakeStringSplitter(std::move(s)); + return ::NStringSplitPrivate::MakeStringSplitter(std::move(s)); } diff --git a/util/string/strip.cpp b/util/string/strip.cpp index c921571cf0..0b942ca06f 100644 --- a/util/string/strip.cpp +++ b/util/string/strip.cpp @@ -1,23 +1,23 @@ #include "strip.h" #include "ascii.h" -#include <util/string/reverse.h> - +#include <util/string/reverse.h> + bool Collapse(const TString& from, TString& to, size_t maxLen) { return CollapseImpl<TString, bool (*)(unsigned char)>(from, to, maxLen, IsAsciiSpace); } void CollapseText(const TString& from, TString& to, size_t maxLen) { Collapse(from, to, maxLen); - StripInPlace(to); + StripInPlace(to); if (to.size() >= maxLen) { to.remove(maxLen - 5); // " ..." - ReverseInPlace(to); + ReverseInPlace(to); size_t pos = to.find_first_of(" .,;"); if (pos != TString::npos && pos < 32) { to.remove(0, pos + 1); } - ReverseInPlace(to); + ReverseInPlace(to); to.append(" ..."); } } diff --git a/util/string/strip.h b/util/string/strip.h index d5ef6da96d..81b97add83 100644 --- a/util/string/strip.h +++ b/util/string/strip.h @@ -183,7 +183,7 @@ static inline bool Strip(const TString& from, TString& to) { } /// Removes leading and trailing spaces from the string. -inline TString& StripInPlace(TString& s) { +inline TString& StripInPlace(TString& s) { Strip(s, s); return s; } @@ -233,14 +233,14 @@ bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const bool Collapse(const TString& from, TString& to, size_t maxLen = 0); /// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes) -inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) { +inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) { Collapse(s, s, maxLen); return s; } - + /// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes) -inline TString Collapse(const TString& s, size_t maxLen = 0) Y_WARN_UNUSED_RESULT; -inline TString Collapse(const TString& s, size_t maxLen) { +inline TString Collapse(const TString& s, size_t maxLen = 0) Y_WARN_UNUSED_RESULT; +inline TString Collapse(const TString& s, size_t maxLen) { TString ret; Collapse(s, ret, maxLen); return ret; diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp index d1029d1498..2118e583d8 100644 --- a/util/string/strip_ut.cpp +++ b/util/string/strip_ut.cpp @@ -116,12 +116,12 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { s = TString(" a b c "); TString s2 = s; - CollapseInPlace(s2); + CollapseInPlace(s2); UNIT_ASSERT(s == s2); -#ifndef TSTRING_IS_STD_STRING +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == s2.c_str()); // Collapse() does not change the string at all -#endif +#endif } Y_UNIT_TEST(TestCollapseText) { diff --git a/util/string/vector.h b/util/string/vector.h index e36c348bbe..0c9f4d39ac 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -7,7 +7,7 @@ #include <util/generic/strbuf.h> #include <util/generic/string.h> #include <util/generic/vector.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/system/yassert.h> #define KEEP_EMPTY_TOKENS 0x01 diff --git a/util/system/atexit.cpp b/util/system/atexit.cpp index 74fb10b6b1..45bde32638 100644 --- a/util/system/atexit.cpp +++ b/util/system/atexit.cpp @@ -124,13 +124,13 @@ void AtExit(TAtExitFunc func, void* ctx) { } static void TraditionalCloser(void* ctx) { - reinterpret_cast<TTraditionalAtExitFunc>(ctx)(); + reinterpret_cast<TTraditionalAtExitFunc>(ctx)(); } void AtExit(TTraditionalAtExitFunc func) { - AtExit(TraditionalCloser, reinterpret_cast<void*>(func)); + AtExit(TraditionalCloser, reinterpret_cast<void*>(func)); } void AtExit(TTraditionalAtExitFunc func, size_t priority) { - AtExit(TraditionalCloser, reinterpret_cast<void*>(func), priority); + AtExit(TraditionalCloser, reinterpret_cast<void*>(func), priority); } diff --git a/util/system/atexit_ut.cpp b/util/system/atexit_ut.cpp index 953f432811..fdf0413e0e 100644 --- a/util/system/atexit_ut.cpp +++ b/util/system/atexit_ut.cpp @@ -28,7 +28,7 @@ struct TAtExitParams { }; void MyAtExitFunc(void* ptr) { - THolder<TAtExitParams> params{static_cast<TAtExitParams*>(ptr)}; + THolder<TAtExitParams> params{static_cast<TAtExitParams*>(ptr)}; if (write(params->fd, params->str, strlen(params->str)) < 0) { abort(); } diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp index b77fe58fb1..1aa745c0cc 100644 --- a/util/system/backtrace.cpp +++ b/util/system/backtrace.cpp @@ -243,7 +243,7 @@ void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtrac } } -TFormatBackTraceFn FormatBackTraceFn = FormatBackTrace; +TFormatBackTraceFn FormatBackTraceFn = FormatBackTrace; TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f) { TFormatBackTraceFn prevFn = FormatBackTraceFn; @@ -251,12 +251,12 @@ TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f) { return prevFn; } -void FormatBackTrace(IOutputStream* out) { - void* array[300]; - const size_t s = BackTrace(array, Y_ARRAY_SIZE(array)); - FormatBackTraceFn(out, array, s); -} - +void FormatBackTrace(IOutputStream* out) { + void* array[300]; + const size_t s = BackTrace(array, Y_ARRAY_SIZE(array)); + FormatBackTraceFn(out, array, s); +} + TFormatBackTraceFn GetFormatBackTraceFn() { return FormatBackTraceFn; } @@ -275,7 +275,7 @@ void TBackTrace::Capture() { } void TBackTrace::PrintTo(IOutputStream& out) const { - FormatBackTraceFn(&out, Data, Size); + FormatBackTraceFn(&out, Data, Size); } TString TBackTrace::PrintToString() const { @@ -283,7 +283,7 @@ TString TBackTrace::PrintToString() const { PrintTo(ss); return ss.Str(); } - + size_t TBackTrace::size() const { return Size; } @@ -296,12 +296,12 @@ TBackTrace::operator TBackTraceView() const { return TBackTraceView(Data, Size); } -TBackTrace TBackTrace::FromCurrentException() { -#ifdef _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE - TBackTrace result; - result.Size = __cxxabiv1::__cxa_collect_current_exception_backtrace(result.Data, CAPACITY); - return result; -#else - return TBackTrace(); -#endif -} +TBackTrace TBackTrace::FromCurrentException() { +#ifdef _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_SIZE + TBackTrace result; + result.Size = __cxxabiv1::__cxa_collect_current_exception_backtrace(result.Data, CAPACITY); + return result; +#else + return TBackTrace(); +#endif +} diff --git a/util/system/backtrace.h b/util/system/backtrace.h index 2fce7585c3..4271597f57 100644 --- a/util/system/backtrace.h +++ b/util/system/backtrace.h @@ -18,7 +18,7 @@ void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtrac void FormatBackTrace(IOutputStream* out); void PrintBackTrace(); -using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize); +using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize); TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f); TFormatBackTraceFn GetFormatBackTraceFn(); @@ -27,7 +27,7 @@ using TBackTraceView = TArrayRef<void* const>; class TBackTrace { private: - static constexpr size_t CAPACITY = 300; + static constexpr size_t CAPACITY = 300; void* Data[CAPACITY]; size_t Size; @@ -39,6 +39,6 @@ public: size_t size() const; const void* const* data() const; operator TBackTraceView() const; - - static TBackTrace FromCurrentException(); + + static TBackTrace FromCurrentException(); }; diff --git a/util/system/condvar_ut.cpp b/util/system/condvar_ut.cpp index 5130a18d32..a0c5b86576 100644 --- a/util/system/condvar_ut.cpp +++ b/util/system/condvar_ut.cpp @@ -6,7 +6,7 @@ #include <util/system/atomic.h> #include <util/system/atomic_ops.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> class TCondVarTest: public TTestBase { UNIT_TEST_SUITE(TCondVarTest); @@ -194,7 +194,7 @@ private: } #undef RUN_CYCLE TSharedData Data_; - TThreadPool Q_; + TThreadPool Q_; }; UNIT_TEST_SUITE_REGISTRATION(TCondVarTest); diff --git a/util/system/context.cpp b/util/system/context.cpp index ad99309088..1edc6a9b7a 100644 --- a/util/system/context.cpp +++ b/util/system/context.cpp @@ -189,7 +189,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c) __mysetjmp(Buf_); - JmpBufProgrReg(Buf_) = reinterpret_cast<void*>(ContextTrampoLine); + JmpBufProgrReg(Buf_) = reinterpret_cast<void*>(ContextTrampoLine); JmpBufStackReg(Buf_) = stack.StackPtr(); JmpBufFrameReg(Buf_) = nullptr; } diff --git a/util/system/cpu_id.cpp b/util/system/cpu_id.cpp index 598c71f4d9..67eabee3be 100644 --- a/util/system/cpu_id.cpp +++ b/util/system/cpu_id.cpp @@ -162,10 +162,10 @@ bool NX86::HaveBMI1() noexcept { return (TX86CpuInfo(0x7, 0).EBX >> 3) & 1u; } -bool NX86::HaveBMI2() noexcept { - return (TX86CpuInfo(0x7, 0).EBX >> 8) & 1u; -} - +bool NX86::HaveBMI2() noexcept { + return (TX86CpuInfo(0x7, 0).EBX >> 8) & 1u; +} + bool NX86::HaveAVX512F() noexcept { #if defined(_x86_) // https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support diff --git a/util/system/cpu_id.h b/util/system/cpu_id.h index 3c49e728a7..dc300cdbff 100644 --- a/util/system/cpu_id.h +++ b/util/system/cpu_id.h @@ -14,7 +14,7 @@ F(F16C) \ F(POPCNT) \ F(BMI1) \ - F(BMI2) \ + F(BMI2) \ F(PCLMUL) \ F(AES) \ F(AVX) \ diff --git a/util/system/cpu_id_ut.cpp b/util/system/cpu_id_ut.cpp index 68f1f8aac7..9e0898ea89 100644 --- a/util/system/cpu_id_ut.cpp +++ b/util/system/cpu_id_ut.cpp @@ -23,7 +23,7 @@ static void ExecuteAVXInstruction(); static void ExecuteAVX2Instruction(); static void ExecutePOPCNTInstruction(); static void ExecuteBMI1Instruction(); -static void ExecuteBMI2Instruction(); +static void ExecuteBMI2Instruction(); static void ExecutePCLMULInstruction(); static void ExecuteAESInstruction(); static void ExecuteAVXInstruction(); @@ -169,13 +169,13 @@ void ExecuteBMI1Instruction() { : "eax"); } -void ExecuteBMI2Instruction() { - __asm__ __volatile__("pdep %%rax, %%rdi, %%rax\n" - : - : - : "rax"); -} - +void ExecuteBMI2Instruction() { + __asm__ __volatile__("pdep %%rax, %%rdi, %%rax\n" + : + : + : "rax"); +} + void ExecutePCLMULInstruction() { __asm__ __volatile__("pclmullqlqdq %%xmm0, %%xmm0\n" : @@ -291,9 +291,9 @@ void ExecutePOPCNTInstruction() { void ExecuteBMI1Instruction() { } -void ExecuteBMI2Instruction() { -} - +void ExecuteBMI2Instruction() { +} + void ExecutePCLMULInstruction() { } @@ -388,9 +388,9 @@ void ExecutePOPCNTInstruction() { void ExecuteBMI1Instruction() { } -void ExecuteBMI2Instruction() { -} - +void ExecuteBMI2Instruction() { +} + void ExecutePCLMULInstruction() { } diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp index 2506cb7a91..5e94a0890f 100644 --- a/util/system/event_ut.cpp +++ b/util/system/event_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> namespace { struct TSharedData { @@ -85,7 +85,7 @@ namespace { Y_UNIT_TEST_SUITE(EventTest) { Y_UNIT_TEST(WaitAndSignalTest) { TSharedData data; - TThreadPool queue; + TThreadPool queue; queue.Start(5); for (size_t i = 0; i < 5; ++i) { UNIT_ASSERT(queue.Add(new TThreadTask(data, i))); @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(EventTest) { // test for problem detected by thread-sanitizer (signal/wait race) SEARCH-2113 const size_t limit = 200; TManualEvent event[limit]; - TThreadPool queue; + TThreadPool queue; queue.Start(limit); TVector<THolder<IObjectInQueue>> tasks; for (size_t i = 0; i < limit; ++i) { @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(EventTest) { tasks.emplace_back(std::move(owner)); } - TThreadPool queue; + TThreadPool queue; queue.Start(4); for (auto& task : tasks) { UNIT_ASSERT(queue.Add(task.Get())); diff --git a/util/system/execpath.cpp b/util/system/execpath.cpp index 33198af58b..1b8d1ad4e4 100644 --- a/util/system/execpath.cpp +++ b/util/system/execpath.cpp @@ -159,13 +159,13 @@ static bool GetPersistentExecPathImpl(TString& to) { #if defined(_solaris_) to = TString("/proc/self/object/a.out"); return true; -#elif defined(_linux_) || defined(_cygwin_) +#elif defined(_linux_) || defined(_cygwin_) to = TString("/proc/self/exe"); return true; #elif defined(_freebsd_) to = TString("/proc/curproc/file"); return true; -#else // defined(_win_) || defined(_darwin_) or unknown +#else // defined(_win_) || defined(_darwin_) or unknown Y_UNUSED(to); return false; #endif diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp index 057a814f0a..8a93e76137 100644 --- a/util/system/fasttime.cpp +++ b/util/system/fasttime.cpp @@ -34,16 +34,16 @@ namespace { : Func(nullptr) { // not DEFAULT, cause library/cpp/gettimeofday - Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday")); + Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday")); #if defined(_musl_) if (!Func) { - Func = reinterpret_cast<TFunc>(NVdso::Function("__vdso_gettimeofday", "LINUX_2.6")); + Func = reinterpret_cast<TFunc>(NVdso::Function("__vdso_gettimeofday", "LINUX_2.6")); } #endif if (!Func) { - Func = reinterpret_cast<TFunc>(Libc()->Sym("gettimeofday")); + Func = reinterpret_cast<TFunc>(Libc()->Sym("gettimeofday")); } } diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index 7454a4cb94..40bf8cfea1 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -1,7 +1,7 @@ #include "info.h" #include "madvise.h" #include "defaults.h" -#include "hi_lo.h" +#include "hi_lo.h" #include <util/generic/buffer.h> #include <util/generic/yexception.h> @@ -239,7 +239,7 @@ public: result.Ptr = MapViewOfFile(Mapping_, (Mode_ & oAccessMask) == oRdOnly ? FILE_MAP_READ : (Mode_ & oAccessMask) == oCopyOnWr ? FILE_MAP_COPY : FILE_MAP_WRITE, - Hi32(base), Lo32(base), size); + Hi32(base), Lo32(base), size); #else #if defined(_unix_) if (Mode_ & oNotGreedy) { diff --git a/util/system/guard_ut.cpp b/util/system/guard_ut.cpp index 404ede99ab..14edb97f45 100644 --- a/util/system/guard_ut.cpp +++ b/util/system/guard_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> struct TTestGuard: public TTestBase { UNIT_TEST_SUITE(TTestGuard); diff --git a/util/system/hi_lo.cpp b/util/system/hi_lo.cpp index 97c3eba8be..2950bc6096 100644 --- a/util/system/hi_lo.cpp +++ b/util/system/hi_lo.cpp @@ -1 +1 @@ -#include "hi_lo.h" +#include "hi_lo.h" diff --git a/util/system/hi_lo.h b/util/system/hi_lo.h index f86870534f..3dad401140 100644 --- a/util/system/hi_lo.h +++ b/util/system/hi_lo.h @@ -1,149 +1,149 @@ -#pragma once - -#include "unaligned_mem.h" - +#pragma once + +#include "unaligned_mem.h" + #include <utility> -#ifndef _little_endian_ +#ifndef _little_endian_ #error "Not implemented" -#endif - -namespace NHiLoPrivate { - template <class TRepr> - class TConstIntRef { - public: - explicit TConstIntRef(const char* ptr) - : Ptr(ptr) - { - } - +#endif + +namespace NHiLoPrivate { + template <class TRepr> + class TConstIntRef { + public: + explicit TConstIntRef(const char* ptr) + : Ptr(ptr) + { + } + TRepr Get() const { return ReadUnaligned<TRepr>(Ptr); } operator TRepr() const { return Get(); } - + const char* GetPtr() const { return Ptr; } - - protected: - const char* Ptr; - }; - - template <class TRepr> + + protected: + const char* Ptr; + }; + + template <class TRepr> class TIntRef: public TConstIntRef<TRepr> { - public: - explicit TIntRef(char* ptr) - : TConstIntRef<TRepr>(ptr) - { - } - - TIntRef& operator=(TRepr value) { + public: + explicit TIntRef(char* ptr) + : TConstIntRef<TRepr>(ptr) + { + } + + TIntRef& operator=(TRepr value) { WriteUnaligned<TRepr>(GetPtr(), value); - return *this; - } - + return *this; + } + char* GetPtr() const { return const_cast<char*>(this->Ptr); } - }; - - template <class T> - struct TReferenceType { - using TType = T; - }; - - template <class T> - struct TReferenceType<TConstIntRef<T>> { - using TType = T; - }; - - template <class T> - struct TReferenceType<TIntRef<T>> { - using TType = T; - }; - - template <class TRepr> - auto MakeIntRef(const char* ptr) { - return TConstIntRef<TRepr>(ptr); - } - - template <class TRepr> - auto MakeIntRef(char* ptr) { - return TIntRef<TRepr>(ptr); - } - - template <class T> - const char* CharPtrOf(const T& value) { + }; + + template <class T> + struct TReferenceType { + using TType = T; + }; + + template <class T> + struct TReferenceType<TConstIntRef<T>> { + using TType = T; + }; + + template <class T> + struct TReferenceType<TIntRef<T>> { + using TType = T; + }; + + template <class TRepr> + auto MakeIntRef(const char* ptr) { + return TConstIntRef<TRepr>(ptr); + } + + template <class TRepr> + auto MakeIntRef(char* ptr) { + return TIntRef<TRepr>(ptr); + } + + template <class T> + const char* CharPtrOf(const T& value) { return reinterpret_cast<const char*>(&value); - } - - template <class T> - char* CharPtrOf(T& value) { + } + + template <class T> + char* CharPtrOf(T& value) { return reinterpret_cast<char*>(&value); - } - - template <class T> - const char* CharPtrOf(TConstIntRef<T> value) { - return value.GetPtr(); - } - - template <class T> - char* CharPtrOf(TIntRef<T> value) { - return value.GetPtr(); - } - - template <bool IsLow, class TRepr, class T> - auto MakeIntRef(T&& value) { - using TRef = typename TReferenceType<typename std::decay<T>::type>::TType; - static_assert( + } + + template <class T> + const char* CharPtrOf(TConstIntRef<T> value) { + return value.GetPtr(); + } + + template <class T> + char* CharPtrOf(TIntRef<T> value) { + return value.GetPtr(); + } + + template <bool IsLow, class TRepr, class T> + auto MakeIntRef(T&& value) { + using TRef = typename TReferenceType<typename std::decay<T>::type>::TType; + static_assert( std::is_scalar<TRef>::value, "Hi* and Lo* functions can be applied only to scalar values"); - static_assert(sizeof(TRef) >= sizeof(TRepr), "Requested bit range is not within provided value"); - constexpr size_t offset = IsLow ? 0 : sizeof(TRef) - sizeof(TRepr); - - return MakeIntRef<TRepr>(CharPtrOf(std::forward<T>(value)) + offset); - } -} - -/** - * Return manipulator object that allows to get and set lower or higher bits of the value. - * - * @param value Must be a scalar value of sufficient size or a manipulator object obtained by - * calling any of the other Hi/Lo functions. - * - * @{ - */ -template <class T> -auto Lo32(T&& value) { - return NHiLoPrivate::MakeIntRef<true, ui32>(std::forward<T>(value)); -} - -template <class T> -auto Hi32(T&& value) { - return NHiLoPrivate::MakeIntRef<false, ui32>(std::forward<T>(value)); -} - -template <class T> -auto Lo16(T&& value) { - return NHiLoPrivate::MakeIntRef<true, ui16>(std::forward<T>(value)); -} - -template <class T> -auto Hi16(T&& value) { - return NHiLoPrivate::MakeIntRef<false, ui16>(std::forward<T>(value)); -} - -template <class T> -auto Lo8(T&& value) { - return NHiLoPrivate::MakeIntRef<true, ui8>(std::forward<T>(value)); -} - -template <class T> -auto Hi8(T&& value) { - return NHiLoPrivate::MakeIntRef<false, ui8>(std::forward<T>(value)); -} - -/** @} */ + static_assert(sizeof(TRef) >= sizeof(TRepr), "Requested bit range is not within provided value"); + constexpr size_t offset = IsLow ? 0 : sizeof(TRef) - sizeof(TRepr); + + return MakeIntRef<TRepr>(CharPtrOf(std::forward<T>(value)) + offset); + } +} + +/** + * Return manipulator object that allows to get and set lower or higher bits of the value. + * + * @param value Must be a scalar value of sufficient size or a manipulator object obtained by + * calling any of the other Hi/Lo functions. + * + * @{ + */ +template <class T> +auto Lo32(T&& value) { + return NHiLoPrivate::MakeIntRef<true, ui32>(std::forward<T>(value)); +} + +template <class T> +auto Hi32(T&& value) { + return NHiLoPrivate::MakeIntRef<false, ui32>(std::forward<T>(value)); +} + +template <class T> +auto Lo16(T&& value) { + return NHiLoPrivate::MakeIntRef<true, ui16>(std::forward<T>(value)); +} + +template <class T> +auto Hi16(T&& value) { + return NHiLoPrivate::MakeIntRef<false, ui16>(std::forward<T>(value)); +} + +template <class T> +auto Lo8(T&& value) { + return NHiLoPrivate::MakeIntRef<true, ui8>(std::forward<T>(value)); +} + +template <class T> +auto Hi8(T&& value) { + return NHiLoPrivate::MakeIntRef<false, ui8>(std::forward<T>(value)); +} + +/** @} */ diff --git a/util/system/hi_lo_ut.cpp b/util/system/hi_lo_ut.cpp index 850c12327d..c19e7bbb02 100644 --- a/util/system/hi_lo_ut.cpp +++ b/util/system/hi_lo_ut.cpp @@ -1,62 +1,62 @@ -#include <util/system/hi_lo.h> - +#include <util/system/hi_lo.h> + #include <library/cpp/testing/unittest/registar.h> - -#include "defaults.h" - -Y_UNIT_TEST_SUITE(HiLo) { + +#include "defaults.h" + +Y_UNIT_TEST_SUITE(HiLo) { Y_UNIT_TEST(HiLo32) { ui64 x = 0; Lo32(x) = 18; UNIT_ASSERT_VALUES_EQUAL(x, 18); - + Hi32(x) = 33; UNIT_ASSERT_VALUES_EQUAL(x, 141733920786); - + const ui64 y = 0x33c06196e94c03ab; UNIT_ASSERT_VALUES_EQUAL(Lo32(y).Get(), 0xe94c03ab); UNIT_ASSERT_VALUES_EQUAL(Hi32(y).Get(), 0x33c06196); } - + Y_UNIT_TEST(HiLo16) { ui32 x = 0; Lo16(x) = 18; UNIT_ASSERT_VALUES_EQUAL(x, 18); - + Hi16(x) = 33; UNIT_ASSERT_VALUES_EQUAL(x, 2162706); - + const ui32 y = 0xe94c03ab; UNIT_ASSERT_VALUES_EQUAL(Lo16(y).Get(), 0x03ab); UNIT_ASSERT_VALUES_EQUAL(Hi16(y).Get(), 0xe94c); } - + Y_UNIT_TEST(HiLo8) { ui16 x = 0; Lo8(x) = 18; UNIT_ASSERT_VALUES_EQUAL(x, 18); - + Hi8(x) = 33; UNIT_ASSERT_VALUES_EQUAL(x, 8466); - + const ui16 y = 0x03ab; UNIT_ASSERT_VALUES_EQUAL(Lo8(y).Get(), 0xab); UNIT_ASSERT_VALUES_EQUAL(Hi8(y).Get(), 0x03); } - + Y_UNIT_TEST(Combined) { ui32 x = 0; Lo8(Lo16(x)) = 18; UNIT_ASSERT_VALUES_EQUAL(x, 18); - + Hi8(Lo16(x)) = 33; UNIT_ASSERT_VALUES_EQUAL(x, 8466); - + const ui32 y = 0xe94c03ab; UNIT_ASSERT_VALUES_EQUAL(Lo8(Lo16(y)).Get(), 0xab); UNIT_ASSERT_VALUES_EQUAL(Hi8(Lo16(y)).Get(), 0x03); } - + Y_UNIT_TEST(NarrowFromWide) { const ui64 x = 0x1122334455667788ull; UNIT_ASSERT_VALUES_EQUAL(Lo8(x).Get(), 0x88); @@ -66,4 +66,4 @@ Y_UNIT_TEST_SUITE(HiLo) { UNIT_ASSERT_VALUES_EQUAL(Lo32(x).Get(), 0x55667788); UNIT_ASSERT_VALUES_EQUAL(Hi32(x).Get(), 0x11223344); } -} +} diff --git a/util/system/mutex_ut.cpp b/util/system/mutex_ut.cpp index c8d7caafa1..1dba4eb0bd 100644 --- a/util/system/mutex_ut.cpp +++ b/util/system/mutex_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/random/random.h> class TMutexTest: public TTestBase { @@ -123,7 +123,7 @@ private: private: TSharedData Data_; - TThreadPool Q_; + TThreadPool Q_; }; UNIT_TEST_SUITE_REGISTRATION(TMutexTest) diff --git a/util/system/rwlock_ut.cpp b/util/system/rwlock_ut.cpp index 2b384c05b3..235d28a363 100644 --- a/util/system/rwlock_ut.cpp +++ b/util/system/rwlock_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/random/random.h> class TRWMutexTest: public TTestBase { @@ -118,7 +118,7 @@ private: #undef RUN_CYCLE private: TSharedData Data_; - TThreadPool Q_; + TThreadPool Q_; }; UNIT_TEST_SUITE_REGISTRATION(TRWMutexTest) diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp index b1989b5c8c..0ba5b81ac0 100644 --- a/util/system/shellcommand.cpp +++ b/util/system/shellcommand.cpp @@ -13,7 +13,7 @@ #include <util/network/socket.h> #include <util/stream/pipe.h> #include <util/stream/str.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/system/info.h> #include <errno.h> diff --git a/util/system/thread.cpp b/util/system/thread.cpp index 6236746c2d..d471cfa0f2 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -44,7 +44,7 @@ namespace { inline void SetThrName(const TParams& p) { try { if (p.Name) { - TThread::SetCurrentThreadName(p.Name.data()); + TThread::SetCurrentThreadName(p.Name.data()); } } catch (...) { // ¯\_(ツ)_/¯ @@ -445,7 +445,7 @@ namespace { } #endif // _win_ -void TThread::SetCurrentThreadName(const char* name) { +void TThread::SetCurrentThreadName(const char* name) { (void)name; #if defined(_freebsd_) @@ -469,7 +469,7 @@ void TThread::SetCurrentThreadName(const char* name) { #endif // OS } -TString TThread::CurrentThreadName() { +TString TThread::CurrentThreadName() { #if defined(_freebsd_) // TODO: check pthread_get_name_np API availability #elif defined(_linux_) diff --git a/util/system/thread.h b/util/system/thread.h index a6e8abdb5b..2a666fb9c2 100644 --- a/util/system/thread.h +++ b/util/system/thread.h @@ -1,8 +1,8 @@ #pragma once /// This code should not be used directly unless you really understand what you do. -/// If you need threads, use thread pool functionality in <util/thread/factory.h> -/// @see SystemThreadFactory() +/// If you need threads, use thread pool functionality in <util/thread/factory.h> +/// @see SystemThreadFactory() #include <util/generic/ptr.h> #include <util/generic/string.h> @@ -26,7 +26,7 @@ public: void* Data; size_t StackSize; void* StackPointer; - // See comments for `SetCurrentThreadName` + // See comments for `SetCurrentThreadName` TString Name = GetProgramName(); inline TParams() @@ -114,12 +114,12 @@ public: // // NOTE: On Linux thread name is limited to 15 symbols which is probably the smallest one among // all platforms. If you provide a name longer than 15 symbols it will be cut. So if you expect - // `CurrentThreadName` to return the same name as `name` make sure it's not longer than 15 + // `CurrentThreadName` to return the same name as `name` make sure it's not longer than 15 // symbols. - static void SetCurrentThreadName(const char* name); + static void SetCurrentThreadName(const char* name); // NOTE: Will return empty string where CanGetCurrentThreadName() returns false. - static TString CurrentThreadName(); + static TString CurrentThreadName(); // NOTE: Depends on a platform version. // Will return true for Darwin, Linux or fresh Windows 10. diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp index d820898fd5..a2a4aab4cb 100644 --- a/util/system/thread_ut.cpp +++ b/util/system/thread_ut.cpp @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { } void* ThreadProc(void*) { - TThread::SetCurrentThreadName("CurrentThreadSetNameTest"); + TThread::SetCurrentThreadName("CurrentThreadSetNameTest"); return nullptr; } @@ -56,16 +56,16 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { } void* ThreadProc3(void*) { - const auto name = TThread::CurrentThreadName(); + const auto name = TThread::CurrentThreadName(); Y_FAKE_READ(name); return nullptr; } void* ThreadProc4(void*) { const TString setName = "ThreadName"; - TThread::SetCurrentThreadName(setName.data()); + TThread::SetCurrentThreadName(setName.data()); - const auto getName = TThread::CurrentThreadName(); + const auto getName = TThread::CurrentThreadName(); if (TThread::CanGetCurrentThreadName()) { UNIT_ASSERT_VALUES_EQUAL(setName, getName); } else { @@ -75,7 +75,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { } void* ThreadProcChild(void*) { - const auto name = TThread::CurrentThreadName(); + const auto name = TThread::CurrentThreadName(); const auto defaultName = GetProgramName(); (void)name; @@ -89,14 +89,14 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { void* ThreadProcParent(void*) { const TString setName = "Parent"; - TThread::SetCurrentThreadName(setName.data()); + TThread::SetCurrentThreadName(setName.data()); TThread thread(&ThreadProcChild, nullptr); thread.Start(); thread.Join(); - const auto getName = TThread::CurrentThreadName(); + const auto getName = TThread::CurrentThreadName(); if (TThread::CanGetCurrentThreadName()) { UNIT_ASSERT_VALUES_EQUAL(setName, getName); } else { diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make index 127e7c261e..99d468ef35 100644 --- a/util/system/ut/ya.make +++ b/util/system/ut/ya.make @@ -48,7 +48,7 @@ SRCS( system/fstat_ut.cpp system/getpid_ut.cpp system/guard_ut.cpp - system/hi_lo_ut.cpp + system/hi_lo_ut.cpp system/hostname_ut.cpp system/info_ut.cpp system/interrupt_signals_ut.cpp diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp index 48e898f32d..afe2d20760 100644 --- a/util/thread/factory.cpp +++ b/util/thread/factory.cpp @@ -1,12 +1,12 @@ -#include "factory.h" +#include "factory.h" #include <util/system/thread.h> #include <util/generic/singleton.h> -using IThread = IThreadFactory::IThread; +using IThread = IThreadFactory::IThread; namespace { - class TSystemThreadFactory: public IThreadFactory { + class TSystemThreadFactory: public IThreadFactory { public: class TPoolThread: public IThread { public: @@ -42,7 +42,7 @@ namespace { THolder<TThread> Thr_; }; - inline TSystemThreadFactory() noexcept { + inline TSystemThreadFactory() noexcept { } IThread* DoCreate() override { @@ -50,14 +50,14 @@ namespace { } }; - class TThreadFactoryFuncObj: public IThreadFactory::IThreadAble { + class TThreadFactoryFuncObj: public IThreadFactory::IThreadAble { public: - TThreadFactoryFuncObj(const std::function<void()>& func) + TThreadFactoryFuncObj(const std::function<void()>& func) : Func(func) { } void DoExecute() override { - THolder<TThreadFactoryFuncObj> self(this); + THolder<TThreadFactoryFuncObj> self(this); Func(); } @@ -69,18 +69,18 @@ namespace { THolder<IThread> IThreadFactory::Run(std::function<void()> func) { THolder<IThread> ret(DoCreate()); - ret->Run(new ::TThreadFactoryFuncObj(func)); + ret->Run(new ::TThreadFactoryFuncObj(func)); return ret; } -static IThreadFactory* SystemThreadPoolImpl() { - return Singleton<TSystemThreadFactory>(); +static IThreadFactory* SystemThreadPoolImpl() { + return Singleton<TSystemThreadFactory>(); } -static IThreadFactory* systemPool = nullptr; +static IThreadFactory* systemPool = nullptr; -IThreadFactory* SystemThreadFactory() { +IThreadFactory* SystemThreadFactory() { if (systemPool) { return systemPool; } @@ -88,6 +88,6 @@ IThreadFactory* SystemThreadFactory() { return SystemThreadPoolImpl(); } -void SetSystemThreadFactory(IThreadFactory* pool) { +void SetSystemThreadFactory(IThreadFactory* pool) { systemPool = pool; } diff --git a/util/thread/factory.h b/util/thread/factory.h index 561fcbac88..f60a8ba56d 100644 --- a/util/thread/factory.h +++ b/util/thread/factory.h @@ -3,7 +3,7 @@ #include <util/generic/ptr.h> #include <functional> -class IThreadFactory { +class IThreadFactory { public: class IThreadAble { public: @@ -20,7 +20,7 @@ public: }; class IThread { - friend class IThreadFactory; + friend class IThreadFactory; public: inline IThread() noexcept = default; @@ -42,9 +42,9 @@ public: virtual void DoJoin() noexcept = 0; }; - inline IThreadFactory() noexcept = default; + inline IThreadFactory() noexcept = default; - virtual ~IThreadFactory() = default; + virtual ~IThreadFactory() = default; // XXX: rename to Start inline THolder<IThread> Run(IThreadAble* func) { @@ -61,5 +61,5 @@ private: virtual IThread* DoCreate() = 0; }; -IThreadFactory* SystemThreadFactory(); -void SetSystemThreadFactory(IThreadFactory* pool); +IThreadFactory* SystemThreadFactory(); +void SetSystemThreadFactory(IThreadFactory* pool); diff --git a/util/thread/factory_ut.cpp b/util/thread/factory_ut.cpp index 647d96c901..d366467787 100644 --- a/util/thread/factory_ut.cpp +++ b/util/thread/factory_ut.cpp @@ -1,5 +1,5 @@ -#include "factory.h" -#include "pool.h" +#include "factory.h" +#include "pool.h" #include <library/cpp/testing/unittest/registar.h> @@ -9,7 +9,7 @@ class TThrPoolTest: public TTestBase { UNIT_TEST(TestAdaptivePool) UNIT_TEST_SUITE_END(); - struct TRunAble: public IThreadFactory::IThreadAble { + struct TRunAble: public IThreadFactory::IThreadAble { inline TRunAble() : done(false) { @@ -41,7 +41,7 @@ private: TRunAble r; { - TAdaptiveThreadPool pool; + TAdaptiveThreadPool pool; pool.Start(0); diff --git a/util/thread/fwd.h b/util/thread/fwd.h index 6f1caed21c..f55d566b62 100644 --- a/util/thread/fwd.h +++ b/util/thread/fwd.h @@ -13,18 +13,18 @@ class TAutoLockFreeQueue; template <class T> class TLockFreeStack; -class IThreadFactory; +class IThreadFactory; struct IObjectInQueue; -class TThreadFactoryHolder; +class TThreadFactoryHolder; using TThreadFunction = std::function<void()>; -class IThreadPool; -class TFakeThreadPool; -class TThreadPool; -class TAdaptiveThreadPool; -class TSimpleThreadPool; +class IThreadPool; +class TFakeThreadPool; +class TThreadPool; +class TAdaptiveThreadPool; +class TSimpleThreadPool; template <class TQueueType, class TSlave> -class TThreadPoolBinder; +class TThreadPoolBinder; diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index 05fad02e9b..3564449f74 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -24,8 +24,8 @@ #include <util/datetime/base.h> -#include "factory.h" -#include "pool.h" +#include "factory.h" +#include "pool.h" namespace { class TThreadNamer { @@ -60,13 +60,13 @@ namespace { }; } -TThreadFactoryHolder::TThreadFactoryHolder() noexcept - : Pool_(SystemThreadFactory()) +TThreadFactoryHolder::TThreadFactoryHolder() noexcept + : Pool_(SystemThreadFactory()) { } -class TThreadPool::TImpl: public TIntrusiveListItem<TImpl>, public IThreadFactory::IThreadAble { - using TTsr = IThreadPool::TTsr; +class TThreadPool::TImpl: public TIntrusiveListItem<TImpl>, public IThreadFactory::IThreadAble { + using TTsr = IThreadPool::TTsr; using TJobQueue = TFastQueue<IObjectInQueue*>; using TThreadRef = THolder<IThreadFactory::IThread>; @@ -253,7 +253,7 @@ private: } private: - TThreadPool* Parent_; + TThreadPool* Parent_; const bool Blocking; const bool Catching; TThreadNamer Namer; @@ -315,9 +315,9 @@ private: }; }; -TThreadPool::~TThreadPool() = default; +TThreadPool::~TThreadPool() = default; -size_t TThreadPool::Size() const noexcept { +size_t TThreadPool::Size() const noexcept { if (!Impl_.Get()) { return 0; } @@ -325,7 +325,7 @@ size_t TThreadPool::Size() const noexcept { return Impl_->Size(); } -size_t TThreadPool::GetThreadCountExpected() const noexcept { +size_t TThreadPool::GetThreadCountExpected() const noexcept { if (!Impl_.Get()) { return 0; } @@ -333,7 +333,7 @@ size_t TThreadPool::GetThreadCountExpected() const noexcept { return Impl_->GetThreadCountExpected(); } -size_t TThreadPool::GetThreadCountReal() const noexcept { +size_t TThreadPool::GetThreadCountReal() const noexcept { if (!Impl_.Get()) { return 0; } @@ -341,7 +341,7 @@ size_t TThreadPool::GetThreadCountReal() const noexcept { return Impl_->GetThreadCountReal(); } -size_t TThreadPool::GetMaxQueueSize() const noexcept { +size_t TThreadPool::GetMaxQueueSize() const noexcept { if (!Impl_.Get()) { return 0; } @@ -349,7 +349,7 @@ size_t TThreadPool::GetMaxQueueSize() const noexcept { return Impl_->GetMaxQueueSize(); } -bool TThreadPool::Add(IObjectInQueue* obj) { +bool TThreadPool::Add(IObjectInQueue* obj) { Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); if (Impl_->NeedRestart()) { @@ -359,19 +359,19 @@ bool TThreadPool::Add(IObjectInQueue* obj) { return Impl_->Add(obj); } -void TThreadPool::Start(size_t thrnum, size_t maxque) { +void TThreadPool::Start(size_t thrnum, size_t maxque) { Impl_.Reset(new TImpl(this, thrnum, maxque, Params)); } -void TThreadPool::Stop() noexcept { +void TThreadPool::Stop() noexcept { Impl_.Destroy(); } static TAtomic mtp_queue_counter = 0; -class TAdaptiveThreadPool::TImpl { +class TAdaptiveThreadPool::TImpl { public: - class TThread: public IThreadFactory::IThreadAble { + class TThread: public IThreadFactory::IThreadAble { public: inline TThread(TImpl* parent) : Impl_(parent) @@ -533,7 +533,7 @@ private: } private: - TAdaptiveThreadPool* Parent_; + TAdaptiveThreadPool* Parent_; const bool Catching; TThreadNamer Namer; TAtomic ThrCount_; @@ -563,9 +563,9 @@ DEFINE_THREAD_POOL_CTORS(TThreadPool) DEFINE_THREAD_POOL_CTORS(TAdaptiveThreadPool) DEFINE_THREAD_POOL_CTORS(TSimpleThreadPool) -TAdaptiveThreadPool::~TAdaptiveThreadPool() = default; +TAdaptiveThreadPool::~TAdaptiveThreadPool() = default; -bool TAdaptiveThreadPool::Add(IObjectInQueue* obj) { +bool TAdaptiveThreadPool::Add(IObjectInQueue* obj) { Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); Impl_->Add(obj); @@ -573,15 +573,15 @@ bool TAdaptiveThreadPool::Add(IObjectInQueue* obj) { return true; } -void TAdaptiveThreadPool::Start(size_t, size_t) { +void TAdaptiveThreadPool::Start(size_t, size_t) { Impl_.Reset(new TImpl(this, Params)); } -void TAdaptiveThreadPool::Stop() noexcept { +void TAdaptiveThreadPool::Stop() noexcept { Impl_.Destroy(); } -size_t TAdaptiveThreadPool::Size() const noexcept { +size_t TAdaptiveThreadPool::Size() const noexcept { if (Impl_.Get()) { return Impl_->Size(); } @@ -589,13 +589,13 @@ size_t TAdaptiveThreadPool::Size() const noexcept { return 0; } -void TAdaptiveThreadPool::SetMaxIdleTime(TDuration interval) { +void TAdaptiveThreadPool::SetMaxIdleTime(TDuration interval) { Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); Impl_->SetMaxIdleTime(interval); } -TSimpleThreadPool::~TSimpleThreadPool() { +TSimpleThreadPool::~TSimpleThreadPool() { try { Stop(); } catch (...) { @@ -603,15 +603,15 @@ TSimpleThreadPool::~TSimpleThreadPool() { } } -bool TSimpleThreadPool::Add(IObjectInQueue* obj) { +bool TSimpleThreadPool::Add(IObjectInQueue* obj) { Y_ENSURE_EX(Slave_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); return Slave_->Add(obj); } -void TSimpleThreadPool::Start(size_t thrnum, size_t maxque) { - THolder<IThreadPool> tmp; - TAdaptiveThreadPool* adaptive(nullptr); +void TSimpleThreadPool::Start(size_t thrnum, size_t maxque) { + THolder<IThreadPool> tmp; + TAdaptiveThreadPool* adaptive(nullptr); if (thrnum) { tmp.Reset(new TThreadPoolBinder<TThreadPool, TSimpleThreadPool>(this, Params)); @@ -629,11 +629,11 @@ void TSimpleThreadPool::Start(size_t thrnum, size_t maxque) { Slave_.Swap(tmp); } -void TSimpleThreadPool::Stop() noexcept { +void TSimpleThreadPool::Stop() noexcept { Slave_.Destroy(); } -size_t TSimpleThreadPool::Size() const noexcept { +size_t TSimpleThreadPool::Size() const noexcept { if (Slave_.Get()) { return Slave_->Size(); } @@ -659,7 +659,7 @@ namespace { }; } -void IThreadPool::SafeAdd(IObjectInQueue* obj) { +void IThreadPool::SafeAdd(IObjectInQueue* obj) { Y_ENSURE_EX(Add(obj), TThreadPoolException() << TStringBuf("can not add object to queue")); } @@ -676,8 +676,8 @@ bool IThreadPool::AddAndOwn(THolder<IObjectInQueue> obj) { return added; } -using IThread = IThreadFactory::IThread; -using IThreadAble = IThreadFactory::IThreadAble; +using IThread = IThreadFactory::IThread; +using IThreadAble = IThreadFactory::IThreadAble; namespace { class TPoolThread: public IThread { @@ -724,7 +724,7 @@ namespace { using TThreadImplRef = TIntrusivePtr<TThreadImpl>; public: - inline TPoolThread(IThreadPool* parent) + inline TPoolThread(IThreadPool* parent) : Parent_(parent) { } @@ -751,21 +751,21 @@ namespace { } private: - IThreadPool* Parent_; + IThreadPool* Parent_; TThreadImplRef Impl_; }; } -IThread* IThreadPool::DoCreate() { +IThread* IThreadPool::DoCreate() { return new TPoolThread(this); } THolder<IThreadPool> CreateThreadPool(size_t threadsCount, size_t queueSizeLimit, const TThreadPoolParams& params) { - THolder<IThreadPool> queue; + THolder<IThreadPool> queue; if (threadsCount > 1) { queue.Reset(new TThreadPool(params)); } else { - queue.Reset(new TFakeThreadPool()); + queue.Reset(new TFakeThreadPool()); } queue->Start(threadsCount, queueSizeLimit); return queue; diff --git a/util/thread/pool.h b/util/thread/pool.h index d1ea3a67cb..9876cfc0c0 100644 --- a/util/thread/pool.h +++ b/util/thread/pool.h @@ -1,7 +1,7 @@ #pragma once #include "fwd.h" -#include "factory.h" +#include "factory.h" #include <util/system/yassert.h> #include <util/system/defaults.h> @@ -20,8 +20,8 @@ struct IObjectInQueue { * in multiple threads. * * @param threadSpecificResource is nullptr by default. But if you override - * IThreadPool::CreateThreadSpecificResource, then result of - * IThreadPool::CreateThreadSpecificResource is passed as threadSpecificResource + * IThreadPool::CreateThreadSpecificResource, then result of + * IThreadPool::CreateThreadSpecificResource is passed as threadSpecificResource * parameter. */ virtual void Process(void* threadSpecificResource) = 0; @@ -31,26 +31,26 @@ struct IObjectInQueue { * Mighty class to add 'Pool' method to derived classes. * Useful only for creators of new queue classes. */ -class TThreadFactoryHolder { +class TThreadFactoryHolder { public: - TThreadFactoryHolder() noexcept; + TThreadFactoryHolder() noexcept; - inline TThreadFactoryHolder(IThreadFactory* pool) noexcept + inline TThreadFactoryHolder(IThreadFactory* pool) noexcept : Pool_(pool) { } - inline ~TThreadFactoryHolder() = default; + inline ~TThreadFactoryHolder() = default; - inline IThreadFactory* Pool() const noexcept { + inline IThreadFactory* Pool() const noexcept { return Pool_; } private: - IThreadFactory* Pool_; + IThreadFactory* Pool_; }; -class TThreadPoolException: public yexception { +class TThreadPoolException: public yexception { }; template <class T> @@ -136,11 +136,11 @@ struct TThreadPoolParams { /** * A queue processed simultaneously by several threads */ -class IThreadPool: public IThreadFactory, public TNonCopyable { +class IThreadPool: public IThreadFactory, public TNonCopyable { public: using TParams = TThreadPoolParams; - ~IThreadPool() override = default; + ~IThreadPool() override = default; /** * Safe versions of Add*() functions. Behave exactly like as non-safe @@ -183,11 +183,11 @@ public: public: /** * RAII wrapper for Create/DestroyThreadSpecificResource. - * Useful only for implementers of new IThreadPool queues. + * Useful only for implementers of new IThreadPool queues. */ class TTsr { public: - inline TTsr(IThreadPool* q) + inline TTsr(IThreadPool* q) : Q_(q) , Data_(Q_->CreateThreadSpecificResource()) { @@ -206,14 +206,14 @@ public: } private: - IThreadPool* Q_; + IThreadPool* Q_; void* Data_; }; /** * CreateThreadSpecificResource and DestroyThreadSpecificResource - * called from internals of (TAdaptiveThreadPool, TThreadPool, ...) implementation, - * not by user of IThreadPool interface. + * called from internals of (TAdaptiveThreadPool, TThreadPool, ...) implementation, + * not by user of IThreadPool interface. * Created resource is passed to IObjectInQueue::Proccess function. */ virtual void* CreateThreadSpecificResource() { @@ -231,11 +231,11 @@ private: }; /** - * Single-threaded implementation of IThreadPool, process tasks in same thread when + * Single-threaded implementation of IThreadPool, process tasks in same thread when * added. * Can be used to remove multithreading. */ -class TFakeThreadPool: public IThreadPool { +class TFakeThreadPool: public IThreadPool { public: bool Add(IObjectInQueue* pObj) override Y_WARN_UNUSED_RESULT { TTsr tsr(this); @@ -267,7 +267,7 @@ protected: class TThreadPool: public TThreadPoolBase { public: TThreadPool(const TParams& params = {}); - ~TThreadPool() override; + ~TThreadPool() override; bool Add(IObjectInQueue* obj) override Y_WARN_UNUSED_RESULT; /** @@ -293,7 +293,7 @@ private: class TAdaptiveThreadPool: public TThreadPoolBase { public: TAdaptiveThreadPool(const TParams& params = {}); - ~TAdaptiveThreadPool() override; + ~TAdaptiveThreadPool() override; /** * If working thread waits task too long (more then interval parameter), @@ -313,34 +313,34 @@ private: THolder<TImpl> Impl_; }; -/** Behave like TThreadPool or TAdaptiveThreadPool, choosen by thrnum parameter of Start() */ +/** Behave like TThreadPool or TAdaptiveThreadPool, choosen by thrnum parameter of Start() */ class TSimpleThreadPool: public TThreadPoolBase { public: TSimpleThreadPool(const TParams& params = {}); - ~TSimpleThreadPool() override; + ~TSimpleThreadPool() override; bool Add(IObjectInQueue* obj) override Y_WARN_UNUSED_RESULT; /** - * @parameter thrnum. If thrnum is 0, use TAdaptiveThreadPool with small - * SetMaxIdleTime interval parameter. if thrnum is not 0, use non-blocking TThreadPool + * @parameter thrnum. If thrnum is 0, use TAdaptiveThreadPool with small + * SetMaxIdleTime interval parameter. if thrnum is not 0, use non-blocking TThreadPool */ void Start(size_t thrnum, size_t maxque = 0) override; void Stop() noexcept override; size_t Size() const noexcept override; private: - THolder<IThreadPool> Slave_; + THolder<IThreadPool> Slave_; }; /** * Helper to override virtual functions Create/DestroyThreadSpecificResource - * from IThreadPool and implement them using functions with same name from + * from IThreadPool and implement them using functions with same name from * pointer to TSlave. */ template <class TQueueType, class TSlave> -class TThreadPoolBinder: public TQueueType { +class TThreadPoolBinder: public TQueueType { public: - inline TThreadPoolBinder(TSlave* slave) + inline TThreadPoolBinder(TSlave* slave) : Slave_(slave) { } @@ -352,12 +352,12 @@ public: { } - inline TThreadPoolBinder(TSlave& slave) + inline TThreadPoolBinder(TSlave& slave) : Slave_(&slave) { } - ~TThreadPoolBinder() override { + ~TThreadPoolBinder() override { try { this->Stop(); } catch (...) { @@ -384,7 +384,7 @@ inline void Delete(THolder<IThreadPool> q) { } /** - * Creates and starts TThreadPool if threadsCount > 1, or TFakeThreadPool otherwise - * You could specify blocking and catching modes for TThreadPool only + * Creates and starts TThreadPool if threadsCount > 1, or TFakeThreadPool otherwise + * You could specify blocking and catching modes for TThreadPool only */ THolder<IThreadPool> CreateThreadPool(size_t threadCount, size_t queueSizeLimit = 0, const IThreadPool::TParams& params = {}); diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp index 893770d0c4..f11851ead3 100644 --- a/util/thread/pool_ut.cpp +++ b/util/thread/pool_ut.cpp @@ -1,4 +1,4 @@ -#include "pool.h" +#include "pool.h" #include <library/cpp/testing/unittest/registar.h> @@ -9,15 +9,15 @@ #include <util/system/mutex.h> #include <util/system/condvar.h> -struct TThreadPoolTest { +struct TThreadPoolTest { TSpinLock Lock; long R = -1; struct TTask: public IObjectInQueue { - TThreadPoolTest* Test = nullptr; + TThreadPoolTest* Test = nullptr; long Value = 0; - TTask(TThreadPoolTest* test, int value) + TTask(TThreadPoolTest* test, int value) : Test(test) , Value(value) { @@ -50,7 +50,7 @@ struct TThreadPoolTest { } }; - inline void TestAnyQueue(IThreadPool* queue, size_t queueSize = 1000) { + inline void TestAnyQueue(IThreadPool* queue, size_t queueSize = 1000) { TReallyFastRng32 rand(17); const size_t cnt = 1000; @@ -73,7 +73,7 @@ struct TThreadPoolTest { } }; -class TFailAddQueue: public IThreadPool { +class TFailAddQueue: public IThreadPool { public: bool Add(IObjectInQueue* /*obj*/) override Y_WARN_UNUSED_RESULT { return false; @@ -90,35 +90,35 @@ public: } }; -Y_UNIT_TEST_SUITE(TThreadPoolTest) { - Y_UNIT_TEST(TestTThreadPool) { - TThreadPoolTest t; - TThreadPool q; +Y_UNIT_TEST_SUITE(TThreadPoolTest) { + Y_UNIT_TEST(TestTThreadPool) { + TThreadPoolTest t; + TThreadPool q; t.TestAnyQueue(&q); } - Y_UNIT_TEST(TestTThreadPoolBlocking) { - TThreadPoolTest t; + Y_UNIT_TEST(TestTThreadPoolBlocking) { + TThreadPoolTest t; TThreadPool q(TThreadPool::TParams().SetBlocking(true)); t.TestAnyQueue(&q, 100); } // disabled by pg@ long time ago due to test flaps // Tried to enable: REVIEW:78772 - Y_UNIT_TEST(TestTAdaptiveThreadPool) { + Y_UNIT_TEST(TestTAdaptiveThreadPool) { if (false) { - TThreadPoolTest t; - TAdaptiveThreadPool q; + TThreadPoolTest t; + TAdaptiveThreadPool q; t.TestAnyQueue(&q); } } Y_UNIT_TEST(TestAddAndOwn) { - TThreadPool q; + TThreadPool q; q.Start(2); bool processed = false; bool destructed = false; - q.SafeAddAndOwn(MakeHolder<TThreadPoolTest::TOwnedTask>(processed, destructed)); + q.SafeAddAndOwn(MakeHolder<TThreadPoolTest::TOwnedTask>(processed, destructed)); q.Stop(); UNIT_ASSERT_C(processed, "Not processed"); @@ -135,7 +135,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) { Y_UNIT_TEST(TestSafeAddFuncThrows) { TFailAddQueue queue; - UNIT_CHECK_GENERATED_EXCEPTION(queue.SafeAddFunc([] {}), TThreadPoolException); + UNIT_CHECK_GENERATED_EXCEPTION(queue.SafeAddFunc([] {}), TThreadPoolException); } Y_UNIT_TEST(TestFunctionNotCopied) { @@ -147,7 +147,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) { } TFailOnCopy(const TFailOnCopy&) { - UNIT_FAIL("Don't copy std::function inside TThreadPool"); + UNIT_FAIL("Don't copy std::function inside TThreadPool"); } }; @@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) { } Y_UNIT_TEST(TestInfoGetters) { - TThreadPool queue; + TThreadPool queue; queue.Start(2, 7); diff --git a/util/thread/ut/ya.make b/util/thread/ut/ya.make index 93198bfaf1..af50ab2452 100644 --- a/util/thread/ut/ya.make +++ b/util/thread/ut/ya.make @@ -4,15 +4,15 @@ OWNER(g:util) SUBSCRIBER(g:util-subscribers) SRCS( - thread/factory_ut.cpp + thread/factory_ut.cpp thread/lfqueue_ut.cpp thread/lfstack_ut.cpp - thread/pool_ut.cpp + thread/pool_ut.cpp thread/singleton_ut.cpp ) -PEERDIR( - library/cpp/threading/future -) - +PEERDIR( + library/cpp/threading/future +) + END() diff --git a/util/ya.make b/util/ya.make index 6ebe7e40cf..a1e8f84534 100644 --- a/util/ya.make +++ b/util/ya.make @@ -228,7 +228,7 @@ JOIN_SRCS( string/hex.cpp string/join.cpp string/printf.cpp - string/reverse.cpp + string/reverse.cpp string/split.cpp string/strip.cpp string/strspn.cpp @@ -242,10 +242,10 @@ IF (ARCH_ARM) CFLAGS(-D_FORTIFY_SOURCE=0) ENDIF() -IF (TSTRING_IS_STD_STRING) - CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) -ENDIF() - +IF (TSTRING_IS_STD_STRING) + CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) +ENDIF() + JOIN_SRCS( all_system_1.cpp system/atexit.cpp @@ -270,7 +270,7 @@ JOIN_SRCS( system/fs.cpp system/fstat.cpp system/getpid.cpp - system/hi_lo.cpp + system/hi_lo.cpp system/hostname.cpp system/hp_timer.cpp system/info.cpp @@ -372,11 +372,11 @@ ENDIF() # thread JOIN_SRCS( all_thread.cpp - thread/factory.cpp + thread/factory.cpp thread/fwd.cpp thread/lfqueue.cpp thread/lfstack.cpp - thread/pool.cpp + thread/pool.cpp thread/singleton.cpp ) diff --git a/util/ysaveload.h b/util/ysaveload.h index 02efb4049b..17279b1f17 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -370,10 +370,10 @@ template <> class TSerializer<TUtf16String>: public TVectorSerializer<TUtf16String> { }; -template <class TChar> -class TSerializer<std::basic_string<TChar>>: public TVectorSerializer<std::basic_string<TChar>> { -}; - +template <class TChar> +class TSerializer<std::basic_string<TChar>>: public TVectorSerializer<std::basic_string<TChar>> { +}; + template <class T, class A> class TSerializer<TDeque<T, A>>: public TVectorSerializer<TDeque<T, A>> { }; @@ -640,7 +640,7 @@ public: }; #ifndef __NVCC__ - + namespace NPrivate { template <class Variant, class T, size_t I> void LoadVariantAlternative(IInputStream* is, Variant& v) { @@ -651,14 +651,14 @@ namespace NPrivate { } template <typename... Args> -struct TSerializer<std::variant<Args...>> { - using TVar = std::variant<Args...>; +struct TSerializer<std::variant<Args...>> { + using TVar = std::variant<Args...>; static_assert(sizeof...(Args) < 256, "We use ui8 to store tag"); static void Save(IOutputStream* os, const TVar& v) { - ::Save<ui8>(os, v.index()); - std::visit([os](const auto& data) { + ::Save<ui8>(os, v.index()); + std::visit([os](const auto& data) { ::Save(os, data); }, v); } @@ -681,8 +681,8 @@ private: } }; -#endif - +#endif + template <class T> static inline void SaveLoad(IOutputStream* out, const T& t) { Save(out, t); @@ -711,15 +711,15 @@ static inline void LoadMany(S* s, Ts&... t) { inline void Load(IInputStream* s) { \ ::LoadMany(s, __VA_ARGS__); \ } - -#define Y_SAVELOAD_DEFINE_OVERRIDE(...) \ - void Save(IOutputStream* s) const override { \ - ::SaveMany(s, __VA_ARGS__); \ - } \ - \ - void Load(IInputStream* s) override { \ - ::LoadMany(s, __VA_ARGS__); \ - } + +#define Y_SAVELOAD_DEFINE_OVERRIDE(...) \ + void Save(IOutputStream* s) const override { \ + ::SaveMany(s, __VA_ARGS__); \ + } \ + \ + void Load(IInputStream* s) override { \ + ::LoadMany(s, __VA_ARGS__); \ + } template <class T> struct TNonVirtualSaver { diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp index 723c68f391..3f6c9d8bd1 100644 --- a/util/ysaveload_ut.cpp +++ b/util/ysaveload_ut.cpp @@ -284,9 +284,9 @@ private: } UNIT_ASSERT_EQUAL(values.size(), 3); - UNIT_ASSERT_EQUAL(values.contains(3), true); - UNIT_ASSERT_EQUAL(values.contains(4), true); - UNIT_ASSERT_EQUAL(values.contains(5), true); + UNIT_ASSERT_EQUAL(values.contains(3), true); + UNIT_ASSERT_EQUAL(values.contains(4), true); + UNIT_ASSERT_EQUAL(values.contains(5), true); } { @@ -413,11 +413,11 @@ private: TBufferStream s; ::Save(&s, v); ::Load(&s, v); - UNIT_ASSERT_VALUES_EQUAL(std::get<T>(v), expected); + UNIT_ASSERT_VALUES_EQUAL(std::get<T>(v), expected); } void TestVariant() { - std::variant<int, bool, TString, TVector<char>> v(1); + std::variant<int, bool, TString, TVector<char>> v(1); TestVariantImpl(v, 42); TestVariantImpl(v, true); TestVariantImpl(v, TString("foo")); @@ -427,7 +427,7 @@ private: TBufferStream s; ::Save(&s, v); - std::variant<char, bool> v2 = false; + std::variant<char, bool> v2 = false; UNIT_ASSERT_EXCEPTION(::Load(&s, v2), TLoadEOF); } diff --git a/ydb/core/actorlib_impl/test_interconnect_ut.cpp b/ydb/core/actorlib_impl/test_interconnect_ut.cpp index 0d9d3535ef..754af028c0 100644 --- a/ydb/core/actorlib_impl/test_interconnect_ut.cpp +++ b/ydb/core/actorlib_impl/test_interconnect_ut.cpp @@ -12,7 +12,7 @@ #include <library/cpp/json/json_value.h> #include <library/cpp/testing/unittest/registar.h> #include <util/system/sanitizers.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> namespace NKikimr { using namespace NActors; diff --git a/ydb/core/actorlib_impl/test_protocols_ut.cpp b/ydb/core/actorlib_impl/test_protocols_ut.cpp index 2e622406a0..dbdd8b97a4 100644 --- a/ydb/core/actorlib_impl/test_protocols_ut.cpp +++ b/ydb/core/actorlib_impl/test_protocols_ut.cpp @@ -23,29 +23,29 @@ auto& Ctest = Cnull; //auto& Ctest = Cerr; namespace { - class TFailingMtpQueue: public TSimpleThreadPool { + class TFailingMtpQueue: public TSimpleThreadPool { private: bool FailOnAdd_ = false; public: void SetFailOnAdd(bool fail = true) { FailOnAdd_ = fail; } - [[nodiscard]] bool Add(IObjectInQueue* pObj) override { + [[nodiscard]] bool Add(IObjectInQueue* pObj) override { if (FailOnAdd_) { return false; } - return TSimpleThreadPool::Add(pObj); + return TSimpleThreadPool::Add(pObj); } TFailingMtpQueue() = default; - TFailingMtpQueue(IThreadFactory* pool) - : TSimpleThreadPool(pool) + TFailingMtpQueue(IThreadFactory* pool) + : TSimpleThreadPool(pool) { } }; using TFailingServerMtpQueue = - TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; + TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; class THTTP200OkServer: public THttpServer::ICallBack { class TRequest: public THttpClientRequestEx { @@ -224,9 +224,9 @@ Y_UNIT_TEST_SUITE(TestProtocols) { THttpServer::TOptions options(port); THttpServer::TMtpQueueRef mainWorkers = - new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); + new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); THttpServer::TMtpQueueRef failWorkers = - new TThreadPool(SystemThreadFactory()); + new TThreadPool(SystemThreadFactory()); THttpServer server(&serverImpl, mainWorkers, failWorkers, options); UNIT_ASSERT(server.Start()); @@ -353,9 +353,9 @@ Y_UNIT_TEST_SUITE(TestProtocols) { THttpServer::TOptions options(port); THttpServer::TMtpQueueRef mainWorkers = - new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); + new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); THttpServer::TMtpQueueRef failWorkers = - new TThreadPool(SystemThreadFactory()); + new TThreadPool(SystemThreadFactory()); THttpServer server(&serverImpl, mainWorkers, failWorkers, options); UNIT_ASSERT(server.Start()); @@ -688,9 +688,9 @@ Y_UNIT_TEST_SUITE(TestProtocols) { THttpServer::TOptions options(port); THttpServer::TMtpQueueRef mainWorkers = - new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); + new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); THttpServer::TMtpQueueRef failWorkers = - new TThreadPool(SystemThreadFactory()); + new TThreadPool(SystemThreadFactory()); THttpServer server(&serverImpl, mainWorkers, failWorkers, options); UNIT_ASSERT(server.Start()); diff --git a/ydb/core/base/logoblob.h b/ydb/core/base/logoblob.h index 36eea54393..aa62b73467 100644 --- a/ydb/core/base/logoblob.h +++ b/ydb/core/base/logoblob.h @@ -222,7 +222,7 @@ namespace NKikimr { public: struct THash { - ui32 operator()(const TLogoBlobID &id) const noexcept { + ui32 operator()(const TLogoBlobID &id) const noexcept { return id.Hash(); } }; @@ -316,7 +316,7 @@ inline void Out<TVector<NKikimr::TLogoBlobID>>(IOutputStream& out, const TVector template<> struct THash<NKikimr::TLogoBlobID> { - inline ui64 operator()(const NKikimr::TLogoBlobID& x) const noexcept { + inline ui64 operator()(const NKikimr::TLogoBlobID& x) const noexcept { return x.Hash(); } }; diff --git a/ydb/core/blobstorage/base/ptr.h b/ydb/core/blobstorage/base/ptr.h index ceb701c9f9..59b46778fa 100644 --- a/ydb/core/blobstorage/base/ptr.h +++ b/ydb/core/blobstorage/base/ptr.h @@ -13,30 +13,30 @@ namespace NKikimr { template <class T, class TCounter, class TDeleter> class TRefCountWithDeleter { public: - inline TRefCountWithDeleter(long initval = 0) noexcept + inline TRefCountWithDeleter(long initval = 0) noexcept : Counter_(initval) , Deleter_() { } - inline TRefCountWithDeleter(const TDeleter &deleter) noexcept + inline TRefCountWithDeleter(const TDeleter &deleter) noexcept : Counter_(0) , Deleter_(deleter) { } - inline ~TRefCountWithDeleter() { + inline ~TRefCountWithDeleter() { } - inline void Ref(TAtomicBase d) noexcept { + inline void Ref(TAtomicBase d) noexcept { Counter_.Add(d); } - inline void Ref() noexcept { + inline void Ref() noexcept { Counter_.Inc(); } - inline void UnRef(TAtomicBase d) noexcept { + inline void UnRef(TAtomicBase d) noexcept { TAtomicBase resultCount = Counter_.Sub(d); Y_ASSERT(resultCount >= 0); if (resultCount == 0) { @@ -44,15 +44,15 @@ namespace NKikimr { } } - inline void UnRef() noexcept { + inline void UnRef() noexcept { UnRef(1); } - inline long RefCount() const noexcept { + inline long RefCount() const noexcept { return Counter_.Val(); } - inline void DecRef() noexcept { + inline void DecRef() noexcept { Counter_.Dec(); } diff --git a/ydb/core/blobstorage/base/transparent.h b/ydb/core/blobstorage/base/transparent.h index 2590ec7d9c..ae69b9cf7f 100644 --- a/ydb/core/blobstorage/base/transparent.h +++ b/ydb/core/blobstorage/base/transparent.h @@ -27,12 +27,12 @@ namespace NKikimr { TrackingFree(); } - void ClearKeepFirstChunk() noexcept { + void ClearKeepFirstChunk() noexcept { TrackingFree(); MemoryPool.ClearKeepFirstChunk(); } - void* Allocate(size_t len) noexcept { + void* Allocate(size_t len) noexcept { i64 l = static_cast<i64>(len); Consumer.Add(l); TotalAllocated += l; diff --git a/ydb/core/blobstorage/crypto/secured_block.h b/ydb/core/blobstorage/crypto/secured_block.h index 9992d70933..8c2322b42f 100644 --- a/ydb/core/blobstorage/crypto/secured_block.h +++ b/ydb/core/blobstorage/crypto/secured_block.h @@ -6,7 +6,7 @@ #include <util/system/compiler.h> #include <util/generic/utility.h> #include <util/generic/strbuf.h> -#include <util/generic/cast.h> +#include <util/generic/cast.h> #ifdef _win_ #include <windows.h> @@ -48,7 +48,7 @@ inline void SecureWipeBuffer(ui8* buf, size_t size) inline void SecureWipeBuffer(char* buf, size_t size) { - SecureWipeBuffer(reinterpret_cast<ui8*>(buf), size); + SecureWipeBuffer(reinterpret_cast<ui8*>(buf), size); } class TAlignedAllocator @@ -254,7 +254,7 @@ public: } TStringBuf AsStringBuf() const { - return { reinterpret_cast<const char*>(Data()), Size() }; + return { reinterpret_cast<const char*>(Data()), Size() }; } private: @@ -275,7 +275,7 @@ public: : TBaseBlock<A>(data, size) {} TSecuredBlock(const char* data, size_t size) - : TBaseBlock<A>(reinterpret_cast<const ui8*>(data), size) {} + : TBaseBlock<A>(reinterpret_cast<const ui8*>(data), size) {} template<typename U> void Append(const TBaseBlock<U>& other) { @@ -303,5 +303,5 @@ public: : TBaseBlock<A>(data, nbytes) {} explicit TFixedSecuredBlock(const char* data) - : TBaseBlock<A>(reinterpret_cast<const ui8*>(data), nbytes) {} + : TBaseBlock<A>(reinterpret_cast<const ui8*>(data), nbytes) {} }; diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp index fcced0b6f8..8530cf4518 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp @@ -122,7 +122,7 @@ public: ++*Mon->NodeMon->RestartPatch; TEvBlobStorage::TEvPatch *patch; std::unique_ptr<IEventBase> ev(patch = new TEvBlobStorage::TEvPatch(OriginalGroupId, OriginalId, PatchedId, - MaskForCookieBruteForcing, std::move(Diffs), DiffCount, Deadline)); + MaskForCookieBruteForcing, std::move(Diffs), DiffCount, Deadline)); patch->RestartCounter = counter; patch->Orbit = std::move(Orbit); return std::move(ev); diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp index e234f8c18e..2dacaceb30 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp @@ -6,7 +6,7 @@ #include <ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h> #include <ydb/core/blobstorage/base/wilson_events.h> -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> namespace NKikimr { diff --git a/ydb/core/blobstorage/dsproxy/ut/dsproxy_env_mock_ut.h b/ydb/core/blobstorage/dsproxy/ut/dsproxy_env_mock_ut.h index 0f2350daf8..6758d63d4e 100644 --- a/ydb/core/blobstorage/dsproxy/ut/dsproxy_env_mock_ut.h +++ b/ydb/core/blobstorage/dsproxy/ut/dsproxy_env_mock_ut.h @@ -103,7 +103,7 @@ struct TDSProxyEnv { TMaybe<TGroupStat::EKind> kind = PutHandleClassToGroupStatKind(ev->Get()->HandleClass); return std::unique_ptr<IActor>(CreateBlobStorageGroupPutRequest(Info, GroupQueues, ev->Sender, Mon, ev->Get(), ev->Cookie, std::move(ev->TraceId), Mon->TimeStats.IsEnabled(), PerDiskStatsPtr, kind, - TInstant::Now(), StoragePoolCounters, false)); + TInstant::Now(), StoragePoolCounters, false)); } std::unique_ptr<IActor> CreatePutRequestActor(TBatchedVec<TEvBlobStorage::TEvPut::TPtr> &batched, @@ -112,7 +112,7 @@ struct TDSProxyEnv { TMaybe<TGroupStat::EKind> kind = PutHandleClassToGroupStatKind(handleClass); return std::unique_ptr<IActor>(CreateBlobStorageGroupPutRequest(Info, GroupQueues, Mon, batched, Mon->TimeStats.IsEnabled(), PerDiskStatsPtr, kind,TInstant::Now(), - StoragePoolCounters, handleClass, tactic, false)); + StoragePoolCounters, handleClass, tactic, false)); } std::unique_ptr<IActor> CreateGetRequestActor(TEvBlobStorage::TEvGet::TPtr &ev, @@ -121,13 +121,13 @@ struct TDSProxyEnv { TMaybe<TGroupStat::EKind> kind = PutHandleClassToGroupStatKind(handleClass); return std::unique_ptr<IActor>(CreateBlobStorageGroupGetRequest(Info, GroupQueues, ev->Sender, Mon, ev->Get(), ev->Cookie, std::move(ev->TraceId), TNodeLayoutInfoPtr(NodeLayoutInfo), - kind, TInstant::Now(), StoragePoolCounters, withMultiPut)); + kind, TInstant::Now(), StoragePoolCounters, withMultiPut)); } std::unique_ptr<IActor> CreatePatchRequestActor(TEvBlobStorage::TEvPatch::TPtr &ev, bool useVPatch = false) { return std::unique_ptr<IActor>(CreateBlobStorageGroupPatchRequest(Info, GroupQueues, ev->Sender, Mon, ev->Get(), ev->Cookie, std::move(ev->TraceId), TInstant::Now(), StoragePoolCounters, - FakeProxyActorId, useVPatch)); + FakeProxyActorId, useVPatch)); } }; diff --git a/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp b/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp index 6a8fbff0e2..9d439d6691 100644 --- a/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp @@ -35,7 +35,7 @@ void RunTest(TBlobStorageGroupType groupType, bool minimum = false, ui32 testPar std::exception_ptr eptr; auto test = MakeHolder<T>(&finishEvent, &eptr, NUnitTest::NPrivate::GetCurrentTest(), runtime, testPartCount, testPartIdx); - runtime.ActorSystem->Register(new TActorCoro(std::move(test)), TMailboxType::Simple, 0, {}); + runtime.ActorSystem->Register(new TActorCoro(std::move(test)), TMailboxType::Simple, 0, {}); finishEvent.WaitI(); runtime.Finish(); if (eptr) { diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp index 054d5be665..9d1be9aa71 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp @@ -8,7 +8,7 @@ #include <library/cpp/actors/core/interconnect.h> -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <library/cpp/digest/crc32c/crc32c.h> diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h index 132e0cce85..59f57b230a 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h @@ -3,7 +3,7 @@ #include "defs.h" #include "blobstorage_groupinfo_iter.h" -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> namespace NKikimr { diff --git a/ydb/core/blobstorage/groupinfo/ya.make b/ydb/core/blobstorage/groupinfo/ya.make index 59db5e1e52..b5eb828fcf 100644 --- a/ydb/core/blobstorage/groupinfo/ya.make +++ b/ydb/core/blobstorage/groupinfo/ya.make @@ -5,7 +5,7 @@ OWNER(g:kikimr) PEERDIR( library/cpp/actors/core library/cpp/digest/crc32c - library/cpp/pop_count + library/cpp/pop_count ydb/core/base ydb/core/base/services ydb/core/blobstorage/crypto diff --git a/ydb/core/blobstorage/incrhuge/incrhuge_keeper_log.cpp b/ydb/core/blobstorage/incrhuge/incrhuge_keeper_log.cpp index 62da8c0f7e..c327057c2d 100644 --- a/ydb/core/blobstorage/incrhuge/incrhuge_keeper_log.cpp +++ b/ydb/core/blobstorage/incrhuge/incrhuge_keeper_log.cpp @@ -325,7 +325,7 @@ namespace NKikimr { struct TLogger::TChunkQueueItem { // log entry content - std::variant<TChunkRecordMerger::TChunkAllocation, TChunkRecordMerger::TChunkDeletion, + std::variant<TChunkRecordMerger::TChunkAllocation, TChunkRecordMerger::TChunkDeletion, TChunkRecordMerger::TCompleteChunk, NKikimrVDiskData::TIncrHugeChunks> Content; // commit chunks @@ -347,7 +347,7 @@ namespace NKikimr { struct TLogger::TDeleteQueueItem { // actual record content depending on its type; for blob deletes it contains TBlobDeletes item, for // entrypoint -- full record that; this record will be simply merged into confirmed state upon success - std::variant<TDeleteRecordMerger::TBlobDeletes, TDeleteRecordMerger::TDeleteChunk, + std::variant<TDeleteRecordMerger::TBlobDeletes, TDeleteRecordMerger::TDeleteChunk, NKikimrVDiskData::TIncrHugeDelete> Content; // vector of callbacks that are invoked on success or failure of logging @@ -422,7 +422,7 @@ namespace NKikimr { TChunkQueueItem& item = ChunkQueue.back(); // serialize it into string - TString data = std::visit([](const auto& content) { return TChunkRecordMerger::Serialize(content); }, item.Content); + TString data = std::visit([](const auto& content) { return TChunkRecordMerger::Serialize(content); }, item.Content); // generate LSN item.Lsn = Lsn++; @@ -467,9 +467,9 @@ namespace NKikimr { ConfirmedChunkMerger = TChunkRecordMerger(); } // update confirmed state - std::visit([this](const auto& content) { ConfirmedChunkMerger(content); }, item.Content); + std::visit([this](const auto& content) { ConfirmedChunkMerger(content); }, item.Content); // if it was chunk deletion, propagate this information to deleter state - if (auto *record = std::get_if<TChunkRecordMerger::TChunkDeletion>(&item.Content)) { + if (auto *record = std::get_if<TChunkRecordMerger::TChunkDeletion>(&item.Content)) { IHLOG_DEBUG(ctx, "DeleteChunk ChunkIdx# %" PRIu32 " ChunkSerNum# %s", record->ChunkIdx, record->ChunkSerNum.ToString().data()); @@ -612,7 +612,7 @@ namespace NKikimr { merger = ConfirmedDeletesMerger; } for (; it != DeleteQueue.end(); ++it) { - std::visit([&merger](const auto& content) { merger(content); }, it->Content); + std::visit([&merger](const auto& content) { merger(content); }, it->Content); } // create new log queue item @@ -650,7 +650,7 @@ namespace NKikimr { }; // serialize it into string, depending on its type - TString data = std::visit([](const auto& content) { return TDeleteRecordMerger::Serialize(content); }, item.Content); + TString data = std::visit([](const auto& content) { return TDeleteRecordMerger::Serialize(content); }, item.Content); // format commit record NPDisk::TCommitRecord commit; @@ -684,7 +684,7 @@ namespace NKikimr { // update confirmed state IHLOG_DEBUG(ctx, "ApplyLogDeleteItem Entrypoint# %s Lsn# %" PRIu64 " Virtual# %s", item.Entrypoint ? "true" : "false", item.Lsn, item.Virtual ? "true" : "false"); - std::visit([this](const auto& content) { ConfirmedDeletesMerger(content); }, item.Content); + std::visit([this](const auto& content) { ConfirmedDeletesMerger(content); }, item.Content); } else { // set failure expected flag for all pending items -- they are already in flight and should also fail for (TDeleteQueueItem& item : DeleteQueue) { diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp index d92b19c6cc..4dc3c82415 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp @@ -801,7 +801,7 @@ public: } TEvWhiteboardReportResult *response = new TEvWhiteboardReportResult(); - response->PDiskState = MakeHolder<NNodeWhiteboard::TEvWhiteboard::TEvPDiskStateUpdate>(); + response->PDiskState = MakeHolder<NNodeWhiteboard::TEvWhiteboard::TEvPDiskStateUpdate>(); response->VDiskStateVect.reserve(16); // Pessimistic upper estimate of a number of owners THolder<TWhiteboardReport> request(PDisk->ReqCreator.CreateFromArgs<TWhiteboardReport>(SelfId(), response)); ui64 whiteboardReportCycles = 0; diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp index 34c20999b7..cb9accf12a 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp @@ -107,7 +107,7 @@ class TRealBlockDevice : public IBlockDevice { // Schedule action execution // pass action = nullptr to quit - void Schedule(TCompletionAction *action) noexcept { + void Schedule(TCompletionAction *action) noexcept { TAtomicBase queueActions = AtomicIncrement(QueuedActions); if (queueActions >= MaxQueuedActions) { Device.Mon.L7.Set(true, AtomicGetAndIncrement(SeqnoL7)); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp index d00fc0f220..c1bba59970 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp @@ -1185,7 +1185,7 @@ void TPDisk::WhiteboardReport(TWhiteboardReport &whiteboardReport) { const auto& state = static_cast<NKikimrBlobStorage::TPDiskState::E>(Mon.PDiskState->Val()); pdiskState.SetState(state); - reportResult->DiskMetrics = MakeHolder<TEvBlobStorage::TEvControllerUpdateDiskStatus>(); + reportResult->DiskMetrics = MakeHolder<TEvBlobStorage::TEvControllerUpdateDiskStatus>(); i64 minSlotSize = Max<i64>(); for (const auto& [vdiskId, owner] : VDiskOwners) { const TOwnerData &data = OwnerData[owner]; @@ -2294,8 +2294,8 @@ void TPDisk::PrepareLogError(TLogWrite *logWrite, TStringStream& err, NKikimrPro << " lsn# " << logWrite->Lsn; LOG_ERROR_S(*ActorSystem, NKikimrServices::BS_PDISK, err.Str()); - logWrite->Result.Reset(new NPDisk::TEvLogResult(status, - GetStatusFlags(logWrite->Owner, logWrite->OwnerGroupType), err.Str())); + logWrite->Result.Reset(new NPDisk::TEvLogResult(status, + GetStatusFlags(logWrite->Owner, logWrite->OwnerGroupType), err.Str())); logWrite->Result->Results.push_back(NPDisk::TEvLogResult::TRecord(logWrite->Lsn, logWrite->Cookie)); WILSON_TRACE(*ActorSystem, &logWrite->TraceId, EnqueueLogWrite); } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp index b49b5bd206..197f73a81b 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp @@ -778,7 +778,7 @@ std::atomic<ui64> TVDiskMock::OwnerRound = 2; ); const auto& sender = ev->Sender; - THolder<NPDisk::TUndelivered> req{testCtx.GetPDisk()->ReqCreator.CreateFromEv<NPDisk::TUndelivered>(ev, sender)}; + THolder<NPDisk::TUndelivered> req{testCtx.GetPDisk()->ReqCreator.CreateFromEv<NPDisk::TUndelivered>(ev, sender)}; } Y_UNIT_TEST(PDiskRestart) { diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.cpp index 3ea3033b19..157c18bb99 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.cpp @@ -6,11 +6,11 @@ namespace NPDisk { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TAtomicBlockCounter //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool TAtomicBlockCounter::IsBlocked() const noexcept { +bool TAtomicBlockCounter::IsBlocked() const noexcept { return GetBlocked(AtomicGet(Data)); } -void TAtomicBlockCounter::Block(ui64 flag, TResult& res) noexcept { +void TAtomicBlockCounter::Block(ui64 flag, TResult& res) noexcept { while (true) { ui64 prevData = AtomicGet(Data); if (prevData & flag) { @@ -25,7 +25,7 @@ void TAtomicBlockCounter::Block(ui64 flag, TResult& res) noexcept { } } -void TAtomicBlockCounter::Unblock(ui64 flag, TResult& res) noexcept { +void TAtomicBlockCounter::Unblock(ui64 flag, TResult& res) noexcept { while (true) { ui64 prevData = AtomicGet(Data); if (!(prevData & flag)) { @@ -40,7 +40,7 @@ void TAtomicBlockCounter::Unblock(ui64 flag, TResult& res) noexcept { } } -ui64 TAtomicBlockCounter::Add(ui64 value) noexcept { +ui64 TAtomicBlockCounter::Add(ui64 value) noexcept { Y_VERIFY_S(value > 0, "zero value# " << value); while (true) { ui64 prevData = AtomicGet(Data); @@ -54,7 +54,7 @@ ui64 TAtomicBlockCounter::Add(ui64 value) noexcept { } } -ui64 TAtomicBlockCounter::Sub(ui64 value) noexcept { +ui64 TAtomicBlockCounter::Sub(ui64 value) noexcept { Y_VERIFY_S(value > 0, "zero value# " << value); while (true) { ui64 prevData = AtomicGet(Data); @@ -65,7 +65,7 @@ ui64 TAtomicBlockCounter::Sub(ui64 value) noexcept { } } -ui64 TAtomicBlockCounter::ThresholdAdd(ui64 value, ui64 threshold, TAtomicBlockCounter::TResult& res) noexcept { +ui64 TAtomicBlockCounter::ThresholdAdd(ui64 value, ui64 threshold, TAtomicBlockCounter::TResult& res) noexcept { Y_VERIFY_S(value > 0, "zero value# " << value); while (true) { ui64 prevData = AtomicGet(Data); @@ -81,7 +81,7 @@ ui64 TAtomicBlockCounter::ThresholdAdd(ui64 value, ui64 threshold, TAtomicBlockC } } -ui64 TAtomicBlockCounter::ThresholdSub(ui64 value, ui64 threshold, TAtomicBlockCounter::TResult& res) noexcept { +ui64 TAtomicBlockCounter::ThresholdSub(ui64 value, ui64 threshold, TAtomicBlockCounter::TResult& res) noexcept { Y_VERIFY_S(value > 0, "zero value# " << value); while (true) { ui64 prevData = AtomicGet(Data); @@ -93,7 +93,7 @@ ui64 TAtomicBlockCounter::ThresholdSub(ui64 value, ui64 threshold, TAtomicBlockC } } -ui64 TAtomicBlockCounter::ThresholdUpdate(ui64 threshold, TAtomicBlockCounter::TResult& res) noexcept { +ui64 TAtomicBlockCounter::ThresholdUpdate(ui64 threshold, TAtomicBlockCounter::TResult& res) noexcept { while (true) { ui64 prevData = AtomicGet(Data); ui64 data = NextSeqno(ThresholdBlock(prevData, threshold)); @@ -104,25 +104,25 @@ ui64 TAtomicBlockCounter::ThresholdUpdate(ui64 threshold, TAtomicBlockCounter::T } } -ui64 TAtomicBlockCounter::Get() const noexcept { +ui64 TAtomicBlockCounter::Get() const noexcept { return GetCounter(AtomicGet(Data)); } -ui64 TAtomicBlockCounter::CheckedAddCounter(ui64 prevData, ui64 value) noexcept { +ui64 TAtomicBlockCounter::CheckedAddCounter(ui64 prevData, ui64 value) noexcept { Y_VERIFY_S(!(value & ~CounterMask), "invalid value# " << value); Y_VERIFY_S(!((GetCounter(prevData) + value) & ~CounterMask), "overflow value# " << value << " prevData# " << GetCounter(prevData)); return prevData + value; // No overflow, so higher bits are untouched } -ui64 TAtomicBlockCounter::CheckedSubCounter(ui64 prevData, ui64 value) noexcept { +ui64 TAtomicBlockCounter::CheckedSubCounter(ui64 prevData, ui64 value) noexcept { Y_VERIFY_S(!(value & ~CounterMask), "invalid value# " << value); Y_VERIFY_S(!((GetCounter(prevData) - value) & ~CounterMask), "underflow value# " << value << " prevData# " << GetCounter(prevData)); return prevData - value; // No underflow, so higher bits are untouched } -void TAtomicBlockCounter::FillResult(ui64 prevData, ui64 data, TAtomicBlockCounter::TResult& res) noexcept { +void TAtomicBlockCounter::FillResult(ui64 prevData, ui64 data, TAtomicBlockCounter::TResult& res) noexcept { res.PrevA = prevData & BlockAFlag; res.PrevB = prevData & BlockBFlag; res.A = data & BlockAFlag; @@ -131,19 +131,19 @@ void TAtomicBlockCounter::FillResult(ui64 prevData, ui64 data, TAtomicBlockCount res.PrevSeqno = GetSeqno(prevData); } -bool TAtomicBlockCounter::GetBlocked(ui64 data) noexcept { +bool TAtomicBlockCounter::GetBlocked(ui64 data) noexcept { return data & BlockMask; } -ui16 TAtomicBlockCounter::GetSeqno(ui64 data) noexcept { +ui16 TAtomicBlockCounter::GetSeqno(ui64 data) noexcept { return (data & SeqnoMask) >> SeqnoShift; } -ui64 TAtomicBlockCounter::GetCounter(ui64 data) noexcept { +ui64 TAtomicBlockCounter::GetCounter(ui64 data) noexcept { return data & CounterMask; } -ui64 TAtomicBlockCounter::ThresholdBlock(ui64 data, ui64 threshold) noexcept { +ui64 TAtomicBlockCounter::ThresholdBlock(ui64 data, ui64 threshold) noexcept { if (GetCounter(data) > threshold) { return data | BlockAFlag; } else { @@ -151,7 +151,7 @@ ui64 TAtomicBlockCounter::ThresholdBlock(ui64 data, ui64 threshold) noexcept { } } -ui64 TAtomicBlockCounter::NextSeqno(ui64 data) noexcept { +ui64 TAtomicBlockCounter::NextSeqno(ui64 data) noexcept { if (GetSeqno(data) == Max<ui16>()) { // Overflow case return data & ~SeqnoMask; } else { // No overflow case diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.h index 4991facc94..f995792855 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_atomicblockcounter.h @@ -25,84 +25,84 @@ struct TAtomicBlockCounter { ui16 Seqno = 0; ui16 PrevSeqno = 0; - bool Toggled() const noexcept { + bool Toggled() const noexcept { return WasBlocked() ^ IsBlocked(); } - bool WasBlocked() const noexcept { + bool WasBlocked() const noexcept { return PrevA || PrevB; } - bool IsBlocked() const noexcept { + bool IsBlocked() const noexcept { return A || B; } }; - TAtomicBlockCounter() noexcept {} + TAtomicBlockCounter() noexcept {} - bool IsBlocked() const noexcept; + bool IsBlocked() const noexcept; // Blocking - void Block(ui64 flag, TResult& res) noexcept; - void BlockA() noexcept { + void Block(ui64 flag, TResult& res) noexcept; + void BlockA() noexcept { TResult res; Block(BlockAFlag, res); } - void BlockB() noexcept { + void BlockB() noexcept { TResult res; Block(BlockBFlag, res); } - void BlockA(TResult& res) noexcept { + void BlockA(TResult& res) noexcept { Block(BlockAFlag, res); } - void BlockB(TResult& res) noexcept { + void BlockB(TResult& res) noexcept { Block(BlockBFlag, res); } // Unblocking - void Unblock(ui64 flag, TResult& res) noexcept; - void UnblockA() noexcept { + void Unblock(ui64 flag, TResult& res) noexcept; + void UnblockA() noexcept { TResult res; Unblock(BlockAFlag, res); } - void UnblockB() noexcept { + void UnblockB() noexcept { TResult res; Unblock(BlockBFlag, res); } - void UnblockA(TResult& res) noexcept { + void UnblockA(TResult& res) noexcept { Unblock(BlockAFlag, res); } - void UnblockB(TResult& res) noexcept { + void UnblockB(TResult& res) noexcept { Unblock(BlockBFlag, res); } // Returns counter on success, 0 iff is blocked - ui64 Add(ui64 value) noexcept; - ui64 Increment() noexcept { + ui64 Add(ui64 value) noexcept; + ui64 Increment() noexcept { return Add(1); } - ui64 Sub(ui64 value) noexcept; - ui64 Decrement() noexcept { + ui64 Sub(ui64 value) noexcept; + ui64 Decrement() noexcept { return Sub(1); } // Operations with BlockA attached to Counter overflow over specified threshold - ui64 ThresholdAdd(ui64 value, ui64 threshold, TResult& res) noexcept; - ui64 ThresholdSub(ui64 value, ui64 threshold, TResult& res) noexcept; - ui64 ThresholdUpdate(ui64 threshold, TResult& res) noexcept; + ui64 ThresholdAdd(ui64 value, ui64 threshold, TResult& res) noexcept; + ui64 ThresholdSub(ui64 value, ui64 threshold, TResult& res) noexcept; + ui64 ThresholdUpdate(ui64 threshold, TResult& res) noexcept; - ui64 Get() const noexcept; + ui64 Get() const noexcept; private: - inline static ui64 CheckedAddCounter(ui64 prevData, ui64 value) noexcept; - inline static ui64 CheckedSubCounter(ui64 prevData, ui64 value) noexcept; - inline static void FillResult(ui64 prevData, ui64 data, TResult& res) noexcept; - inline static bool GetBlocked(ui64 data) noexcept; - inline static ui16 GetSeqno(ui64 data) noexcept; - inline static ui64 GetCounter(ui64 data) noexcept; - inline static ui64 ThresholdBlock(ui64 prevData, ui64 threshold) noexcept; - inline static ui64 NextSeqno(ui64 data) noexcept; + inline static ui64 CheckedAddCounter(ui64 prevData, ui64 value) noexcept; + inline static ui64 CheckedSubCounter(ui64 prevData, ui64 value) noexcept; + inline static void FillResult(ui64 prevData, ui64 data, TResult& res) noexcept; + inline static bool GetBlocked(ui64 data) noexcept; + inline static ui16 GetSeqno(ui64 data) noexcept; + inline static ui64 GetCounter(ui64 data) noexcept; + inline static ui64 ThresholdBlock(ui64 prevData, ui64 threshold) noexcept; + inline static ui64 NextSeqno(ui64 data) noexcept; }; } // NPDisk diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueuemanyone.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueuemanyone.h index a0ac88b250..685c5d3865 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueuemanyone.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueuemanyone.h @@ -26,7 +26,7 @@ public: Y_VERIFY_S(AtomicGet(SizeLowerEstimate) == 0, "Unexpected SizeLowerEstimate# " << AtomicGet(SizeLowerEstimate)); } - void Push(T *x) noexcept { + void Push(T *x) noexcept { Queue.Push(x); AtomicIncrement(SizeLowerEstimate); WakeUp(); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueueoneone.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueueoneone.h index fc2951466c..c59aa81933 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueueoneone.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_countedqueueoneone.h @@ -24,7 +24,7 @@ public: Y_VERIFY_S(AtomicGet(SizeLowerEstimate) == 0, "Unexpected SizeLowerEstimate# " << AtomicGet(SizeLowerEstimate)); } - void Push(T x) noexcept { + void Push(T x) noexcept { Queue.Push(x); AtomicIncrement(SizeLowerEstimate); WakeUp(); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp index 97938cfcdc..df63e927d5 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp @@ -462,7 +462,7 @@ void TestPayloadOffset(ui64 firstSector, ui64 lastSector, ui64 currentSector, ui TBufferPoolCommon pool(512, 10, TBufferPool::TPDiskParams{}); for (ui32 i = 0; i < 100; ++i) { - TBuffer::TPtr buffers{pool.Pop()}; + TBuffer::TPtr buffers{pool.Pop()}; } std::vector<TBuffer::TPtr> buffers; diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_wcache.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_wcache.cpp index f613c70bee..eb2d9575b0 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_wcache.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_wcache.cpp @@ -572,7 +572,7 @@ static constexpr ui64 NVME_ID_FIRMWARE_REVISION_SIZE = 8; static TArrayHolder<char> GetNvmeIdentifyStruct(int fd, TStringStream *outDetails) { - TArrayHolder<char> id_ctrl_buffer{new char[NVME_IDENTIFY_DATA_SIZE]}; + TArrayHolder<char> id_ctrl_buffer{new char[NVME_IDENTIFY_DATA_SIZE]}; memset(id_ctrl_buffer.Get(), 0, NVME_IDENTIFY_DATA_SIZE); struct nvme_admin_cmd cmd; memset(&cmd, 0, sizeof(struct nvme_admin_cmd)); diff --git a/ydb/core/blobstorage/testload/test_load_interval_gen.h b/ydb/core/blobstorage/testload/test_load_interval_gen.h index 1d5c093db0..fdb20399c8 100644 --- a/ydb/core/blobstorage/testload/test_load_interval_gen.h +++ b/ydb/core/blobstorage/testload/test_load_interval_gen.h @@ -47,11 +47,11 @@ namespace NKikimr { } }; - struct TItem : public std::variant<TUniformItem, TPoissonItem> { - using TBase = std::variant<TUniformItem, TPoissonItem>; + struct TItem : public std::variant<TUniformItem, TPoissonItem> { + using TBase = std::variant<TUniformItem, TPoissonItem>; TItem(const NKikimrBlobStorage::TEvTestLoadRequest::TIntervalInfo& x) - : TBase(CreateVariantFromProtobuf(x)) + : TBase(CreateVariantFromProtobuf(x)) {} template<typename TProto> @@ -72,7 +72,7 @@ namespace NKikimr { TDuration Generate() const { auto f = [](const auto& item) { return item.Generate(); }; - return std::visit(f, *this); + return std::visit(f, *this); } }; diff --git a/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp b/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp index 1e1bca2fe9..f5c0e190f8 100644 --- a/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp +++ b/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp @@ -524,7 +524,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { int goodCount = 0; for(int i = 0; i < eventsCount; ++i) { events[i].reset(new TEvBlobStorage::TEvVMultiPut(test.Info->GetVDiskId(0), - TInstant::Max(), NKikimrBlobStorage::EPutHandleClass::TabletLog, false, nullptr)); + TInstant::Max(), NKikimrBlobStorage::EPutHandleClass::TabletLog, false, nullptr)); if (i % 19 != 18) { ++goodCount; TLogoBlobID blob(i, 1, 0, 0, blobSize, 0, 1); diff --git a/ydb/core/blobstorage/ut_blobstorage/patch.cpp b/ydb/core/blobstorage/ut_blobstorage/patch.cpp index b68c05b80e..1de4d43c3b 100644 --- a/ydb/core/blobstorage/ut_blobstorage/patch.cpp +++ b/ydb/core/blobstorage/ut_blobstorage/patch.cpp @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(BlobPatching) { void SendGet(const TTestInfo &test, const TLogoBlobID &blobId, const TString &data, NKikimrProto::EReplyStatus status) { - TArrayHolder<TEvBlobStorage::TEvGet::TQuery> getQueries{new TEvBlobStorage::TEvGet::TQuery[1]}; + TArrayHolder<TEvBlobStorage::TEvGet::TQuery> getQueries{new TEvBlobStorage::TEvGet::TQuery[1]}; getQueries[0].Id = blobId; std::unique_ptr<IEventBase> ev = std::make_unique<TEvBlobStorage::TEvGet>(getQueries, 1, TInstant::Max(), NKikimrBlobStorage::AsyncRead); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(BlobPatching) { void SendPatch(const TTestInfo &test, const TLogoBlobID &originalBlobId, const TLogoBlobID &patchedBlobId, ui32 mask, const TVector<TEvBlobStorage::TEvPatch::TDiff> &diffs, NKikimrProto::EReplyStatus status) { - TArrayHolder<TEvBlobStorage::TEvPatch::TDiff> diffArr{new TEvBlobStorage::TEvPatch::TDiff[diffs.size()]}; + TArrayHolder<TEvBlobStorage::TEvPatch::TDiff> diffArr{new TEvBlobStorage::TEvPatch::TDiff[diffs.size()]}; for (ui32 idx = 0; idx < diffs.size(); ++idx) { diffArr[idx] = diffs[idx]; } diff --git a/ydb/core/blobstorage/ut_pdiskfit/lib/fail_injection_test.h b/ydb/core/blobstorage/ut_pdiskfit/lib/fail_injection_test.h index 7e0bfa05e0..7b8cd7588e 100644 --- a/ydb/core/blobstorage/ut_pdiskfit/lib/fail_injection_test.h +++ b/ydb/core/blobstorage/ut_pdiskfit/lib/fail_injection_test.h @@ -177,7 +177,7 @@ struct TPDiskFailureInjectionTest { auto setup = MakeHolder<TActorSystemSetup>(); setup->NodeId = 1; setup->ExecutorsCount = 4; // system, user, io, batch - setup->Executors.Reset(new TAutoPtr<IExecutorPool>[setup->ExecutorsCount]); + setup->Executors.Reset(new TAutoPtr<IExecutorPool>[setup->ExecutorsCount]); setup->Executors[0] = new TBasicExecutorPool(AppData->SystemPoolId, 8, 10); setup->Executors[1] = new TBasicExecutorPool(AppData->UserPoolId, 8, 10); setup->Executors[2] = new TIOExecutorPool(AppData->IOPoolId, 10); diff --git a/ydb/core/blobstorage/vdisk/common/disk_part.h b/ydb/core/blobstorage/vdisk/common/disk_part.h index f8916ba6ee..aa6df9a876 100644 --- a/ydb/core/blobstorage/vdisk/common/disk_part.h +++ b/ydb/core/blobstorage/vdisk/common/disk_part.h @@ -258,7 +258,7 @@ namespace NKikimr { template<> struct THash<NKikimr::TDiskPart> { - inline ui64 operator()(const NKikimr::TDiskPart& x) const noexcept { + inline ui64 operator()(const NKikimr::TDiskPart& x) const noexcept { return x.Hash(); } }; diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_queues.h b/ydb/core/blobstorage/vdisk/common/vdisk_queues.h index 9deed7fb43..f167a8117f 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_queues.h +++ b/ydb/core/blobstorage/vdisk/common/vdisk_queues.h @@ -63,7 +63,7 @@ namespace NKikimr { queue.reset(CreateVDiskBackpressureClient(gInfo, vdisk, vDiskQueueId, groupCounters, vCtx, queueClientId, queueName, interconnectChannel, vdiskActorId.NodeId() == parent.NodeId(), - TDuration::Minutes(1), flowRecord, NMonitoring::TCountableBase::EVisibility::Private)); + TDuration::Minutes(1), flowRecord, NMonitoring::TCountableBase::EVisibility::Private)); TActorId serviceId = TActivationContext::Register(queue.release(), parent); EmplaceToContainer(cont, vdisk, wrapper.Wrap(std::move(serviceId))); } diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h index 9bb8e64c08..d447af3ad3 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h @@ -367,7 +367,7 @@ namespace NKikimr { template<> struct THash<NKikimr::NHuge::THugeSlot> { - inline ui64 operator()(const NKikimr::NHuge::THugeSlot& x) const noexcept { + inline ui64 operator()(const NKikimr::NHuge::THugeSlot& x) const noexcept { return x.Hash(); } }; diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob.h b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob.h index 56fcf7a9e8..ff57946325 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob.h @@ -128,7 +128,7 @@ namespace NKikimr { } } - inline TPartIterator& operator++() noexcept { + inline TPartIterator& operator++() noexcept { if (Blob->Rope) { Iter += Blob->GetPartSize(Part); } @@ -136,7 +136,7 @@ namespace NKikimr { return *this; } - inline TPartIterator operator++(int) noexcept { + inline TPartIterator operator++(int) noexcept { TPartIterator res(*this); ++*this; return res; diff --git a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp index 4e9f1f03c3..a0989e4c9e 100644 --- a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp +++ b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp @@ -3,7 +3,7 @@ #include <ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.h> #include <ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h> -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <util/generic/bitops.h> diff --git a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h index 29ef015032..c71f906ba1 100644 --- a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h +++ b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h @@ -2,7 +2,7 @@ #include <ydb/core/util/bits.h> -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <util/stream/str.h> #include <util/string/cast.h> diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp index 96b813d317..631d718daf 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp @@ -213,7 +213,7 @@ namespace NKikimr { UpdateVPatchCtx(); std::unique_ptr<IActor> actor{CreateSkeletonVPatchActor(SelfId(), GInfo->Type, ev, now, SkeletonFrontIDPtr, IFaceMonGroup->PatchFoundPartsMsgsPtr(), IFaceMonGroup->PatchResMsgsPtr(), VPatchCtx, - VCtx->VDiskLogPrefix, Db->GetVDiskIncarnationGuid())}; + VCtx->VDiskLogPrefix, Db->GetVDiskIncarnationGuid())}; TActorId vPatchActor = Register(actor.release()); VPatchActors.emplace(patchedBlobId, vPatchActor); } diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor_ut.cpp b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor_ut.cpp index ca54eeec88..a874676cfd 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor_ut.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor_ut.cpp @@ -177,8 +177,8 @@ namespace NKikimr { patchCtx->AsyncBlobQueues.emplace(id, EdgeActors[idx]); } - THolder<IActor> actor{CreateSkeletonVPatchActor(EdgeActors[nodeId], GType, - ev, TInstant(), nullptr, nullptr, nullptr, patchCtx, VDiskIds[nodeId].ToString(), 0)}; + THolder<IActor> actor{CreateSkeletonVPatchActor(EdgeActors[nodeId], GType, + ev, TInstant(), nullptr, nullptr, nullptr, patchCtx, VDiskIds[nodeId].ToString(), 0)}; if constexpr (!std::is_void_v<DecoratorType>) { TVPatchDecoratorArgs args{EdgeActors[nodeId], IsCheckingEventsByDecorator, diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h index 4186dea1c6..227799fed4 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h @@ -108,7 +108,7 @@ namespace NKikimr { TSyncLogPageDeleter &operator=(const TSyncLogPageDeleter &) = default; TSyncLogPageDeleter &operator=(TSyncLogPageDeleter &&) = default; - void operator () (TSyncLogPage *page) noexcept { + void operator () (TSyncLogPage *page) noexcept { char *ptr = (char *)page; delete [] ptr; MemBytes.Subtract(PageSize); diff --git a/ydb/core/client/client_ut.cpp b/ydb/core/client/client_ut.cpp index b94c722588..fe2236179c 100644 --- a/ydb/core/client/client_ut.cpp +++ b/ydb/core/client/client_ut.cpp @@ -19,7 +19,7 @@ #include <util/folder/path.h> #include <util/generic/xrange.h> #include <util/string/subst.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> namespace NKikimr { diff --git a/ydb/core/client/flat_ut.cpp b/ydb/core/client/flat_ut.cpp index 362c052aa1..e17c424e4c 100644 --- a/ydb/core/client/flat_ut.cpp +++ b/ydb/core/client/flat_ut.cpp @@ -25,29 +25,29 @@ using namespace Tests; using NClient::TValue; namespace { - class TFailingMtpQueue: public TSimpleThreadPool { + class TFailingMtpQueue: public TSimpleThreadPool { private: bool FailOnAdd_ = false; public: void SetFailOnAdd(bool fail = true) { FailOnAdd_ = fail; } - [[nodiscard]] bool Add(IObjectInQueue* pObj) override { + [[nodiscard]] bool Add(IObjectInQueue* pObj) override { if (FailOnAdd_) { return false; } - return TSimpleThreadPool::Add(pObj); + return TSimpleThreadPool::Add(pObj); } TFailingMtpQueue() = default; - TFailingMtpQueue(IThreadFactory* pool) - : TSimpleThreadPool(pool) + TFailingMtpQueue(IThreadFactory* pool) + : TSimpleThreadPool(pool) { } }; using TFailingServerMtpQueue = - TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; + TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; class THTTP200OkServer: public THttpServer::ICallBack { class TRequest: public THttpClientRequestEx { diff --git a/ydb/core/client/minikql_compile/compile_context.cpp b/ydb/core/client/minikql_compile/compile_context.cpp index 44526ee5aa..f725ddb135 100644 --- a/ydb/core/client/minikql_compile/compile_context.cpp +++ b/ydb/core/client/minikql_compile/compile_context.cpp @@ -26,7 +26,7 @@ bool TContext::NewParamsBuilder() { TRuntimeNode TContext::NewParam(TStringBuf name, TType* type) { WasParams = true; - return PgmBuilder->Parameter(TString(name), type); + return PgmBuilder->Parameter(TString(name), type); } void TContext::AddTableLookup(const IDbSchemeResolver::TTable& request) { diff --git a/ydb/core/client/server/grpc_server.h b/ydb/core/client/server/grpc_server.h index 2f2ae1da6b..32cfd7798e 100644 --- a/ydb/core/client/server/grpc_server.h +++ b/ydb/core/client/server/grpc_server.h @@ -9,7 +9,7 @@ #include <ydb/public/lib/base/defs.h> #include <ydb/public/lib/base/msgbus.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <util/generic/queue.h> namespace NKikimr { @@ -74,7 +74,7 @@ private: void SetupIncomingRequests(); private: - using IThreadRef = TAutoPtr<IThreadFactory::IThread>; + using IThreadRef = TAutoPtr<IThreadFactory::IThread>; NActors::TActorSystem* ActorSystem; diff --git a/ydb/core/client/server/msgbus_server.cpp b/ydb/core/client/server/msgbus_server.cpp index 8a4d8a3bbd..d8d8339ca0 100644 --- a/ydb/core/client/server/msgbus_server.cpp +++ b/ydb/core/client/server/msgbus_server.cpp @@ -57,7 +57,7 @@ public: return GetMessage()->GetHeader()->Id; } - THolder<TMessageBusSessionIdentHolder::TImpl> CreateSessionIdentHolder() override; + THolder<TMessageBusSessionIdentHolder::TImpl> CreateSessionIdentHolder() override; }; class TBusMessageContext::TImplGRpc @@ -188,7 +188,7 @@ public: SendReply(response.Get()); } - THolder<TMessageBusSessionIdentHolder::TImpl> CreateSessionIdentHolder() override; + THolder<TMessageBusSessionIdentHolder::TImpl> CreateSessionIdentHolder() override; }; TBusMessageContext::TBusMessageContext() @@ -286,10 +286,10 @@ public: } }; -THolder<TMessageBusSessionIdentHolder::TImpl> TBusMessageContext::TImplMessageBus::CreateSessionIdentHolder() { - return MakeHolder<TMessageBusSessionIdentHolder::TImplMessageBus>(static_cast<NBus::TOnMessageContext&>(*this)); -} - +THolder<TMessageBusSessionIdentHolder::TImpl> TBusMessageContext::TImplMessageBus::CreateSessionIdentHolder() { + return MakeHolder<TMessageBusSessionIdentHolder::TImplMessageBus>(static_cast<NBus::TOnMessageContext&>(*this)); +} + class TMessageBusSessionIdentHolder::TImplGRpc : public TMessageBusSessionIdentHolder::TImpl { @@ -326,10 +326,10 @@ public: } }; -THolder<TMessageBusSessionIdentHolder::TImpl> TBusMessageContext::TImplGRpc::CreateSessionIdentHolder() { - return MakeHolder<TMessageBusSessionIdentHolder::TImplGRpc>(this); -} - +THolder<TMessageBusSessionIdentHolder::TImpl> TBusMessageContext::TImplGRpc::CreateSessionIdentHolder() { + return MakeHolder<TMessageBusSessionIdentHolder::TImplGRpc>(this); +} + TMessageBusSessionIdentHolder::TMessageBusSessionIdentHolder() {} diff --git a/ydb/core/client/server/msgbus_server_persqueue.cpp b/ydb/core/client/server/msgbus_server_persqueue.cpp index 78b83ef3a3..d878a55faf 100644 --- a/ydb/core/client/server/msgbus_server_persqueue.cpp +++ b/ydb/core/client/server/msgbus_server_persqueue.cpp @@ -1044,7 +1044,7 @@ public: for (ui32 i = 0; i < pqDescr.PartitionsSize(); ++i) { ui32 part = pqDescr.GetPartitions(i).GetPartitionId(); ui64 tabletId = pqDescr.GetPartitions(i).GetTabletId(); - if (!it->second.PartitionsToRequest.empty() && !it->second.PartitionsToRequest.contains(part)) { + if (!it->second.PartitionsToRequest.empty() && !it->second.PartitionsToRequest.contains(part)) { continue; } bool res = it->second.PartitionToTablet.insert({part, tabletId}).second; diff --git a/ydb/core/client/server/msgbus_server_persqueue.h b/ydb/core/client/server/msgbus_server_persqueue.h index 52c67832e4..e7759b5a2a 100644 --- a/ydb/core/client/server/msgbus_server_persqueue.h +++ b/ydb/core/client/server/msgbus_server_persqueue.h @@ -120,7 +120,7 @@ protected: bool ReadyToCreateChildren() const; // true returned from this function means that we called Die(). - [[nodiscard]] bool CreateChildren(const TActorContext& ctx); + [[nodiscard]] bool CreateChildren(const TActorContext& ctx); virtual bool ReadyForAnswer(const TActorContext& ctx); void AnswerAndDie(const TActorContext& ctx); @@ -242,7 +242,7 @@ protected: // Wait in case TPipeEvent is not TEvTabletPipe::TEvClientConnected. // true returned from this function means that we called Die(). - [[nodiscard]] bool WaitAllPipeEvents(const TActorContext& ctx) { + [[nodiscard]] bool WaitAllPipeEvents(const TActorContext& ctx) { static_assert(TPipeEvent::EventType != TEvTabletPipe::TEvClientConnected::EventType, "Use WaitAllConnections()"); if (EventsAreReady()) { @@ -257,7 +257,7 @@ protected: // Wait in case TPipeEvent is TEvTabletPipe::TEvClientConnected. // true returned from this function means that we called Die(). - [[nodiscard]] bool WaitAllConnections(const TActorContext& ctx) { + [[nodiscard]] bool WaitAllConnections(const TActorContext& ctx) { static_assert(TPipeEvent::EventType == TEvTabletPipe::TEvClientConnected::EventType, "Use WaitAllPipeEvents()"); if (EventsAreReady()) { @@ -271,19 +271,19 @@ protected: } // true returned from this function means that we called Die(). - [[nodiscard]] virtual bool OnPipeEvent(ui64 tabletId, typename TPipeEvent::TPtr& ev, const TActorContext& /*ctx*/) { + [[nodiscard]] virtual bool OnPipeEvent(ui64 tabletId, typename TPipeEvent::TPtr& ev, const TActorContext& /*ctx*/) { Y_VERIFY(!IsIn(PipeAnswers, tabletId) || !PipeAnswers.find(tabletId)->second); PipeAnswers[tabletId] = ev; return false; } // true returned from this function means that we called Die(). - [[nodiscard]] virtual bool OnClientConnected(TEvTabletPipe::TEvClientConnected::TPtr& /*ev*/, const TActorContext& /*ctx*/) { + [[nodiscard]] virtual bool OnClientConnected(TEvTabletPipe::TEvClientConnected::TPtr& /*ev*/, const TActorContext& /*ctx*/) { return false; } // true returned from this function means that we called Die(). - [[nodiscard]] virtual bool OnPipeEventsAreReady(const TActorContext& ctx) = 0; + [[nodiscard]] virtual bool OnPipeEventsAreReady(const TActorContext& ctx) = 0; void Die(const TActorContext& ctx) override { for (const auto& pipe : Pipes) { diff --git a/ydb/core/client/server/msgbus_server_pq_metarequest.h b/ydb/core/client/server/msgbus_server_pq_metarequest.h index 1d56c28dc0..0883bd6db4 100644 --- a/ydb/core/client/server/msgbus_server_pq_metarequest.h +++ b/ydb/core/client/server/msgbus_server_pq_metarequest.h @@ -195,7 +195,7 @@ public: bool ReadyToAnswer() const; // true returned from this function means that we called Die(). - [[nodiscard]] bool WaitAllPipeEvents(const TActorContext& ctx); + [[nodiscard]] bool WaitAllPipeEvents(const TActorContext& ctx); STFUNC(WaitAllPipeEventsStateFunc); void Handle(TEvPersQueue::TEvReadSessionsInfoResponse::TPtr& ev, const TActorContext& ctx); diff --git a/ydb/core/client/server/msgbus_server_s3_listing.cpp b/ydb/core/client/server/msgbus_server_s3_listing.cpp index 3626866322..de6296fc47 100644 --- a/ydb/core/client/server/msgbus_server_s3_listing.cpp +++ b/ydb/core/client/server/msgbus_server_s3_listing.cpp @@ -249,7 +249,7 @@ private: } for (const auto& name : requestedColumns) { - if (!columnByName.contains(name)) { + if (!columnByName.contains(name)) { ReplyWithError(MSTATUS_ERROR, NTxProxy::TResultStatus::EStatus::WrongRequest, Sprintf("Unknown column '%s'", name.data()), ctx); return false; diff --git a/ydb/core/client/server/msgbus_server_tracer.h b/ydb/core/client/server/msgbus_server_tracer.h index 57a3812f5d..21b48db115 100644 --- a/ydb/core/client/server/msgbus_server_tracer.h +++ b/ydb/core/client/server/msgbus_server_tracer.h @@ -1,6 +1,6 @@ #pragma once #include <util/stream/file.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/generic/buffer.h> #include <library/cpp/messagebus/handler.h> #include <library/cpp/messagebus/message.h> diff --git a/ydb/core/cms/cluster_info.cpp b/ydb/core/cms/cluster_info.cpp index a1dc8a0b95..89fadd6469 100644 --- a/ydb/core/cms/cluster_info.cpp +++ b/ydb/core/cms/cluster_info.cpp @@ -518,8 +518,8 @@ void TClusterInfo::AddBSGroup(const NKikimrBlobStorage::TBaseConfig::TGroup &inf } auto &pdisk = PDiskRef(pdiskId); - Y_VERIFY_DEBUG(pdisk.VSlots.contains(vdisk.GetVSlotId())); - if (!pdisk.VSlots.contains(vdisk.GetVSlotId())) { + Y_VERIFY_DEBUG(pdisk.VSlots.contains(vdisk.GetVSlotId())); + if (!pdisk.VSlots.contains(vdisk.GetVSlotId())) { BLOG_ERROR("Group " << bsgroup.GroupId << " refers unknown slot " << vdisk.GetVSlotId() << " in disk " << pdiskId.ToString()); return; diff --git a/ydb/core/cms/cluster_info.h b/ydb/core/cms/cluster_info.h index af5fe24af8..72a80b4301 100644 --- a/ydb/core/cms/cluster_info.h +++ b/ydb/core/cms/cluster_info.h @@ -476,7 +476,7 @@ public: bool HasNode(ui32 nodeId) const { - return Nodes.contains(nodeId); + return Nodes.contains(nodeId); } bool HasNode(const TString &hostName) const @@ -484,7 +484,7 @@ public: ui32 nodeId; if (TryFromString(hostName, nodeId)) return HasNode(nodeId); - return HostNameToNodeId.contains(hostName); + return HostNameToNodeId.contains(hostName); } const TNodeInfo &Node(ui32 nodeId) const @@ -549,7 +549,7 @@ public: bool HasTablet(ui64 id) const { - return Tablets.contains(id); + return Tablets.contains(id); } const TTabletInfo &Tablet(ui64 id) const @@ -565,7 +565,7 @@ public: bool HasPDisk(TPDiskID pdId) const { - return PDisks.contains(pdId); + return PDisks.contains(pdId); } bool HasPDisk(const TString &name) const @@ -573,7 +573,7 @@ public: if (!TPDiskInfo::IsDeviceName(name)) return false; auto id = TPDiskInfo::NameToId(name); - return PDisks.contains(id); + return PDisks.contains(id); } bool HasPDisk(const TString &hostName, const TString &path) const @@ -610,7 +610,7 @@ public: bool HasVDisk(const TVDiskID &vdId) const { - return VDisks.contains(vdId); + return VDisks.contains(vdId); } bool HasVDisk(const TString &name) const @@ -618,7 +618,7 @@ public: if (!TVDiskInfo::IsDeviceName(name)) return false; auto id = TVDiskInfo::NameToId(name); - return VDisks.contains(id); + return VDisks.contains(id); } const TVDiskInfo &VDisk(const TVDiskID &vdId) const @@ -645,7 +645,7 @@ public: bool HasBSGroup(ui32 groupId) const { - return BSGroups.contains(groupId); + return BSGroups.contains(groupId); } const TBSGroupInfo &BSGroup(ui32 groupId) const diff --git a/ydb/core/cms/cluster_info_ut.cpp b/ydb/core/cms/cluster_info_ut.cpp index 8b9d3b3d65..17be5f520e 100644 --- a/ydb/core/cms/cluster_info_ut.cpp +++ b/ydb/core/cms/cluster_info_ut.cpp @@ -128,7 +128,7 @@ void CheckPDisk(const TPDiskInfo &pdisk, ui32 id, ui32 nodeId, NKikimrCms::EStat void CheckVDiskGroups(const TVDiskInfo &vdisk, ui32 group) { - UNIT_ASSERT(vdisk.BSGroups.contains(group)); + UNIT_ASSERT(vdisk.BSGroups.contains(group)); } template<typename... Ts> @@ -166,7 +166,7 @@ void CheckVDisk(const TVDiskInfo &vdisk, TVDiskID id, ui32 nodeId, NKikimrCms::E void CheckBSGroupVDisks(const TBSGroupInfo &group, TVDiskID vdisk) { - UNIT_ASSERT(group.VDisks.contains(vdisk)); + UNIT_ASSERT(group.VDisks.contains(vdisk)); } template<typename... Ts> @@ -297,7 +297,7 @@ Y_UNIT_TEST_SUITE(TClusterInfoTest) { UNIT_ASSERT(!cluster.HasPDisk(NCms::TPDiskID(1, 2))); UNIT_ASSERT(!cluster.HasPDisk(NCms::TPDiskID(2, 1))); CheckPDisk(cluster.PDisk(NCms::TPDiskID(1, 1)), 1, 1, UP, 0); - UNIT_ASSERT(cluster.Node(1).PDisks.contains(NCms::TPDiskID(1, 1))); + UNIT_ASSERT(cluster.Node(1).PDisks.contains(NCms::TPDiskID(1, 1))); cluster.AddVDisk(MakeVSlotConfig(1, {0, 1, 0, 0, 0}, 1, 0)); cluster.UpdateVDiskState({0, 1, 0, 0, 0}, MakeVDiskInfo({0, 1, 0, 0, 0}, 1, 0)); @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TClusterInfoTest) { UNIT_ASSERT(!cluster.HasVDisk({0, 1, 0, 1, 0})); CheckVDisk(cluster.VDisk({0, 1, 0, 0, 0}), {0, 1, 0, 0, 0}, 1, UP, 1, 0); UNIT_ASSERT_VALUES_EQUAL(cluster.PDisk(NCms::TPDiskID(1, 1)).VDisks.size(), 1); - UNIT_ASSERT(cluster.PDisk(NCms::TPDiskID(1, 1)).VDisks.contains(TVDiskID(0, 1, 0, 0, 0))); + UNIT_ASSERT(cluster.PDisk(NCms::TPDiskID(1, 1)).VDisks.contains(TVDiskID(0, 1, 0, 0, 0))); cluster.AddPDisk(MakePDiskConfig(2, 2)); cluster.UpdatePDiskState(NCms::TPDiskID(2, 2), MakePDiskInfo(2)); @@ -317,7 +317,7 @@ Y_UNIT_TEST_SUITE(TClusterInfoTest) { UNIT_ASSERT(cluster.HasVDisk({0, 1, 0, 1, 0})); UNIT_ASSERT(cluster.HasPDisk(NCms::TPDiskID(2, 2))); CheckPDisk(cluster.PDisk(NCms::TPDiskID(2, 2)), 2, 2, UP, 1); - UNIT_ASSERT(cluster.PDisk(NCms::TPDiskID(2, 2)).VDisks.contains(TVDiskID(0, 1, 0, 1, 0))); + UNIT_ASSERT(cluster.PDisk(NCms::TPDiskID(2, 2)).VDisks.contains(TVDiskID(0, 1, 0, 1, 0))); cluster.AddBSGroup(MakeBSGroup(1, "none", 1, 1, 0, 2, 2, 0)); UNIT_ASSERT(cluster.HasBSGroup(1)); diff --git a/ydb/core/cms/cms.cpp b/ydb/core/cms/cms.cpp index 0a205024e3..3bfc8cc6a9 100644 --- a/ydb/core/cms/cms.cpp +++ b/ydb/core/cms/cms.cpp @@ -896,7 +896,7 @@ void TCms::CleanupWalleTasks(const TActorContext &ctx) for (const auto &entry : State->ScheduledRequests) { const auto &request = entry.second; if (request.Owner == WALLE_CMS_USER - && !State->WalleRequests.contains(request.RequestId)) + && !State->WalleRequests.contains(request.RequestId)) requestsToRemove.push_back(request.RequestId); } @@ -908,7 +908,7 @@ void TCms::CleanupWalleTasks(const TActorContext &ctx) for (const auto &entry : State->Permissions) { const auto &permission = entry.second; if (permission.Owner == WALLE_CMS_USER - && !State->WalleRequests.contains(permission.RequestId)) + && !State->WalleRequests.contains(permission.RequestId)) permissionsToRemove.push_back(permission.PermissionId); } @@ -929,7 +929,7 @@ void TCms::RemoveEmptyWalleTasks(const TActorContext &ctx) TVector<TString> tasksToRemove; for (const auto &entry : State->WalleTasks) { const auto &task = entry.second; - if (!State->ScheduledRequests.contains(task.RequestId) && task.Permissions.empty()) { + if (!State->ScheduledRequests.contains(task.RequestId) && task.Permissions.empty()) { LOG_DEBUG(ctx, NKikimrServices::CMS, "Found empty task %s", task.TaskId.data()); tasksToRemove.push_back(task.TaskId); } @@ -1035,7 +1035,7 @@ void TCms::GetPermission(TEvCms::TEvManagePermissionRequest::TPtr &ev, bool all, LOG_DEBUG(ctx, NKikimrServices::CMS, "Resulting status: %s %s", TStatus::ECode_Name(resp->Record.GetStatus().GetCode()).data(), resp->Record.GetStatus().GetReason().data()); - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } void TCms::RemovePermission(TEvCms::TEvManagePermissionRequest::TPtr &ev, bool done, const TActorContext &ctx) @@ -1073,9 +1073,9 @@ void TCms::RemovePermission(TEvCms::TEvManagePermissionRequest::TPtr &ev, bool d if (!rec.GetDryRun() && resp->Record.GetStatus().GetCode() == TStatus::OK) { auto handle = new IEventHandle(ev->Sender, SelfId(), resp.Release(), 0, ev->Cookie); - Execute(CreateTxRemovePermissions(std::move(ids), std::move(ev->Release()), handle), ctx); + Execute(CreateTxRemovePermissions(std::move(ids), std::move(ev->Release()), handle), ctx); } else { - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } } @@ -1114,7 +1114,7 @@ void TCms::GetRequest(TEvCms::TEvManageRequestRequest::TPtr &ev, bool all, const LOG_DEBUG(ctx, NKikimrServices::CMS, "Resulting status: %s %s", TStatus::ECode_Name(resp->Record.GetStatus().GetCode()).data(), resp->Record.GetStatus().GetReason().data()); - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } void TCms::RemoveRequest(TEvCms::TEvManageRequestRequest::TPtr &ev, const TActorContext &ctx) @@ -1145,9 +1145,9 @@ void TCms::RemoveRequest(TEvCms::TEvManageRequestRequest::TPtr &ev, const TActor if (!rec.GetDryRun() && resp->Record.GetStatus().GetCode() == TStatus::OK) { auto handle = new IEventHandle(ev->Sender, SelfId(), resp.Release(), 0, ev->Cookie); - Execute(CreateTxRemoveRequest(id, std::move(ev->Release()), handle), ctx); + Execute(CreateTxRemoveRequest(id, std::move(ev->Release()), handle), ctx); } else { - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } } @@ -1188,7 +1188,7 @@ void TCms::GetNotifications(TEvCms::TEvManageNotificationRequest::TPtr &ev, bool LOG_DEBUG(ctx, NKikimrServices::CMS, "Resulting status: %s %s", ToString(resp->Record.GetStatus().GetCode()).data(), resp->Record.GetStatus().GetReason().data()); - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } bool TCms::RemoveNotification(const TString &id, const TString &user, bool remove, TErrorInfo &error) @@ -1474,7 +1474,7 @@ void TCms::Handle(TEvCms::TEvClusterStateRequest::TPtr &ev, resp->Record.MutableStatus()->SetCode(TStatus::OK); resp->Record.MutableState()->SetTimestamp(ClusterInfo->GetTimestamp().GetValue()); - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } void TCms::Handle(TEvCms::TEvPermissionRequest::TPtr &ev, @@ -1515,7 +1515,7 @@ void TCms::Handle(TEvCms::TEvPermissionRequest::TPtr &ev, // Schedule request if required. if (rec.GetDryRun()) { - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } else { auto reqId = user + "-r-" + ToString(State->NextRequestId++); resp->Record.SetRequestId(reqId); @@ -1540,7 +1540,7 @@ void TCms::Handle(TEvCms::TEvPermissionRequest::TPtr &ev, AcceptPermissions(resp->Record, reqId, user, ctx); auto handle = new IEventHandle(ev->Sender, SelfId(), resp.Release(), 0, ev->Cookie); - Execute(CreateTxStorePermissions(std::move(ev->Release()), handle, user, std::move(copy)), ctx); + Execute(CreateTxStorePermissions(std::move(ev->Release()), handle, user, std::move(copy)), ctx); } } @@ -1576,7 +1576,7 @@ void TCms::Handle(TEvCms::TEvCheckRequest::TPtr &ev, const TActorContext &ctx) // Schedule request if required. if (rec.GetDryRun()) { - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } else { TAutoPtr<TRequestInfo> copy; auto order = request.Order; @@ -1603,7 +1603,7 @@ void TCms::Handle(TEvCms::TEvCheckRequest::TPtr &ev, const TActorContext &ctx) AcceptPermissions(resp->Record, scheduled.RequestId, user, ctx, true); auto handle = new IEventHandle(ev->Sender, SelfId(), resp.Release(), 0, ev->Cookie); - Execute(CreateTxStorePermissions(std::move(ev->Release()), handle, user, std::move(copy)), ctx); + Execute(CreateTxStorePermissions(std::move(ev->Release()), handle, user, std::move(copy)), ctx); } } @@ -1805,7 +1805,7 @@ void TCms::Handle(TEvCms::TEvStoreWalleTask::TPtr &ev, const TActorContext &ctx) State->WalleRequests.emplace(event->Task.RequestId, event->Task.TaskId); auto handle = new IEventHandle(ev->Sender, SelfId(), new TEvCms::TEvWalleTaskStored(event->Task.TaskId), 0, ev->Cookie); - Execute(CreateTxStoreWalleTask(event->Task, std::move(ev->Release()), handle), ctx); + Execute(CreateTxStoreWalleTask(event->Task, std::move(ev->Release()), handle), ctx); } void TCms::Handle(TEvCms::TEvRemoveWalleTask::TPtr &ev, const TActorContext &ctx) @@ -1813,17 +1813,17 @@ void TCms::Handle(TEvCms::TEvRemoveWalleTask::TPtr &ev, const TActorContext &ctx TString id = ev->Get()->TaskId; TAutoPtr<TEvCms::TEvWalleTaskRemoved> resp = new TEvCms::TEvWalleTaskRemoved(id); - if (State->WalleTasks.contains(id)) { + if (State->WalleTasks.contains(id)) { auto &task = State->WalleTasks.find(id)->second; auto handle = new IEventHandle(ev->Sender, SelfId(), resp.Release(), 0, ev->Cookie); if (State->ScheduledRequests.contains(task.RequestId)) { - Execute(CreateTxRemoveRequest(task.RequestId, std::move(ev->Release()), handle), ctx); + Execute(CreateTxRemoveRequest(task.RequestId, std::move(ev->Release()), handle), ctx); } else { TVector<TString> ids(task.Permissions.begin(), task.Permissions.end()); - Execute(CreateTxRemovePermissions(ids, std::move(ev->Release()), handle), ctx); + Execute(CreateTxRemovePermissions(ids, std::move(ev->Release()), handle), ctx); } } else { - Reply(ev, std::move(resp), ctx); + Reply(ev, std::move(resp), ctx); } } @@ -1834,7 +1834,7 @@ void TCms::Handle(TEvCms::TEvGetConfigRequest::TPtr &ev, const TActorContext &ct State->Config.Serialize(*response->Record.MutableConfig()); response->Record.MutableStatus()->SetCode(TStatus::OK); - Reply(ev, std::move(response), ctx); + Reply(ev, std::move(response), ctx); } void TCms::Handle(TEvCms::TEvSetConfigRequest::TPtr &ev, const TActorContext &ctx) diff --git a/ydb/core/cms/cms_tenants_ut.cpp b/ydb/core/cms/cms_tenants_ut.cpp index e14fe4dd57..99b0ebe22b 100644 --- a/ydb/core/cms/cms_tenants_ut.cpp +++ b/ydb/core/cms/cms_tenants_ut.cpp @@ -43,12 +43,12 @@ Y_UNIT_TEST_SUITE(TCmsTenatsTest) { UNIT_ASSERT_VALUES_EQUAL(node.Host, "::1"); UNIT_ASSERT_VALUES_EQUAL(node.State, NKikimrCms::UP); UNIT_ASSERT_VALUES_EQUAL(node.PDisks.size(), 1); - UNIT_ASSERT(node.PDisks.contains(NCms::TPDiskID(nodeId, nodeId))); + UNIT_ASSERT(node.PDisks.contains(NCms::TPDiskID(nodeId, nodeId))); UNIT_ASSERT_VALUES_EQUAL(node.VDisks.size(), 4); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(0, 1, 0, nodeIndex, 0))); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(1, 1, 0, nodeIndex, 0))); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(2, 1, 0, nodeIndex, 0))); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(3, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(0, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(1, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(2, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(3, 1, 0, nodeIndex, 0))); UNIT_ASSERT(info.HasPDisk(NCms::TPDiskID(nodeId, nodeId))); @@ -62,14 +62,14 @@ Y_UNIT_TEST_SUITE(TCmsTenatsTest) { UNIT_ASSERT(info.HasBSGroup(groupId)); const auto &group = info.BSGroup(groupId); UNIT_ASSERT_VALUES_EQUAL(group.VDisks.size(), 8); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 0, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 1, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 2, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 3, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 4, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 5, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 6, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 7, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 0, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 1, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 2, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 3, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 4, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 5, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 6, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 7, 0))); } } diff --git a/ydb/core/cms/cms_tx_load_state.cpp b/ydb/core/cms/cms_tx_load_state.cpp index eb144dc0de..c06a31576e 100644 --- a/ydb/core/cms/cms_tx_load_state.cpp +++ b/ydb/core/cms/cms_tx_load_state.cpp @@ -126,7 +126,7 @@ public: state->Permissions.emplace(id, permission); - if (state->WalleRequests.contains(requestId)) { + if (state->WalleRequests.contains(requestId)) { const auto &taskId = state->WalleRequests[requestId]; state->WalleTasks[taskId].Permissions.insert(id); diff --git a/ydb/core/cms/cms_tx_process_notification.cpp b/ydb/core/cms/cms_tx_process_notification.cpp index 2174a82f17..c660597d27 100644 --- a/ydb/core/cms/cms_tx_process_notification.cpp +++ b/ydb/core/cms/cms_tx_process_notification.cpp @@ -53,7 +53,7 @@ public: LOG_DEBUG(ctx, NKikimrServices::CMS, "TTxProcessNotification complete with response: %s", Response->Record.ShortDebugString().data()); - Self->Reply(Event, std::move(Response), ctx); + Self->Reply(Event, std::move(Response), ctx); Self->ScheduleNotificationsCleanup(ctx); } diff --git a/ydb/core/cms/cms_tx_reject_notification.cpp b/ydb/core/cms/cms_tx_reject_notification.cpp index 5612dd9fbb..ab608fab3c 100644 --- a/ydb/core/cms/cms_tx_reject_notification.cpp +++ b/ydb/core/cms/cms_tx_reject_notification.cpp @@ -53,7 +53,7 @@ public: { LOG_DEBUG(ctx, NKikimrServices::CMS, "TTxRejectNotification Complete"); - Self->Reply(Event, std::move(Response), ctx); + Self->Reply(Event, std::move(Response), ctx); } private: diff --git a/ydb/core/cms/cms_tx_remove_permissions.cpp b/ydb/core/cms/cms_tx_remove_permissions.cpp index 6e638c72ff..9d392a0a8a 100644 --- a/ydb/core/cms/cms_tx_remove_permissions.cpp +++ b/ydb/core/cms/cms_tx_remove_permissions.cpp @@ -23,7 +23,7 @@ public: NIceDb::TNiceDb db(txc.DB); for (auto id : Ids) { - if (!Self->State->Permissions.contains(id)) + if (!Self->State->Permissions.contains(id)) continue; auto requestId = Self->State->Permissions.find(id)->second.RequestId; @@ -39,7 +39,7 @@ public: << ", reason# " << "permission " << id << " has expired"); } - if (Self->State->WalleRequests.contains(requestId)) { + if (Self->State->WalleRequests.contains(requestId)) { auto taskId = Self->State->WalleRequests.find(requestId)->second; Self->State->WalleTasks.find(taskId)->second.Permissions.erase(id); } diff --git a/ydb/core/cms/cms_ut.cpp b/ydb/core/cms/cms_ut.cpp index 9842fb7156..8880608602 100644 --- a/ydb/core/cms/cms_ut.cpp +++ b/ydb/core/cms/cms_ut.cpp @@ -69,12 +69,12 @@ Y_UNIT_TEST_SUITE(TCmsTest) { UNIT_ASSERT_VALUES_EQUAL(node.Host, "::1"); UNIT_ASSERT_VALUES_EQUAL(node.State, NKikimrCms::UP); UNIT_ASSERT_VALUES_EQUAL(node.PDisks.size(), 1); - UNIT_ASSERT(node.PDisks.contains(NCms::TPDiskID(nodeId, nodeId))); + UNIT_ASSERT(node.PDisks.contains(NCms::TPDiskID(nodeId, nodeId))); UNIT_ASSERT_VALUES_EQUAL(node.VDisks.size(), 4); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(0, 1, 0, nodeIndex, 0))); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(1, 1, 0, nodeIndex, 0))); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(2, 1, 0, nodeIndex, 0))); - UNIT_ASSERT(node.VDisks.contains(TVDiskID(3, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(0, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(1, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(2, 1, 0, nodeIndex, 0))); + UNIT_ASSERT(node.VDisks.contains(TVDiskID(3, 1, 0, nodeIndex, 0))); UNIT_ASSERT(info.HasPDisk(NCms::TPDiskID(nodeId, nodeId))); @@ -88,14 +88,14 @@ Y_UNIT_TEST_SUITE(TCmsTest) { UNIT_ASSERT(info.HasBSGroup(groupId)); const auto &group = info.BSGroup(groupId); UNIT_ASSERT_VALUES_EQUAL(group.VDisks.size(), 8); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 0, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 1, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 2, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 3, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 4, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 5, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 6, 0))); - UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 7, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 0, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 1, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 2, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 3, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 4, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 5, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 6, 0))); + UNIT_ASSERT(group.VDisks.contains(TVDiskID(groupId, 1, 0, 7, 0))); } } diff --git a/ydb/core/cms/cms_ut_common.cpp b/ydb/core/cms/cms_ut_common.cpp index b458fe672c..196cf8a54c 100644 --- a/ydb/core/cms/cms_ut_common.cpp +++ b/ydb/core/cms/cms_ut_common.cpp @@ -408,7 +408,7 @@ static void SetupServices(TTestActorRuntime &runtime, runtime.AddLocalService(NNodeWhiteboard::MakeNodeWhiteboardServiceId(runtime.GetNodeId(nodeIndex)), TActorSetupCmd(CreateFakeNodeWhiteboardService(), TMailboxType::Simple, 0), nodeIndex); TVector<TString> nodeTenants; - if (tenants.contains(nodeIndex)) + if (tenants.contains(nodeIndex)) nodeTenants = tenants.at(nodeIndex); runtime.AddLocalService(MakeTenantPoolID(runtime.GetNodeId(nodeIndex)), TActorSetupCmd(new TFakeTenantPool(nodeTenants), TMailboxType::Simple, 0), nodeIndex); @@ -745,7 +745,7 @@ void TCmsTestEnv::CheckWalleCreateTask(TAutoPtr<NCms::TEvCms::TEvWalleCreateTask UNIT_ASSERT_VALUES_EQUAL(rec.GetTaskId(), id); UNIT_ASSERT_VALUES_EQUAL(rec.HostsSize(), hosts.size()); for (auto &host : rec.GetHosts()) - UNIT_ASSERT(hosts.contains(host)); + UNIT_ASSERT(hosts.contains(host)); } void TCmsTestEnv::CheckTasksEqual(const NKikimrCms::TWalleTaskInfo &l, diff --git a/ydb/core/cms/config.h b/ydb/core/cms/config.h index 471880e34f..b5c7725106 100644 --- a/ydb/core/cms/config.h +++ b/ydb/core/cms/config.h @@ -172,7 +172,7 @@ struct TCmsLogConfig { bool IsLogEnabled(ui32 recordType) const { - if (RecordLevels.contains(recordType)) + if (RecordLevels.contains(recordType)) return RecordLevels.at(recordType); return EnabledByDefault; } diff --git a/ydb/core/cms/console/config_index.cpp b/ydb/core/cms/console/config_index.cpp index 98ede70c6f..077fcff801 100644 --- a/ydb/core/cms/console/config_index.cpp +++ b/ydb/core/cms/console/config_index.cpp @@ -78,11 +78,11 @@ bool TUsageScope::HasConflict(const TUsageScope &other, if (!NodeIds.empty()) { for (auto id : NodeIds) - if (other.NodeIds.contains(id)) + if (other.NodeIds.contains(id)) return true; } else if (!Hosts.empty()) { for (auto &host : Hosts) - if (other.Hosts.contains(host)) + if (other.Hosts.contains(host)) return true; } else if (Tenant == other.Tenant && NodeType == other.NodeType) return true; @@ -278,7 +278,7 @@ TConfigItem::TPtr TConfigIndex::GetItem(ui64 id) const void TConfigIndex::AddItem(TConfigItem::TPtr item) { - Y_VERIFY(!ConfigItems.contains(item->Id)); + Y_VERIFY(!ConfigItems.contains(item->Id)); ConfigItems.emplace(item->Id, item); if (!item->UsageScope.NodeIds.empty()) { @@ -535,7 +535,7 @@ void TConfigIndex::CollectTenantAndNodeTypeUsageScopes(const TDynBitMap &kinds, if (!kinds.Empty()) { bool found = false; Y_FOR_EACH_BIT(kind, kinds) { - if (pr.second.contains(kind)) { + if (pr.second.contains(kind)) { found = true; break; } @@ -668,7 +668,7 @@ const THashMap<ui64, TSubscription::TPtr> &TSubscriptionIndex::GetSubscriptions( void TSubscriptionIndex::AddSubscription(TSubscription::TPtr subscription) { - Y_VERIFY(!Subscriptions.contains(subscription->Id)); + Y_VERIFY(!Subscriptions.contains(subscription->Id)); Subscriptions.emplace(subscription->Id, subscription); SubscriptionsBySubscriber[subscription->Subscriber].insert(subscription); SubscriptionsByNodeId[subscription->NodeId].insert(subscription); @@ -794,7 +794,7 @@ void TSubscriptionIndex::CollectAffectedSubscriptions(const TUsageScope &scope, auto it = SubscriptionsByNodeId.find(nodeId); if (it != SubscriptionsByNodeId.end()) { for (auto & subscription : it->second) - if (subscription->ItemKinds.contains(kind)) + if (subscription->ItemKinds.contains(kind)) subscriptions.insert(subscription); } hasFilter = true; @@ -804,7 +804,7 @@ void TSubscriptionIndex::CollectAffectedSubscriptions(const TUsageScope &scope, auto it = SubscriptionsByHost.find(host); if (it != SubscriptionsByHost.end()) { for (auto & subscription : it->second) - if (subscription->ItemKinds.contains(kind)) + if (subscription->ItemKinds.contains(kind)) subscriptions.insert(subscription); } hasFilter = true; @@ -814,7 +814,7 @@ void TSubscriptionIndex::CollectAffectedSubscriptions(const TUsageScope &scope, auto it = SubscriptionsByTenant.find(scope.Tenant); if (it != SubscriptionsByTenant.end()) { for (auto & subscription : it->second) - if (subscription->ItemKinds.contains(kind)) + if (subscription->ItemKinds.contains(kind)) subscriptions.insert(subscription); } hasFilter = true; @@ -824,7 +824,7 @@ void TSubscriptionIndex::CollectAffectedSubscriptions(const TUsageScope &scope, auto it = SubscriptionsByNodeType.find(scope.NodeType); if (it != SubscriptionsByNodeType.end()) { for (auto & subscription : it->second) - if (subscription->ItemKinds.contains(kind)) + if (subscription->ItemKinds.contains(kind)) subscriptions.insert(subscription); } hasFilter = true; diff --git a/ydb/core/cms/console/config_index.h b/ydb/core/cms/console/config_index.h index b332b90b8f..7b6bf0320b 100644 --- a/ydb/core/cms/console/config_index.h +++ b/ydb/core/cms/console/config_index.h @@ -497,7 +497,7 @@ private: TIndexMap &map) { auto &set = map[key][item->Kind]; - Y_VERIFY(!forced || !set.contains(item)); + Y_VERIFY(!forced || !set.contains(item)); set.insert(item); } @@ -632,7 +632,7 @@ private: { auto it = index.find(key); Y_VERIFY(it != index.end()); - Y_VERIFY(it->second.contains(subscription)); + Y_VERIFY(it->second.contains(subscription)); it->second.erase(subscription); if (it->second.empty()) index.erase(it); diff --git a/ydb/core/cms/console/configs_dispatcher.cpp b/ydb/core/cms/console/configs_dispatcher.cpp index 8e50754239..da6ae77cb3 100644 --- a/ydb/core/cms/console/configs_dispatcher.cpp +++ b/ydb/core/cms/console/configs_dispatcher.cpp @@ -429,7 +429,7 @@ void TConfigsDispatcher::RemoveSubscriber(TSubscriber::TPtr subscriber) BLOG_D("Remove subscriber " << subscriber->Subscriber); for (auto subscription : subscriber->Subscriptions) { - Y_VERIFY(subscription->Subscribers.contains(subscriber->Subscriber)); + Y_VERIFY(subscription->Subscribers.contains(subscriber->Subscriber)); subscription->Subscribers.erase(subscriber->Subscriber); if (subscription->UpdateInProcess) { @@ -702,7 +702,7 @@ void TConfigsDispatcher::Handle(TEvConfigsDispatcher::TEvGetConfigRequest::TPtr } } - if (ConfigsCache.contains(kinds)) { + if (ConfigsCache.contains(kinds)) { auto resp = MakeHolder<TEvConfigsDispatcher::TEvGetConfigResponse>(); resp->Config = ConfigsCache.at(kinds); @@ -802,7 +802,7 @@ void TConfigsDispatcher::Handle(TEvConsole::TEvConfigNotificationResponse::TPtr return; } - if (!subscription->SubscribersToUpdate.contains(ev->Sender)) { + if (!subscription->SubscribersToUpdate.contains(ev->Sender)) { BLOG_ERROR("Notification from unexpected subscriber for subscription " << rec.GetSubscriptionId()); return; } diff --git a/ydb/core/cms/console/console__alter_tenant.cpp b/ydb/core/cms/console/console__alter_tenant.cpp index dc44c25082..536fd0e487 100644 --- a/ydb/core/cms/console/console__alter_tenant.cpp +++ b/ydb/core/cms/console/console__alter_tenant.cpp @@ -222,7 +222,7 @@ public: if (rec.computational_units_to_add_size() || rec.computational_units_to_remove_size()) { ComputationalUnitsModified = true; for (auto &pr : Tenant->ComputationalUnits) { - if (!NewComputationalUnits.contains(pr.first)) + if (!NewComputationalUnits.contains(pr.first)) Self->DbRemoveComputationalUnit(Tenant, pr.first.first, pr.first.second, txc, ctx); } for (auto &pr : NewComputationalUnits) @@ -234,7 +234,7 @@ public: TStoragePool::TPtr pool; auto &kind = pr.first; auto size = pr.second; - if (Tenant->StoragePools.contains(kind)) { + if (Tenant->StoragePools.contains(kind)) { pool = new TStoragePool(*Tenant->StoragePools.at(kind)); pool->AddRequiredGroups(size); pool->State = TStoragePool::NOT_UPDATED; @@ -344,7 +344,7 @@ public: TStoragePool::TPtr pool; auto &kind = pr.first; auto size = pr.second; - if (Tenant->StoragePools.contains(kind)) { + if (Tenant->StoragePools.contains(kind)) { pool = Tenant->StoragePools.at(kind); pool->AddRequiredGroups(size); pool->State = TStoragePool::NOT_UPDATED; diff --git a/ydb/core/cms/console/console__configure.cpp b/ydb/core/cms/console/console__configure.cpp index f28417e760..bf48440fd0 100644 --- a/ydb/core/cms/console/console__configure.cpp +++ b/ydb/core/cms/console/console__configure.cpp @@ -188,7 +188,7 @@ public: if (!IsGenerationOk(item, action.GetConfigItemId().GetGeneration(), ctx)) return false; - if (Self->PendingConfigModifications.ModifiedItems.contains(item->Id)) { + if (Self->PendingConfigModifications.ModifiedItems.contains(item->Id)) { Error(Ydb::StatusIds::BAD_REQUEST, TStringBuilder() << "removal action for config item #" << item->Id << " conflicts with its modification", @@ -262,13 +262,13 @@ public: if (!IsConfigKindOk(newItem.GetConfig(), newItem.GetKind(), ctx)) return false; - if (Self->PendingConfigModifications.ModifiedItems.contains(item->Id)) { + if (Self->PendingConfigModifications.ModifiedItems.contains(item->Id)) { Error(Ydb::StatusIds::BAD_REQUEST, TStringBuilder() << "multiple modification actions for config item #" << item->Id << " are not allowed", ctx); return false; - } else if (Self->PendingConfigModifications.RemovedItems.contains(item->Id)) { + } else if (Self->PendingConfigModifications.RemovedItems.contains(item->Id)) { Error(Ydb::StatusIds::BAD_REQUEST, TStringBuilder() << "modification action conflicts with removal action" " for config item #" << item->Id, @@ -329,8 +329,8 @@ public: TConfigItems conflicts; Self->ConfigIndex.CollectItemsByConflictingScope(item->UsageScope, {item->Kind}, false, conflicts); for (auto &conflictItem : conflicts) { - if (!Self->PendingConfigModifications.ModifiedItems.contains(conflictItem->Id) - && !Self->PendingConfigModifications.RemovedItems.contains(conflictItem->Id)) { + if (!Self->PendingConfigModifications.ModifiedItems.contains(conflictItem->Id) + && !Self->PendingConfigModifications.RemovedItems.contains(conflictItem->Id)) { Error(Ydb::StatusIds::BAD_REQUEST, TStringBuilder() << ItemName(item) << " (scope: " << item->UsageScope.ToString() << ") has order conflict with config item #" << conflictItem->Id @@ -371,8 +371,8 @@ public: Self->ConfigIndex.CollectItemsByConflictingScope(item->UsageScope, {item->Kind}, true, conflicts); ui32 maxOrder = 0; for (auto &conflictItem : conflicts) { - if (!Self->PendingConfigModifications.ModifiedItems.contains(conflictItem->Id) - && !Self->PendingConfigModifications.RemovedItems.contains(conflictItem->Id)) + if (!Self->PendingConfigModifications.ModifiedItems.contains(conflictItem->Id) + && !Self->PendingConfigModifications.RemovedItems.contains(conflictItem->Id)) maxOrder = Max(maxOrder, conflictItem->UsageScope.Order); } diff --git a/ydb/core/cms/console/console__update_pool_state.cpp b/ydb/core/cms/console/console__update_pool_state.cpp index 1f12ff0e0d..5a36be6ba5 100644 --- a/ydb/core/cms/console/console__update_pool_state.cpp +++ b/ydb/core/cms/console/console__update_pool_state.cpp @@ -34,7 +34,7 @@ public: return true; } - if (!Tenant->StoragePools.contains(Pool->Kind) + if (!Tenant->StoragePools.contains(Pool->Kind) || Pool != Tenant->StoragePools.at(Pool->Kind)) { LOG_ERROR_S(ctx, NKikimrServices::CMS_TENANTS, "TTxUpdatePoolState pool " << Pool->Config.GetName() << " mismatch"); diff --git a/ydb/core/cms/console/console_configs_manager.cpp b/ydb/core/cms/console/console_configs_manager.cpp index a0415de947..0af63f0c49 100644 --- a/ydb/core/cms/console/console_configs_manager.cpp +++ b/ydb/core/cms/console/console_configs_manager.cpp @@ -164,21 +164,21 @@ bool TConfigsManager::IsConfigItemScopeAllowed(TConfigItem::TPtr item, const TConfigsConfig &config) { if (item->UsageScope.NodeIds.size()) - return config.AllowedNodeIdScopeKinds.contains(item->Kind); + return config.AllowedNodeIdScopeKinds.contains(item->Kind); if (item->UsageScope.Hosts.size()) { for (auto &host : item->UsageScope.Hosts) if (host.find(' ') != TString::npos) return false; - return config.AllowedHostScopeKinds.contains(item->Kind); + return config.AllowedHostScopeKinds.contains(item->Kind); } if (item->UsageScope.Tenant && item->UsageScope.NodeType) - return (config.AllowedTenantScopeKinds.contains(item->Kind) - && config.AllowedNodeTypeScopeKinds.contains(item->Kind)); + return (config.AllowedTenantScopeKinds.contains(item->Kind) + && config.AllowedNodeTypeScopeKinds.contains(item->Kind)); if (item->UsageScope.Tenant) - return config.AllowedTenantScopeKinds.contains(item->Kind); + return config.AllowedTenantScopeKinds.contains(item->Kind); if (item->UsageScope.NodeType) - return config.AllowedNodeTypeScopeKinds.contains(item->Kind); - return !config.DisallowedDomainScopeKinds.contains(item->Kind); + return config.AllowedNodeTypeScopeKinds.contains(item->Kind); + return !config.DisallowedDomainScopeKinds.contains(item->Kind); } bool TConfigsManager::IsSupportedMergeStrategy(ui32 value) const diff --git a/ydb/core/cms/console/console_configs_provider.cpp b/ydb/core/cms/console/console_configs_provider.cpp index 4ba6f46033..7f1d259615 100644 --- a/ydb/core/cms/console/console_configs_provider.cpp +++ b/ydb/core/cms/console/console_configs_provider.cpp @@ -782,7 +782,7 @@ void TConfigsProvider::Handle(TEvConsole::TEvGetConfigItemsRequest::TPtr &ev, co if (rec.ItemIdsSize()) { for (ui64 id : rec.GetItemIds()) { auto item = ConfigIndex.GetItem(id); - if (item && (kinds.empty() || kinds.contains(item->Kind))) + if (item && (kinds.empty() || kinds.contains(item->Kind))) items.insert(item); } hasFilter = true; @@ -846,7 +846,7 @@ void TConfigsProvider::Handle(TEvConsole::TEvGetConfigItemsRequest::TPtr &ev, co } if (!hasFilter) { for (auto &pr : ConfigIndex.GetConfigItems()) - if (kinds.empty() || kinds.contains(pr.second->Kind)) + if (kinds.empty() || kinds.contains(pr.second->Kind)) items.insert(pr.second); } diff --git a/ydb/core/cms/console/console_tenants_manager.cpp b/ydb/core/cms/console/console_tenants_manager.cpp index 0db3f5dced..caa6691069 100644 --- a/ydb/core/cms/console/console_tenants_manager.cpp +++ b/ydb/core/cms/console/console_tenants_manager.cpp @@ -1052,7 +1052,7 @@ bool TTenantsManager::TTenantsConfig::Parse(const NKikimrConsole::TTenantsConfig DefaultComputationalUnitsQuota = config.GetDefaultComputationalUnitsQuota(); for (auto &kind : config.GetAvailabilityZoneKinds()) { - if (AvailabilityZones.contains(kind.GetKind())) { + if (AvailabilityZones.contains(kind.GetKind())) { error = Sprintf("double definition of zone kind '%s'", kind.GetKind().data()); return false; } @@ -1087,13 +1087,13 @@ bool TTenantsManager::TTenantsConfig::Parse(const NKikimrConsole::TTenantsConfig THashMap<TString, TSet<TString>> zoneSets; for (auto &set : config.GetAvailabilityZoneSets()) { - if (zoneSets.contains(set.GetName())) { + if (zoneSets.contains(set.GetName())) { error = Sprintf("double definition of zone set '%s'", set.GetName().data()); return false; } for (auto &kind : set.GetZoneKinds()) { - if (!AvailabilityZones.contains(kind)) { + if (!AvailabilityZones.contains(kind)) { error = Sprintf("uknown zone kind '%s' in zone set '%s'", kind.data(), set.GetName().data()); return false; } @@ -1106,7 +1106,7 @@ bool TTenantsManager::TTenantsConfig::Parse(const NKikimrConsole::TTenantsConfig switch (kind.GetResourceCase()) { case NKikimrConsole::TComputationalUnitKind::kTenantSlotType: { - if (TenantSlotKinds.contains(kind.GetKind())) { + if (TenantSlotKinds.contains(kind.GetKind())) { error = Sprintf("double definition of computational unit kind '%s'", kind.GetKind().data()); return false; } @@ -1115,7 +1115,7 @@ bool TTenantsManager::TTenantsConfig::Parse(const NKikimrConsole::TTenantsConfig slotKind.Kind = kind.GetKind(); slotKind.TenantSlotType = kind.GetTenantSlotType(); - if(!zoneSets.contains(kind.GetAvailabilityZoneSet())) { + if(!zoneSets.contains(kind.GetAvailabilityZoneSet())) { error = Sprintf("unknown zone set '%s' is referred from computational unit kind '%s'", kind.GetAvailabilityZoneSet().data(), kind.GetKind().data()); return false; @@ -1368,7 +1368,7 @@ TTenantsManager::TTenant::TPtr TTenantsManager::FindComputationalUnitKindUsage(c const TString &zone) { for (auto &pr : Tenants) - if (pr.second->ComputationalUnits.contains(std::make_pair(kind, zone))) + if (pr.second->ComputationalUnits.contains(std::make_pair(kind, zone))) return pr.second; return nullptr; } @@ -1391,7 +1391,7 @@ TTenantsManager::TTenant::TPtr TTenantsManager::GetTenant(const TDomainId &domai void TTenantsManager::AddTenant(TTenant::TPtr tenant) { - Y_VERIFY(!Tenants.contains(tenant->Path)); + Y_VERIFY(!Tenants.contains(tenant->Path)); Tenants[tenant->Path] = tenant; if (tenant->DomainId) { Y_VERIFY(!TenantIdToName.contains(tenant->DomainId)); @@ -1475,7 +1475,7 @@ bool TTenantsManager::CheckTenantSlots(TTenant::TPtr tenant, const NKikimrTenant for (auto &slot : state.GetRequiredSlots()) { TSlotDescription key(slot); auto count = slot.GetCount(); - if (!tenant->Slots.contains(key) || tenant->Slots.at(key) != count) + if (!tenant->Slots.contains(key) || tenant->Slots.at(key) != count) return false; } @@ -1490,7 +1490,7 @@ bool TTenantsManager::MakeBasicPoolCheck(const TString &kind, ui64 size, Ydb::St return false; } - if (!Domain->StoragePoolTypes.contains(kind)) { + if (!Domain->StoragePoolTypes.contains(kind)) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("Unsupported storage unit kind '%s'.", kind.data()); return false; @@ -1503,21 +1503,21 @@ bool TTenantsManager::MakeBasicComputationalUnitCheck(const TString &kind, const Ydb::StatusIds::StatusCode &code, TString &error) { - if (!Config.TenantSlotKinds.contains(kind)) { + if (!Config.TenantSlotKinds.contains(kind)) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("Unknown computational unit kind '%s'", kind.data()); return false; } if (zone) { - if (!Config.AvailabilityZones.contains(zone)) { + if (!Config.AvailabilityZones.contains(zone)) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("Unknown availability zone '%s'", zone.data()); return false; } auto &slotKind = Config.TenantSlotKinds.at(kind); - if (!slotKind.AllowedZones.contains(zone)) { + if (!slotKind.AllowedZones.contains(zone)) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("Zone '%s' is unavailable for units of kind '%s'", zone.data(), kind.data()); return false; @@ -1652,7 +1652,7 @@ bool TTenantsManager::CheckTenantsConfig(const NKikimrConsole::TTenantsConfig &c // Check is some used zone within the unit kind is missing now. if (it->second.AllowedZones != pr.second.AllowedZones) { for (auto &zone : pr.second.AllowedZones) { - if (!it->second.AllowedZones.contains(zone)) { + if (!it->second.AllowedZones.contains(zone)) { auto tenant = FindComputationalUnitKindUsage(pr.first, zone); if (tenant) { code = Ydb::StatusIds::BAD_REQUEST; @@ -2056,7 +2056,7 @@ TTenantsManager::TTenant::TPtr TTenantsManager::FillOperationStatus(const TStrin Y_VERIFY(tenant->IsCreating() || tenant->IsConfiguring()); operation.set_ready(false); } - } else if (RemovedTenants.contains(path) + } else if (RemovedTenants.contains(path) && RemovedTenants.at(path).TxId == txId) { auto &removed = RemovedTenants.at(path); operation.set_ready(true); @@ -2074,7 +2074,7 @@ TTenantsManager::TTenant::TPtr TTenantsManager::FillOperationStatus(const TStrin tenant = GetTenant(path); if (tenant && tenant->TxId == txId) { operation.set_ready(false); - } else if (RemovedTenants.contains(path) + } else if (RemovedTenants.contains(path) && RemovedTenants.at(path).TxId == txId) { operation.set_ready(true); operation.set_status(RemovedTenants.at(path).Code); diff --git a/ydb/core/cms/console/console_tenants_manager.h b/ydb/core/cms/console/console_tenants_manager.h index a21615dd62..c7070a12a8 100644 --- a/ydb/core/cms/console/console_tenants_manager.h +++ b/ydb/core/cms/console/console_tenants_manager.h @@ -112,7 +112,7 @@ public: static bool IsDeriv(ECounter counter) { - return DerivSensors.contains(counter); + return DerivSensors.contains(counter); } TCounterPtr GetCounter(ECounter counter) diff --git a/ydb/core/cms/console/console_ut_configs.cpp b/ydb/core/cms/console/console_ut_configs.cpp index 0cb1655281..2753b044b4 100644 --- a/ydb/core/cms/console/console_ut_configs.cpp +++ b/ydb/core/cms/console/console_ut_configs.cpp @@ -208,7 +208,7 @@ void CollectItems(THashMap<ui64, TConfigItem::TPtr> &) void CollectItems(THashMap<ui64, TConfigItem::TPtr> &items, const NKikimrConsole::TConfigItem &item) { - Y_VERIFY(!items.contains(item.GetId().GetId())); + Y_VERIFY(!items.contains(item.GetId().GetId())); items.emplace(item.GetId().GetId(), new TConfigItem(item)); } @@ -507,7 +507,7 @@ void CheckGetConfigSubscription(TTenantTestRuntime &runtime, Ydb::StatusIds::Sta UNIT_ASSERT_VALUES_EQUAL(reply->Record.GetSubscription().GetOptions().GetTenant(), tenant); UNIT_ASSERT_VALUES_EQUAL(reply->Record.GetSubscription().GetOptions().GetNodeType(), nodeType); for (auto &kind : reply->Record.GetSubscription().GetConfigItemKinds()) { - UNIT_ASSERT(k.contains(kind)); + UNIT_ASSERT(k.contains(kind)); k.erase(kind); } UNIT_ASSERT(k.empty()); diff --git a/ydb/core/cms/console/console_ut_tenants.cpp b/ydb/core/cms/console/console_ut_tenants.cpp index 57e4820af7..118b0c197d 100644 --- a/ydb/core/cms/console/console_ut_tenants.cpp +++ b/ydb/core/cms/console/console_ut_tenants.cpp @@ -238,7 +238,7 @@ void CheckListTenants(TTenantTestRuntime &runtime, TVector<TString> tenants) Ydb::Cms::ListDatabasesResult result; reply->Record.GetResponse().operation().result().UnpackTo(&result); for (auto &tenant : result.paths()) { - UNIT_ASSERT(paths.contains(tenant)); + UNIT_ASSERT(paths.contains(tenant)); paths.erase(tenant); } UNIT_ASSERT(paths.empty()); @@ -458,7 +458,7 @@ Y_UNIT_TEST_SUITE(TConsoleTxProcessorTests) { bool Execute(const THashSet<ui64> &allowed) { - return allowed.contains(No); + return allowed.contains(No); } void Complete(const TActorContext &ctx) override @@ -479,7 +479,7 @@ Y_UNIT_TEST_SUITE(TConsoleTxProcessorTests) { void Execute(ITransaction *transaction, const TActorContext &ctx) override { - THolder<TTestTransaction> tx{dynamic_cast<TTestTransaction*>(transaction)}; + THolder<TTestTransaction> tx{dynamic_cast<TTestTransaction*>(transaction)}; if (tx->Execute(Allowed)) { Result.push_back(tx->No); tx->Complete(ctx); diff --git a/ydb/core/cms/console/modifications_validator.cpp b/ydb/core/cms/console/modifications_validator.cpp index b3125be585..97682d714f 100644 --- a/ydb/core/cms/console/modifications_validator.cpp +++ b/ydb/core/cms/console/modifications_validator.cpp @@ -275,7 +275,7 @@ TModificationsValidator::ComputeAffectedConfigs(const TDynBitMap &kinds, // the resulting config index then its config is equal to // domain one (which is unmodified) and shouldn't be checked. for (auto &tenant : affectedTenants) { - if (allTenants.contains(tenant)) + if (allTenants.contains(tenant)) affected.insert({tenant, TString()}); } @@ -284,7 +284,7 @@ TModificationsValidator::ComputeAffectedConfigs(const TDynBitMap &kinds, // Filter out those types which have no more config items // in the resulting config index. for (auto &type : affectedNodeTypes) { - if (allNodeTypes.contains(type)) { + if (allNodeTypes.contains(type)) { affected.insert({TString(), type}); for (auto &tenant : allTenants) @@ -294,7 +294,7 @@ TModificationsValidator::ComputeAffectedConfigs(const TDynBitMap &kinds, // Similarly to affected node types affected tenants should be // checked with all node types. for (auto &tenant : affectedTenants) { - if (allTenants.contains(tenant)) { + if (allTenants.contains(tenant)) { for (auto &type : allNodeTypes) affected.insert({tenant, type}); } diff --git a/ydb/core/cms/console/modifications_validator_ut.cpp b/ydb/core/cms/console/modifications_validator_ut.cpp index c29d8c563e..c1549d542e 100644 --- a/ydb/core/cms/console/modifications_validator_ut.cpp +++ b/ydb/core/cms/console/modifications_validator_ut.cpp @@ -546,7 +546,7 @@ public: THashSet<ui64> orders; orders.insert(ITEM_DOMAIN_LOG_4.GetId().GetId()); for (auto &item : validator.ModifiedItems) { - UNIT_ASSERT(orders.contains(item->UsageScope.Order)); + UNIT_ASSERT(orders.contains(item->UsageScope.Order)); orders.erase(item->UsageScope.Order); } UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 1); @@ -574,7 +574,7 @@ public: orders.insert(ITEM_DOMAIN_LOG_4.GetId().GetId()); orders.insert(ITEM_TENANT1_LOG_2.GetId().GetId()); for (auto &item : validator.ModifiedItems) { - UNIT_ASSERT(orders.contains(item->UsageScope.Order)); + UNIT_ASSERT(orders.contains(item->UsageScope.Order)); orders.erase(item->UsageScope.Order); } UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 2); @@ -610,7 +610,7 @@ public: orders.insert(ITEM_TYPE1_LOG_2.GetId().GetId()); orders.insert(ITEM_TENANT1_TYPE1_LOG_2.GetId().GetId()); for (auto &item : validator.ModifiedItems) { - UNIT_ASSERT(orders.contains(item->UsageScope.Order)); + UNIT_ASSERT(orders.contains(item->UsageScope.Order)); orders.erase(item->UsageScope.Order); } UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 4); @@ -642,7 +642,7 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 2); // Expect all removed items with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 1); } @@ -662,8 +662,8 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 4); // Expect all removed items with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT1_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT1_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 2); } @@ -687,10 +687,10 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 8); // Expect all removed items with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT1_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE1_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT1_TYPE1_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT1_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE1_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT1_TYPE1_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 4); } @@ -721,8 +721,8 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 3); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 2); } @@ -744,10 +744,10 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 6); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 4); } @@ -775,14 +775,14 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 12); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 8); } @@ -817,11 +817,11 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 6); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_NODE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_NODE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 5); } @@ -847,13 +847,13 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 9); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_NODE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_NODE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 7); } @@ -884,16 +884,16 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 14); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_NODE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_HOST2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_NODE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_HOST2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 10); } @@ -924,7 +924,7 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 2); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 1); } @@ -946,9 +946,9 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 5); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 3); } @@ -975,12 +975,12 @@ public: UNIT_ASSERT_VALUES_EQUAL(validator.Index.GetConfigItems().size(), 10); // Expect all modified items (both original and resulting ones) with required scope. - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); - UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(index.GetItem(ITEM_TENANT2_TYPE2_LOG_1.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_DOMAIN_LOG_2.GetId().GetId()))); + UNIT_ASSERT(validator.ModifiedItems.contains(validator.Index.GetItem(ITEM_TYPE2_LOG_1.GetId().GetId()))); UNIT_ASSERT_VALUES_EQUAL(validator.ModifiedItems.size(), 6); } diff --git a/ydb/core/cms/console/tx_processor.cpp b/ydb/core/cms/console/tx_processor.cpp index 9ba7e9ad4c..9e00ee357d 100644 --- a/ydb/core/cms/console/tx_processor.cpp +++ b/ydb/core/cms/console/tx_processor.cpp @@ -79,7 +79,7 @@ void TTxProcessor::RemoveSubProcessor(TTxProcessor::TPtr sub, { LOG_TRACE_S(ctx, Service, LogPrefix << "removing sub-processor " << sub->Name); - Y_VERIFY(SubProcessors.contains(sub->Name)); + Y_VERIFY(SubProcessors.contains(sub->Name)); SubProcessors.erase(sub->Name); if (CheckTemporary(ctx)) diff --git a/ydb/core/cms/console/ut_helpers.h b/ydb/core/cms/console/ut_helpers.h index 9faf6468fa..93ea50d6e5 100644 --- a/ydb/core/cms/console/ut_helpers.h +++ b/ydb/core/cms/console/ut_helpers.h @@ -221,7 +221,7 @@ void CheckListConfigSubscriptions(TTenantTestRuntime &runtime, Ydb::StatusIds::S for (auto &rec : reply->Record.GetSubscriptions()) { TSubscription subscription(rec); - UNIT_ASSERT(subscriptions.contains(subscription.Id)); + UNIT_ASSERT(subscriptions.contains(subscription.Id)); UNIT_ASSERT(subscriptions.at(subscription.Id).IsEqual(subscription)); subscriptions.erase(subscription.Id); } @@ -238,7 +238,7 @@ inline bool CompareState(THashMap<std::pair<TString, TString>, TSlotState> slots for (auto &unit : resources.computational_units()) { auto key = std::make_pair(unit.unit_kind(), unit.availability_zone()); auto count = unit.count(); - if (!slots.contains(key)) + if (!slots.contains(key)) return false; if (slots[key].Required != count) return false; @@ -248,7 +248,7 @@ inline bool CompareState(THashMap<std::pair<TString, TString>, TSlotState> slots for (auto &unit : resources.storage_units()) { auto key = unit.unit_kind(); auto size = unit.count(); - if (!pools.contains(key)) + if (!pools.contains(key)) return false; if (pools[key].PoolSize != size) return false; @@ -258,7 +258,7 @@ inline bool CompareState(THashMap<std::pair<TString, TString>, TSlotState> slots for (auto &unit : status.allocated_resources().computational_units()) { auto key = std::make_pair(unit.unit_kind(), unit.availability_zone()); auto count = unit.count(); - if (!slots.contains(key)) + if (!slots.contains(key)) return false; if (slots[key].Allocated != count) return false; @@ -268,7 +268,7 @@ inline bool CompareState(THashMap<std::pair<TString, TString>, TSlotState> slots for (auto &unit : status.allocated_resources().storage_units()) { auto key = unit.unit_kind(); auto size = unit.count(); - if (!pools.contains(key)) + if (!pools.contains(key)) return false; if (pools[key].Allocated != size) return false; @@ -277,7 +277,7 @@ inline bool CompareState(THashMap<std::pair<TString, TString>, TSlotState> slots for (auto &unit : status.registered_resources()) { auto key = std::make_pair(unit.host(), unit.port()); - if (!registrations.contains(key)) + if (!registrations.contains(key)) return false; if (registrations.at(key).Kind != unit.unit_kind()) return false; diff --git a/ydb/core/cms/console/validators/registry.cpp b/ydb/core/cms/console/validators/registry.cpp index 26819bf514..a639f8a682 100644 --- a/ydb/core/cms/console/validators/registry.cpp +++ b/ydb/core/cms/console/validators/registry.cpp @@ -33,7 +33,7 @@ bool TValidatorsRegistry::AddValidator(IConfigValidator::TPtr validator) { TGuard<TMutex> guard(Mutex); - if (IsLocked() || Validators.contains(validator->GetName())) + if (IsLocked() || Validators.contains(validator->GetName())) return false; Validators.emplace(validator->GetName(), validator); @@ -59,7 +59,7 @@ bool TValidatorsRegistry::CheckConfig(const NKikimrConfig::TAppConfig &oldConfig TVector<Ydb::Issue::IssueMessage> &issues) const { Y_VERIFY(Locked); - if (!ItemClasses.contains(validatorClass)) + if (!ItemClasses.contains(validatorClass)) return true; for (auto &validator : ValidatorsByItemClass.at(validatorClass)) @@ -142,7 +142,7 @@ void TValidatorsRegistry::DisableValidators() IConfigValidator::TPtr TValidatorsRegistry::GetValidator(const TString &name) const { Y_VERIFY(Locked); - if (Validators.contains(name)) + if (Validators.contains(name)) return Validators.at(name); return nullptr; } diff --git a/ydb/core/cms/console/validators/registry_ut.cpp b/ydb/core/cms/console/validators/registry_ut.cpp index dade37b722..0280d4262f 100644 --- a/ydb/core/cms/console/validators/registry_ut.cpp +++ b/ydb/core/cms/console/validators/registry_ut.cpp @@ -104,7 +104,7 @@ void CheckValidatorClasses(Ts... args) UNIT_ASSERT_VALUES_EQUAL(TValidatorsRegistry::Instance()->GetValidatorClasses().size(), classes.size()); for (auto kinds : TValidatorsRegistry::Instance()->GetValidatorClasses()) { - UNIT_ASSERT(classes.contains(kinds)); + UNIT_ASSERT(classes.contains(kinds)); } } diff --git a/ydb/core/cms/console/validators/validator_bootstrap.cpp b/ydb/core/cms/console/validators/validator_bootstrap.cpp index 4732fa802a..42051c1262 100644 --- a/ydb/core/cms/console/validators/validator_bootstrap.cpp +++ b/ydb/core/cms/console/validators/validator_bootstrap.cpp @@ -125,7 +125,7 @@ bool TBootstrapConfigValidator::CheckResourceBrokerConfig(const NKikimrConfig::T AddError(issues, "queue with empty name is not allowed"); return false; } - if (queues.contains(queue.GetName())) { + if (queues.contains(queue.GetName())) { AddError(issues, Sprintf("multiple queues with '%s' name", queue.GetName().data())); return false; @@ -149,12 +149,12 @@ bool TBootstrapConfigValidator::CheckResourceBrokerConfig(const NKikimrConfig::T AddError(issues, "task with empty name is not allowed"); return false; } - if (tasks.contains(task.GetName())) { + if (tasks.contains(task.GetName())) { AddError(issues, Sprintf("multiple tasks with '%s' name", task.GetName().data())); return false; } - if (!queues.contains(task.GetQueueName())) { + if (!queues.contains(task.GetQueueName())) { AddError(issues, Sprintf("task '%s' uses unknown queue '%s'", task.GetName().data(), task.GetQueueName().data())); return false; @@ -168,12 +168,12 @@ bool TBootstrapConfigValidator::CheckResourceBrokerConfig(const NKikimrConfig::T unusedQueues.erase(task.GetQueueName()); } - if (!queues.contains(NLocalDb::DefaultQueueName)) { + if (!queues.contains(NLocalDb::DefaultQueueName)) { AddError(issues, Sprintf("config should have '%s' queue defined", NLocalDb::DefaultQueueName.data())); return false; } - if (!tasks.contains(NLocalDb::UnknownTaskName)) { + if (!tasks.contains(NLocalDb::UnknownTaskName)) { AddError(issues, Sprintf("config should have '%s' task defined", NLocalDb::UnknownTaskName.data())); return false; diff --git a/ydb/core/cms/walle_api_handler.cpp b/ydb/core/cms/walle_api_handler.cpp index 7b62f3275a..e91917d965 100644 --- a/ydb/core/cms/walle_api_handler.cpp +++ b/ydb/core/cms/walle_api_handler.cpp @@ -86,7 +86,7 @@ private: *request->Record.AddHosts() = host.GetString(); const auto ¶ms = http.GetParams(); - if (params.contains("dry_run")) + if (params.contains("dry_run")) request->Record.SetDryRun(params.find("dry_run")->second == "true"); SendToCms(request.Release(), ctx); diff --git a/ydb/core/cms/walle_check_task_adapter.cpp b/ydb/core/cms/walle_check_task_adapter.cpp index e5570c9af9..825b8f3d4a 100644 --- a/ydb/core/cms/walle_check_task_adapter.cpp +++ b/ydb/core/cms/walle_check_task_adapter.cpp @@ -30,7 +30,7 @@ public: LOG_INFO(ctx, NKikimrServices::CMS, "Processing Wall-E request: %s", RequestEvent->Get()->Record.ShortDebugString().data()); - if (!State->WalleTasks.contains(id)) { + if (!State->WalleTasks.contains(id)) { ReplyWithErrorAndDie(TStatus::WRONG_REQUEST, "Unknown task", ctx); return; } @@ -40,7 +40,7 @@ public: auto &task = State->WalleTasks.find(id)->second; info.SetTaskId(id); - if (State->ScheduledRequests.contains(task.RequestId)) { + if (State->ScheduledRequests.contains(task.RequestId)) { auto &req = State->ScheduledRequests.find(task.RequestId)->second; for (auto &action : req.Request.GetActions()) @@ -55,7 +55,7 @@ public: Become(&TThis::StateWork, ctx, TDuration::Seconds(10), new TEvents::TEvWakeup()); } else { for (auto &id : task.Permissions) { - if (State->Permissions.contains(id)) + if (State->Permissions.contains(id)) *info.AddHosts() = State->Permissions.find(id)->second.Action.GetHost(); } diff --git a/ydb/core/cms/walle_list_tasks_adapter.cpp b/ydb/core/cms/walle_list_tasks_adapter.cpp index d256294cc1..a431ab6148 100644 --- a/ydb/core/cms/walle_list_tasks_adapter.cpp +++ b/ydb/core/cms/walle_list_tasks_adapter.cpp @@ -35,14 +35,14 @@ public: auto &info = *response->Record.AddTasks(); info.SetTaskId(task.TaskId); - if (State->ScheduledRequests.contains(task.RequestId)) { + if (State->ScheduledRequests.contains(task.RequestId)) { auto &req = State->ScheduledRequests.find(task.RequestId)->second; for (auto &action : req.Request.GetActions()) *info.AddHosts() = action.GetHost(); info.SetStatus("in-process"); } else { for (auto &id : task.Permissions) { - if (State->Permissions.contains(id)) + if (State->Permissions.contains(id)) *info.AddHosts() = State->Permissions.find(id)->second.Action.GetHost(); } info.SetStatus("ok"); diff --git a/ydb/core/cms/walle_remove_task_adapter.cpp b/ydb/core/cms/walle_remove_task_adapter.cpp index 899d484825..993c359e47 100644 --- a/ydb/core/cms/walle_remove_task_adapter.cpp +++ b/ydb/core/cms/walle_remove_task_adapter.cpp @@ -30,7 +30,7 @@ public: LOG_INFO(ctx, NKikimrServices::CMS, "Processing Wall-E request: %s", RequestEvent->Get()->Record.ShortDebugString().data()); - if (!State->WalleTasks.contains(id)) { + if (!State->WalleTasks.contains(id)) { ReplyWithErrorAndDie(TStatus::WRONG_REQUEST, "Unknown task", ctx); return; } diff --git a/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp b/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp index 450d4135c6..e507350ab9 100644 --- a/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp +++ b/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp @@ -819,7 +819,7 @@ public: TClientCommand::Parse(config); if (CommandConfig.ClientConfig.Defined()) { - auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); + auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); if (p) { ClientConfig.Locator = p->Locator; ClientConfig.Timeout = p->Timeout; @@ -948,7 +948,7 @@ public: return; } - auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); + auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); if (!p) { return; } diff --git a/ydb/core/driver_lib/cli_base/cli_cmds_root.cpp b/ydb/core/driver_lib/cli_base/cli_cmds_root.cpp index 197eccfcfd..33ce0ba765 100644 --- a/ydb/core/driver_lib/cli_base/cli_cmds_root.cpp +++ b/ydb/core/driver_lib/cli_base/cli_cmds_root.cpp @@ -121,7 +121,7 @@ public: } CommandConfig.ClientConfig = NGrpc::TGRpcClientConfig(hostname + ':' + ToString(port)); if (config.EnableSsl) { - auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); + auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); p->EnableSsl = config.EnableSsl; p->SslCaCert = config.CaCerts; } diff --git a/ydb/core/driver_lib/cli_base/cli_grpc.h b/ydb/core/driver_lib/cli_base/cli_grpc.h index 61d09c9f70..a0a6c497a7 100644 --- a/ydb/core/driver_lib/cli_base/cli_grpc.h +++ b/ydb/core/driver_lib/cli_base/cli_grpc.h @@ -88,7 +88,7 @@ public: TClientCommand::Parse(config); if (CommandConfig.ClientConfig.Defined()) { - auto *p = std::get_if<NGRpcProxy::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); + auto *p = std::get_if<NGRpcProxy::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); if (p) { ClientConfig.Locator = p->Locator; ClientConfig.Timeout = p->Timeout; diff --git a/ydb/core/driver_lib/cli_base/cli_kicli.cpp b/ydb/core/driver_lib/cli_base/cli_kicli.cpp index 5ba51e77a6..cb8dbe5d9d 100644 --- a/ydb/core/driver_lib/cli_base/cli_kicli.cpp +++ b/ydb/core/driver_lib/cli_base/cli_kicli.cpp @@ -77,7 +77,7 @@ int InvokeThroughKikimr(TClientCommand::TConfig& config, std::function<int(NClie return handler(kikimr); }; if (const auto& conf = CommandConfig.ClientConfig) { - return std::visit(std::move(visitor), *conf); + return std::visit(std::move(visitor), *conf); } else { Cerr << "Client configuration is not provided" << Endl; return 1; diff --git a/ydb/core/driver_lib/cli_config_base/config_base.h b/ydb/core/driver_lib/cli_config_base/config_base.h index 6db66dc7d1..5b0203ea34 100644 --- a/ydb/core/driver_lib/cli_config_base/config_base.h +++ b/ydb/core/driver_lib/cli_config_base/config_base.h @@ -34,7 +34,7 @@ TDuration ParseDuration(const TStringBuf& str); const TString ArgFormatDescription(); struct TCommandConfig { - TMaybe<std::variant<NMsgBusProxy::TMsgBusClientConfig, NGRpcProxy::TGRpcClientConfig>> ClientConfig; + TMaybe<std::variant<NMsgBusProxy::TMsgBusClientConfig, NGRpcProxy::TGRpcClientConfig>> ClientConfig; enum class EServerType { MessageBus, diff --git a/ydb/core/driver_lib/cli_utils/cli_cmd_config.cpp b/ydb/core/driver_lib/cli_utils/cli_cmd_config.cpp index fcc9305996..d20ec9d8e4 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmd_config.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmd_config.cpp @@ -29,7 +29,7 @@ namespace NDriverClient { case TCommandConfig::EServerType::GRpc: ClientConfig = NGrpc::TGRpcClientConfig(endpoint.Address); if (endpoint.EnableSsl.Defined()) { - auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&ClientConfig.GetRef()); + auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&ClientConfig.GetRef()); p->EnableSsl = endpoint.EnableSsl.GetRef(); } break; diff --git a/ydb/core/driver_lib/cli_utils/cli_cmd_config.h b/ydb/core/driver_lib/cli_utils/cli_cmd_config.h index bb0b69dbcb..4c480cd315 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmd_config.h +++ b/ydb/core/driver_lib/cli_utils/cli_cmd_config.h @@ -7,7 +7,7 @@ namespace NKikimr { namespace NDriverClient { struct TCliCmdConfig : TNonCopyable { - TMaybe<std::variant<NMsgBusProxy::TMsgBusClientConfig, NGRpcProxy::TGRpcClientConfig>> ClientConfig; + TMaybe<std::variant<NMsgBusProxy::TMsgBusClientConfig, NGRpcProxy::TGRpcClientConfig>> ClientConfig; NMsgBusProxy::TMsgBusClientConfig MsgBusClientConfig; TString Address; @@ -43,7 +43,7 @@ namespace NDriverClient { return data.GetTransportStatus(); }; if (const auto& conf = ClientConfig) { - return std::visit(std::move(visitor), *conf); + return std::visit(std::move(visitor), *conf); } else { Y_FAIL("Client configuration is not provided"); } diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp index ec049fab11..fe6fe49d1f 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp @@ -58,7 +58,7 @@ public: case TCommandConfig::EServerType::GRpc: CommandConfig.ClientConfig = NGrpc::TGRpcClientConfig(endpoint.Address); if (config.EnableSsl) { - auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); + auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); p->EnableSsl = config.EnableSsl; p->SslCaCert = config.CaCerts; } diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp index 6766dd3171..3944b35035 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp @@ -7,7 +7,7 @@ #include <ydb/public/lib/deprecated/kicli/kicli.h> #include <util/digest/city.h> #include <util/random/random.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/system/file.h> #include <util/system/fs.h> #include <util/system/hostname.h> diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_tenant.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_tenant.cpp index db44a3a516..7d0285c880 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_tenant.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_tenant.cpp @@ -135,7 +135,7 @@ public: TTenantClientCommand::Parse(config); if (CommandConfig.ClientConfig.Defined()) { - auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); + auto *p = std::get_if<NGrpc::TGRpcClientConfig>(&CommandConfig.ClientConfig.GetRef()); if (p) { ClientConfig.Locator = p->Locator; ClientConfig.Timeout = p->Timeout; diff --git a/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp b/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp index df1fa4a79f..8bdb62f502 100644 --- a/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp @@ -25,7 +25,7 @@ int MessageBusTrace(TCommandConfig &cmdConf, int argc, char** argv) { TCmdMessageBusTraceConfig messageBusTraceConfig; messageBusTraceConfig.Parse(argc, argv); - NMsgBusProxy::TMsgBusClient client(std::get<NMsgBusProxy::TMsgBusClientConfig>(*messageBusTraceConfig.ClientConfig)); + NMsgBusProxy::TMsgBusClient client(std::get<NMsgBusProxy::TMsgBusClientConfig>(*messageBusTraceConfig.ClientConfig)); client.Init(); if (messageBusTraceConfig.Command == "play") { diff --git a/ydb/core/driver_lib/cli_utils/cli_persqueue_cluster_discovery.cpp b/ydb/core/driver_lib/cli_utils/cli_persqueue_cluster_discovery.cpp index 79800a67da..8a88fd9617 100644 --- a/ydb/core/driver_lib/cli_utils/cli_persqueue_cluster_discovery.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_persqueue_cluster_discovery.cpp @@ -74,8 +74,8 @@ static void PrintGRpcConfigAndRequest(const NGrpc::TGRpcClientConfig& grpcConfig template <class TConfig> static int MakeRequest(const TConfig& config, const Ydb::PersQueue::ClusterDiscovery::DiscoverClustersRequest& request) { if (config.ClientConfig.Defined()) { - if (std::holds_alternative<NGrpc::TGRpcClientConfig>(*config.ClientConfig)) { - const auto& grpcConfig = std::get<NGrpc::TGRpcClientConfig>(*config.ClientConfig); + if (std::holds_alternative<NGrpc::TGRpcClientConfig>(*config.ClientConfig)) { + const auto& grpcConfig = std::get<NGrpc::TGRpcClientConfig>(*config.ClientConfig); if (config.IsVerbose) { PrintGRpcConfigAndRequest(grpcConfig, request); diff --git a/ydb/core/driver_lib/run/run.cpp b/ydb/core/driver_lib/run/run.cpp index a4f74aa4e0..a13213be93 100644 --- a/ydb/core/driver_lib/run/run.cpp +++ b/ydb/core/driver_lib/run/run.cpp @@ -147,7 +147,7 @@ public: const TString domainName = domain.HasName() ? domain.GetName() : Sprintf("domain-%" PRIu32, domainId); TDomainsInfo::TDomain::TStoragePoolKinds poolTypes; for (auto &type : domain.GetStoragePoolTypes()) { - Y_VERIFY(!poolTypes.contains(type.GetKind()), "duplicated slot type"); + Y_VERIFY(!poolTypes.contains(type.GetKind()), "duplicated slot type"); poolTypes[type.GetKind()] = type.GetPoolConfig(); } diff --git a/ydb/core/engine/mkql_engine_flat.cpp b/ydb/core/engine/mkql_engine_flat.cpp index c7fe388eef..38af69298b 100644 --- a/ydb/core/engine/mkql_engine_flat.cpp +++ b/ydb/core/engine/mkql_engine_flat.cpp @@ -411,7 +411,7 @@ public: bool hasWrites = false; const auto& strings = Strings; auto writesCheck = [&hasWrites, &strings](TInternName name) { - if (strings.DbWrites.contains(name)) { + if (strings.DbWrites.contains(name)) { hasWrites = true; } @@ -429,9 +429,9 @@ public: ui64 coordinatorRequiresShardCount = 0; for (ui64 shard : affectedShardSet) { auto shardData = TShardData(shard, TString()); - if (writeSet.contains(shard)) + if (writeSet.contains(shard)) shardData.HasWrites = true; - if (onlineReadSet.contains(shard)) + if (onlineReadSet.contains(shard)) shardData.HasOnlineReads = true; if (shardData.HasWrites || shardData.HasOnlineReads) @@ -943,9 +943,9 @@ public: TValidatedKey validKey(std::move(desc), false); auto targetIt = readTargets.find(uniqId); - if (replyIds.contains(uniqId) || targetIt != readTargets.end()) { + if (replyIds.contains(uniqId) || targetIt != readTargets.end()) { // Is this read result included in the reply? - if (replyIds.contains(uniqId)) { + if (replyIds.contains(uniqId)) { validKey.IsResultPart = true; } // Is this read result included into outgoing read sets? @@ -1605,7 +1605,7 @@ private: } } - if (ProxyRepliesCallables.contains(callable.first)) { + if (ProxyRepliesCallables.contains(callable.first)) { TCallableContext* readCtx = &callable.second; auto replyRead = ProxyRepliesReads.FindPtr(callable.first); @@ -1741,11 +1741,11 @@ private: auto callable = static_cast<TCallable*>(node); auto name = callable->GetType()->GetNameStr(); - if (name == Strings.Builtins.Arg && !knownArgIds.contains(callable->GetUniqueId())) { + if (name == Strings.Builtins.Arg && !knownArgIds.contains(callable->GetUniqueId())) { foundArgs.push_back(callable); } - if (Strings.All.contains(name)) { + if (Strings.All.contains(name)) { return false; } } @@ -1754,7 +1754,7 @@ private: for (TCallable* arg : foundArgs) { auto& consumers = ProxyProgramExplorer.GetConsumerNodes(*arg); for (auto& consumer : consumers) { - if (!visitedNodes.contains(consumer)) { + if (!visitedNodes.contains(consumer)) { return false; } } @@ -1855,7 +1855,7 @@ private: return nullptr; } - if (!pureCallables.contains(callable->GetUniqueId())) { + if (!pureCallables.contains(callable->GetUniqueId())) { return nullptr; } @@ -1873,7 +1873,7 @@ private: auto tryPushdownCallable = [this, callable, &pureCallables, &aggregatedCallables, getCallableForPushdown] (TCallable* input, bool aggregated) { - if (!pureCallables.contains(callable->GetUniqueId())) { + if (!pureCallables.contains(callable->GetUniqueId())) { return; } @@ -1885,10 +1885,10 @@ private: } } - if (ProxyRepliesCallables.contains(input->GetUniqueId()) && - !aggregatedCallables.contains(input->GetUniqueId())) + if (ProxyRepliesCallables.contains(input->GetUniqueId()) && + !aggregatedCallables.contains(input->GetUniqueId())) { - if (ProxyRepliesReads.contains(callable->GetUniqueId())) { + if (ProxyRepliesReads.contains(callable->GetUniqueId())) { return; } @@ -1998,21 +1998,21 @@ private: if (name == Strings.CombineByKeyMerge) { return TCallableVisitFunc([this](TCallable& callable, const TTypeEnvironment& env) { Y_UNUSED(env); - return ProxyRepliesCallables.contains(callable.GetUniqueId()) + return ProxyRepliesCallables.contains(callable.GetUniqueId()) ? TRuntimeNode(&callable, false) : callable.GetInput(0); }); } else if (name == Strings.PartialSort) { return TCallableVisitFunc([this](TCallable& callable, const TTypeEnvironment& env) { - return ProxyRepliesCallables.contains(callable.GetUniqueId()) + return ProxyRepliesCallables.contains(callable.GetUniqueId()) ? TRuntimeNode(&callable, false) : RenameCallable(callable, "Sort", env); }); } else if (name == Strings.PartialTake) { return TCallableVisitFunc([this](TCallable& callable, const TTypeEnvironment& env) { - return ProxyRepliesCallables.contains(callable.GetUniqueId()) + return ProxyRepliesCallables.contains(callable.GetUniqueId()) ? TRuntimeNode(&callable, false) : RenameCallable(callable, "Take", env); }); diff --git a/ydb/core/engine/mkql_engine_flat_extfunc.cpp b/ydb/core/engine/mkql_engine_flat_extfunc.cpp index 414d3aeeb4..d7bc930021 100644 --- a/ydb/core/engine/mkql_engine_flat_extfunc.cpp +++ b/ydb/core/engine/mkql_engine_flat_extfunc.cpp @@ -485,7 +485,7 @@ namespace { const THashSet<ui32>& localReadCallables, IEngineFlatHost* host, const TComputationNodeFactoryContext& ctx) { TUnboxedValueVector values; - if (localReadCallables.contains(callable.GetUniqueId())) { + if (localReadCallables.contains(callable.GetUniqueId())) { values.push_back(PerformLocalSelectRow(callable, *host, ctx.HolderFactory, ctx.Env)); } @@ -575,7 +575,7 @@ namespace { const TFlatEngineStrings& strings) { TUnboxedValueVector values; - if (localReadCallables.contains(callable.GetUniqueId())) { + if (localReadCallables.contains(callable.GetUniqueId())) { values.push_back(PerformLocalSelectRange(callable, *host, ctx.HolderFactory, ctx.Env)); } diff --git a/ydb/core/engine/mkql_engine_flat_ut.cpp b/ydb/core/engine/mkql_engine_flat_ut.cpp index e2b12e2d7a..4bdb75557f 100644 --- a/ydb/core/engine/mkql_engine_flat_ut.cpp +++ b/ydb/core/engine/mkql_engine_flat_ut.cpp @@ -244,7 +244,7 @@ namespace { *RandomProvider, *TimeProvider, hosts[shardPgm.first].Get())); UNIT_ASSERT(dataEngine->AddProgram(shardPgm.first, shardPgm.second) == IEngineFlat::EResult::Ok); - if (incomingReadsets.contains(shardPgm.first)) { + if (incomingReadsets.contains(shardPgm.first)) { for (ui64 rsOrigin : incomingReadsets[shardPgm.first]) { auto it = outgoingReadsets.find(rsOrigin); UNIT_ASSERT(it != outgoingReadsets.end()); diff --git a/ydb/core/grpc_services/grpc_request_proxy.cpp b/ydb/core/grpc_services/grpc_request_proxy.cpp index a1e7accb87..08efaac874 100644 --- a/ydb/core/grpc_services/grpc_request_proxy.cpp +++ b/ydb/core/grpc_services/grpc_request_proxy.cpp @@ -501,7 +501,7 @@ void TGRpcRequestProxyImpl::SubscribeToDatabase(const TString& database) { auto& domain = AppData()->DomainsInfo->Domains.begin()->second; ui64 domainOwnerId = domain->SchemeRoot; ui32 schemeBoardGroup = domain->DefaultSchemeBoardGroup; - THolder<IActor> subscriber{CreateSchemeBoardSubscriber(SelfId(), database, schemeBoardGroup, domainOwnerId)}; + THolder<IActor> subscriber{CreateSchemeBoardSubscriber(SelfId(), database, schemeBoardGroup, domainOwnerId)}; TActorId subscriberId = Register(subscriber.Release()); auto itSubscriber = Subscribers.emplace(database, subscriberId); if (!itSubscriber.second) { diff --git a/ydb/core/grpc_services/local_rate_limiter.cpp b/ydb/core/grpc_services/local_rate_limiter.cpp index 3a2fcb78cb..b0d91aaecc 100644 --- a/ydb/core/grpc_services/local_rate_limiter.cpp +++ b/ydb/core/grpc_services/local_rate_limiter.cpp @@ -144,7 +144,7 @@ TVector<std::pair<Actions, Ydb::RateLimiter::AcquireResourceRequest>> MakeReques auto f = [&](const auto& item) { Fill(item, rlPath.CoordinationNode, rlPath.ResourcePath, result); }; - std::visit(f, action); + std::visit(f, action); } return result; diff --git a/ydb/core/grpc_services/local_rate_limiter.h b/ydb/core/grpc_services/local_rate_limiter.h index cfc04b8d56..e444d76eca 100644 --- a/ydb/core/grpc_services/local_rate_limiter.h +++ b/ydb/core/grpc_services/local_rate_limiter.h @@ -64,7 +64,7 @@ struct TRlConfig { struct TOnRespAction { }; - using TActions = std::variant<TOnReqAction, TOnRespAction>; + using TActions = std::variant<TOnReqAction, TOnRespAction>; TRlConfig(const TString& coordinationNodeKey, const TString& resourceKey, const TVector<TActions>& actions) : CoordinationNodeKey(coordinationNodeKey) diff --git a/ydb/core/grpc_services/table_profiles.cpp b/ydb/core/grpc_services/table_profiles.cpp index 367de4cc89..e31660e390 100644 --- a/ydb/core/grpc_services/table_profiles.cpp +++ b/ydb/core/grpc_services/table_profiles.cpp @@ -76,7 +76,7 @@ NKikimrSchemeOp::TStorageConfig *TTableProfiles::GetDefaultStorageConfig(NKikimr } bool TTableProfiles::HasPresetName(const TString &presetName) const { - return TableProfiles.contains(presetName); + return TableProfiles.contains(presetName); } bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, @@ -92,7 +92,7 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, NKikimrConfig::TCachingPolicy cachingPolicy; auto &partitionConfig = *tableDesc.MutablePartitionConfig(); - if (profile.preset_name() && !TableProfiles.contains(profile.preset_name())) { + if (profile.preset_name() && !TableProfiles.contains(profile.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown table profile preset '%s'", profile.preset_name().data()); return false; @@ -100,32 +100,32 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, TString name = profile.preset_name() ? profile.preset_name() : "default"; NKikimrConfig::TTableProfile tableProfile; - if (TableProfiles.contains(name)) + if (TableProfiles.contains(name)) tableProfile = TableProfiles.at(name); // Determine used compaction policy. if (profile.has_compaction_policy()) { auto &policy = profile.compaction_policy(); - if (!CompactionPolicies.contains(policy.preset_name())) { + if (!CompactionPolicies.contains(policy.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown compaction policy preset '%s'", policy.preset_name().data()); return false; } compactionPolicy = CompactionPolicies.at(policy.preset_name()); - } else if (CompactionPolicies.contains(tableProfile.GetCompactionPolicy())) { + } else if (CompactionPolicies.contains(tableProfile.GetCompactionPolicy())) { compactionPolicy = CompactionPolicies.at(tableProfile.GetCompactionPolicy()); } // Determine used execution policy. if (profile.has_execution_policy()) { auto &policy = profile.execution_policy(); - if (!ExecutionPolicies.contains(policy.preset_name())) { + if (!ExecutionPolicies.contains(policy.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown execution policy preset '%s'", policy.preset_name().data()); return false; } executionPolicy = ExecutionPolicies.at(policy.preset_name()); - } else if (ExecutionPolicies.contains(tableProfile.GetExecutionPolicy())) { + } else if (ExecutionPolicies.contains(tableProfile.GetExecutionPolicy())) { executionPolicy = ExecutionPolicies.at(tableProfile.GetExecutionPolicy()); } @@ -133,13 +133,13 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, if (profile.has_partitioning_policy()) { auto &policy = profile.partitioning_policy(); if (policy.preset_name()) { - if (!PartitioningPolicies.contains(policy.preset_name())) { + if (!PartitioningPolicies.contains(policy.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown partitioning policy preset '%s'", policy.preset_name().data()); return false; } partitioningPolicy = PartitioningPolicies.at(policy.preset_name()); - } else if (PartitioningPolicies.contains(tableProfile.GetPartitioningPolicy())) { + } else if (PartitioningPolicies.contains(tableProfile.GetPartitioningPolicy())) { partitioningPolicy = PartitioningPolicies.at(tableProfile.GetPartitioningPolicy()); } // Apply auto partitioning overwrites. @@ -176,7 +176,7 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, default: break; } - } else if (PartitioningPolicies.contains(tableProfile.GetPartitioningPolicy())) { + } else if (PartitioningPolicies.contains(tableProfile.GetPartitioningPolicy())) { partitioningPolicy = PartitioningPolicies.at(tableProfile.GetPartitioningPolicy()); } @@ -184,13 +184,13 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, if (profile.has_storage_policy()) { auto &policy = profile.storage_policy(); if (policy.preset_name()) { - if (!StoragePolicies.contains(policy.preset_name())) { + if (!StoragePolicies.contains(policy.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown storage policy preset '%s'", policy.preset_name().data()); return false; } storagePolicy = StoragePolicies.at(policy.preset_name()); - } else if (StoragePolicies.contains(tableProfile.GetStoragePolicy())) { + } else if (StoragePolicies.contains(tableProfile.GetStoragePolicy())) { storagePolicy = StoragePolicies.at(tableProfile.GetStoragePolicy()); } // Apply overwritten storage settings for syslog. @@ -305,7 +305,7 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, return false; } } - } else if (StoragePolicies.contains(tableProfile.GetStoragePolicy())) { + } else if (StoragePolicies.contains(tableProfile.GetStoragePolicy())) { storagePolicy = StoragePolicies.at(tableProfile.GetStoragePolicy()); } @@ -313,13 +313,13 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, if (profile.has_replication_policy()) { auto &policy = profile.replication_policy(); if (policy.preset_name()) { - if (!ReplicationPolicies.contains(policy.preset_name())) { + if (!ReplicationPolicies.contains(policy.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown replciation policy preset '%s'", policy.preset_name().data()); return false; } replicationPolicy = ReplicationPolicies.at(policy.preset_name()); - } else if (ReplicationPolicies.contains(tableProfile.GetReplicationPolicy())) { + } else if (ReplicationPolicies.contains(tableProfile.GetReplicationPolicy())) { replicationPolicy = ReplicationPolicies.at(tableProfile.GetReplicationPolicy()); } if (policy.replicas_count()) @@ -354,20 +354,20 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, (ui32)policy.allow_promotion()); return false; } - } else if (ReplicationPolicies.contains(tableProfile.GetReplicationPolicy())) { + } else if (ReplicationPolicies.contains(tableProfile.GetReplicationPolicy())) { replicationPolicy = ReplicationPolicies.at(tableProfile.GetReplicationPolicy()); } // Determine used caching policy. if (profile.has_caching_policy()) { auto &policy = profile.caching_policy(); - if (!CachingPolicies.contains(policy.preset_name())) { + if (!CachingPolicies.contains(policy.preset_name())) { code = Ydb::StatusIds::BAD_REQUEST; error = Sprintf("unknown caching policy preset '%s'", policy.preset_name().data()); return false; } cachingPolicy = CachingPolicies.at(policy.preset_name()); - } else if (CachingPolicies.contains(tableProfile.GetCachingPolicy())) { + } else if (CachingPolicies.contains(tableProfile.GetCachingPolicy())) { cachingPolicy = CachingPolicies.at(tableProfile.GetCachingPolicy()); } diff --git a/ydb/core/kesus/proxy/proxy_actor.cpp b/ydb/core/kesus/proxy/proxy_actor.cpp index e93d90355f..d09ad9c3ea 100644 --- a/ydb/core/kesus/proxy/proxy_actor.cpp +++ b/ydb/core/kesus/proxy/proxy_actor.cpp @@ -425,7 +425,7 @@ private: void HandleDirectRequest(const TActorId& sender, ui64 cookie, THolder<IEventBase> event) { KPROXY_LOG_TRACE_S("Received " << event->ToStringHeader() << " from " << sender); - Y_VERIFY(!DirectRequestBySender.contains(sender), "Only one outgoing request per sender is allowed"); + Y_VERIFY(!DirectRequestBySender.contains(sender), "Only one outgoing request per sender is allowed"); const ui64 seqNo = ++SeqNo; auto& req = DirectRequests[seqNo]; req.Sender = sender; @@ -532,7 +532,7 @@ private: void Handle(TEvKesus::TEvAttachSession::TPtr& ev) { KPROXY_LOG_TRACE_S("Received TEvAttachSession from " << ev->Sender); Y_VERIFY(ev->Sender); - Y_VERIFY(!SessionByOwner.contains(ev->Sender), "Only one outgoing request per sender is allowed"); + Y_VERIFY(!SessionByOwner.contains(ev->Sender), "Only one outgoing request per sender is allowed"); auto& record = ev->Get()->Record; const ui64 sessionId = record.GetSessionId(); diff --git a/ydb/core/kesus/proxy/ut_helpers.cpp b/ydb/core/kesus/proxy/ut_helpers.cpp index 74580d10f7..d1836bf1bc 100644 --- a/ydb/core/kesus/proxy/ut_helpers.cpp +++ b/ydb/core/kesus/proxy/ut_helpers.cpp @@ -156,11 +156,11 @@ void TTestContext::VerifySemaphoreOwners(ui64 proxyId, const TString& name, cons auto desc = DescribeSemaphore(proxyId, name); UNIT_ASSERT_VALUES_EQUAL(desc.Ephemeral, ephemeral); for (ui64 sessionId : sessionIds) { - UNIT_ASSERT_C(desc.Owners.contains(sessionId), "Session " << sessionId << " is not an owner of " << name); + UNIT_ASSERT_C(desc.Owners.contains(sessionId), "Session " << sessionId << " is not an owner of " << name); } for (const auto& kv : desc.Owners) { ui64 sessionId = kv.first; - UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected owner of " << name); + UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected owner of " << name); } } @@ -168,11 +168,11 @@ void TTestContext::VerifySemaphoreWaiters(ui64 proxyId, const TString& name, con auto desc = DescribeSemaphore(proxyId, name, true); UNIT_ASSERT_VALUES_EQUAL(desc.Ephemeral, ephemeral); for (ui64 sessionId : sessionIds) { - UNIT_ASSERT_C(desc.Waiters.contains(sessionId), "Session " << sessionId << " is not a waiter of " << name); + UNIT_ASSERT_C(desc.Waiters.contains(sessionId), "Session " << sessionId << " is not a waiter of " << name); } for (const auto& kv : desc.Waiters) { ui64 sessionId = kv.first; - UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected waiter of " << name); + UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected waiter of " << name); } } diff --git a/ydb/core/kesus/tablet/tablet_db.cpp b/ydb/core/kesus/tablet/tablet_db.cpp index e4d9a1e276..864376c84c 100644 --- a/ydb/core/kesus/tablet/tablet_db.cpp +++ b/ydb/core/kesus/tablet/tablet_db.cpp @@ -96,7 +96,7 @@ void TKesusTablet::DoDeleteSessionSemaphore( LOG_DEBUG_S(TActivationContext::AsActorContext(), NKikimrServices::KESUS_TABLET, "[" << TabletID() << "] Deleting session " << sessionId << " / semaphore " << semaphoreId << " " << semaphore->Name.Quote() << " owner link"); - Y_VERIFY(semaphore->Owners.contains(owner)); + Y_VERIFY(semaphore->Owners.contains(owner)); semaphore->Count -= owner->Count; semaphore->Owners.erase(owner); PersistDeleteSessionSemaphore(db, sessionId, semaphoreId); @@ -156,7 +156,7 @@ void TKesusTablet::DoProcessSemaphoreQueue( "Semaphore %s points to missing session: %" PRIu64 " (wait order %" PRIu64 ")", semaphore->Name.Quote().data(), sessionId, orderId); - Y_VERIFY(!session->OwnedSemaphores.contains(semaphoreId)); + Y_VERIFY(!session->OwnedSemaphores.contains(semaphoreId)); auto* owner = &session->OwnedSemaphores[semaphoreId]; owner->OrderId = orderId; owner->SessionId = sessionId; diff --git a/ydb/core/kesus/tablet/tx_init.cpp b/ydb/core/kesus/tablet/tx_init.cpp index 1f3f96ff9f..a4e7fdd61b 100644 --- a/ydb/core/kesus/tablet/tx_init.cpp +++ b/ydb/core/kesus/tablet/tx_init.cpp @@ -130,7 +130,7 @@ struct TKesusTablet::TTxInit : public TTxBase { TString description = sessionsRowset.GetValue<Schema::Sessions::Description>(); TString protectionKey = sessionsRowset.GetValueOrDefault<Schema::Sessions::ProtectionKey>(TString()); Y_VERIFY(sessionId > 0); - Y_VERIFY(!Self->Sessions.contains(sessionId)); + Y_VERIFY(!Self->Sessions.contains(sessionId)); auto* session = &Self->Sessions[sessionId]; session->Id = sessionId; session->TimeoutMillis = timeoutMillis; @@ -154,7 +154,7 @@ struct TKesusTablet::TTxInit : public TTxBase { ui64 limit = semaphoresRowset.GetValue<Schema::Semaphores::Limit>(); bool ephemeral = semaphoresRowset.GetValue<Schema::Semaphores::Ephemeral>(); Y_VERIFY(semaphoreId > 0); - Y_VERIFY(!Self->Semaphores.contains(semaphoreId)); + Y_VERIFY(!Self->Semaphores.contains(semaphoreId)); auto* semaphore = &Self->Semaphores[semaphoreId]; semaphore->Id = semaphoreId; semaphore->Name = std::move(name); @@ -183,16 +183,16 @@ struct TKesusTablet::TTxInit : public TTxBase { ui64 count = sessionSemaphoresRowset.GetValue<Schema::SessionSemaphores::Count>(); TString data = sessionSemaphoresRowset.GetValue<Schema::SessionSemaphores::Data>(); Y_VERIFY(sessionId > 0); - Y_VERIFY(Self->Sessions.contains(sessionId), "Missing session: %" PRIu64, sessionId); + Y_VERIFY(Self->Sessions.contains(sessionId), "Missing session: %" PRIu64, sessionId); Y_VERIFY(semaphoreId > 0); - Y_VERIFY(Self->Semaphores.contains(semaphoreId), "Missing semaphore: %" PRIu64, semaphoreId); + Y_VERIFY(Self->Semaphores.contains(semaphoreId), "Missing semaphore: %" PRIu64, semaphoreId); Y_VERIFY(orderId > 0); Y_VERIFY(count > 0, "Unexpected count: %" PRIu64, count); auto* session = &Self->Sessions[sessionId]; auto* semaphore = &Self->Semaphores[semaphoreId]; - Y_VERIFY(!session->WaitingSemaphores.contains(semaphoreId), + Y_VERIFY(!session->WaitingSemaphores.contains(semaphoreId), "Session %" PRIu64 " has duplicate semaphore %s", sessionId, semaphore->Name.Quote().data()); - Y_VERIFY(!semaphore->Waiters.contains(orderId), + Y_VERIFY(!semaphore->Waiters.contains(orderId), "Semaphore %s has duplicate order id: %" PRIu64, semaphore->Name.Quote().data(), orderId); auto* waiter = &session->WaitingSemaphores[semaphoreId]; waiter->OrderId = orderId; diff --git a/ydb/core/kesus/tablet/tx_semaphore_acquire.cpp b/ydb/core/kesus/tablet/tx_semaphore_acquire.cpp index 996dca18bf..898e0a4283 100644 --- a/ydb/core/kesus/tablet/tx_semaphore_acquire.cpp +++ b/ydb/core/kesus/tablet/tx_semaphore_acquire.cpp @@ -107,7 +107,7 @@ struct TKesusTablet::TTxSemaphoreAcquire : public TTxBase { ui64 semaphoreId = Self->NextSemaphoreId++; Y_VERIFY(semaphoreId > 0); - Y_VERIFY(!Self->Semaphores.contains(semaphoreId)); + Y_VERIFY(!Self->Semaphores.contains(semaphoreId)); Self->PersistSysParam(db, Schema::SysParam_NextSemaphoreId, ToString(Self->NextSemaphoreId)); semaphore = &Self->Semaphores[semaphoreId]; semaphore->Id = semaphoreId; @@ -173,7 +173,7 @@ struct TKesusTablet::TTxSemaphoreAcquire : public TTxBase { auto* waiter = session->WaitingSemaphores.FindPtr(semaphoreId); if (waiter) { // This session is already waiting for the semaphore - Y_VERIFY(semaphore->Waiters.contains(waiter->OrderId)); + Y_VERIFY(semaphore->Waiters.contains(waiter->OrderId)); if (Record.GetCount() > waiter->Count) { // Increasing count is not allowed ReplyError( @@ -250,7 +250,7 @@ struct TKesusTablet::TTxSemaphoreAcquire : public TTxBase { } // Notify sender if session is now waiting for the semaphore - if (session->WaitingSemaphores.contains(semaphoreId)) { + if (session->WaitingSemaphores.contains(semaphoreId)) { Y_VERIFY(Self->ScheduleWaiterTimeout(semaphoreId, waiter, ctx)); ReplyPending(); } diff --git a/ydb/core/kesus/tablet/tx_semaphore_create.cpp b/ydb/core/kesus/tablet/tx_semaphore_create.cpp index 100cf550b3..44a1683c7f 100644 --- a/ydb/core/kesus/tablet/tx_semaphore_create.cpp +++ b/ydb/core/kesus/tablet/tx_semaphore_create.cpp @@ -83,7 +83,7 @@ struct TKesusTablet::TTxSemaphoreCreate : public TTxBase { ui64 semaphoreId = Self->NextSemaphoreId++; Y_VERIFY(semaphoreId > 0); - Y_VERIFY(!Self->Semaphores.contains(semaphoreId)); + Y_VERIFY(!Self->Semaphores.contains(semaphoreId)); Self->PersistSysParam(db, Schema::SysParam_NextSemaphoreId, ToString(Self->NextSemaphoreId)); semaphore = &Self->Semaphores[semaphoreId]; semaphore->Id = semaphoreId; diff --git a/ydb/core/kesus/tablet/tx_session_attach.cpp b/ydb/core/kesus/tablet/tx_session_attach.cpp index ca5f4191f2..159253d16b 100644 --- a/ydb/core/kesus/tablet/tx_session_attach.cpp +++ b/ydb/core/kesus/tablet/tx_session_attach.cpp @@ -101,7 +101,7 @@ struct TKesusTablet::TTxSessionAttach : public TTxBase { SessionId = Self->NextSessionId++; Y_VERIFY(SessionId > 0); - Y_VERIFY(!Self->Sessions.contains(SessionId)); + Y_VERIFY(!Self->Sessions.contains(SessionId)); Self->PersistSysParam(db, Schema::SysParam_NextSessionId, ToString(Self->NextSessionId)); session = &Self->Sessions[SessionId]; session->Id = SessionId; diff --git a/ydb/core/kesus/tablet/ut_helpers.cpp b/ydb/core/kesus/tablet/ut_helpers.cpp index f559800a76..9d57027fd0 100644 --- a/ydb/core/kesus/tablet/ut_helpers.cpp +++ b/ydb/core/kesus/tablet/ut_helpers.cpp @@ -451,26 +451,26 @@ THashMap<TActorId, TTestContext::TSimpleProxyInfo> TTestContext::DescribeProxies void TTestContext::VerifyProxyRegistered(const TActorId& proxy, ui64 generation) { auto proxies = DescribeProxies(); - UNIT_ASSERT_C(proxies.contains(proxy), "Proxy " << proxy << " is not registered"); + UNIT_ASSERT_C(proxies.contains(proxy), "Proxy " << proxy << " is not registered"); const auto& proxyInfo = proxies.at(proxy); UNIT_ASSERT_VALUES_EQUAL(proxyInfo.Generation, generation); } void TTestContext::VerifyProxyNotRegistered(const TActorId& proxy) { auto proxies = DescribeProxies(); - UNIT_ASSERT_C(!proxies.contains(proxy), "Proxy " << proxy << " is registered"); + UNIT_ASSERT_C(!proxies.contains(proxy), "Proxy " << proxy << " is registered"); } void TTestContext::VerifyProxyHasSessions(const TActorId& proxy, ui64 generation, const THashSet<ui64>& expectedSessions) { auto proxies = DescribeProxies(); - UNIT_ASSERT_C(proxies.contains(proxy), "Proxy " << proxy << " is not registered"); + UNIT_ASSERT_C(proxies.contains(proxy), "Proxy " << proxy << " is not registered"); const auto& proxyInfo = proxies.at(proxy); UNIT_ASSERT_VALUES_EQUAL(proxyInfo.Generation, generation); for (ui64 sessionId : expectedSessions) { - UNIT_ASSERT_C(proxyInfo.AttachedSessions.contains(sessionId), "Proxy " << proxy << " does not own session " << sessionId); + UNIT_ASSERT_C(proxyInfo.AttachedSessions.contains(sessionId), "Proxy " << proxy << " does not own session " << sessionId); } for (ui64 sessionId : proxyInfo.AttachedSessions) { - UNIT_ASSERT_C(expectedSessions.contains(sessionId), "Proxy " << proxy << " owns unexpected session " << sessionId); + UNIT_ASSERT_C(expectedSessions.contains(sessionId), "Proxy " << proxy << " owns unexpected session " << sessionId); } } @@ -481,7 +481,7 @@ THashMap<ui64, TTestContext::TSimpleSessionInfo> TTestContext::DescribeSessions( auto result = ExpectEdgeEvent<TEvKesus::TEvDescribeSessionsResult>(edge, cookie); THashMap<ui64, TSimpleSessionInfo> sessions; for (const auto& sessionInfo : result->Record.GetSessions()) { - Y_VERIFY(!sessions.contains(sessionInfo.GetSessionId())); + Y_VERIFY(!sessions.contains(sessionInfo.GetSessionId())); auto& session = sessions[sessionInfo.GetSessionId()]; session.TimeoutMillis = sessionInfo.GetTimeoutMillis(); session.Description = sessionInfo.GetDescription(); @@ -492,12 +492,12 @@ THashMap<ui64, TTestContext::TSimpleSessionInfo> TTestContext::DescribeSessions( void TTestContext::VerifySessionNotFound(ui64 sessionId) { auto sessions = DescribeSessions(); - UNIT_ASSERT_C(!sessions.contains(sessionId), "Session " << sessionId << " actually exist"); + UNIT_ASSERT_C(!sessions.contains(sessionId), "Session " << sessionId << " actually exist"); } void TTestContext::VerifySessionExists(ui64 sessionId) { auto sessions = DescribeSessions(); - UNIT_ASSERT_C(sessions.contains(sessionId), "Session " << sessionId << " does not exist"); + UNIT_ASSERT_C(sessions.contains(sessionId), "Session " << sessionId << " does not exist"); } TTestContext::TSimpleLockDescription TTestContext::DescribeLock(const TString& lockName, bool includeWaiters) { @@ -559,21 +559,21 @@ void TTestContext::VerifyLockExclusive(const TString& lockName, ui64 sessionId) void TTestContext::VerifyLockShared(const TString& lockName, const THashSet<ui64>& sessionIds) { auto desc = DescribeLock(lockName); for (ui64 sessionId : sessionIds) { - UNIT_ASSERT_C(desc.SharedOwners.contains(sessionId), "Session " << sessionId << " is not a shared owner of " << lockName); + UNIT_ASSERT_C(desc.SharedOwners.contains(sessionId), "Session " << sessionId << " is not a shared owner of " << lockName); } for (ui64 sessionId : desc.SharedOwners) { - UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected shared owner of " << lockName); + UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected shared owner of " << lockName); } } void TTestContext::VerifyLockWaiters(const TString& lockName, const THashSet<ui64>& sessionIds) { auto desc = DescribeLock(lockName, true); for (ui64 sessionId : sessionIds) { - UNIT_ASSERT_C(desc.Waiters.contains(sessionId), "Session " << sessionId << " is not a waiter of " << lockName); + UNIT_ASSERT_C(desc.Waiters.contains(sessionId), "Session " << sessionId << " is not a waiter of " << lockName); } for (const auto& kv : desc.Waiters) { ui64 sessionId = kv.first; - UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected waiter of " << lockName); + UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected waiter of " << lockName); } } @@ -617,11 +617,11 @@ void TTestContext::VerifySemaphoreOwners(const TString& name, const THashSet<ui6 auto desc = DescribeSemaphore(name); UNIT_ASSERT_VALUES_EQUAL(desc.Ephemeral, ephemeral); for (ui64 sessionId : sessionIds) { - UNIT_ASSERT_C(desc.Owners.contains(sessionId), "Session " << sessionId << " is not an owner of " << name); + UNIT_ASSERT_C(desc.Owners.contains(sessionId), "Session " << sessionId << " is not an owner of " << name); } for (const auto& kv : desc.Owners) { ui64 sessionId = kv.first; - UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected owner of " << name); + UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected owner of " << name); } } @@ -629,11 +629,11 @@ void TTestContext::VerifySemaphoreWaiters(const TString& name, const THashSet<ui auto desc = DescribeSemaphore(name, true); UNIT_ASSERT_VALUES_EQUAL(desc.Ephemeral, ephemeral); for (ui64 sessionId : sessionIds) { - UNIT_ASSERT_C(desc.Waiters.contains(sessionId), "Session " << sessionId << " is not a waiter of " << name); + UNIT_ASSERT_C(desc.Waiters.contains(sessionId), "Session " << sessionId << " is not a waiter of " << name); } for (const auto& kv : desc.Waiters) { ui64 sessionId = kv.first; - UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected waiter of " << name); + UNIT_ASSERT_C(sessionIds.contains(sessionId), "Session " << sessionId << " is an unexpected waiter of " << name); } } diff --git a/ydb/core/kqp/compile/kqp_mkql_compiler.cpp b/ydb/core/kqp/compile/kqp_mkql_compiler.cpp index 0413044698..978967f320 100644 --- a/ydb/core/kqp/compile/kqp_mkql_compiler.cpp +++ b/ydb/core/kqp/compile/kqp_mkql_compiler.cpp @@ -303,7 +303,7 @@ TIntrusivePtr<IMkqlCallableCompiler> CreateKqlCompiler(const TKqlCompileContext& THashSet<TStringBuf> keySet(tableMeta.KeyColumnNames.begin(), tableMeta.KeyColumnNames.end()); THashSet<TStringBuf> upsertSet; for (const auto& column : upsertRows.Columns()) { - if (keySet.contains(column)) { + if (keySet.contains(column)) { keySet.erase(column); } else { upsertSet.insert(column); diff --git a/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp b/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp index f8e3cd0c77..028af50e39 100644 --- a/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp +++ b/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp @@ -117,7 +117,7 @@ public: SetTaskRunner(taskRunner); auto wakeup = [this]{ ContinueExecute(); }; - PrepareTaskRunner(TKqpTaskRunnerExecutionContext(std::get<ui64>(TxId), RuntimeSettings.UseSpilling, std::move(wakeup), + PrepareTaskRunner(TKqpTaskRunnerExecutionContext(std::get<ui64>(TxId), RuntimeSettings.UseSpilling, std::move(wakeup), TlsActivationContext->AsActorContext())); ComputeCtx.AddTableScan(0, Meta, GetStatsMode()); @@ -830,7 +830,7 @@ private: } ev->Record.SetStatsMode(RuntimeSettings.StatsMode); ev->Record.SetScanId(0); - ev->Record.SetTxId(std::get<ui64>(TxId)); + ev->Record.SetTxId(std::get<ui64>(TxId)); ev->Record.SetTablePath(ScanData->TablePath); ev->Record.SetSchemaVersion(ScanData->TableId.SchemaVersion); diff --git a/ydb/core/kqp/kqp_response.cpp b/ydb/core/kqp/kqp_response.cpp index d3859cd39c..55a0e91363 100644 --- a/ydb/core/kqp/kqp_response.cpp +++ b/ydb/core/kqp/kqp_response.cpp @@ -124,15 +124,15 @@ Ydb::StatusIds::StatusCode GetYdbStatus(const NYql::NCommon::TOperationResult& q CollectYdbStatuses(topIssue, statuses); } - if (statuses.contains(Ydb::StatusIds::UNAUTHORIZED)) { + if (statuses.contains(Ydb::StatusIds::UNAUTHORIZED)) { return Ydb::StatusIds::UNAUTHORIZED; } - if (statuses.contains(Ydb::StatusIds::INTERNAL_ERROR)) { + if (statuses.contains(Ydb::StatusIds::INTERNAL_ERROR)) { return Ydb::StatusIds::INTERNAL_ERROR; } - if (statuses.contains(Ydb::StatusIds::GENERIC_ERROR)) { + if (statuses.contains(Ydb::StatusIds::GENERIC_ERROR)) { return Ydb::StatusIds::GENERIC_ERROR; } diff --git a/ydb/core/kqp/node/kqp_node.cpp b/ydb/core/kqp/node/kqp_node.cpp index 24f8f2ac79..b47bee2c09 100644 --- a/ydb/core/kqp/node/kqp_node.cpp +++ b/ydb/core/kqp/node/kqp_node.cpp @@ -238,7 +238,7 @@ private: resources.MemoryPool = NRm::EKqpMemoryPool::ScanQuery; resources.Memory = memory; - if (rm->AllocateResources(std::get<ui64>(txId), taskId, resources)) { + if (rm->AllocateResources(std::get<ui64>(txId), taskId, resources)) { return true; } diff --git a/ydb/core/kqp/prepare/kqp_query_analyze.cpp b/ydb/core/kqp/prepare/kqp_query_analyze.cpp index b37e4eb058..79db2945fe 100644 --- a/ydb/core/kqp/prepare/kqp_query_analyze.cpp +++ b/ydb/core/kqp/prepare/kqp_query_analyze.cpp @@ -102,7 +102,7 @@ bool IsSafePayloadCallable(const TCallable& callable) { return false; } - return SafeCallables.contains(callable.CallableName()); + return SafeCallables.contains(callable.CallableName()); } bool IsModeratePayloadCallable(TCoNameValueTupleList key, const TCallable& callable) { @@ -114,7 +114,7 @@ bool IsModeratePayloadCallable(TCoNameValueTupleList key, const TCallable& calla return selectRow.Cast().Key().Raw() == key.Raw(); } - return ModerateCallables.contains(callable.CallableName()); + return ModerateCallables.contains(callable.CallableName()); } struct TAnalyzeTxContext { diff --git a/ydb/core/kqp/prepare/kqp_query_rewrite.cpp b/ydb/core/kqp/prepare/kqp_query_rewrite.cpp index cb24a1b8a1..8604970fbb 100644 --- a/ydb/core/kqp/prepare/kqp_query_rewrite.cpp +++ b/ydb/core/kqp/prepare/kqp_query_rewrite.cpp @@ -57,7 +57,7 @@ TExprBase RebuildMapToList(TMapNode map, TExprContext& ctx) { } TExprNode::TPtr NormalizeCallables(TExprBase node, TExprContext& ctx, const TKqpAnalyzeResults& analyzeResults) { - if (!analyzeResults.CallableToExecRootsMap.contains(node.Raw())) { + if (!analyzeResults.CallableToExecRootsMap.contains(node.Raw())) { return node.Ptr(); } @@ -168,7 +168,7 @@ TExprBase SplitMap(TExprBase input, TCoLambda lambda, TExprContext& ctx, const T YQL_ENSURE(node->GetTypeAnn()); bool isComputable = node->IsComputable(); - if (innerNodes.contains(node.Get())) { + if (innerNodes.contains(node.Get())) { if (isComputable) { jointsMap.insert(std::make_pair(node.Get(), TExprBase(node))); } @@ -179,11 +179,11 @@ TExprBase SplitMap(TExprBase input, TCoLambda lambda, TExprContext& ctx, const T bool hasInnerChild = false; if (isComputable && !node->Children().empty() && nodeInfo->IsExecutable) { for (const auto& child : node->Children()) { - if (jointsMap.contains(child.Get())) { + if (jointsMap.contains(child.Get())) { return true; } - bool innerChild = innerNodes.contains(child.Get()); + bool innerChild = innerNodes.contains(child.Get()); hasInnerChild = hasInnerChild | innerChild; YQL_ENSURE(child->GetTypeAnn()); diff --git a/ydb/core/kqp/provider/yql_kikimr_datasink.cpp b/ydb/core/kqp/provider/yql_kikimr_datasink.cpp index 035d6b7701..62bc857e8f 100644 --- a/ydb/core/kqp/provider/yql_kikimr_datasink.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_datasink.cpp @@ -408,8 +408,8 @@ public: return node.Child(1)->Child(0)->Content() == KikimrProviderName; } - if (KikimrDataSinkFunctions().contains(node.Content()) || - KikimrKqlFunctions().contains(node.Content())) + if (KikimrDataSinkFunctions().contains(node.Content()) || + KikimrKqlFunctions().contains(node.Content())) { return true; } @@ -770,7 +770,7 @@ IGraphTransformer::TStatus TKiSinkVisitorTransformer::DoTransform(TExprNode::TPt return HandleEffects(node.Cast(), ctx); } - if (KikimrKqlFunctions().contains(callable.CallableName())) { + if (KikimrKqlFunctions().contains(callable.CallableName())) { return HandleKql(callable, ctx); } diff --git a/ydb/core/kqp/provider/yql_kikimr_datasource.cpp b/ydb/core/kqp/provider/yql_kikimr_datasource.cpp index 65ef7eb932..dce9d4f2a0 100644 --- a/ydb/core/kqp/provider/yql_kikimr_datasource.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_datasource.cpp @@ -387,7 +387,7 @@ public: return TKiDataSource(node.ChildPtr(1)).Category() == KikimrProviderName; } - YQL_ENSURE(!KikimrDataSourceFunctions().contains(node.Content())); + YQL_ENSURE(!KikimrDataSourceFunctions().contains(node.Content())); return false; } diff --git a/ydb/core/kqp/provider/yql_kikimr_exec.cpp b/ydb/core/kqp/provider/yql_kikimr_exec.cpp index ad360fcaeb..7e3edacd15 100644 --- a/ydb/core/kqp/provider/yql_kikimr_exec.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_exec.cpp @@ -262,12 +262,12 @@ public: } auto configure = TCoConfigure(input); - auto clusterName = TString(configure.DataSource().Arg(1).Cast<TCoAtom>().Value()); + auto clusterName = TString(configure.DataSource().Arg(1).Cast<TCoAtom>().Value()); if (configure.Arg(2).Cast<TCoAtom>().Value() == TStringBuf("Attr")) { - auto name = TString(configure.Arg(3).Cast<TCoAtom>().Value()); + auto name = TString(configure.Arg(3).Cast<TCoAtom>().Value()); TMaybe<TString> value; if (configure.Args().Count() == 5) { - value = TString(configure.Arg(4).Cast<TCoAtom>().Value()); + value = TString(configure.Arg(4).Cast<TCoAtom>().Value()); } SessionCtx->Config().Dispatch(clusterName, name, value, NCommon::TSettingDispatcher::EStage::RUNTIME); diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp index e49f84b5e1..f262c4ce19 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp @@ -50,7 +50,7 @@ TKikimrClusterMapping::TKikimrClusterMapping(const TKikimrGatewayConfig& config) auto name = cluster.GetName(); - if (Clusters.contains(name)) { + if (Clusters.contains(name)) { ythrow yexception() << "TKikimrGatewayConfig: Duplicate cluster name: " << name; } @@ -103,7 +103,7 @@ TString TKikimrClusterMapping::GetDefaultClusterName() const { } bool TKikimrClusterMapping::HasCluster(const TString& cluster) const { - return Clusters.contains(cluster); + return Clusters.contains(cluster); } TKikimrPathId TKikimrPathId::Parse(const TStringBuf& str) { diff --git a/ydb/core/kqp/provider/yql_kikimr_opt.cpp b/ydb/core/kqp/provider/yql_kikimr_opt.cpp index cdbb6e600d..18ba0f7c6b 100644 --- a/ydb/core/kqp/provider/yql_kikimr_opt.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_opt.cpp @@ -214,7 +214,7 @@ TExprNode::TPtr KiRedundantSortByPk(TExprBase node, TExprContext& ctx, return false; } - if (passthroughFields && !passthroughFields->contains(column)) { + if (passthroughFields && !passthroughFields->contains(column)) { return false; } @@ -810,7 +810,7 @@ bool IsKqlPureExpr(NNodes::TExprBase expr) { return false; } - if (!KikimrKqlFunctions().contains(node->Content())) { + if (!KikimrKqlFunctions().contains(node->Content())) { return false; } diff --git a/ydb/core/kqp/provider/yql_kikimr_opt_join.cpp b/ydb/core/kqp/provider/yql_kikimr_opt_join.cpp index 662082c543..ff9aea1014 100644 --- a/ydb/core/kqp/provider/yql_kikimr_opt_join.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_opt_join.cpp @@ -4,7 +4,7 @@ #include <ydb/library/yql/core/yql_join.h> #include <ydb/library/yql/core/yql_opt_utils.h> #include <ydb/library/yql/utils/log/log.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NYql { namespace { @@ -215,7 +215,7 @@ bool EquiJoinToIdxLookup(TGetExprFunc getLeftExpr, TCoEquiJoinTuple joinTuple, c YQL_ENSURE(!leftLabelReps.empty()); auto rightLabelReps = GetEquiJoinLabelReps(joinTuple.RightScope()); YQL_ENSURE(rightLabelReps.size() == 1); - YQL_ENSURE(rightLabelReps.contains(joinTuple.RightScope().Cast<TCoAtom>().Value())); + YQL_ENSURE(rightLabelReps.contains(joinTuple.RightScope().Cast<TCoAtom>().Value())); auto joinKeyCount = joinTuple.RightKeys().Size() / 2; @@ -235,7 +235,7 @@ bool EquiJoinToIdxLookup(TGetExprFunc getLeftExpr, TCoEquiJoinTuple joinTuple, c auto joinRightLabel = joinTuple.RightKeys().Item(i * 2); auto joinRightColumn = joinTuple.RightKeys().Item(i * 2 + 1); - if (!rightLabelReps.contains(joinRightLabel) || !leftLabelReps.contains(joinLeftLabel)) { + if (!rightLabelReps.contains(joinRightLabel) || !leftLabelReps.contains(joinLeftLabel)) { // Join already rewritten, skip opt return false; } @@ -253,7 +253,7 @@ bool EquiJoinToIdxLookup(TGetExprFunc getLeftExpr, TCoEquiJoinTuple joinTuple, c return false; } - if (rightKeyColumnsSet.contains(rightColumnName)) { + if (rightKeyColumnsSet.contains(rightColumnName)) { // Can't lookup same column twice return false; } @@ -740,7 +740,7 @@ TExprBase GetEquiJoinTreeExpr(const TExprBase& joinScope, const TVector<TCoEquiJ auto index = joinLabels.FindInputIndex(label); YQL_ENSURE(index); - if (!usedIndices.contains(*index)) { + if (!usedIndices.contains(*index)) { newJoinInputs.push_back(joinInputs[*index]); usedIndices.insert(*index); } diff --git a/ydb/core/kqp/provider/yql_kikimr_opt_range.cpp b/ydb/core/kqp/provider/yql_kikimr_opt_range.cpp index cce81efc42..0e808f72d4 100644 --- a/ydb/core/kqp/provider/yql_kikimr_opt_range.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_opt_range.cpp @@ -149,7 +149,7 @@ TMaybeNode<TExprBase> KiTableLookupGetValue(TExprBase node, const TTypeAnnotatio } if (auto maybeArg = node.Maybe<TCoArgument>()) { - if (!knownArgs.contains(maybeArg.Cast().Raw())) { + if (!knownArgs.contains(maybeArg.Cast().Raw())) { canPush = false; return false; } @@ -158,7 +158,7 @@ TMaybeNode<TExprBase> KiTableLookupGetValue(TExprBase node, const TTypeAnnotatio if (auto maybeCallable = node.Maybe<TCallable>()) { auto callable = maybeCallable.Cast(); - if (KikimrKqlFunctions().contains(callable.CallableName())) { + if (KikimrKqlFunctions().contains(callable.CallableName())) { if (callable.Maybe<TKiSelectRow>()) { return true; } diff --git a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp index 692165204a..a71e8370d1 100644 --- a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp @@ -1140,7 +1140,7 @@ private: if (settings.Mode) { auto mode = settings.Mode.Cast().Value(); - if (!KikimrCommitModes().contains(mode)) { + if (!KikimrCommitModes().contains(mode)) { ctx.AddError(TIssue(ctx.GetPosition(node.Pos()), TStringBuilder() << "Unsupported Kikimr commit mode: " << mode)); return TStatus::Error; diff --git a/ydb/core/kqp/proxy/kqp_proxy_service.cpp b/ydb/core/kqp/proxy/kqp_proxy_service.cpp index decd2cb301..d88ae62d3d 100644 --- a/ydb/core/kqp/proxy/kqp_proxy_service.cpp +++ b/ydb/core/kqp/proxy/kqp_proxy_service.cpp @@ -1116,7 +1116,7 @@ private: /* * TODO: disabled due to SLYDB-42. Remove (or rework) it after KIKIMR-9650 & KIKIMR-9652 - if (!Tenants.contains(database)) { + if (!Tenants.contains(database)) { TString error = TStringBuilder() << "Unexpected node for database: " << database; LOG_ERROR_S(ctx, NKikimrServices::KQP_PROXY, requestInfo << error diff --git a/ydb/core/kqp/rm/kqp_rm_ut.cpp b/ydb/core/kqp/rm/kqp_rm_ut.cpp index 3ea0e1beb5..99df3783c9 100644 --- a/ydb/core/kqp/rm/kqp_rm_ut.cpp +++ b/ydb/core/kqp/rm/kqp_rm_ut.cpp @@ -100,7 +100,7 @@ NKikimrConfig::TTableServiceConfig::TResourceManager MakeKqpResourceManagerConfi class KqpRm : public TTestBase { public: void SetUp() override { - Runtime = MakeHolder<TTenantTestRuntime>(MakeTenantTestConfig()); + Runtime = MakeHolder<TTenantTestRuntime>(MakeTenantTestConfig()); NActors::NLog::EPriority priority = DETAILED_LOG ? NLog::PRI_DEBUG : NLog::PRI_ERROR; Runtime->SetLogPriority(NKikimrServices::RESOURCE_BROKER, priority); diff --git a/ydb/core/metering/metering.cpp b/ydb/core/metering/metering.cpp index 598de38692..7a1378fd5a 100644 --- a/ydb/core/metering/metering.cpp +++ b/ydb/core/metering/metering.cpp @@ -112,7 +112,7 @@ void TMeteringWriteActor::HandleUnexpectedEvent(STFUNC_SIG) //////////////////////////////////////////////////////////////////////////////// THolder<NActors::IActor> CreateMeteringWriter(THolder<TLogBackend> meteringFile) { - return MakeHolder<TMeteringWriteActor>(std::move(meteringFile)); + return MakeHolder<TMeteringWriteActor>(std::move(meteringFile)); } diff --git a/ydb/core/mind/dynamic_nameserver.cpp b/ydb/core/mind/dynamic_nameserver.cpp index 6f4f147982..b5eb832bd5 100644 --- a/ydb/core/mind/dynamic_nameserver.cpp +++ b/ydb/core/mind/dynamic_nameserver.cpp @@ -20,7 +20,7 @@ void TDynamicNodeResolverBase::Bootstrap(const TActorContext &ctx) auto dinfo = AppData(ctx)->DomainsInfo; auto domain = NodeIdToDomain(NodeId, *dinfo); - if (!dinfo->Domains.contains(domain)) { + if (!dinfo->Domains.contains(domain)) { ReplyWithErrorAndDie(ctx); return; } @@ -291,7 +291,7 @@ void TDynamicNameserver::UpdateState(const NKikimrNodeBroker::TNodesInfo &rec, } else { for (auto &node : rec.GetNodes()) { auto nodeId = node.GetNodeId(); - if (!config->DynamicNodes.contains(nodeId)) + if (!config->DynamicNodes.contains(nodeId)) config->DynamicNodes.emplace(nodeId, node); } config->Epoch = rec.GetEpoch(); @@ -304,7 +304,7 @@ void TDynamicNameserver::OnPipeDestroyed(ui32 domain, NodeBrokerPipes[domain] = TActorId(); PendingRequestAnswered(domain, ctx); - if (EpochUpdates.contains(domain)) { + if (EpochUpdates.contains(domain)) { ctx.Schedule(TDuration::Seconds(1), new TEvPrivate::TEvUpdateEpoch(domain, EpochUpdates.at(domain))); EpochUpdates.erase(domain); @@ -374,7 +374,7 @@ void TDynamicNameserver::Handle(TEvInterconnect::TEvGetNode::TPtr &ev, const TAc it->second.Host, it->second.ResolveHost, it->second.Port, it->second.Location); ctx.Send(ev->Sender, reply.Release()); - } else if (DynamicConfigs[domain]->ExpiredNodes.contains(nodeId) + } else if (DynamicConfigs[domain]->ExpiredNodes.contains(nodeId) && ctx.Now() < DynamicConfigs[domain]->Epoch.End) { ctx.Send(ev->Sender, reply.Release()); } else { @@ -412,7 +412,7 @@ void TDynamicNameserver::Handle(TEvNodeBroker::TEvNodesInfo::TPtr &ev, const TAc if (rec.GetEpoch().GetVersion() != DynamicConfigs[domain]->Epoch.Version) UpdateState(rec, ctx); - if (EpochUpdates.contains(domain) && EpochUpdates.at(domain) <= rec.GetEpoch().GetId()) + if (EpochUpdates.contains(domain) && EpochUpdates.at(domain) <= rec.GetEpoch().GetId()) EpochUpdates.erase(domain); PendingRequestAnswered(rec.GetDomain(), ctx); @@ -424,7 +424,7 @@ void TDynamicNameserver::Handle(TEvPrivate::TEvUpdateEpoch::TPtr &ev, const TAct ui64 epoch = ev->Get()->Epoch; if (DynamicConfigs[domain]->Epoch.Id < epoch - && (!EpochUpdates.contains(domain) + && (!EpochUpdates.contains(domain) || EpochUpdates.at(domain) < epoch)) RequestEpochUpdate(domain, epoch, ctx); } diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index 0383d49a12..b35581ed6f 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -270,7 +270,7 @@ namespace { for (ui32 nodeIndex = 0; nodeIndex < runtime.GetNodeCount(); ++nodeIndex) { auto it = NodeWardenConfigs.find(nodeIndex); if (it != NodeWardenConfigs.end()) { - runtime.GetAppData(nodeIndex).StaticBlobStorageConfig = MakeHolder<NKikimrBlobStorage::TNodeWardenServiceSet>(it->second->ServiceSet); + runtime.GetAppData(nodeIndex).StaticBlobStorageConfig = MakeHolder<NKikimrBlobStorage::TNodeWardenServiceSet>(it->second->ServiceSet); } } @@ -802,7 +802,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); MakeSureTabletIsUp(runtime, hiveTablet, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -814,7 +814,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); MakeSureTabletIsUp(runtime, hiveTablet, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); THolder<TEvHive::TEvDeleteOwnerTablets> deleteOwner = MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 1); TActorId senderB = runtime.AllocateEdgeActor(0); @@ -958,7 +958,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -977,7 +977,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createTablet->Record.AddAllowedDomains(); createTablet->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createTablet->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 tabletId = SendCreateTestTablet(runtime, subHiveTablet, testerTablet, std::move(createTablet), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, subHiveTablet, testerTablet, std::move(createTablet), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); // dummy from sub hive also good runtime.SetObserverFunc(prevObserverFunc); } @@ -1020,7 +1020,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -1039,18 +1039,18 @@ Y_UNIT_TEST_SUITE(THiveTest) { createTablet1->Record.AddAllowedDomains(); createTablet1->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createTablet1->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); + ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); MakeSureTabletIsUp(runtime, tabletId1, 0); THolder<TEvHive::TEvCreateTablet> createTablet2 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 2, TTabletTypes::Dummy, BINDED_CHANNELS); createTablet2->Record.AddAllowedDomains(); createTablet2->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createTablet2->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 tabletId2 = SendCreateTestTablet(runtime, subHiveTablet, testerTablet, std::move(createTablet2), 0, true); + ui64 tabletId2 = SendCreateTestTablet(runtime, subHiveTablet, testerTablet, std::move(createTablet2), 0, true); MakeSureTabletIsUp(runtime, tabletId2, 0); // dummy from sub hive also good // retry create request to sub domain hive - createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); + createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); createTablet1->Record.SetTabletID(tabletId1); runtime.SendToPipe(subHiveTablet, sender, createTablet1.Release(), 0, GetPipeConfigWithRetries()); @@ -1071,7 +1071,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_VALUES_EQUAL(deleteTabletReply->Record.GetForwardRequest().GetHiveTabletId(), hiveTablet); // retry create request to root hive - createTablet2 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 2, TTabletTypes::Dummy, BINDED_CHANNELS); + createTablet2 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 2, TTabletTypes::Dummy, BINDED_CHANNELS); createTablet2->Record.SetTabletID(tabletId2); runtime.SendToPipe(hiveTablet, sender, createTablet2.Release(), 0, GetPipeConfigWithRetries()); @@ -1132,7 +1132,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -1161,7 +1161,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createTablet1->Record.AddAllowedDomains(); createTablet1->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createTablet1->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); + ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); MakeSureTabletIsUp(runtime, tabletId1, 0); // tablet up in root hive @@ -1192,7 +1192,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId1, 0); // tablet up in sub hive // retry create request to sub domain hive - createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); + createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); createTablet1->Record.SetTabletID(tabletId1); runtime.SendToPipe(hiveTablet, sender, createTablet1.Release(), 0, GetPipeConfigWithRetries()); @@ -1243,7 +1243,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -1277,7 +1277,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createTablet1->Record.AddAllowedDomains(); createTablet1->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createTablet1->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); + ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); MakeSureTabletIsUp(runtime, tabletId1, 0); // tablet up in root hive tabletIds.push_back(tabletId1); } @@ -1310,7 +1310,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletIds[i], 0); // tablet up in sub hive // retry create request to sub domain hive - THolder<TEvHive::TEvCreateTablet> createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, i + 1, TTabletTypes::Dummy, BINDED_CHANNELS); + THolder<TEvHive::TEvCreateTablet> createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, i + 1, TTabletTypes::Dummy, BINDED_CHANNELS); createTablet1->Record.SetTabletID(tabletIds[i]); runtime.SendToPipe(hiveTablet, sender, createTablet1.Release(), 0, GetPipeConfigWithRetries()); @@ -1361,7 +1361,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -1454,7 +1454,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -1555,7 +1555,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createHive->Record.AddAllowedDomains(); createHive->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createHive->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); + ui64 subHiveTablet = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createHive), 0, false); TTestActorRuntime::TEventObserver prevObserverFunc; prevObserverFunc = runtime.SetObserverFunc([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -1586,7 +1586,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { createTablet1->Record.AddAllowedDomains(); createTablet1->Record.MutableAllowedDomains(0)->SetSchemeShard(subdomainKey.first); createTablet1->Record.MutableAllowedDomains(0)->SetPathId(subdomainKey.second); - ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); + ui64 tabletId1 = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(createTablet1), 0, true); MakeSureTabletIsUp(runtime, tabletId1, 0); // tablet up in root hive @@ -1625,7 +1625,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId1, 0); // tablet up in sub hive // retry create request to sub domain hive - createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); + createTablet1 = MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 1, TTabletTypes::Dummy, BINDED_CHANNELS); createTablet1->Record.SetTabletID(tabletId1); runtime.SendToPipe(hiveTablet, sender, createTablet1.Release(), 0, GetPipeConfigWithRetries()); @@ -1703,7 +1703,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); MakeSureTabletIsUp(runtime, tabletId, 0); - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -1739,7 +1739,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } MakeSureTabletIsUp(runtime, tabletId, 0); - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -1793,7 +1793,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* msg = ev->Get<TEvTablet::TEvCommit>(); if (msg->TabletID == hiveTablet) { Ctest << "blocked commit for tablet " << msg->TabletID << Endl; - blockedCommits.push_back(std::move(ev)); + blockedCommits.push_back(std::move(ev)); return TTestActorRuntime::EEventAction::DROP; } } @@ -1890,14 +1890,14 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 testerTablet = MakeDefaultHiveID(1); CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; - const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); + const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvBootTablet); runtime.DispatchEvents(options); } - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -1917,14 +1917,14 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 testerTablet = MakeDefaultHiveID(1); CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; - const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); + const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvBootTablet); runtime.DispatchEvents(options); } - if (!SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 123))) { + if (!SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 123))) { WaitEvDeleteTabletResult(runtime); } @@ -1935,7 +1935,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_VALUES_UNEQUAL(tablet.GetTabletID(), tabletId); } - SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 124), 0, NKikimrProto::ALREADY); + SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 124), 0, NKikimrProto::ALREADY); } Y_UNIT_TEST(TestDeleteOwnerTabletsMany) { @@ -1949,11 +1949,11 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 count = 100; TSet<ui64> tabletIds; for (ui64 i = 0; i < count; ++i) { - const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, i, tabletType, BINDED_CHANNELS), 0, false); + const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, i, tabletType, BINDED_CHANNELS), 0, false); tabletIds.insert(tabletId); } - SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 123)); + SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 123)); runtime.SendToPipe(hiveTablet, sender, new TEvHive::TEvRequestHiveInfo(true)); TAutoPtr<IEventHandle> handle; @@ -1962,7 +1962,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT(!tabletIds.contains(tablet.GetTabletID())); } - SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 124), 0, NKikimrProto::ALREADY); + SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 124), 0, NKikimrProto::ALREADY); } Y_UNIT_TEST(TestDeleteTabletWithFollowers) { @@ -1976,7 +1976,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* followerGroup = ev->Record.AddFollowerGroups(); followerGroup->SetFollowerCount(2); followerGroup->SetRequireDifferentNodes(true); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); @@ -1987,7 +1987,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 1, &pipeConfig); MakeSureTabletIsUp(runtime, tabletId, 2, &pipeConfig); - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 100500, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 100500, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -2007,9 +2007,9 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 testerTablet = 1; CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; - const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); + const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } MakeSureTabletIsDown(runtime, tabletId, 0); @@ -2116,7 +2116,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui32 nodeIndex = 0; SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), nodeIndex, true); + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), nodeIndex, true); { runtime.SendToPipe(hiveTablet, sender, new TEvHive::TEvCreateTablet(testerTablet, 0, TTabletTypes::TxAllocator, BINDED_CHANNELS), nodeIndex, GetPipeConfigWithRetries()); @@ -2196,7 +2196,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { ui32 nodeIndex = 0; TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 100500, tabletType, BINDED_CHANNELS), nodeIndex, true); + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 100500, tabletType, BINDED_CHANNELS), nodeIndex, true); MakeSureTabletIsUp(runtime, tabletId, nodeIndex); SendKillLocal(runtime, nodeIndex); WaitForEvServerDisconnected(runtime); @@ -2217,7 +2217,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetFollowerCount(1); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); @@ -2252,7 +2252,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // Create the tablet TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 100500, tabletType, BINDED_CHANNELS), 0, true); + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 100500, tabletType, BINDED_CHANNELS), 0, true); // Make sure the tablet is OK WaitForTabletIsUp(runtime, tabletId, 0); // Re-create the local on node 1 @@ -2278,7 +2278,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { ui32 nodeIndex = 0; TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 100500, tabletType, BINDED_CHANNELS), nodeIndex, true); + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 100500, tabletType, BINDED_CHANNELS), nodeIndex, true); MakeSureTabletIsUp(runtime, tabletId, nodeIndex); TActorId senderA = runtime.AllocateEdgeActor(); @@ -2331,7 +2331,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.AddAllowedNodeIDs(runtime.GetNodeId(1)); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); // Make sure the tablet is down MakeSureTabletIsDown(runtime, tabletId, 0); // Re-create the local on node 1 @@ -2349,7 +2349,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); SendReassignTablet(runtime, hiveTablet, tabletId, {}, 0); MakeSureTabletIsUp(runtime, tabletId, 0); @@ -2366,7 +2366,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TChannelsBindings channlesBinds = {GetDefaultChannelBind("NoExistStoragePool"), GetDefaultChannelBind("NoExistStoragePool")}; auto ev = new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, channlesBinds); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, THolder(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, THolder(ev), 0, false); MakeSureTabletIsDown(runtime, tabletId, 0); @@ -2378,7 +2378,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { runtime.DispatchEvents(options); }*/ - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -2394,7 +2394,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); SendReassignTablet(runtime, hiveTablet, tabletId, {}, 0); SendReassignTablet(runtime, hiveTablet, tabletId, {}, 0); @@ -2453,7 +2453,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); @@ -2477,7 +2477,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, - MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), + MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true, NKikimrProto::ALREADY); @@ -2674,7 +2674,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* followerGroup = ev->Record.AddFollowerGroups(); followerGroup->SetFollowerCount(2); followerGroup->SetRequireDifferentNodes(true); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); @@ -2701,7 +2701,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* followerGroup = ev->Record.AddFollowerGroups(); followerGroup->SetFollowerCount(2); followerGroup->SetRequireDifferentNodes(true); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); @@ -2753,7 +2753,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { followerGroup->SetFollowerCount(2); followerGroup->SetAllowLeaderPromotion(true); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); @@ -2823,7 +2823,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* followerGroup = ev->Record.AddFollowerGroups(); followerGroup->SetFollowerCount(3); followerGroup->SetAllowLeaderPromotion(true); - SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvTabletStatus, 4); @@ -2855,7 +2855,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); SendKillLocal(runtime, 0); CreateLocal(runtime, 0); { @@ -2904,7 +2904,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(i); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -2979,7 +2979,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 200500 + i, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(NUM_TABLETS + i); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); } @@ -3041,7 +3041,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { ev->Record.SetFollowerCount(3); ev->Record.MutableDataCentersPreference()->AddDataCentersGroups()->AddDataCenter(ToString(1)); ev->Record.MutableDataCentersPreference()->AddDataCentersGroups()->AddDataCenter(ToString(2)); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -3107,7 +3107,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* group = ev->Record.MutableDataCentersPreference()->AddDataCentersGroups(); group->AddDataCenter(ToString(1)); group->AddDataCenter(ToString(2)); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -3169,7 +3169,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tablets; for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -3212,7 +3212,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(1); ev->Record.SetFollowerCount(3); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -3349,7 +3349,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(i); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } @@ -3389,7 +3389,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetAllowFollowerPromotion(false); ev->Record.SetFollowerCount(2); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, 3); @@ -3451,7 +3451,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetCrossDataCenterFollowerCount(2); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, 7); @@ -3506,7 +3506,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { followerGroup->SetFollowerCount(1); followerGroup->SetLocalNodeOnly(true); followerGroup->SetAllowClientRead(true); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, 2); @@ -3603,7 +3603,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, NODES + 1); @@ -3656,7 +3656,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); //WaitForTabletsBecomeActive(runtime, 3 * 3 + 1); @@ -3759,7 +3759,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(1337); ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, FOLLOWERS * DCS + 1); @@ -3931,7 +3931,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } // Delete tablet while info request is pending - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -4099,7 +4099,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsDown(runtime, tabletId, 0); // Delete tablet while it is locked - if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { + if (!SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0))) { WaitEvDeleteTabletResult(runtime); } @@ -4143,7 +4143,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { }); // Delete tablet while it is locked - SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0)); + SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0)); // Reboot hive while tablet deletion is still delayed. RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); @@ -4368,7 +4368,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TAutoPtr<TEvHive::TEvCreateTablet> ev = new TEvHive::TEvCreateTablet(testerTablet, 0, TTabletTypes::Dummy, BINDED_CHANNELS); ev->Record.SetTabletBootMode(NKikimrHive::ETabletBootMode::TABLET_BOOT_MODE_EXTERNAL); - ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); TActorId owner1 = runtime.AllocateEdgeActor(0); runtime.SendToPipe(hiveTablet, owner1, new TEvHive::TEvInitiateTabletExternalBoot(tabletId), 0, GetPipeConfigWithRetries()); diff --git a/ydb/core/mind/hive/monitoring.cpp b/ydb/core/mind/hive/monitoring.cpp index 7e9a83b354..3499f91654 100644 --- a/ydb/core/mind/hive/monitoring.cpp +++ b/ydb/core/mind/hive/monitoring.cpp @@ -732,7 +732,7 @@ public: Self->BuildCurrentConfig(); db.Table<Schema::State>().Key(TSchemeIds::State::DefaultState).Update<Schema::State::Config>(Self->DatabaseConfig); } - if (params.contains("allowedMetrics")) { + if (params.contains("allowedMetrics")) { TVector<TString> allowedMetrics = SplitString(params.Get("allowedMetrics"), ";"); for (TStringBuf tabletAllowedMetrics : allowedMetrics) { TStringBuf tabletType = tabletAllowedMetrics.NextTok(':'); diff --git a/ydb/core/mind/hive/tx__release_tablets.cpp b/ydb/core/mind/hive/tx__release_tablets.cpp index cdfd82ce06..a327be9297 100644 --- a/ydb/core/mind/hive/tx__release_tablets.cpp +++ b/ydb/core/mind/hive/tx__release_tablets.cpp @@ -6,7 +6,7 @@ namespace NHive { class TTxReleaseTablets : public TTransactionBase<THive> { THolder<TEvHive::TEvReleaseTablets::THandle> Request; - THolder<TEvHive::TEvReleaseTabletsReply> Response = MakeHolder<TEvHive::TEvReleaseTabletsReply>(); + THolder<TEvHive::TEvReleaseTabletsReply> Response = MakeHolder<TEvHive::TEvReleaseTabletsReply>(); TVector<std::pair<TTabletId, TActorId>> UnlockedFromActor; bool NeedToProcessPendingOperations = false; @@ -90,7 +90,7 @@ public: }; ITransaction* THive::CreateReleaseTablets(TEvHive::TEvReleaseTablets::TPtr event) { - return new TTxReleaseTablets(THolder(std::move(event.Release())), this); + return new TTxReleaseTablets(THolder(std::move(event.Release())), this); } } // NHive diff --git a/ydb/core/mind/hive/tx__seize_tablets.cpp b/ydb/core/mind/hive/tx__seize_tablets.cpp index 09a93c9656..f66c161392 100644 --- a/ydb/core/mind/hive/tx__seize_tablets.cpp +++ b/ydb/core/mind/hive/tx__seize_tablets.cpp @@ -6,7 +6,7 @@ namespace NHive { class TTxSeizeTablets : public TTransactionBase<THive> { THolder<TEvHive::TEvSeizeTablets::THandle> Request; - THolder<TEvHive::TEvSeizeTabletsReply> Response = MakeHolder<TEvHive::TEvSeizeTabletsReply>(); + THolder<TEvHive::TEvSeizeTabletsReply> Response = MakeHolder<TEvHive::TEvSeizeTabletsReply>(); public: TTxSeizeTablets(THolder<TEvHive::TEvSeizeTablets::THandle> event, THive *hive) @@ -157,7 +157,7 @@ public: }; ITransaction* THive::CreateSeizeTablets(TEvHive::TEvSeizeTablets::TPtr event) { - return new TTxSeizeTablets(THolder(std::move(event.Release())), this); + return new TTxSeizeTablets(THolder(std::move(event.Release())), this); } } // NHive diff --git a/ydb/core/mind/hive/tx__seize_tablets_reply.cpp b/ydb/core/mind/hive/tx__seize_tablets_reply.cpp index 6e6db7131b..e349c913a5 100644 --- a/ydb/core/mind/hive/tx__seize_tablets_reply.cpp +++ b/ydb/core/mind/hive/tx__seize_tablets_reply.cpp @@ -167,7 +167,7 @@ public: }; ITransaction* THive::CreateSeizeTabletsReply(TEvHive::TEvSeizeTabletsReply::TPtr event) { - return new TTxSeizeTabletsReply(THolder(std::move(event.Release())), this); + return new TTxSeizeTabletsReply(THolder(std::move(event.Release())), this); } } // NHive diff --git a/ydb/core/mind/local.cpp b/ydb/core/mind/local.cpp index 09fc15f76d..3492aab5cd 100644 --- a/ydb/core/mind/local.cpp +++ b/ydb/core/mind/local.cpp @@ -1063,7 +1063,7 @@ class TDomainLocal : public TActorBootstrapped<TDomainLocal> { void RegisterAsDomain(const TRegistrationInfo &info, const TActorContext &ctx) { - Y_VERIFY(!RunningTenants.contains(info.TenantName)); + Y_VERIFY(!RunningTenants.contains(info.TenantName)); const auto domainKey = TSubDomainKey(SchemeRoot, 1); RunningTenants.emplace(std::make_pair(info.TenantName, TTenantInfo(info, domainKey))); for (auto id : HiveIds) { @@ -1084,7 +1084,7 @@ class TDomainLocal : public TActorBootstrapped<TDomainLocal> { const auto &domainDesc = rec.GetPathDescription().GetDomainDescription(); const auto domainKey = TSubDomainKey(domainDesc.GetDomainKey()); - Y_VERIFY(!RunningTenants.contains(task.Info.TenantName)); + Y_VERIFY(!RunningTenants.contains(task.Info.TenantName)); TTenantInfo info(task.Info, domainKey); for (auto &attr : rec.GetPathDescription().GetUserAttributes()) info.Attributes.emplace(std::make_pair(attr.GetKey(), attr.GetValue())); @@ -1160,7 +1160,7 @@ class TDomainLocal : public TActorBootstrapped<TDomainLocal> { LogPrefix << "HandleResolve from schemeshard " << SchemeRoot << ": " << rec.ShortDebugString()); - if (!ResolveTasks.contains(rec.GetPath())) { + if (!ResolveTasks.contains(rec.GetPath())) { LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, LogPrefix << "Missing task for " << rec.GetPath()); return; @@ -1265,7 +1265,7 @@ class TDomainLocal : public TActorBootstrapped<TDomainLocal> { auto &info = ev->Get()->TenantInfo; // Already started? - if (RunningTenants.contains(info.TenantName)) { + if (RunningTenants.contains(info.TenantName)) { SendStatus(info.TenantName, ev->Sender, ctx); return; } @@ -1296,7 +1296,7 @@ class TDomainLocal : public TActorBootstrapped<TDomainLocal> { // In-fly? auto it = ResolveTasks.find(tenant); if (it != ResolveTasks.end()) { - Y_VERIFY(!RunningTenants.contains(tenant)); + Y_VERIFY(!RunningTenants.contains(tenant)); SendStatus(tenant, it->second.Senders, ctx); ResolveTasks.erase(it); } else { @@ -1427,7 +1427,7 @@ public: return false; } - if (!DomainLocals.contains(domainName)) { + if (!DomainLocals.contains(domainName)) { auto actor = new TDomainLocal(domainsInfo, *domain, Config); DomainLocals[domainName] = ctx.Register(actor); } diff --git a/ydb/core/mind/node_broker__extend_lease.cpp b/ydb/core/mind/node_broker__extend_lease.cpp index 1117664266..af481bb68f 100644 --- a/ydb/core/mind/node_broker__extend_lease.cpp +++ b/ydb/core/mind/node_broker__extend_lease.cpp @@ -45,7 +45,7 @@ public: auto it = Self->Nodes.find(nodeId); if (it == Self->Nodes.end()) { - if (Self->ExpiredNodes.contains(nodeId)) + if (Self->ExpiredNodes.contains(nodeId)) return Error(TStatus::WRONG_REQUEST, "Node has expired", ctx); else return Error(TStatus::WRONG_REQUEST, "Unknown node", ctx); diff --git a/ydb/core/mind/node_broker_ut.cpp b/ydb/core/mind/node_broker_ut.cpp index 0d9498ddcd..a5bc0a9e3b 100644 --- a/ydb/core/mind/node_broker_ut.cpp +++ b/ydb/core/mind/node_broker_ut.cpp @@ -341,12 +341,12 @@ void CheckNodesListResponse(const NKikimrNodeBroker::TNodesInfo &rec, { UNIT_ASSERT_VALUES_EQUAL(rec.NodesSize(), ids.size()); for (auto &node : rec.GetNodes()) { - UNIT_ASSERT(ids.contains(node.GetNodeId())); + UNIT_ASSERT(ids.contains(node.GetNodeId())); ids.erase(node.GetNodeId()); } UNIT_ASSERT_VALUES_EQUAL(rec.ExpiredNodesSize(), expiredIds.size()); for (auto &node : rec.GetExpiredNodes()) { - UNIT_ASSERT(expiredIds.contains(node.GetNodeId())); + UNIT_ASSERT(expiredIds.contains(node.GetNodeId())); expiredIds.erase(node.GetNodeId()); } } @@ -836,7 +836,7 @@ Y_UNIT_TEST_SUITE(TNodeBrokerTest) { TString host = hosts[no]; TStatus::ECode code = TStatus::OK; ui64 nodeId = 0; - if (state.contains(host)) { + if (state.contains(host)) { nodeId = state[host].NodeId; if (state[host].PingEpoch != epoch.GetId()) { //epoch.SetVersion(epoch.GetVersion() + 1); @@ -891,7 +891,7 @@ Y_UNIT_TEST_SUITE(TNodeBrokerTest) { TStatus::ECode code = TStatus::OK; ui64 nodeId = 0; - if (state.contains(host)) { + if (state.contains(host)) { nodeId = state[host].NodeId; if (state[host].PingEpoch == epoch.GetId()) { // no modifications @@ -920,7 +920,7 @@ Y_UNIT_TEST_SUITE(TNodeBrokerTest) { ui64 nodeId = 0; ui64 expire = 0; - if (state.contains(host)) { + if (state.contains(host)) { nodeId = state[host].NodeId; if (state[host].PingEpoch == epoch.GetId()) expire = epoch.GetNextEnd(); diff --git a/ydb/core/mind/tenant_pool.cpp b/ydb/core/mind/tenant_pool.cpp index 80236570b9..a46691385f 100644 --- a/ydb/core/mind/tenant_pool.cpp +++ b/ydb/core/mind/tenant_pool.cpp @@ -311,7 +311,7 @@ public: const TString &label, const TActorContext &ctx) { Y_VERIFY(!slot->AssignedTenant); - Y_VERIFY(!tenant->AssignedSlots.contains(slot)); + Y_VERIFY(!tenant->AssignedSlots.contains(slot)); slot->AssignedTenant = tenant; slot->Label = label; tenant->AssignedSlots.insert(slot); @@ -324,7 +324,7 @@ public: void DetachSlot(TDynamicSlotInfo::TPtr slot, const TActorContext &ctx) { Y_VERIFY(slot->AssignedTenant); - Y_VERIFY(slot->AssignedTenant->AssignedSlots.contains(slot)); + Y_VERIFY(slot->AssignedTenant->AssignedSlots.contains(slot)); LOG_NOTICE_S(ctx, NKikimrServices::TENANT_POOL, LogPrefix << "detach tenant " << slot->AssignedTenant->Name @@ -642,7 +642,7 @@ public: return; } - if (!DynamicSlots.contains(rec.GetSlotId())) { + if (!DynamicSlots.contains(rec.GetSlotId())) { LOG_DEBUG_S(ctx, NKikimrServices::TENANT_POOL, LogPrefix << "got configure for unknown slot " << rec.GetSlotId()); SendConfigureError(ev, rec.GetSlotId(), NKikimrTenantPool::UNKNOWN_SLOT, @@ -834,7 +834,7 @@ public: NMon::IEvHttpInfoRes::EContentType::Html)); } else if (msg->Request.GetPathInfo().StartsWith(DomainPrefix)) { TString domain{msg->Request.GetPathInfo().substr(DomainPrefix.size())}; - if (!DomainTenantPools.contains(domain)) { + if (!DomainTenantPools.contains(domain)) { ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes("Unknown domain " + domain, 0, NMon::IEvHttpInfoRes::EContentType::Html)); } else { @@ -893,7 +893,7 @@ public: for (auto &pr : Config->StaticSlots) { TString domain = TString(ExtractDomain(pr.second.GetTenantName())); Y_VERIFY(domain, "cannot extract domain from tenant name"); - if (!domainConfigs.contains(domain)) + if (!domainConfigs.contains(domain)) domainConfigs[domain] = CreateDomainConfig(); domainConfigs[domain]->AddStaticSlot(pr.second); } @@ -902,7 +902,7 @@ public: TString domain = pr.second.GetDomainName(); Y_VERIFY(domain, "empty domain for dynamic slot"); Y_VERIFY(pr.second.GetType(), "empty type for dynamic slot"); - if (!domainConfigs.contains(domain)) + if (!domainConfigs.contains(domain)) domainConfigs[domain] = CreateDomainConfig(); domainConfigs[domain]->AddDynamicSlot(pr.second); } @@ -974,7 +974,7 @@ void TTenantPoolConfig::AddStaticSlot(const NKikimrTenantPool::TSlotConfig &slot { TString name = CanonizePath(slot.GetTenantName()); Y_VERIFY(IsEnabled); - Y_VERIFY(!StaticSlots.contains(name), + Y_VERIFY(!StaticSlots.contains(name), "two static slots for the same tenant '%s'", name.data()); StaticSlots[name] = slot; StaticSlots[name].SetTenantName(name); @@ -993,7 +993,7 @@ void TTenantPoolConfig::AddStaticSlot(const TString &tenant, void TTenantPoolConfig::AddDynamicSlot(const NKikimrTenantPool::TSlotConfig &slot) { Y_VERIFY(IsEnabled); - Y_VERIFY(!DynamicSlots.contains(slot.GetId()), + Y_VERIFY(!DynamicSlots.contains(slot.GetId()), "two dynamic slots with the same id '%s'", slot.GetId().data()); DynamicSlots[slot.GetId()] = slot; DynamicSlots[slot.GetId()].SetTenantName(CanonizePath(slot.GetTenantName())); diff --git a/ydb/core/mind/tenant_slot_broker.cpp b/ydb/core/mind/tenant_slot_broker.cpp index 65f7a86328..901d6d5469 100644 --- a/ydb/core/mind/tenant_slot_broker.cpp +++ b/ydb/core/mind/tenant_slot_broker.cpp @@ -56,7 +56,7 @@ const TSlotDescription TTenantSlotBroker::TTenant::PinnedSlotDescription = {PIN_ void TTenantSlotBroker::TTenant::AddSlotsAllocation(const TSlotDescription &descr, ui64 count) { - Y_VERIFY(!Allocations.contains(descr)); + Y_VERIFY(!Allocations.contains(descr)); TSlotsAllocation::TPtr allocation = new TSlotsAllocation(descr, Stats); Allocations[descr] = allocation; if (descr.CollocationGroup @@ -73,7 +73,7 @@ void TTenantSlotBroker::TTenant::AddSlotsAllocation(const TSlotDescription &desc TTenantSlotBroker::TSlotsAllocation::TPtr TTenantSlotBroker::TTenant::GetOrCreateAllocation(const TSlotDescription &descr) { - if (!Allocations.contains(descr)) + if (!Allocations.contains(descr)) AddSlotsAllocation(descr, 0); return Allocations.at(descr); } @@ -151,7 +151,7 @@ void TTenantSlotBroker::TTenant::AddSlotLabels(ui64 count, ui64 no = 1; while (count) { auto label = SlotLabelByNo(no); - if (!UsedSlotLabels.contains(label) && !UnusedSlotLabels.contains(label)) { + if (!UsedSlotLabels.contains(label) && !UnusedSlotLabels.contains(label)) { db.Table<Schema::SlotLabels>().Key(Name, label).Update(); UnusedSlotLabels.insert(label); --count; @@ -177,7 +177,7 @@ TString TTenantSlotBroker::TTenant::MakePinnedSlotLabel() ui64 no = 1; while (true) { auto label = Sprintf("pinned-%" PRIu64, no); - if (!PinnedSlotLabels.contains(label)) { + if (!PinnedSlotLabels.contains(label)) { AddPinnedSlotLabel(label); return label; } @@ -187,20 +187,20 @@ TString TTenantSlotBroker::TTenant::MakePinnedSlotLabel() void TTenantSlotBroker::TTenant::AddPinnedSlotLabel(const TString &label) { - Y_VERIFY(!PinnedSlotLabels.contains(label)); + Y_VERIFY(!PinnedSlotLabels.contains(label)); PinnedSlotLabels.insert(label); } void TTenantSlotBroker::TTenant::RemovePinnedSlotLabel(const TString &label) { - Y_VERIFY(PinnedSlotLabels.contains(label)); + Y_VERIFY(PinnedSlotLabels.contains(label)); PinnedSlotLabels.erase(label); } void TTenantSlotBroker::TTenant::MarkSlotLabelAsUsed(const TString &label) { - Y_VERIFY(UnusedSlotLabels.contains(label)); - Y_VERIFY(!UsedSlotLabels.contains(label)); + Y_VERIFY(UnusedSlotLabels.contains(label)); + Y_VERIFY(!UsedSlotLabels.contains(label)); UnusedSlotLabels.erase(label); UsedSlotLabels.insert(label); @@ -208,8 +208,8 @@ void TTenantSlotBroker::TTenant::MarkSlotLabelAsUsed(const TString &label) void TTenantSlotBroker::TTenant::MarkSlotLabelAsUnused(const TString &label) { - Y_VERIFY(!UnusedSlotLabels.contains(label)); - Y_VERIFY(UsedSlotLabels.contains(label)); + Y_VERIFY(!UnusedSlotLabels.contains(label)); + Y_VERIFY(UsedSlotLabels.contains(label)); UnusedSlotLabels.insert(label); UsedSlotLabels.erase(label); @@ -668,7 +668,7 @@ TTenantSlotBroker::TTenant::TPtr TTenantSlotBroker::GetTenant(const TString &nam TTenantSlotBroker::TTenant::TPtr TTenantSlotBroker::AddTenant(const TString &name) { - Y_VERIFY(!Tenants.contains(name)); + Y_VERIFY(!Tenants.contains(name)); auto tenant = new TTenant(name, Counters); Tenants.emplace(name, tenant); *Counters->KnownTenants = Tenants.size(); @@ -955,9 +955,9 @@ void TTenantSlotBroker::DetachSlotNoConfigureNoDb(TSlot::TPtr slot, if (updateUnhappy) RemoveUnhappyTenant(tenant); - Y_VERIFY_DEBUG(!UnhappyTenants.contains(tenant)); - Y_VERIFY_DEBUG(!MisplacedTenants.contains(tenant)); - Y_VERIFY_DEBUG(!SplitTenants.contains(tenant)); + Y_VERIFY_DEBUG(!UnhappyTenants.contains(tenant)); + Y_VERIFY_DEBUG(!MisplacedTenants.contains(tenant)); + Y_VERIFY_DEBUG(!SplitTenants.contains(tenant)); auto allocation = tenant->GetAllocation(slot->UsedAs); allocation->RemoveAssignedSlot(slot); @@ -1015,7 +1015,7 @@ void TTenantSlotBroker::AttachSlotNoConfigureNoDb(TSlot::TPtr slot, const TString &label) { Y_VERIFY(!slot->AssignedTenant); - Y_VERIFY_DEBUG(!UnhappyTenants.contains(tenant)); + Y_VERIFY_DEBUG(!UnhappyTenants.contains(tenant)); if (slot->IsFree()) FreeSlots.Remove(slot); @@ -1137,7 +1137,7 @@ bool TTenantSlotBroker::AssignFreeSlots(TTenant::TPtr tenant, auto allocation = *cur; if (allocation->Group) { - if (!visitedGroups.contains(allocation->Group->Id)) { + if (!visitedGroups.contains(allocation->Group->Id)) { if (AssignFreeSlotsForGroup(tenant, allocation->Group, txc, ctx)) assigned = true; visitedGroups.insert(allocation->Group->Id); @@ -1331,12 +1331,12 @@ void TTenantSlotBroker::ApplyLayout(TTenant::TPtr tenant, for (auto it = allocation->AssignedSlots.begin(); it != allocation->AssignedSlots.end(); ) { auto slot = *(it++); - if (!allAssignedSlots.contains(slot)) + if (!allAssignedSlots.contains(slot)) DetachSlot(slot, txc, ctx, false); } for (auto slot : slots) { - if (!allocation->AssignedSlots.contains(slot)) { + if (!allocation->AssignedSlots.contains(slot)) { if (slot->AssignedTenant) { auto label = slot->Label; // Currently we are not expected to change slot's owner. @@ -1392,7 +1392,7 @@ bool TTenantSlotBroker::AssignFreeSlotsForGroup(TTenant::TPtr tenant, } // Check if it's OK to stay in current data center. - if (currentDC && !layouts.contains(currentDC)) { + if (currentDC && !layouts.contains(currentDC)) { auto layout = ComputeLayoutForGroup(group, currentDC); layouts[currentDC] = layout; LOG_DEBUG_S(ctx, NKikimrServices::TENANT_SLOT_BROKER, @@ -1407,7 +1407,7 @@ bool TTenantSlotBroker::AssignFreeSlotsForGroup(TTenant::TPtr tenant, // Compute layouts for other data centers. for (auto &pr : FreeSlots.FreeSlotsByDataCenter) { - if (!layouts.contains(pr.first)) { + if (!layouts.contains(pr.first)) { layouts[pr.first] = ComputeLayoutForGroup(group, pr.first); LOG_DEBUG_S(ctx, NKikimrServices::TENANT_SLOT_BROKER, "Computed layout for group " << group->Id << " in " @@ -1461,7 +1461,7 @@ bool TTenantSlotBroker::AssignFreeSlotsForGroup(TTenant::TPtr tenant, void TTenantSlotBroker::OnClientDisconnected(TActorId clientId, const TActorContext &ctx) { - if (KnownPoolPipes.contains(clientId)) { + if (KnownPoolPipes.contains(clientId)) { ui32 nodeId = clientId.NodeId(); LOG_DEBUG_S(ctx, NKikimrServices::TENANT_SLOT_BROKER, "Pipe disconnected from pool on node " << nodeId); diff --git a/ydb/core/mind/tenant_slot_broker__alter_tenant.cpp b/ydb/core/mind/tenant_slot_broker__alter_tenant.cpp index 6b3066e7d7..9d8876018f 100644 --- a/ydb/core/mind/tenant_slot_broker__alter_tenant.cpp +++ b/ydb/core/mind/tenant_slot_broker__alter_tenant.cpp @@ -54,7 +54,7 @@ public: // Check if slot may actually be left assigned // by another allocation. for (auto allocation : tenant->GetMissing()) { - if (detach.contains(allocation->Description)) + if (detach.contains(allocation->Description)) continue; if (allocation->IsSlotOk(slot->Type, slot->DataCenter)) { reattached = true; @@ -106,7 +106,7 @@ public: if (slot.GetCount() == 0) continue; TSlotDescription key(slot); - if (newSlots.contains(key)) + if (newSlots.contains(key)) newSlots[key] += slot.GetCount(); else newSlots[key] = slot.GetCount(); @@ -172,7 +172,7 @@ public: // Handle required slots not mentioned in new tenant config. for (auto &key : oldSlots) { - if (newSlots.contains(key)) + if (newSlots.contains(key)) continue; auto allocation = tenant->GetAllocation(key); @@ -186,7 +186,7 @@ public: } for (auto &pr : tenant->GetAllocations()) - if (detach.contains(pr.first)) + if (detach.contains(pr.first)) DetachSlots(tenant, detach, pr.second, txc, ctx); Y_VERIFY(detach.empty()); diff --git a/ydb/core/mind/tenant_slot_broker__assign_free_slots.cpp b/ydb/core/mind/tenant_slot_broker__assign_free_slots.cpp index e2520d7256..f9dd0ab82d 100644 --- a/ydb/core/mind/tenant_slot_broker__assign_free_slots.cpp +++ b/ydb/core/mind/tenant_slot_broker__assign_free_slots.cpp @@ -67,7 +67,7 @@ public: auto allocation = *(it++); Y_VERIFY(allocation->Group); - if (visitedGroups.contains(allocation->Group)) + if (visitedGroups.contains(allocation->Group)) continue; visitedGroups.insert(allocation->Group); @@ -112,7 +112,7 @@ public: ) { auto allocation = *(it++); - if (allocation->Group && visitedGroups.contains(allocation->Group)) + if (allocation->Group && visitedGroups.contains(allocation->Group)) continue; Self->RemoveUnhappyTenant(tenant); diff --git a/ydb/core/mind/tenant_slot_broker__load_state.cpp b/ydb/core/mind/tenant_slot_broker__load_state.cpp index 345b131ea3..efb6dda78d 100644 --- a/ydb/core/mind/tenant_slot_broker__load_state.cpp +++ b/ydb/core/mind/tenant_slot_broker__load_state.cpp @@ -128,7 +128,7 @@ public: dataCenter = DataCenterToString(slotRowset.GetValue<Schema::Slots::DataCenter>()); } - Y_VERIFY(!Self->Slots.contains(id)); + Y_VERIFY(!Self->Slots.contains(id)); TSlot::TPtr slot = new TSlot(id, slotType, dataCenter); slot->LastRequestId = reqId; Self->AddSlot(slot); diff --git a/ydb/core/mind/tenant_slot_broker__update_node_location.cpp b/ydb/core/mind/tenant_slot_broker__update_node_location.cpp index 3ed528dcbc..f1a6cfb634 100644 --- a/ydb/core/mind/tenant_slot_broker__update_node_location.cpp +++ b/ydb/core/mind/tenant_slot_broker__update_node_location.cpp @@ -26,7 +26,7 @@ public: auto dc = nodeInfo->Location.GetDataCenterId(); - if (Self->NodeIdToDataCenter.contains(nodeId) + if (Self->NodeIdToDataCenter.contains(nodeId) && Self->NodeIdToDataCenter[nodeId] == dc) return true; diff --git a/ydb/core/mind/tenant_slot_broker__update_pool_status.cpp b/ydb/core/mind/tenant_slot_broker__update_pool_status.cpp index 1e43062762..165868e2b2 100644 --- a/ydb/core/mind/tenant_slot_broker__update_pool_status.cpp +++ b/ydb/core/mind/tenant_slot_broker__update_pool_status.cpp @@ -22,7 +22,7 @@ public: LOG_DEBUG_S(ctx, NKikimrServices::TENANT_SLOT_BROKER, "TTxUpdatePoolStatus execute for node " << nodeId); TString dc = ANY_DATA_CENTER; - if (Self->NodeIdToDataCenter.contains(nodeId)) + if (Self->NodeIdToDataCenter.contains(nodeId)) dc = Self->NodeIdToDataCenter[nodeId]; for (auto &slotProto : rec.GetSlots()) { @@ -74,7 +74,7 @@ public: } } - if (!Self->NodeIdToDataCenter.contains(nodeId)) + if (!Self->NodeIdToDataCenter.contains(nodeId)) ctx.Send(GetNameserviceActorId(), new TEvInterconnect::TEvGetNode(nodeId)); return true; diff --git a/ydb/core/mind/tenant_slot_broker_impl.h b/ydb/core/mind/tenant_slot_broker_impl.h index b5e3b107ab..7b1f2a7bf3 100644 --- a/ydb/core/mind/tenant_slot_broker_impl.h +++ b/ydb/core/mind/tenant_slot_broker_impl.h @@ -561,13 +561,13 @@ private: void AddAssignedSlot(TSlot::TPtr slot) { - Y_VERIFY(!AssignedSlots.contains(slot)); + Y_VERIFY(!AssignedSlots.contains(slot)); AssignedSlots.insert(slot); } void RemoveAssignedSlot(TSlot::TPtr slot) { - Y_VERIFY(AssignedSlots.contains(slot)); + Y_VERIFY(AssignedSlots.contains(slot)); AssignedSlots.erase(slot); } diff --git a/ydb/core/mind/tenant_ut_broker.cpp b/ydb/core/mind/tenant_ut_broker.cpp index 4c124b3d83..8928beae70 100644 --- a/ydb/core/mind/tenant_ut_broker.cpp +++ b/ydb/core/mind/tenant_ut_broker.cpp @@ -313,31 +313,31 @@ void CheckState(const NKikimrTenantSlotBroker::TTenantState &rec, UNIT_ASSERT_VALUES_EQUAL(name, rec.GetTenantName()); for (auto &slot : rec.GetRequiredSlots()) { TSlotDescription key(slot); - UNIT_ASSERT(expected.contains(key)); + UNIT_ASSERT(expected.contains(key)); UNIT_ASSERT_VALUES_EQUAL(slot.GetCount(), expected[key].Required); expected[key].Required = 0; } for (auto &slot : rec.GetPendingSlots()) { TSlotDescription key(slot); - UNIT_ASSERT(expected.contains(key)); + UNIT_ASSERT(expected.contains(key)); UNIT_ASSERT_VALUES_EQUAL(slot.GetCount(), expected[key].Pending); expected[key].Pending = 0; } for (auto &slot : rec.GetMissingSlots()) { TSlotDescription key(slot); - UNIT_ASSERT(expected.contains(key)); + UNIT_ASSERT(expected.contains(key)); UNIT_ASSERT_VALUES_EQUAL(slot.GetCount(), expected[key].Missing); expected[key].Missing = 0; } for (auto &slot : rec.GetMisplacedSlots()) { TSlotDescription key(slot); - UNIT_ASSERT(expected.contains(key)); + UNIT_ASSERT(expected.contains(key)); UNIT_ASSERT_VALUES_EQUAL(slot.GetCount(), expected[key].Misplaced); expected[key].Misplaced = 0; } for (auto &slot : rec.GetSplitSlots()) { TSlotDescription key(slot); - UNIT_ASSERT(expected.contains(key)); + UNIT_ASSERT(expected.contains(key)); UNIT_ASSERT_VALUES_EQUAL(slot.GetCount(), expected[key].Split); expected[key].Split = 0; } @@ -357,7 +357,7 @@ bool CompareState(NKikimrTenantSlotBroker::TTenantState &rec, const TString &nam return false; for (auto &slot : rec.GetRequiredSlots()) { TSlotDescription key(slot); - if (!expected.contains(key)) + if (!expected.contains(key)) return false; if (slot.GetCount() != expected[key].Required) return false; @@ -365,7 +365,7 @@ bool CompareState(NKikimrTenantSlotBroker::TTenantState &rec, const TString &nam } for (auto &slot : rec.GetPendingSlots()) { TSlotDescription key(slot); - if (!expected.contains(key)) + if (!expected.contains(key)) return false; if (slot.GetCount() != expected[key].Pending) return false; @@ -373,7 +373,7 @@ bool CompareState(NKikimrTenantSlotBroker::TTenantState &rec, const TString &nam } for (auto &slot : rec.GetMissingSlots()) { TSlotDescription key(slot); - if (!expected.contains(key)) + if (!expected.contains(key)) return false; if (slot.GetCount() != expected[key].Missing) return false; @@ -381,7 +381,7 @@ bool CompareState(NKikimrTenantSlotBroker::TTenantState &rec, const TString &nam } for (auto &slot : rec.GetMisplacedSlots()) { TSlotDescription key(slot); - if (!expected.contains(key)) + if (!expected.contains(key)) return false; if (slot.GetCount() != expected[key].Misplaced) return false; @@ -389,7 +389,7 @@ bool CompareState(NKikimrTenantSlotBroker::TTenantState &rec, const TString &nam } for (auto &slot : rec.GetSplitSlots()) { TSlotDescription key(slot); - if (!expected.contains(key)) + if (!expected.contains(key)) return false; if (slot.GetCount() != expected[key].Split) return false; @@ -397,7 +397,7 @@ bool CompareState(NKikimrTenantSlotBroker::TTenantState &rec, const TString &nam } for (auto &slot : rec.GetPinnedSlots()) { TSlotDescription key(slot); - if (!expected.contains(key)) + if (!expected.contains(key)) return false; if (slot.GetCount() != expected[key].Pinned) return false; @@ -520,7 +520,7 @@ void CheckTenantsList(TTenantTestRuntime &runtime, TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<TEvTenantSlotBroker::TEvTenantsList>(handle); for (auto &tenant : reply->Record.GetTenants()) { - UNIT_ASSERT(expected.contains(tenant.GetTenantName())); + UNIT_ASSERT(expected.contains(tenant.GetTenantName())); CheckState(tenant, tenant.GetTenantName(), expected[tenant.GetTenantName()]); expected.erase(tenant.GetTenantName()); } @@ -1188,7 +1188,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { if (restartNode && false) { ui32 nodeId = RandomNumber<ui32>(runtime.GetNodeCount()); - if (!poolsToRestart.contains(nodeId)) { + if (!poolsToRestart.contains(nodeId)) { runtime.Send(new IEventHandle(MakeTenantPoolID(runtime.GetNodeId(nodeId), 0), runtime.Sender, new TEvents::TEvPoisonPill)); diff --git a/ydb/core/mind/tenant_ut_pool.cpp b/ydb/core/mind/tenant_ut_pool.cpp index 9ac6b6843c..0dd672cd09 100644 --- a/ydb/core/mind/tenant_ut_pool.cpp +++ b/ydb/core/mind/tenant_ut_pool.cpp @@ -53,7 +53,7 @@ public: { auto &rec = ev->Get()->Record; auto &id = rec.GetSlotStatus().GetId(); - UNIT_ASSERT(Answers.contains(id)); + UNIT_ASSERT(Answers.contains(id)); auto &answer = Answers[id].front(); UNIT_ASSERT_VALUES_EQUAL((int)rec.GetStatus(), (int)answer.Status); UNIT_ASSERT_VALUES_EQUAL(ev->Cookie, answer.Cookie); diff --git a/ydb/core/persqueue/partition.cpp b/ydb/core/persqueue/partition.cpp index cc8e2419cf..bf930f3f99 100644 --- a/ydb/core/persqueue/partition.cpp +++ b/ydb/core/persqueue/partition.cpp @@ -2204,7 +2204,7 @@ void TPartition::Handle(TEvPQ::TEvGetMaxSeqNoRequest::TPtr& ev, const TActorCont void TPartition::Handle(TEvPQ::TEvBlobResponse::TPtr& ev, const TActorContext& ctx) { const ui64 cookie = ev->Get()->GetCookie(); - Y_VERIFY(ReadInfo.contains(cookie)); + Y_VERIFY(ReadInfo.contains(cookie)); auto it = ReadInfo.find(cookie); Y_VERIFY(it != ReadInfo.end()); @@ -2297,7 +2297,7 @@ TReadAnswer TReadInfo::FormAnswer( if (HasError(blobResponse)) { return TReadAnswer{ blobResponse.Error.ErrorStr.size(), - MakeHolder<TEvPQ::TEvError>(blobResponse.Error.ErrorCode, blobResponse.Error.ErrorStr, cookie) + MakeHolder<TEvPQ::TEvError>(blobResponse.Error.ErrorCode, blobResponse.Error.ErrorStr, cookie) }; } @@ -2337,7 +2337,7 @@ TReadAnswer TReadInfo::FormAnswer( userInfo->ReadDone(ctx, ctx.Now(), answerSize, cnt, ClientDC); } readResult->SetSizeLag(sizeLag - size); - return {answerSize, std::move(answer)}; + return {answerSize, std::move(answer)}; } Y_VERIFY(blobValue.size() == blobs[pos].Size, "value for offset %" PRIu64 " count %u size must be %u, but got %u", offset, count, blobs[pos].Size, (ui32)blobValue.size()); @@ -2447,7 +2447,7 @@ TReadAnswer TReadInfo::FormAnswer( userInfo->ReadDone(ctx, ctx.Now(), answerSize, cnt, ClientDC); } readResult->SetSizeLag(sizeLag - size); - return {answerSize, std::move(answer)}; + return {answerSize, std::move(answer)}; } diff --git a/ydb/core/persqueue/pq_l2_cache.h b/ydb/core/persqueue/pq_l2_cache.h index f9fcccbc8e..71d2c9309d 100644 --- a/ydb/core/persqueue/pq_l2_cache.h +++ b/ydb/core/persqueue/pq_l2_cache.h @@ -7,7 +7,7 @@ #include <library/cpp/monlib/dynamic_counters/counters.h> #include <library/cpp/cache/cache.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> namespace NKikimr { namespace NPQ { @@ -54,7 +54,7 @@ public: , Offset(blob.Offset) , PartNo(blob.PartNo) { - KeyHash = Hash128to32(ComputeHash(topicName), (static_cast<ui64>(Partition) << 16) + PartNo); + KeyHash = Hash128to32(ComputeHash(topicName), (static_cast<ui64>(Partition) << 16) + PartNo); KeyHash = Hash128to32(KeyHash, Offset); } diff --git a/ydb/core/persqueue/pq_ut.cpp b/ydb/core/persqueue/pq_ut.cpp index 13a6122910..1a0b8bcf7c 100644 --- a/ydb/core/persqueue/pq_ut.cpp +++ b/ydb/core/persqueue/pq_ut.cpp @@ -448,7 +448,7 @@ void CheckLabeledCountersResponse(ui32 count, TTestContext& tc, TVector<TString> } UNIT_ASSERT(groups.size() == count); for (auto& g : mustHave) { - UNIT_ASSERT(groups.contains(g)); + UNIT_ASSERT(groups.contains(g)); } } diff --git a/ydb/core/persqueue/read_balancer.cpp b/ydb/core/persqueue/read_balancer.cpp index 4eb9c7206d..15763b9c6f 100644 --- a/ydb/core/persqueue/read_balancer.cpp +++ b/ydb/core/persqueue/read_balancer.cpp @@ -369,7 +369,7 @@ void TPersQueueReadBalancer::CheckACL(const TEvPersQueue::TEvCheckACL::TPtr &req TString user = record.HasUser() ? record.GetUser() : ""; if (record.GetOperation() == NKikimrPQ::EOperation::READ_OP) { - if (!Consumers.contains(user)) { + if (!Consumers.contains(user)) { RespondWithACL(request, NKikimrPQ::EAccess::DENIED, TStringBuilder() << "no read rule provided for consumer '" << NPersQueue::ConvertOldConsumerName(user) << "' that allows to read topic from cluster '" << NPersQueue::GetDC(Topic) <<"'; may be there is read rule with mode all-original only and you are reading with mirrored topics. Change read-rule to mirror-to-<cluster> or options of reading process.", ctx); return; @@ -613,7 +613,7 @@ void TPersQueueReadBalancer::RestartPipe(const ui64 tabletId, const TActorContex void TPersQueueReadBalancer::RequestTabletIfNeeded(const ui64 tabletId, const TActorContext& ctx) { if ((tabletId == SchemeShardId && !WaitingForACL) || - (tabletId != SchemeShardId && !WaitingForStat.contains(tabletId))) + (tabletId != SchemeShardId && !WaitingForStat.contains(tabletId))) return; auto it = TabletPipes.find(tabletId); diff --git a/ydb/core/persqueue/read_speed_limiter.cpp b/ydb/core/persqueue/read_speed_limiter.cpp index 793338420d..0018bfa645 100644 --- a/ydb/core/persqueue/read_speed_limiter.cpp +++ b/ydb/core/persqueue/read_speed_limiter.cpp @@ -62,7 +62,7 @@ void TReadSpeedLimiter::Bootstrap(const TActorContext& ctx) { auto counters = AppData()->Counters; if (counters && TopicName.Contains("--")) { - QuotaWaitCounter.Reset(new TPercentileCounter( + QuotaWaitCounter.Reset(new TPercentileCounter( GetServiceCounters(counters, "pqproxy|consumerReadQuotaWait"), GetLabels(TopicName), { @@ -75,7 +75,7 @@ void TReadSpeedLimiter::Bootstrap(const TActorContext& ctx) { {20, "20ms"}, {50, "50ms"}, {100, "100ms"}, {500, "500ms"}, {1000, "1000ms"}, {2500, "2500ms"}, {5000, "5000ms"}, {10000, "10000ms"}, {9999999, "999999ms"}}, true - )); + )); } } diff --git a/ydb/core/quoter/ut_helpers.cpp b/ydb/core/quoter/ut_helpers.cpp index e57a073d74..b341b78d2f 100644 --- a/ydb/core/quoter/ut_helpers.cpp +++ b/ydb/core/quoter/ut_helpers.cpp @@ -308,7 +308,7 @@ THolder<TEventHandle<TEvQuota::TEvProxySession>> TKesusProxyTestSetup::ProxyRequ TAutoPtr<IEventHandle> handle; TEvQuota::TEvProxySession* ret = Runtime->GrabEdgeEvent<TEvQuota::TEvProxySession>(handle); UNIT_ASSERT_EQUAL_C(ret->Result, expectedResult, "Actual result: " << static_cast<int>(ret->Result) << ", but expected: " << static_cast<int>(expectedResult)); - return THolder<TEventHandle<TEvQuota::TEvProxySession>>{static_cast<TEventHandle<TEvQuota::TEvProxySession>*>(handle.Release())}; + return THolder<TEventHandle<TEvQuota::TEvProxySession>>{static_cast<TEventHandle<TEvQuota::TEvProxySession>*>(handle.Release())}; } void TKesusProxyTestSetup::SendProxyStats(TDeque<TEvQuota::TProxyStat> stats) { @@ -319,7 +319,7 @@ void TKesusProxyTestSetup::SendProxyStats(TDeque<TEvQuota::TProxyStat> stats) { THolder<TEventHandle<TEvQuota::TEvProxyUpdate>> TKesusProxyTestSetup::GetProxyUpdate() { TAutoPtr<IEventHandle> handle; Runtime->GrabEdgeEvent<TEvQuota::TEvProxyUpdate>(handle); - return THolder<TEventHandle<TEvQuota::TEvProxyUpdate>>{static_cast<TEventHandle<TEvQuota::TEvProxyUpdate>*>(handle.Release())}; + return THolder<TEventHandle<TEvQuota::TEvProxyUpdate>>{static_cast<TEventHandle<TEvQuota::TEvProxyUpdate>*>(handle.Release())}; } void TKesusProxyTestSetup::SendCloseSession(const TString& resource, ui64 resourceId) { diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h index bccfdca97d..4d78169b71 100644 --- a/ydb/core/scheme/scheme_tablecell.h +++ b/ydb/core/scheme/scheme_tablecell.h @@ -5,7 +5,7 @@ #include "scheme_type_order.h" #include "scheme_types_defs.h" -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/system/unaligned_mem.h> #include <type_traits> @@ -270,7 +270,7 @@ inline ui64 GetValueHash(NScheme::TTypeId type, const TCell& cell) { case NYql::NProto::TypeIds::Decimal: case NYql::NProto::TypeIds::JsonDocument: case NYql::NProto::TypeIds::DyNumber: - return ComputeHash(TStringBuf{cell.Data(), cell.Size()}); + return ComputeHash(TStringBuf{cell.Data(), cell.Size()}); default: Y_VERIFY_DEBUG(false, "Type not supported for user columns: %d", type); diff --git a/ydb/core/scheme_types/scheme_raw_type_value.h b/ydb/core/scheme_types/scheme_raw_type_value.h index 1cb0946b6d..d9ae4f943f 100644 --- a/ydb/core/scheme_types/scheme_raw_type_value.h +++ b/ydb/core/scheme_types/scheme_raw_type_value.h @@ -38,7 +38,7 @@ public: // we must distinguish empty raw type value (nothing, buffer == nullptr) // and zero-length string (value exists, but zero-length) bool IsEmpty() const { return Buffer == nullptr; } - explicit operator bool() const noexcept { return !IsEmpty(); } + explicit operator bool() const noexcept { return !IsEmpty(); } TString ToString() const { TStringBuilder builder; diff --git a/ydb/core/tablet/resource_broker.cpp b/ydb/core/tablet/resource_broker.cpp index fff30b2601..d9c480c546 100644 --- a/ydb/core/tablet/resource_broker.cpp +++ b/ydb/core/tablet/resource_broker.cpp @@ -395,20 +395,20 @@ bool TScheduler::SubmitTask(const TEvResourceBroker::TTask &task, if (!task.TaskId) { do { id = std::make_pair(client, NextTaskId++); - } while (Tasks.contains(id)); + } while (Tasks.contains(id)); newTask->TaskId = id.second; LOG_DEBUG(as, NKikimrServices::RESOURCE_BROKER, "Use ID %" PRIu64 " for submitted task", id.second); - } else if (Tasks.contains(id)) { + } else if (Tasks.contains(id)) { LOG_DEBUG(as, NKikimrServices::RESOURCE_BROKER, "SubmitTask failed for task %" PRIu64 " to %s: task with the same ID has been already submitted", task.TaskId, ToString(client).c_str()); return false; } - if (!TaskConfigs.contains(newTask->Type)) + if (!TaskConfigs.contains(newTask->Type)) MissingTaskTypeCounter->Inc(); Tasks.emplace(id, newTask); @@ -668,7 +668,7 @@ void TScheduler::AssignTask(TTaskPtr &task, const TActorSystem &as) TString state = task->InFly ? "in-fly" : "waiting"; TTaskQueuePtr queue = TaskConfig(task->Type).Queue; - if (!TaskConfigs.contains(task->Type)) { + if (!TaskConfigs.contains(task->Type)) { LOG_ERROR(as, NKikimrServices::RESOURCE_BROKER, "Assigning %s task '%s' of unknown type '%s' to default queue", state.data(), task->GetIdString().data(), task->Type.data()); @@ -712,14 +712,14 @@ void TScheduler::AssignTask(TTaskPtr &task, const TActorSystem &as) const TScheduler::TTaskConfig &TScheduler::TaskConfig(const TString &type) const { - if (TaskConfigs.contains(type)) + if (TaskConfigs.contains(type)) return TaskConfigs.at(type); return TaskConfigs.at(NLocalDb::UnknownTaskName); } TScheduler::TTaskConfig &TScheduler::TaskConfig(const TString &type) { - if (TaskConfigs.contains(type)) + if (TaskConfigs.contains(type)) return TaskConfigs.at(type); return TaskConfigs.at(NLocalDb::UnknownTaskName); } @@ -746,7 +746,7 @@ void TScheduler::Configure(const TResourceBrokerConfig &config, const TActorSyst ResourceLimit, TotalCounters); Queues.emplace(queue->Name, queue); } - Y_VERIFY(Queues.contains(NLocalDb::DefaultQueueName), "default queue '%s' wasn't found in config", NLocalDb::DefaultQueueName.data()); + Y_VERIFY(Queues.contains(NLocalDb::DefaultQueueName), "default queue '%s' wasn't found in config", NLocalDb::DefaultQueueName.data()); // Read new tasks config. TaskConfigs.clear(); @@ -755,12 +755,12 @@ void TScheduler::Configure(const TResourceBrokerConfig &config, const TActorSyst TTaskConfig taskConfig(task.GetName(), TDuration::MicroSeconds(task.GetDefaultDuration()), counters); - Y_VERIFY(Queues.contains(task.GetQueueName()), " queue '%s' wasn't found in config", task.GetQueueName().data()); + Y_VERIFY(Queues.contains(task.GetQueueName()), " queue '%s' wasn't found in config", task.GetQueueName().data()); taskConfig.Queue = Queues.at(task.GetQueueName()); TaskConfigs.emplace(taskConfig.Name, taskConfig); } - Y_VERIFY(TaskConfigs.contains(NLocalDb::UnknownTaskName), "task '%s' wasn't found in config", NLocalDb::UnknownTaskName.data()); + Y_VERIFY(TaskConfigs.contains(NLocalDb::UnknownTaskName), "task '%s' wasn't found in config", NLocalDb::UnknownTaskName.data()); // Move all tasks to queues. for (auto &entry : Tasks) @@ -1190,7 +1190,7 @@ void TResourceBrokerActor::Handle(TEvResourceBroker::TEvConfigure::TPtr &ev, for (auto &queue : rec.GetQueues()) queues.insert(queue.GetName()); for (auto &task : rec.GetTasks()) { - if (!queues.contains(task.GetQueueName())) { + if (!queues.contains(task.GetQueueName())) { error = Sprintf("task '%s' uses unknown queue '%s'", task.GetName().data(), task.GetQueueName().data()); success = false; break; @@ -1209,10 +1209,10 @@ void TResourceBrokerActor::Handle(TEvResourceBroker::TEvConfigure::TPtr &ev, if (!success) { response->Record.SetSuccess(false); response->Record.SetMessage(error); - } else if (!queues.contains(NLocalDb::DefaultQueueName)) { + } else if (!queues.contains(NLocalDb::DefaultQueueName)) { response->Record.SetSuccess(false); response->Record.SetMessage("no default queue in config"); - } else if (!tasks.contains(NLocalDb::UnknownTaskName)) { + } else if (!tasks.contains(NLocalDb::UnknownTaskName)) { response->Record.SetSuccess(false); response->Record.SetMessage("no unknown task in config"); } else { diff --git a/ydb/core/tablet/resource_broker_ut.cpp b/ydb/core/tablet/resource_broker_ut.cpp index 5948509025..bae831130d 100644 --- a/ydb/core/tablet/resource_broker_ut.cpp +++ b/ydb/core/tablet/resource_broker_ut.cpp @@ -630,7 +630,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { while (!ids.empty()) { TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<TEvResourceBroker::TEvResourceAllocated>(handle); - UNIT_ASSERT(ids.contains(reply->TaskId)); + UNIT_ASSERT(ids.contains(reply->TaskId)); ids.erase(reply->TaskId); now += TDuration::MilliSeconds(RandomNumber<ui32>(20000)); runtime.UpdateCurrentTime(now); diff --git a/ydb/core/tablet/tablet_counters_app.cpp b/ydb/core/tablet/tablet_counters_app.cpp index bfed7ffd13..f97e3f7bb3 100644 --- a/ydb/core/tablet/tablet_counters_app.cpp +++ b/ydb/core/tablet/tablet_counters_app.cpp @@ -12,29 +12,29 @@ namespace NKikimr { THolder<TTabletCountersBase> CreateAppCountersByTabletType(TTabletTypes::EType type) { switch (type) { case TTabletTypes::SchemeShard: - return MakeHolder<TAppProtobufTabletCounters< + return MakeHolder<TAppProtobufTabletCounters< NSchemeShard::ESimpleCounters_descriptor, NSchemeShard::ECumulativeCounters_descriptor, NSchemeShard::EPercentileCounters_descriptor - >>(); + >>(); case TTabletTypes::DataShard: - return MakeHolder<TAppProtobufTabletCounters< + return MakeHolder<TAppProtobufTabletCounters< NDataShard::ESimpleCounters_descriptor, NDataShard::ECumulativeCounters_descriptor, NDataShard::EPercentileCounters_descriptor - >>(); + >>(); case TTabletTypes::Hive: - return MakeHolder<TAppProtobufTabletCounters< + return MakeHolder<TAppProtobufTabletCounters< NHive::ESimpleCounters_descriptor, NHive::ECumulativeCounters_descriptor, NHive::EPercentileCounters_descriptor - >>(); + >>(); case TTabletTypes::Kesus: - return MakeHolder<TAppProtobufTabletCounters< + return MakeHolder<TAppProtobufTabletCounters< NKesus::ESimpleCounters_descriptor, NKesus::ECumulativeCounters_descriptor, NKesus::EPercentileCounters_descriptor - >>(); + >>(); default: return {}; } diff --git a/ydb/core/tablet/tablet_pipe_client.cpp b/ydb/core/tablet/tablet_pipe_client.cpp index 2fa35af9a0..59753e144b 100644 --- a/ydb/core/tablet/tablet_pipe_client.cpp +++ b/ydb/core/tablet/tablet_pipe_client.cpp @@ -699,7 +699,7 @@ namespace NTabletPipe { } void SendDataWithSeqNo(TActorId self, TActorId clientId, IEventBase *payload, ui64 seqNo, ui64 cookie) { - auto event = MakeHolder<TEvTabletPipe::TEvMessage>(self, THolder<IEventBase>(payload)); + auto event = MakeHolder<TEvTabletPipe::TEvMessage>(self, THolder<IEventBase>(payload)); event->SetSeqNo(seqNo); auto ev = MakeHolder<IEventHandle>(clientId, self, event.Release(), 0, cookie); TActivationContext::Send(ev.Release()); diff --git a/ydb/core/tablet/tablet_req_rebuildhistory.cpp b/ydb/core/tablet/tablet_req_rebuildhistory.cpp index c0b4c0c2bc..c77dbd5b91 100644 --- a/ydb/core/tablet/tablet_req_rebuildhistory.cpp +++ b/ydb/core/tablet/tablet_req_rebuildhistory.cpp @@ -643,7 +643,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil bool refsOk = true; for (TVector<TLogoBlobID>::const_iterator it = entry.References.begin(), end = entry.References.end(); refsOk && it != end; ++it) { const TLogoBlobID &x = *it; - refsOk = !RefsToCheck.contains(x); + refsOk = !RefsToCheck.contains(x); } const bool snapOk = entry.IsTotalSnapshot || (entry.IsSnapshot && (id.second == lastUnbrokenTailEntry + 1)); diff --git a/ydb/core/tablet/tablet_resolver_ut.cpp b/ydb/core/tablet/tablet_resolver_ut.cpp index b341cae133..19631e1bfd 100644 --- a/ydb/core/tablet/tablet_resolver_ut.cpp +++ b/ydb/core/tablet/tablet_resolver_ut.cpp @@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(TTabletResolver) { const TActorId edge = runtime.AllocateEdgeActor(); runtime.Send(new IEventHandle(MakeTabletResolverID(), edge, new TEvTabletResolver::TEvForward(tabletId, nullptr))); auto ev = runtime.GrabEdgeEventRethrow<TEvTabletResolver::TEvForwardResult>(edge); - return std::move(ev->Release()); + return std::move(ev->Release()); } void DoSendNodeProblem(TTestBasicRuntime& runtime, ui32 nodeId, ui64 problemEpoch) { diff --git a/ydb/core/tablet_flat/flat_boot_turns.h b/ydb/core/tablet_flat/flat_boot_turns.h index 7730e9cbb9..617340fd87 100644 --- a/ydb/core/tablet_flat/flat_boot_turns.h +++ b/ydb/core/tablet_flat/flat_boot_turns.h @@ -161,10 +161,10 @@ namespace NBoot { Y_Fail("Part switch has bundle without page collections"); } const auto &bundleId = bundle.LargeGlobIds[0].Lead; - if (Bundles.contains(bundleId)) { + if (Bundles.contains(bundleId)) { Y_Fail("Part switch has a duplicate bundle " << bundleId); } - if (Leaving.contains(bundleId)) { + if (Leaving.contains(bundleId)) { Y_Fail("Part switch has a removed bundle" << bundleId); } Bundles[bundleId] = &bundle; diff --git a/ydb/core/tablet_flat/flat_comp_gen.cpp b/ydb/core/tablet_flat/flat_comp_gen.cpp index 43bf95357b..dbf989207e 100644 --- a/ydb/core/tablet_flat/flat_comp_gen.cpp +++ b/ydb/core/tablet_flat/flat_comp_gen.cpp @@ -772,7 +772,7 @@ void TGenCompactionStrategy::PartMerged(TPartView partView, ui32 level) { const auto label = partView->Label; // Remove the old part data from our model (since it may have been changed) - if (KnownParts.contains(label)) { + if (KnownParts.contains(label)) { Y_VERIFY(KnownParts[label] == level, "Borrowed part cannot be moved between levels"); Y_VERIFY(FinalCompactionId == 0 || FinalCompactionTaken == 0, "Borrowed part attaching while final compaction is in progress"); diff --git a/ydb/core/tablet_flat/flat_cxx_database.h b/ydb/core/tablet_flat/flat_cxx_database.h index 27a260bcb2..32f93236ee 100644 --- a/ydb/core/tablet_flat/flat_cxx_database.h +++ b/ydb/core/tablet_flat/flat_cxx_database.h @@ -258,7 +258,7 @@ public: } static typename NSchemeTypeMapper<NScheme::NTypeIds::String>::Type ConvertFrom(const TStringBuf& value) { - return static_cast<typename NSchemeTypeMapper<NScheme::NTypeIds::String>::Type>(TString(value)); + return static_cast<typename NSchemeTypeMapper<NScheme::NTypeIds::String>::Type>(TString(value)); } static typename NSchemeTypeMapper<NScheme::NTypeIds::String>::Type ConvertFrom(const ::google::protobuf::Message& value) { diff --git a/ydb/core/tablet_flat/flat_exec_scans.h b/ydb/core/tablet_flat/flat_exec_scans.h index 4ab7047351..08dfcb800d 100644 --- a/ydb/core/tablet_flat/flat_exec_scans.h +++ b/ydb/core/tablet_flat/flat_exec_scans.h @@ -169,7 +169,7 @@ namespace NTabletFlatExecutor { one.State = EState::Task; one.TaskId = Emitter->Do(); - const auto* overrides = std::get_if<TScanOptions::TResourceBrokerOptions>(&options.ResourceBroker); + const auto* overrides = std::get_if<TScanOptions::TResourceBrokerOptions>(&options.ResourceBroker); ToBroker(new TEvResourceBroker::TEvSubmitTask( one.TaskId, MakeLabelFor(one), @@ -335,7 +335,7 @@ namespace NTabletFlatExecutor { break; } - if (const auto* overrides = std::get_if<TScanOptions::TReadAheadOptions>(&one.Options.ReadAhead)) { + if (const auto* overrides = std::get_if<TScanOptions::TReadAheadOptions>(&one.Options.ReadAhead)) { conf.AheadLo = overrides->ReadAheadLo; conf.AheadHi = overrides->ReadAheadHi; } else { @@ -350,7 +350,7 @@ namespace NTabletFlatExecutor { logl << NFmt::Do(*Ops) << " starting " << NFmt::Do(*actor); ui32 pool = AppData()->BatchPoolId; - if (const auto* overrides = std::get_if<TScanOptions::TActorPoolById>(&one.Options.ActorPool)) { + if (const auto* overrides = std::get_if<TScanOptions::TActorPoolById>(&one.Options.ActorPool)) { pool = overrides->PoolId; } diff --git a/ydb/core/tablet_flat/flat_executor.cpp b/ydb/core/tablet_flat/flat_executor.cpp index 59afc46215..228376875c 100644 --- a/ydb/core/tablet_flat/flat_executor.cpp +++ b/ydb/core/tablet_flat/flat_executor.cpp @@ -2769,7 +2769,7 @@ THolder<TScanSnapshot> TExecutor::PrepareScanSnapshot(ui32 table, const NTable:: GcLogic->HoldBarrier(barrier->Step); CompactionLogic->UpdateLogUsage(LogicRedo->GrabLogUsage()); - return THolder<TScanSnapshot>(new TScanSnapshot{table, std::move(barrier), subset, snapshot}); + return THolder<TScanSnapshot>(new TScanSnapshot{table, std::move(barrier), subset, snapshot}); } void TExecutor::StartScan(ui64 serial, ui32 table) noexcept @@ -3062,7 +3062,7 @@ void TExecutor::Handle(NOps::TEvResult *ops, TProdCompact *msg, bool cancelled) THashSet<TLogoBlobID> reusedBundles; for (auto &part: ops->Subset->Flatten) { - if (updatedSlices.contains(part->Label)) { + if (updatedSlices.contains(part->Label)) { reusedBundles.insert(part->Label); } } @@ -3455,7 +3455,7 @@ ui64 TExecutor::QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cooki { THolder<TScanSnapshot> snapshot; - if (const auto* byId = std::get_if<TScanOptions::TSnapshotById>(&options.Snapshot)) { + if (const auto* byId = std::get_if<TScanOptions::TSnapshotById>(&options.Snapshot)) { auto snapshotId = byId->SnapshotId; auto it = ScanSnapshots.find(snapshotId); Y_VERIFY_S(it != ScanSnapshots.end(), @@ -3466,7 +3466,7 @@ ui64 TExecutor::QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cooki ScanSnapshots.erase(it); } else { TRowVersion rowVersion; - if (const auto* byVersion = std::get_if<TScanOptions::TSnapshotByRowVersion>(&options.Snapshot)) { + if (const auto* byVersion = std::get_if<TScanOptions::TSnapshotByRowVersion>(&options.Snapshot)) { rowVersion = byVersion->RowVersion; } else { rowVersion = TRowVersion::Max(); diff --git a/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp b/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp index bd52264b10..a0edfcef2b 100644 --- a/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp @@ -568,10 +568,10 @@ TString TExecutorBorrowLogic::DebugCheckBorrowConsistency(THashSet<TLogoBlobID> } if (collected) { - if (knownBundles.contains(xpair.first)) + if (knownBundles.contains(xpair.first)) out << xpair.first << ": collected bundle still present in database. "; } else { - if (!knownBundles.contains(xpair.first)) + if (!knownBundles.contains(xpair.first)) out << xpair.first << ": non-collected bundle not present in database. "; } } diff --git a/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp b/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp index 3d699e8f87..2d484dc5c4 100644 --- a/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp +++ b/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp @@ -255,7 +255,7 @@ TReflectSchemeChangesResult TCompactionLogic::ReflectSchemeChanges() } for (auto it = State->Tables.begin(), end = State->Tables.end(); it != end; ) { - if (scheme.Tables.contains(it->first)) { + if (scheme.Tables.contains(it->first)) { ++it; } else { StopTable(it->second); diff --git a/ydb/core/tablet_flat/tablet_flat_executor.h b/ydb/core/tablet_flat/tablet_flat_executor.h index 075ebce354..f78b557bcf 100644 --- a/ydb/core/tablet_flat/tablet_flat_executor.h +++ b/ydb/core/tablet_flat/tablet_flat_executor.h @@ -380,10 +380,10 @@ struct TScanOptions { }; EReadPrio ReadPrio = EReadPrio::Default; - std::variant<TReadAheadDefaults, TReadAheadOptions> ReadAhead; - std::variant<TResourceBrokerDefaults, TResourceBrokerOptions, TResourceBrokerDisabled> ResourceBroker; - std::variant<TSnapshotNone, TSnapshotById, TSnapshotByRowVersion> Snapshot; - std::variant<TActorPoolDefault, TActorPoolById> ActorPool; + std::variant<TReadAheadDefaults, TReadAheadOptions> ReadAhead; + std::variant<TResourceBrokerDefaults, TResourceBrokerOptions, TResourceBrokerDisabled> ResourceBroker; + std::variant<TSnapshotNone, TSnapshotById, TSnapshotByRowVersion> Snapshot; + std::variant<TActorPoolDefault, TActorPoolById> ActorPool; TScanOptions& SetReadPrio(EReadPrio prio) { ReadPrio = prio; @@ -421,7 +421,7 @@ struct TScanOptions { } bool IsResourceBrokerDisabled() const { - return std::holds_alternative<TResourceBrokerDisabled>(ResourceBroker); + return std::holds_alternative<TResourceBrokerDisabled>(ResourceBroker); } }; diff --git a/ydb/core/tablet_flat/ut/flat_test_db.cpp b/ydb/core/tablet_flat/ut/flat_test_db.cpp index b65757d4bb..d7ec2665de 100644 --- a/ydb/core/tablet_flat/ut/flat_test_db.cpp +++ b/ydb/core/tablet_flat/ut/flat_test_db.cpp @@ -245,7 +245,7 @@ public: FillKey(root, fk, key, true); // Copy previous value from the commited data - if (!TxChanges[root].contains(fk) && Tables[root].contains(fk)) { + if (!TxChanges[root].contains(fk) && Tables[root].contains(fk)) { TxChanges[root][fk] = Tables[root][fk]; } diff --git a/ydb/core/testlib/actors/test_runtime_ut.cpp b/ydb/core/testlib/actors/test_runtime_ut.cpp index fce7f19293..f589ed5655 100644 --- a/ydb/core/testlib/actors/test_runtime_ut.cpp +++ b/ydb/core/testlib/actors/test_runtime_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/actors/core/event_local.h> #include <library/cpp/actors/core/events.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> namespace NKikimr { using namespace NActors; @@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { auto actorSystem = ctx.ExecutorThread.ActorSystem; TMutex *syncMutex = SyncMutex; - SystemThreadFactory()->Run([=](){ + SystemThreadFactory()->Run([=](){ with_lock(*syncMutex) { Sleep(TDuration::MilliSeconds(100)); CurrentTime = actorSystem->Timestamp(); diff --git a/ydb/core/testlib/minikql_compile.h b/ydb/core/testlib/minikql_compile.h index 4d76ca8d73..307bf53a16 100644 --- a/ydb/core/testlib/minikql_compile.h +++ b/ydb/core/testlib/minikql_compile.h @@ -4,7 +4,7 @@ #include <ydb/core/client/minikql_compile/db_key_resolver.h> #include <ydb/core/client/minikql_compile/yql_expr_minikql.h> #include <library/cpp/threading/future/future.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <library/cpp/testing/unittest/registar.h> class TMockDbSchemeResolver : public NYql::IDbSchemeResolver { @@ -70,7 +70,7 @@ public: } private: - TThreadPool MtpQueue; + TThreadPool MtpQueue; THashMap<TString, IDbSchemeResolver::TTableResult> Tables; }; diff --git a/ydb/core/testlib/tablet_helpers.cpp b/ydb/core/testlib/tablet_helpers.cpp index a853040b93..88bec0bf84 100644 --- a/ydb/core/testlib/tablet_helpers.cpp +++ b/ydb/core/testlib/tablet_helpers.cpp @@ -214,7 +214,7 @@ namespace NKikimr { } bool IsTabletEvent(const TAutoPtr<IEventHandle>& event, ui64 tabletId) const { - if (DeletedTablets.contains(tabletId)) + if (DeletedTablets.contains(tabletId)) return false; auto it = TabletLeaders.find(tabletId); @@ -280,7 +280,7 @@ namespace NKikimr { TTabletTracer::OnEvent(runtime, event); TActorId actor = event->Recipient; - if (KillOnCommit && IsCommitResult(event) && HideCommitsFrom.contains(actor)) { + if (KillOnCommit && IsCommitResult(event) && HideCommitsFrom.contains(actor)) { // We dropped one of the previous TEvCommitResult coming to this Executore actor // after that we must drop all TEvCommitResult until this Executor dies if (ENABLE_REBOOT_DISPATCH_LOG) @@ -330,7 +330,7 @@ namespace NKikimr { TDispatchOptions rebootOptions; rebootOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvRestored, 2)); rebootOptions.CustomFinalCondition = [this]() -> bool { - return DeletedTablets.contains(TabletId); + return DeletedTablets.contains(TabletId); }; runtime.DispatchEvents(rebootOptions); @@ -657,7 +657,7 @@ namespace NKikimr { } void SetupChannelProfiles(TAppPrepare &app, ui32 domainId, ui32 nchannels) { - Y_VERIFY(app.Domains && app.Domains->Domains.contains(domainId)); + Y_VERIFY(app.Domains && app.Domains->Domains.contains(domainId)); auto& poolKinds = app.Domains->GetDomain(domainId).StoragePoolTypes; Y_VERIFY(!poolKinds.empty()); @@ -1370,7 +1370,7 @@ namespace NKikimr { void Handle(TEvHive::TEvInitiateTabletExternalBoot::TPtr &ev, const TActorContext &ctx) { ui64 tabletId = ev->Get()->Record.GetTabletID(); - if (!State->TabletIdToOwner.contains(tabletId)) { + if (!State->TabletIdToOwner.contains(tabletId)) { ctx.Send(ev->Sender, new TEvHive::TEvBootTabletReply(NKikimrProto::EReplyStatus::ERROR), 0, ev->Cookie); return; } diff --git a/ydb/core/testlib/tenant_runtime.cpp b/ydb/core/testlib/tenant_runtime.cpp index 974cc166d0..74f41c26bc 100644 --- a/ydb/core/testlib/tenant_runtime.cpp +++ b/ydb/core/testlib/tenant_runtime.cpp @@ -287,7 +287,7 @@ class TFakeTenantSlotBroker : public TActor<TFakeTenantSlotBroker>, public TTabl { auto *resp = new TEvTenantSlotBroker::TEvTenantState; resp->Record.SetTenantName(name); - if (State.contains(name)) + if (State.contains(name)) resp->Record.MutableRequiredSlots()->CopyFrom(State.at(name).GetRequiredSlots()); ctx.Send(sender, resp); } @@ -532,7 +532,7 @@ class TFakeHive : public TActor<TFakeHive>, public TTabletExecutedFlat { ping->Record.SetHiveGeneration(1); ctx.Send(ev->Sender, ping, IEventHandle::FlagTrackDelivery); - if (!SubDomainKeys.contains(info.Key)) + if (!SubDomainKeys.contains(info.Key)) ResolveKey(info.Key, ctx); } @@ -540,7 +540,7 @@ class TFakeHive : public TActor<TFakeHive>, public TTabletExecutedFlat { { auto &record = ev->Get()->Record; - UNIT_ASSERT(Clients.contains(ev->Sender)); + UNIT_ASSERT(Clients.contains(ev->Sender)); if (record.GetStatus() == TEvLocal::TEvStatus::StatusDead) { Clients.erase(ev->Sender); } else { @@ -585,11 +585,11 @@ class TFakeHive : public TActor<TFakeHive>, public TTabletExecutedFlat { ui64 missing = 0; THashMap<TString, TClientInfo> tenants; for (auto &pr : Clients) { - if (!SubDomainKeys.contains(pr.second.Key)) { + if (!SubDomainKeys.contains(pr.second.Key)) { return; } auto name = SubDomainKeys.at(pr.second.Key); - if (tenants.contains(name)) { + if (tenants.contains(name)) { auto &tenant = tenants[name]; if (pr.second.Status != TEvLocal::TEvStatus::StatusOk) tenant.Status = pr.second.Status; @@ -604,7 +604,7 @@ class TFakeHive : public TActor<TFakeHive>, public TTabletExecutedFlat { for (auto &pr : tenants) { if (pr.second.Status != TEvLocal::TEvStatus::StatusOk) { ++missing; - } else if (!ExpectedState.contains(pr.first)) { + } else if (!ExpectedState.contains(pr.first)) { return; } else if (ExpectedState[pr.first] != pr.second) { return; @@ -1170,7 +1170,7 @@ void CheckTenantPoolStatus(TTenantTestRuntime &runtime, ui32 domain, auto reply = runtime.GrabEdgeEventRethrow<TEvTenantPool::TEvTenantPoolStatus>(handle); auto &rec = reply->Record; for (auto &slot : rec.GetSlots()) { - UNIT_ASSERT(status.contains(slot.GetId())); + UNIT_ASSERT(status.contains(slot.GetId())); auto &entry = status[slot.GetId()]; UNIT_ASSERT_VALUES_EQUAL(slot.GetId(), entry.GetId()); UNIT_ASSERT_VALUES_EQUAL(slot.GetType(), entry.GetType()); diff --git a/ydb/core/testlib/test_client.cpp b/ydb/core/testlib/test_client.cpp index d4907c26f1..00a78dddec 100644 --- a/ydb/core/testlib/test_client.cpp +++ b/ydb/core/testlib/test_client.cpp @@ -1735,7 +1735,7 @@ namespace Tests { } TString TClient::CreateStoragePool(const TString& poolKind, const TString& partOfName, ui32 groups) { - Y_VERIFY(StoragePoolTypes.contains(poolKind)); + Y_VERIFY(StoragePoolTypes.contains(poolKind)); const TString poolName = Sprintf("name_%s_kind_%s", partOfName.c_str(), poolKind.c_str()); const ui64 poolId = THash<TString>()(poolName); @@ -2298,7 +2298,7 @@ namespace Tests { } void TTenants::Run(const TString &name, ui32 nodes) { - Y_VERIFY(!Tenants.contains(name)); + Y_VERIFY(!Tenants.contains(name)); Y_VERIFY(Availabe() >= nodes); Tenants[name] = {}; @@ -2306,7 +2306,7 @@ namespace Tests { } void TTenants::Stop(const TString &name) { - Y_VERIFY(Tenants.contains(name)); + Y_VERIFY(Tenants.contains(name)); Free(name, Size(name)); Tenants.erase(name); @@ -2321,21 +2321,21 @@ namespace Tests { } void TTenants::Add(const TString &name, ui32 nodes) { - Y_VERIFY(Tenants.contains(name)); + Y_VERIFY(Tenants.contains(name)); Y_VERIFY(Availabe() >= nodes); return RunNodes(name, nodes); } void TTenants::Free(const TString &name, ui32 nodes) { - Y_VERIFY(Tenants.contains(name)); + Y_VERIFY(Tenants.contains(name)); Y_VERIFY(Size(name) >= nodes); return StopNodes(name, nodes); } void TTenants::FreeNode(const TString &name, ui32 nodeIdx) { - Y_VERIFY(Tenants.contains(name)); + Y_VERIFY(Tenants.contains(name)); Y_VERIFY(Size(name) >= 1); return StopPaticularNode(name, nodeIdx); @@ -2358,13 +2358,13 @@ namespace Tests { } const TVector<ui32> &TTenants::List(const TString &name) const { - Y_VERIFY(Tenants.contains(name)); + Y_VERIFY(Tenants.contains(name)); return Tenants.at(name); } ui32 TTenants::Size(const TString &name) const { - if (!Tenants.contains(name)) + if (!Tenants.contains(name)) return 0; return List(name).size(); } diff --git a/ydb/core/tracing/trace_collection.cpp b/ydb/core/tracing/trace_collection.cpp index d9b1645070..70e507f67c 100644 --- a/ydb/core/tracing/trace_collection.cpp +++ b/ydb/core/tracing/trace_collection.cpp @@ -121,7 +121,7 @@ void TTraceCollection::GetTabletIDs(TVector<ui64>& tabletIDs) const { bool TTraceCollection::HasTabletID(ui64 tabletID) const { - return Indexes.contains(tabletID); + return Indexes.contains(tabletID); } bool TTraceCollection::GetTraces(ui64 tabletID, TVector<TTraceID>& result) { diff --git a/ydb/core/tx/columnshard/columnshard__progress_tx.cpp b/ydb/core/tx/columnshard/columnshard__progress_tx.cpp index 9caf23e866..f9b3acfaa1 100644 --- a/ydb/core/tx/columnshard/columnshard__progress_tx.cpp +++ b/ydb/core/tx/columnshard/columnshard__progress_tx.cpp @@ -73,7 +73,7 @@ public: Self->ProtectSchemaSeqNo(meta.Body.GetSeqNo(), txc); for (TActorId subscriber : meta.NotifySubscribers) { TxEvents.emplace_back(subscriber, 0, - MakeHolder<TEvColumnShard::TEvNotifyTxCompletionResult>(Self->TabletID(), txId)); + MakeHolder<TEvColumnShard::TEvNotifyTxCompletionResult>(Self->TabletID(), txId)); } Self->AltersInFlight.erase(txId); break; diff --git a/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp b/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp index 673115d22b..4275bd7a12 100644 --- a/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp +++ b/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp @@ -34,7 +34,7 @@ struct TTxCoordinator::TTxRestartMediatorQueue : public TTransactionBase<TTxCoor Y_VERIFY(unconfirmedAffectedSet.size() == it.second.size(), "Incosistent affected set in mem in DB for txId %" PRIu64, it.first); for (const TTabletId affectedTabletId : it.second) { - Y_VERIFY(unconfirmedAffectedSet.contains(affectedTabletId), + Y_VERIFY(unconfirmedAffectedSet.contains(affectedTabletId), "Incosistent affected set in mem in DB for txId %" PRIu64 " missing tabletId %" PRIu64, it.first, affectedTabletId); } diff --git a/ydb/core/tx/datashard/backup_unit.cpp b/ydb/core/tx/datashard/backup_unit.cpp index 002b3e74b2..039ed3fc98 100644 --- a/ydb/core/tx/datashard/backup_unit.cpp +++ b/ydb/core/tx/datashard/backup_unit.cpp @@ -74,7 +74,7 @@ protected: return exp->CreateUploader(self, txId, columns, backup); }; - THolder<IBuffer> buffer{exp->CreateBuffer(columns, rowsLimit, bytesLimit)}; + THolder<IBuffer> buffer{exp->CreateBuffer(columns, rowsLimit, bytesLimit)}; THolder<NTable::IScan> scan{CreateExportScan(std::move(buffer), createUploader)}; const auto& taskName = appData->DataShardConfig.GetBackupTaskName(); diff --git a/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp b/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp index ee90c2fc2b..52b719190c 100644 --- a/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp +++ b/ydb/core/tx/datashard/build_distributed_erase_tx_out_rs_unit.cpp @@ -97,7 +97,7 @@ public: Y_VERIFY(DataShard.GetUserTables().contains(tableId)); const TUserTable& tableInfo = *DataShard.GetUserTables().at(tableId); - THolder<IEraseRowsCondition> condition{CreateEraseRowsCondition(request)}; + THolder<IEraseRowsCondition> condition{CreateEraseRowsCondition(request)}; Y_VERIFY(condition.Get()); condition->Prepare(txc.DB.GetRowScheme(tableInfo.LocalTid), 0); diff --git a/ydb/core/tx/datashard/datashard.cpp b/ydb/core/tx/datashard/datashard.cpp index d86568b4a1..9d383cc1af 100644 --- a/ydb/core/tx/datashard/datashard.cpp +++ b/ydb/core/tx/datashard/datashard.cpp @@ -2609,7 +2609,7 @@ public: auto it = pathId ? Self->GetUserTables().find(pathId.LocalPathId) : Self->GetUserTables().begin(); Y_VERIFY(it != Self->GetUserTables().end()); - Reply = MakeHolder<TEvDataShard::TEvGetRemovedRowVersionsResult>(txc.DB.GetRemovedRowVersions(it->second->LocalTid)); + Reply = MakeHolder<TEvDataShard::TEvGetRemovedRowVersionsResult>(txc.DB.GetRemovedRowVersions(it->second->LocalTid)); return true; } diff --git a/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp b/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp index 026b14e461..65692916d4 100644 --- a/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp +++ b/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp @@ -558,8 +558,8 @@ void TDataShard::Handle(TEvDataShard::TEvConditionalEraseRowsRequest::TPtr& ev, if (CheckUnit(column->second.Type, record.GetExpiration().GetColumnUnit(), error)) { localTxId = ++NextTieBreakerIndex; const auto tableId = TTableId(PathOwnerId, localPathId, record.GetSchemaVersion()); - scan.Reset(CreateCondEraseScan(this, ev->Sender, tableId, localTxId, - THolder(CreateEraseRowsCondition(record)), record.GetLimits(), GetIndexes(record))); + scan.Reset(CreateCondEraseScan(this, ev->Sender, tableId, localTxId, + THolder(CreateEraseRowsCondition(record)), record.GetLimits(), GetIndexes(record))); } else { badRequest(error); } diff --git a/ydb/core/tx/datashard/datashard__get_state_tx.cpp b/ydb/core/tx/datashard/datashard__get_state_tx.cpp index 552d27fd64..f379e69963 100644 --- a/ydb/core/tx/datashard/datashard__get_state_tx.cpp +++ b/ydb/core/tx/datashard/datashard__get_state_tx.cpp @@ -14,7 +14,7 @@ bool TDataShard::TTxGetShardState::Execute(TTransactionContext& txc, const TActo Y_UNUSED(txc); Y_UNUSED(ctx); - Result = MakeHolder<TEvDataShard::TEvGetShardStateResult>(Self->TabletID(), Self->State); + Result = MakeHolder<TEvDataShard::TEvGetShardStateResult>(Self->TabletID(), Self->State); if (Self->Pipeline.HasDrop()) Result->Record.SetDropTxId(Self->Pipeline.CurrentSchemaTxId()); return true; diff --git a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp index 7dfb1a294e..144e65aaed 100644 --- a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp +++ b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp @@ -46,8 +46,8 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa if (status != NKikimrTxDataShard::TError::OK) { auto kind = static_cast<NKikimrTxDataShard::ETransactionKind>(Kind); - result.Reset(new TEvDataShard::TEvProposeTransactionResult(kind, Self->TabletID(), TxId, - NKikimrTxDataShard::TEvProposeTransactionResult::ERROR)); + result.Reset(new TEvDataShard::TEvProposeTransactionResult(kind, Self->TabletID(), TxId, + NKikimrTxDataShard::TEvProposeTransactionResult::ERROR)); result->AddError(status, errMessage); } } diff --git a/ydb/core/tx/datashard/datashard__s3.cpp b/ydb/core/tx/datashard/datashard__s3.cpp index 2f7a74bbab..727007e4c5 100644 --- a/ydb/core/tx/datashard/datashard__s3.cpp +++ b/ydb/core/tx/datashard/datashard__s3.cpp @@ -47,7 +47,7 @@ public: const ui64 tableId = Ev->Get()->Record.GetTableId(); const ui64 maxKeys = Ev->Get()->Record.GetMaxKeys(); - if (!Self->TableInfos.contains(tableId)) { + if (!Self->TableInfos.contains(tableId)) { SetError(NKikimrTxDataShard::TError::SCHEME_ERROR, Sprintf("Unknown table id %" PRIu64, tableId)); return true; } diff --git a/ydb/core/tx/datashard/datashard__stats.cpp b/ydb/core/tx/datashard/datashard__stats.cpp index 129a14dca5..e481bdcb67 100644 --- a/ydb/core/tx/datashard/datashard__stats.cpp +++ b/ydb/core/tx/datashard/datashard__stats.cpp @@ -82,7 +82,7 @@ public: Result = new TEvDataShard::TEvGetTableStatsResult(Self->TabletID(), Self->PathOwnerId, tableId); - if (!Self->TableInfos.contains(tableId)) + if (!Self->TableInfos.contains(tableId)) return true; if (Ev->Get()->Record.GetCollectKeySample()) { @@ -180,7 +180,7 @@ void TDataShard::Handle(TEvPrivate::TEvAsyncTableStats::TPtr& ev, const TActorCo LOG_DEBUG(ctx, NKikimrServices::TX_DATASHARD, "Stats rebuilt at datashard %" PRIu64, TabletID()); i64 dataSize = 0; - if (TableInfos.contains(tableId)) { + if (TableInfos.contains(tableId)) { const TUserTable& tableInfo = *TableInfos[tableId]; if (!tableInfo.StatsUpdateInProgress) { diff --git a/ydb/core/tx/datashard/datashard_active_transaction.cpp b/ydb/core/tx/datashard/datashard_active_transaction.cpp index 0226bd42e2..4761b81e0b 100644 --- a/ydb/core/tx/datashard/datashard_active_transaction.cpp +++ b/ydb/core/tx/datashard/datashard_active_transaction.cpp @@ -428,7 +428,7 @@ TValidatedDataTx::TPtr TActiveTransaction::BuildDataTx(TDataShard *self, bool TActiveTransaction::BuildSchemeTx() { Y_VERIFY(TxBody); - SchemeTx.Reset(new NKikimrTxDataShard::TFlatSchemeTransaction); + SchemeTx.Reset(new NKikimrTxDataShard::TFlatSchemeTransaction); bool res = SchemeTx->ParseFromArray(TxBody.data(), TxBody.size()); if (!res) return false; @@ -490,7 +490,7 @@ bool TActiveTransaction::BuildSchemeTx() bool TActiveTransaction::BuildSnapshotTx() { Y_VERIFY(TxBody); - SnapshotTx.Reset(new NKikimrTxDataShard::TSnapshotTransaction); + SnapshotTx.Reset(new NKikimrTxDataShard::TSnapshotTransaction); if (!SnapshotTx->ParseFromArray(TxBody.data(), TxBody.size())) { return false; } @@ -515,7 +515,7 @@ bool TDistributedEraseTx::TryParse(const TString& serialized) { bool TActiveTransaction::BuildDistributedEraseTx() { Y_VERIFY(TxBody); - DistributedEraseTx.Reset(new TDistributedEraseTx); + DistributedEraseTx.Reset(new TDistributedEraseTx); return DistributedEraseTx->TryParse(TxBody); } diff --git a/ydb/core/tx/datashard/datashard_common_upload.cpp b/ydb/core/tx/datashard/datashard_common_upload.cpp index 088da2b521..4a93bcd4a4 100644 --- a/ydb/core/tx/datashard/datashard_common_upload.cpp +++ b/ydb/core/tx/datashard/datashard_common_upload.cpp @@ -18,7 +18,7 @@ bool TCommonUploadOps<TEvRequest, TEvResponse>::Execute(TDataShard* self, TTrans { const auto& record = Ev->Get()->Record; - Result = MakeHolder<TEvResponse>(self->TabletID()); + Result = MakeHolder<TEvResponse>(self->TabletID()); TInstant deadline = TInstant::MilliSeconds(record.GetCancelDeadlineMs()); if (deadline && deadline < AppData()->TimeProvider->Now()) { diff --git a/ydb/core/tx/datashard/datashard_direct_erase.cpp b/ydb/core/tx/datashard/datashard_direct_erase.cpp index 826819596f..a9db281c44 100644 --- a/ydb/core/tx/datashard/datashard_direct_erase.cpp +++ b/ydb/core/tx/datashard/datashard_direct_erase.cpp @@ -177,7 +177,7 @@ bool TDirectTxErase::Execute(TDataShard* self, TTransactionContext& txc, { const auto& record = Ev->Get()->Record; - Result = MakeHolder<TEvDataShard::TEvEraseRowsResponse>(); + Result = MakeHolder<TEvDataShard::TEvEraseRowsResponse>(); Result->Record.SetTabletID(self->TabletID()); const auto params = TExecuteParams::ForExecute(this, &txc, readVersion, writeVersion); diff --git a/ydb/core/tx/datashard/datashard_impl.h b/ydb/core/tx/datashard/datashard_impl.h index 11313474f8..fd4c628c56 100644 --- a/ydb/core/tx/datashard/datashard_impl.h +++ b/ydb/core/tx/datashard/datashard_impl.h @@ -1511,7 +1511,7 @@ private: } void ResendLoans(ui64 ownerTabletId, const TActorContext& ctx) { - if (!LoanReturns.contains(ownerTabletId)) + if (!LoanReturns.contains(ownerTabletId)) return; THashSet<TLogoBlobID> toResend; @@ -1523,7 +1523,7 @@ private: } void AutoAckLoans(ui64 deadTabletId, const TActorContext& ctx) { - if (!LoanReturns.contains(deadTabletId)) + if (!LoanReturns.contains(deadTabletId)) return; TVector<TLogoBlobID> partMetaVec(LoanReturns[deadTabletId].PartMeta.begin(), LoanReturns[deadTabletId].PartMeta.end()); @@ -1532,7 +1532,7 @@ private: } void LoanDone(TLogoBlobID partMeta, const TActorContext& ctx) { - if (!LoanOwners.contains(partMeta)) + if (!LoanOwners.contains(partMeta)) return; ui64 ownerTabletId = LoanOwners[partMeta]; @@ -1546,7 +1546,7 @@ private: } bool Has(ui64 ownerTabletId, TActorId pipeClientActorId) const { - return LoanReturns.contains(ownerTabletId) && LoanReturns.FindPtr(ownerTabletId)->PipeToOwner == pipeClientActorId; + return LoanReturns.contains(ownerTabletId) && LoanReturns.FindPtr(ownerTabletId)->PipeToOwner == pipeClientActorId; } bool Empty() const { @@ -1570,7 +1570,7 @@ private: } void SaveSnapshotForSending(ui64 dstTabletId, TAutoPtr<NKikimrTxDataShard::TEvSplitTransferSnapshot> snapshot) { - Y_VERIFY(Dst.contains(dstTabletId)); + Y_VERIFY(Dst.contains(dstTabletId)); DataToSend[dstTabletId] = snapshot; } @@ -1583,7 +1583,7 @@ private: } void DoSend(ui64 dstTabletId, const TActorContext &ctx) { - Y_VERIFY(Dst.contains(dstTabletId)); + Y_VERIFY(Dst.contains(dstTabletId)); NTabletPipe::TClientConfig clientConfig; PipesToDstShards[dstTabletId] = ctx.Register(NTabletPipe::CreateClient(ctx.SelfID, dstTabletId, clientConfig)); @@ -1608,7 +1608,7 @@ private: } void AckSnapshot(ui64 dstTabletId, const TActorContext &ctx) { - if (!DataToSend.contains(dstTabletId)) + if (!DataToSend.contains(dstTabletId)) return; NTabletPipe::CloseClient(ctx, PipesToDstShards[dstTabletId]); @@ -1625,7 +1625,7 @@ private: } bool Has(ui64 dstTabletId, TActorId pipeClientActorId) const { - return PipesToDstShards.contains(dstTabletId) && *PipesToDstShards.FindPtr(dstTabletId) == pipeClientActorId; + return PipesToDstShards.contains(dstTabletId) && *PipesToDstShards.FindPtr(dstTabletId) == pipeClientActorId; } void Shutdown(const TActorContext &ctx) { @@ -2388,7 +2388,7 @@ protected: ev->Record.MutableTableStats()->SetSearchHeight(ti.Stats.SearchHeight); ev->Record.MutableTableStats()->SetLastFullCompactionTs(ti.Stats.LastFullCompaction.Seconds()); - if (!ti.Stats.PartOwners.contains(TabletID())) { + if (!ti.Stats.PartOwners.contains(TabletID())) { ev->Record.AddUserTablePartOwners(TabletID()); } for (const auto& pi : ti.Stats.PartOwners) { diff --git a/ydb/core/tx/datashard/datashard_outreadset.cpp b/ydb/core/tx/datashard/datashard_outreadset.cpp index 36ded0e897..b5329f4358 100644 --- a/ydb/core/tx/datashard/datashard_outreadset.cpp +++ b/ydb/core/tx/datashard/datashard_outreadset.cpp @@ -34,8 +34,8 @@ bool TOutReadSets::LoadReadSets(NIceDb::TNiceDb& db) { TReadSetKey rsInfo(txId, origin, source, target); - Y_VERIFY(!CurrentReadSets.contains(seqNo)); - Y_VERIFY(!CurrentReadSetInfos.contains(rsInfo)); + Y_VERIFY(!CurrentReadSets.contains(seqNo)); + Y_VERIFY(!CurrentReadSetInfos.contains(rsInfo)); CurrentReadSets[seqNo] = rsInfo; CurrentReadSetInfos[rsInfo] = seqNo; @@ -51,8 +51,8 @@ bool TOutReadSets::LoadReadSets(NIceDb::TNiceDb& db) { void TOutReadSets::SaveReadSet(NIceDb::TNiceDb& db, ui64 seqNo, ui64 step, const TReadSetKey& rsInfo, TString body) { using Schema = TDataShard::Schema; - Y_VERIFY(!CurrentReadSets.contains(seqNo)); - Y_VERIFY(!CurrentReadSetInfos.contains(rsInfo)); + Y_VERIFY(!CurrentReadSets.contains(seqNo)); + Y_VERIFY(!CurrentReadSetInfos.contains(rsInfo)); CurrentReadSetInfos[rsInfo] = seqNo; CurrentReadSets[seqNo] = rsInfo; @@ -103,7 +103,7 @@ void TOutReadSets::SaveAck(const TActorContext &ctx, TAutoPtr<TEvTxProcessing::T ReadSetAcks.emplace_back(ev.Release()); AckedSeqno.insert(seqno); - if (CurrentReadSets.contains(seqno)) { + if (CurrentReadSets.contains(seqno)) { TReadSetKey rsInfo(txId, Self->TabletID(), sender, dest); Y_VERIFY(CurrentReadSetInfos[rsInfo] == seqno); @@ -152,7 +152,7 @@ bool TOutReadSets::ResendRS(NTabletFlatExecutor::TTransactionContext &txc, const using Schema = TDataShard::Schema; NIceDb::TNiceDb db(txc.DB); - if (AckedSeqno.contains(seqNo)) { + if (AckedSeqno.contains(seqNo)) { // Do not resend if we've already got ACK back, but not applied it to DB // Also, it is a good place to actually apply ACK(s) diff --git a/ydb/core/tx/datashard/datashard_outreadset.h b/ydb/core/tx/datashard/datashard_outreadset.h index 901fd4d827..079ef64ef9 100644 --- a/ydb/core/tx/datashard/datashard_outreadset.h +++ b/ydb/core/tx/datashard/datashard_outreadset.h @@ -63,7 +63,7 @@ public: bool Empty() const { return CurrentReadSets.empty(); } bool HasAcks() const { return ! ReadSetAcks.empty(); } - bool Has(const TReadSetKey& rsKey) const { return CurrentReadSetInfos.contains(rsKey); } + bool Has(const TReadSetKey& rsKey) const { return CurrentReadSetInfos.contains(rsKey); } ui64 CountReadSets() const { return CurrentReadSets.size(); } ui64 CountAcks() const { return ReadSetAcks.size(); } diff --git a/ydb/core/tx/datashard/datashard_pipeline.cpp b/ydb/core/tx/datashard/datashard_pipeline.cpp index 3498162c17..22fa86235f 100644 --- a/ydb/core/tx/datashard/datashard_pipeline.cpp +++ b/ydb/core/tx/datashard/datashard_pipeline.cpp @@ -1149,8 +1149,8 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: << " parsed tx body " << txBody; tx->SetAbortedFlag(); - tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult( - rec.GetTxKind(), Self->TabletID(), tx->GetTxId(), NKikimrTxDataShard::TEvProposeTransactionResult::ERROR)); + tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult( + rec.GetTxKind(), Self->TabletID(), tx->GetTxId(), NKikimrTxDataShard::TEvProposeTransactionResult::ERROR)); tx->Result()->SetProcessError(NKikimrTxDataShard::TError::BAD_ARGUMENT, error); LOG_ERROR_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, error); @@ -1218,10 +1218,10 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: if (!dataTx->Ready() && !dataTx->RequirePrepare()) { tx->SetAbortedFlag(); - tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), + tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), Self->TabletID(), tx->GetTxId(), - NKikimrTxDataShard::TEvProposeTransactionResult::ERROR)); + NKikimrTxDataShard::TEvProposeTransactionResult::ERROR)); tx->Result()->SetProcessError(dataTx->Code(), dataTx->GetErrors()); LOG_ERROR_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, @@ -1280,10 +1280,10 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: } else if (tx->IsReadTable() && dataTx->GetReadTableTransaction().HasSnapshotStep() && dataTx->GetReadTableTransaction().HasSnapshotTxId()) { tx->SetAbortedFlag(); TString err = "Ambiguous snapshot info. Cannot use both MVCC and read table snapshots in one transaction"; - tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), + tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), Self->TabletID(), tx->GetTxId(), - NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST)); + NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST)); tx->Result()->SetProcessError(NKikimrTxDataShard::TError::BAD_ARGUMENT, err); LOG_ERROR_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, err); @@ -1291,10 +1291,10 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: } else if (tx->IsKqpScanTransaction() && dataTx->GetKqpTransaction().HasSnapshot()) { tx->SetAbortedFlag(); TString err = "Ambiguous snapshot info. Cannot use both MVCC and kqp scan snapshots in one transaction"; - tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), + tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), Self->TabletID(), tx->GetTxId(), - NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST)); + NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST)); tx->Result()->SetProcessError(NKikimrTxDataShard::TError::BAD_ARGUMENT,err); LOG_ERROR_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, err); @@ -1304,10 +1304,10 @@ TOperation::TPtr TPipeline::BuildOperation(TEvDataShard::TEvProposeTransaction:: if(tx->IsMvccSnapshotRead() && (!tx->IsImmediate() || !tx->IsReadOnly())) { tx->SetAbortedFlag(); TString err = "Snapshot read must be an immediate read only transaction"; - tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), + tx->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(rec.GetTxKind(), Self->TabletID(), tx->GetTxId(), - NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST)); + NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST)); tx->Result()->SetProcessError(NKikimrTxDataShard::TError::BAD_ARGUMENT,err); LOG_ERROR_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, err); diff --git a/ydb/core/tx/datashard/datashard_split_dst.cpp b/ydb/core/tx/datashard/datashard_split_dst.cpp index 6575081001..42bb3b6655 100644 --- a/ydb/core/tx/datashard/datashard_split_dst.cpp +++ b/ydb/core/tx/datashard/datashard_split_dst.cpp @@ -129,7 +129,7 @@ public: void LegacyInitSchema(TTransactionContext& txc) { const auto& tableScheme = Ev->Get()->Record.GetUserTableScheme(); TString tableName = TDataShard::Schema::UserTablePrefix + tableScheme.GetName(); - if (!txc.DB.GetScheme().TableNames.contains(tableName)) { // TODO: properly check if table has already been created + if (!txc.DB.GetScheme().TableNames.contains(tableName)) { // TODO: properly check if table has already been created NKikimrSchemeOp::TTableDescription newTableScheme(tableScheme); // Get this shard's range boundaries from the split/merge description diff --git a/ydb/core/tx/datashard/datashard_trans_queue.cpp b/ydb/core/tx/datashard/datashard_trans_queue.cpp index d7096c25b3..49374c2700 100644 --- a/ydb/core/tx/datashard/datashard_trans_queue.cpp +++ b/ydb/core/tx/datashard/datashard_trans_queue.cpp @@ -146,7 +146,7 @@ bool TTransQueue::Load(NIceDb::TNiceDb& db) { success, error, dataSize, rows); auto saved = SchemaOps.insert(std::make_pair(op.TxId, op)); TSchemaOperation * savedOp = &saved.first->second; - if (schemaTxs.contains(txId)) { // is not done yet + if (schemaTxs.contains(txId)) { // is not done yet Self->Pipeline.SetSchemaOp(savedOp); } else { savedOp->Done = true; diff --git a/ydb/core/tx/datashard/datashard_trans_queue.h b/ydb/core/tx/datashard/datashard_trans_queue.h index 1d392676da..dd64c9e49d 100644 --- a/ydb/core/tx/datashard/datashard_trans_queue.h +++ b/ydb/core/tx/datashard/datashard_trans_queue.h @@ -53,7 +53,7 @@ public: return it->second; return nullptr; } - bool Has(ui64 txId) const {return TxsInFly.contains(txId); } + bool Has(ui64 txId) const {return TxsInFly.contains(txId); } ui64 TxPlanned() const { return PlannedTxs.size(); } const TSet<TStepOrder> &GetPlan() const { return PlannedTxs; } diff --git a/ydb/core/tx/datashard/datashard_user_table.cpp b/ydb/core/tx/datashard/datashard_user_table.cpp index 70bc940073..13521640c4 100644 --- a/ydb/core/tx/datashard/datashard_user_table.cpp +++ b/ydb/core/tx/datashard/datashard_user_table.cpp @@ -488,7 +488,7 @@ void TUserTable::ApplyAlter( ui32 colId = col.first; const TUserColumn& column = col.second; - if (!oldTable.Columns.contains(colId)) { + if (!oldTable.Columns.contains(colId)) { for (ui32 tid : tids) { alter.AddColumn(tid, column.Name, colId, column.Type, column.NotNull); } @@ -504,7 +504,7 @@ void TUserTable::ApplyAlter( const TUserTable::TUserColumn * oldCol = oldTable.Columns.FindPtr(colId); Y_VERIFY(oldCol); Y_VERIFY(oldCol->Name == col.GetName()); - Y_VERIFY(!Columns.contains(colId)); + Y_VERIFY(!Columns.contains(colId)); for (ui32 tid : tids) { alter.DropColumn(tid, colId); diff --git a/ydb/core/tx/datashard/datashard_ut_change_collector.cpp b/ydb/core/tx/datashard/datashard_ut_change_collector.cpp index cdce49ecdb..e514c6594a 100644 --- a/ydb/core/tx/datashard/datashard_ut_change_collector.cpp +++ b/ydb/core/tx/datashard/datashard_ut_change_collector.cpp @@ -126,7 +126,7 @@ THolder<NSchemeCache::TSchemeCacheNavigate> Navigate(TTestActorRuntime& runtime, UNIT_ASSERT(response->ErrorCount == 0); UNIT_ASSERT_VALUES_EQUAL(response->ResultSet.size(), 1); - return THolder(response); + return THolder(response); } using TStructKey = TVector<std::pair<TString, ui32>>; diff --git a/ydb/core/tx/datashard/datashard_ut_common.cpp b/ydb/core/tx/datashard/datashard_ut_common.cpp index d754f7ad0e..6775001363 100644 --- a/ydb/core/tx/datashard/datashard_ut_common.cpp +++ b/ydb/core/tx/datashard/datashard_ut_common.cpp @@ -768,7 +768,7 @@ ui64 TFakeMiniKQLProxy::Plan(ui64 stepId, const TMap<ui64, TFakeProxyTx::TPtr>& if ((prevTxId+1) != immEvent->GetTxId()) break; //Cerr << ">>> imm to " << shard << Endl; - UNIT_ASSERT(ShardActors.contains(shard)); + UNIT_ASSERT(ShardActors.contains(shard)); THolder<IEventHandle> handle(new IEventHandle(ShardActors[shard], Tester.Sender, immEvent.Release())); runtime.Send(handle.Release()); immEvents.pop_front(); diff --git a/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp b/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp index 87a51ef80a..6fd99c18b1 100644 --- a/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp +++ b/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(EraseRowsTests) { EraseRows(server, sender, "/Root/table-1", testTableId, {1}, SerializeKeys({1, 2})); auto content = ReadShardedTable(server, "/Root/table-1"); - UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "key = 3, value = 2020-04-15T00:00:00.000000Z"); + UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "key = 3, value = 2020-04-15T00:00:00.000000Z"); } Y_UNIT_TEST_WITH_MVCC(EraseRowsShouldSuccess) { @@ -454,7 +454,7 @@ Y_UNIT_TEST_SUITE(EraseRowsTests) { UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Record.GetStatus(), TEvResponse::ProtoRecordType::OK); auto content = ReadShardedTable(server, "/Root/table-1"); - UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), Strip(afterErase)); + UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), Strip(afterErase)); } Y_UNIT_TEST_WITH_MVCC(ConditionalEraseRowsShouldErase) { @@ -824,7 +824,7 @@ Y_UNIT_TEST_SUITE(DistributedEraseTests) { UNIT_ASSERT(response->ErrorCount == 0); UNIT_ASSERT_VALUES_EQUAL(response->ResultSet.size(), 1); - return THolder(response); + return THolder(response); } NDataShard::TIndexes GetIndexes(TServer::TPtr server, const TActorId& sender, const TString& path) { @@ -1006,7 +1006,7 @@ Y_UNIT_TEST_SUITE(DistributedEraseTests) { for (const auto& [path, expectedContent] : afterErase) { auto content = ReadShardedTable(server, path); - UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), Strip(expectedContent)); + UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), Strip(expectedContent)); } } @@ -1146,15 +1146,15 @@ tkey = 100, key = 4 } { auto content = ReadShardedTable(server, "/Root/table-1"); - UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "key = 3, skey = 90, tkey = 900, value = 2030-04-15T00:00:00.000000Z"); + UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "key = 3, skey = 90, tkey = 900, value = 2030-04-15T00:00:00.000000Z"); } { auto content = ReadShardedTable(server, "/Root/table-1/by_skey/indexImplTable"); - UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "skey = 90, key = 3"); + UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "skey = 90, key = 3"); } { auto content = ReadShardedTable(server, "/Root/table-1/by_tkey/indexImplTable"); - UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "tkey = 900, key = 3"); + UNIT_ASSERT_STRINGS_EQUAL(StripInPlace(content), "tkey = 900, key = 3"); } // restore previous value in ttl column diff --git a/ydb/core/tx/datashard/datashard_ut_order.cpp b/ydb/core/tx/datashard/datashard_ut_order.cpp index 32472dce59..c04ebfd039 100644 --- a/ydb/core/tx/datashard/datashard_ut_order.cpp +++ b/ydb/core/tx/datashard/datashard_ut_order.cpp @@ -1171,7 +1171,7 @@ Y_UNIT_TEST_WITH_MVCC(ScanFollowedByUpdate) { //Cerr << res.DebugString() << Endl; for (auto &row : res.rows()) { auto &val = row.items(0).text_value(); - UNIT_ASSERT(ref.contains(val)); + UNIT_ASSERT(ref.contains(val)); ref.erase(val); } @@ -1442,7 +1442,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderLockLost, UseMvcc, UseNewEngine) { auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -1578,7 +1578,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestMvccReadDoesntBlockWrites) { auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -1713,7 +1713,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderReadOnlyAllowed, UseMvcc, UseNewEngine) { auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -1823,7 +1823,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderNonConflictingWrites, UseMvcc, UseNewEngine) { auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -1945,7 +1945,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestOutOfOrderRestartLocksSingleWithoutBarrier) { auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -2090,7 +2090,7 @@ Y_UNIT_TEST_NEW_ENGINE(MvccTestOutOfOrderRestartLocksSingleWithoutBarrier) { auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -2231,7 +2231,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderRestartLocksReorderedWithoutBarrier, UseMvcc, Use auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle> &event) -> auto { if (event->GetTypeRewrite() == TEvTxProcessing::EvReadSet) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; @@ -2390,7 +2390,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderNoBarrierRestartImmediateLongTail, UseMvcc, UseNe break; } case TEvTxProcessing::EvReadSet: { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } case EventSpaceBegin(TKikimrEvents::ES_PRIVATE) + 0 /* EvProgressTransaction */: { @@ -2398,7 +2398,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderNoBarrierRestartImmediateLongTail, UseMvcc, UseNe if (blockProgressEvents && tabletId == table1shards[0]) { if (bypassProgressEvents == 0) { Cerr << "... captured TEvProgressTransaction" << Endl; - progressEvents.push_back(std::move(event)); + progressEvents.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } Cerr << "... bypass for TEvProgressTransaction" << Endl; @@ -2597,14 +2597,14 @@ Y_UNIT_TEST_QUAD(TestCopyTableNoDeadlock, UseMvcc, UseNewEngine) { case TEvTxProcessing::EvReadSet: Cerr << "---- observed EvReadSet ----" << Endl; if (captureReadSets) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; case TEvTxProxy::EvProposeTransaction: Cerr << "---- observed EvProposeTransaction ----" << Endl; if (captureTxProposes) { - txProposes.push_back(std::move(event)); + txProposes.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; @@ -2771,21 +2771,21 @@ Y_UNIT_TEST_NEW_ENGINE(TestPlannedCancelSplit) { case TEvDataShard::EvProposeTransaction: Cerr << "---- observed EvProposeTransaction ----" << Endl; if (captureTxPropose) { - txProposes.push_back(std::move(event)); + txProposes.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; case TEvDataShard::EvProposeTransactionResult: Cerr << "---- observed EvProposeTransactionResult ----" << Endl; if (captureTxProposeResult) { - txProposeResults.push_back(std::move(event)); + txProposeResults.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; case TEvDataShard::EvCancelTransactionProposal: Cerr << "---- observed EvCancelTransactionProposal ----" << Endl; if (captureTxCancel) { - txCancels.push_back(std::move(event)); + txCancels.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; @@ -2950,7 +2950,7 @@ Y_UNIT_TEST_QUAD(TestPlannedTimeoutSplit, UseMvcc, UseNewEngine) { switch (event->GetTypeRewrite()) { case TEvTxProxy::EvProposeTransaction: { Cerr << "---- observed EvProposeTransaction ----" << Endl; - txProposes.push_back(std::move(event)); + txProposes.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } default: @@ -3075,7 +3075,7 @@ Y_UNIT_TEST_QUAD(TestPlannedHalfOverloadedSplit, UseMvcc, UseNewEngine) { Cerr << "---- observed EvProposeTransactionResult ----" << Endl; if (txProposes.size() == 0) { // Capture the first propose - txProposes.push_back(std::move(event)); + txProposes.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; @@ -3084,7 +3084,7 @@ Y_UNIT_TEST_QUAD(TestPlannedHalfOverloadedSplit, UseMvcc, UseNewEngine) { Cerr << "---- observed EvProposeTransactionResult ----" << Endl; if (txProposes.size() > 0) { // Capture all propose results - txProposeResults.push_back(std::move(event)); + txProposeResults.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; @@ -3253,7 +3253,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestReadTableWriteConflict) { case TEvTxProcessing::EvReadSet: Cerr << "---- observed EvReadSet ----" << Endl; if (captureReadSets) { - readSets.push_back(std::move(event)); + readSets.push_back(std::move(event)); return TTestActorRuntime::EEventAction::DROP; } break; @@ -4034,7 +4034,7 @@ Y_UNIT_TEST_QUAD(TestShardRestartNoUndeterminedImmediate, UseMvcc, UseNewEngine) auto captureRS = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) -> auto { switch (ev->GetTypeRewrite()) { case TEvTxProcessing::TEvReadSet::EventType: { - readSets.push_back(std::move(ev)); + readSets.push_back(std::move(ev)); return TTestActorRuntime::EEventAction::DROP; } case EventSpaceBegin(TKikimrEvents::ES_PRIVATE) + 2 /* EvDelayedProposeTransaction */: { @@ -4153,7 +4153,7 @@ Y_UNIT_TEST_QUAD(TestShardRestartPlannedCommitShouldSucceed, UseMvcc, UseNewEngi switch (ev->GetTypeRewrite()) { case TEvTxProcessing::TEvReadSet::EventType: { Cerr << "... captured readset" << Endl; - readSets.push_back(std::move(ev)); + readSets.push_back(std::move(ev)); return TTestActorRuntime::EEventAction::DROP; } } @@ -4248,7 +4248,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestShardSnapshotReadNoEarlyReply) { auto* msg = ev->Get<TEvTablet::TEvCommit>(); if (isTableShard(msg->TabletID)) { Cerr << "... blocked commit for tablet " << msg->TabletID << Endl; - blockedCommits.push_back(std::move(ev)); + blockedCommits.push_back(std::move(ev)); return TTestActorRuntime::EEventAction::DROP; } break; @@ -4470,7 +4470,7 @@ Y_UNIT_TEST_TWIN(TestSnapshotReadAfterBrokenLockOutOfOrder, UseNewEngine) { switch (ev->GetTypeRewrite()) { case TEvTxProcessing::TEvReadSet::EventType: { Cerr << "... captured readset" << Endl; - readSets.push_back(std::move(ev)); + readSets.push_back(std::move(ev)); return TTestActorRuntime::EEventAction::DROP; } } @@ -4585,7 +4585,7 @@ Y_UNIT_TEST_TWIN(TestSnapshotReadAfterStuckRW, UseNewEngine) { switch (ev->GetTypeRewrite()) { case TEvTxProcessing::TEvReadSet::EventType: { Cerr << "... captured readset" << Endl; - readSets.push_back(THolder(ev.Release())); + readSets.push_back(THolder(ev.Release())); return TTestActorRuntime::EEventAction::DROP; } } diff --git a/ydb/core/tx/datashard/execution_unit.cpp b/ydb/core/tx/datashard/execution_unit.cpp index 9f6e13fa5c..c69e61646a 100644 --- a/ydb/core/tx/datashard/execution_unit.cpp +++ b/ydb/core/tx/datashard/execution_unit.cpp @@ -247,10 +247,10 @@ TOutputOpData::TResultPtr &TExecutionUnit::BuildResult(TOperation::TPtr op, NKikimrTxDataShard::TEvProposeTransactionResult::EStatus status) { auto kind = static_cast<NKikimrTxDataShard::ETransactionKind>(op->GetKind()); - op->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(kind, + op->Result().Reset(new TEvDataShard::TEvProposeTransactionResult(kind, DataShard.TabletID(), op->GetTxId(), - status)); + status)); if (DataShard.GetProcessingParams()) op->Result()->SetDomainCoordinators(*DataShard.GetProcessingParams()); diff --git a/ydb/core/tx/datashard/read_table_scan.cpp b/ydb/core/tx/datashard/read_table_scan.cpp index 63e94fde96..8acb818df9 100644 --- a/ydb/core/tx/datashard/read_table_scan.cpp +++ b/ydb/core/tx/datashard/read_table_scan.cpp @@ -289,9 +289,9 @@ public: , Finished(false) { if (tx.HasApiVersion() && tx.GetApiVersion() == NKikimrTxUserProxy::TReadTableTransaction::YDB_V1) { - Writer = MakeHolder<TRowsToYdbResult>(tx); + Writer = MakeHolder<TRowsToYdbResult>(tx); } else { - Writer = MakeHolder<TRowsToOldResult>(tx); + Writer = MakeHolder<TRowsToOldResult>(tx); } for (auto &col : tx.GetColumns()) diff --git a/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp b/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp index b3e5967eaf..c4e88edc49 100644 --- a/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp +++ b/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp @@ -115,7 +115,7 @@ namespace NLongTxService { void SendAcquireStep(ui64 coordinator) { if (WaitingCoordinators.insert(coordinator).second) { TXLOG_DEBUG("Sending acquire step to coordinator " << coordinator); - SendToTablet(coordinator, MakeHolder<TEvTxProxy::TEvAcquireReadStep>(coordinator)); + SendToTablet(coordinator, MakeHolder<TEvTxProxy::TEvAcquireReadStep>(coordinator)); } } diff --git a/ydb/core/tx/long_tx_service/commit_impl.cpp b/ydb/core/tx/long_tx_service/commit_impl.cpp index 3a2872bad0..fb9a5b832c 100644 --- a/ydb/core/tx/long_tx_service/commit_impl.cpp +++ b/ydb/core/tx/long_tx_service/commit_impl.cpp @@ -80,11 +80,11 @@ namespace NLongTxService { Y_VERIFY(tx.SerializeToString(&txBody)); TXLOG_DEBUG("Sending TEvProposeTransaction to ColumnShard# " << tabletId << " WriteId# " << writeId); - SendToTablet(tabletId, MakeHolder<TEvColumnShard::TEvProposeTransaction>( + SendToTablet(tabletId, MakeHolder<TEvColumnShard::TEvProposeTransaction>( NKikimrTxColumnShard::TX_KIND_COMMIT, SelfId(), TxId, - std::move(txBody))); + std::move(txBody))); WaitingShards.insert(tabletId); } Become(&TThis::StatePrepare); @@ -310,7 +310,7 @@ namespace NLongTxService { void CancelProposal() { for (const auto& pr : Params.ColumnShardWrites) { const ui64 tabletId = pr.first; - SendToTablet(tabletId, MakeHolder<TEvColumnShard::TEvCancelTransactionProposal>(TxId), false); + SendToTablet(tabletId, MakeHolder<TEvColumnShard::TEvCancelTransactionProposal>(TxId), false); } } diff --git a/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp b/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp index 3e31da2be1..b3b43509b1 100644 --- a/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp +++ b/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp @@ -83,7 +83,7 @@ void TLongTxServiceActor::Handle(TEvLongTxService::TEvCommitTx::TPtr& ev) { } if (txId.NodeId != SelfId().NodeId()) { - return SendProxyRequest(txId.NodeId, ERequestType::Commit, std::move(ev)); + return SendProxyRequest(txId.NodeId, ERequestType::Commit, std::move(ev)); } auto it = Transactions.find(txId.UniqueId); @@ -156,7 +156,7 @@ void TLongTxServiceActor::Handle(TEvLongTxService::TEvRollbackTx::TPtr& ev) { } if (txId.NodeId != SelfId().NodeId()) { - return SendProxyRequest(txId.NodeId, ERequestType::Rollback, std::move(ev)); + return SendProxyRequest(txId.NodeId, ERequestType::Rollback, std::move(ev)); } auto it = Transactions.find(txId.UniqueId); @@ -209,7 +209,7 @@ void TLongTxServiceActor::Handle(TEvLongTxService::TEvAttachColumnShardWrites::T } if (txId.NodeId != SelfId().NodeId()) { - return SendProxyRequest(txId.NodeId, ERequestType::AttachColumnShardWrites, std::move(ev)); + return SendProxyRequest(txId.NodeId, ERequestType::AttachColumnShardWrites, std::move(ev)); } auto it = Transactions.find(txId.UniqueId); diff --git a/ydb/core/tx/mediator/mediator_impl.h b/ydb/core/tx/mediator/mediator_impl.h index c98bd4246b..3b08f96881 100644 --- a/ydb/core/tx/mediator/mediator_impl.h +++ b/ydb/core/tx/mediator/mediator_impl.h @@ -39,7 +39,7 @@ namespace NTxMediator { } struct TCmpOrderId { - bool operator()(const TTx &left, const TTx &right) const noexcept { + bool operator()(const TTx &left, const TTx &right) const noexcept { return left.TxId < right.TxId; } }; diff --git a/ydb/core/tx/scheme_board/cache.cpp b/ydb/core/tx/scheme_board/cache.cpp index 8e778a4a1d..9bf4f4ebb4 100644 --- a/ydb/core/tx/scheme_board/cache.cpp +++ b/ydb/core/tx/scheme_board/cache.cpp @@ -53,7 +53,7 @@ using TResolve = NSchemeCache::TSchemeCacheRequest; using TResolveContext = NSchemeCache::TSchemeCacheRequestContext; using TResolveContextPtr = TIntrusivePtr<TResolveContext>; -using TVariantContextPtr = std::variant<TNavigateContextPtr, TResolveContextPtr>; +using TVariantContextPtr = std::variant<TNavigateContextPtr, TResolveContextPtr>; namespace { @@ -1139,9 +1139,9 @@ class TSchemeCache: public TMonitorableActor<TSchemeCache> { } for (const auto& [contextVariant, requests] : InFlight) { - if (auto* context = std::get_if<TNavigateContextPtr>(&contextVariant)) { + if (auto* context = std::get_if<TNavigateContextPtr>(&contextVariant)) { ProcessInFlightNoCheck(*context, requests); - } else if (auto* context = std::get_if<TResolveContextPtr>(&contextVariant)) { + } else if (auto* context = std::get_if<TResolveContextPtr>(&contextVariant)) { ProcessInFlightNoCheck(*context, requests); } else { Y_FAIL("unknown context type"); @@ -1169,7 +1169,7 @@ class TSchemeCache: public TMonitorableActor<TSchemeCache> { void MoveInFlightNavigateByPathRequests(TCacheItem& recipient) { EraseNodesIf(InFlight, [&recipient](auto& kv) { - auto* context = std::get_if<TNavigateContextPtr>(&kv.first); + auto* context = std::get_if<TNavigateContextPtr>(&kv.first); if (!context) { return false; } @@ -1243,9 +1243,9 @@ class TSchemeCache: public TMonitorableActor<TSchemeCache> { EraseNodesIf(InFlight, [this, &processed, response](auto& kv) { processed.push_back(kv.first); - if (auto* context = std::get_if<TNavigateContextPtr>(&kv.first)) { + if (auto* context = std::get_if<TNavigateContextPtr>(&kv.first)) { ProcessInFlight(context->Get(), kv.second, response); - } else if (auto* context = std::get_if<TResolveContextPtr>(&kv.first)) { + } else if (auto* context = std::get_if<TResolveContextPtr>(&kv.first)) { ProcessInFlight(context->Get(), kv.second, response); } else { Y_FAIL("unknown context type"); @@ -2295,11 +2295,11 @@ class TSchemeCache: public TMonitorableActor<TSchemeCache> { } for (const auto& x : cacheItem->ProcessInFlight(response)) { - if (auto* context = std::get_if<TNavigateContextPtr>(&x)) { + if (auto* context = std::get_if<TNavigateContextPtr>(&x)) { if (!context->Get()->WaitCounter) { Complete(*context); } - } else if (auto* context = std::get_if<TResolveContextPtr>(&x)) { + } else if (auto* context = std::get_if<TResolveContextPtr>(&x)) { if (!context->Get()->WaitCounter) { Complete(*context); } diff --git a/ydb/core/tx/scheme_board/monitoring.cpp b/ydb/core/tx/scheme_board/monitoring.cpp index deda604655..34a7ca7107 100644 --- a/ydb/core/tx/scheme_board/monitoring.cpp +++ b/ydb/core/tx/scheme_board/monitoring.cpp @@ -1224,9 +1224,9 @@ class TMonitoring: public TActorBootstrapped<TMonitoring> { IEventBase* MakeRequest() const override { switch (Path.index()) { case 0: - return new TSchemeBoardMonEvents::TEvDescribeRequest(std::get<TString>(Path)); + return new TSchemeBoardMonEvents::TEvDescribeRequest(std::get<TString>(Path)); case 1: - return new TSchemeBoardMonEvents::TEvDescribeRequest(std::get<TPathId>(Path)); + return new TSchemeBoardMonEvents::TEvDescribeRequest(std::get<TPathId>(Path)); default: Y_FAIL("unreachable"); } @@ -1246,7 +1246,7 @@ class TMonitoring: public TActorBootstrapped<TMonitoring> { } private: - std::variant<TString, TPathId> Path; + std::variant<TString, TPathId> Path; }; // TDescriber diff --git a/ydb/core/tx/scheme_board/replica.cpp b/ydb/core/tx/scheme_board/replica.cpp index 638656e91d..056e49d1e4 100644 --- a/ydb/core/tx/scheme_board/replica.cpp +++ b/ydb/core/tx/scheme_board/replica.cpp @@ -650,7 +650,7 @@ private: desc->Subscribe(subscriber, path, domainOwnerId, capabilities); auto it = Subscribers.find(subscriber); - Y_VERIFY_DEBUG(it == Subscribers.end() || std::holds_alternative<TPath>(it->second) && std::get<TPath>(it->second) == path); + Y_VERIFY_DEBUG(it == Subscribers.end() || std::holds_alternative<TPath>(it->second) && std::get<TPath>(it->second) == path); Subscribers.emplace(subscriber, path); } @@ -1052,9 +1052,9 @@ private: for (const auto& [subscriber, id] : Subscribers) { TDescription* desc = nullptr; - if (const TString* path = std::get_if<TString>(&id)) { + if (const TString* path = std::get_if<TString>(&id)) { desc = Descriptions.FindPtr(*path); - } else if (const TPathId* pathId = std::get_if<TPathId>(&id)) { + } else if (const TPathId* pathId = std::get_if<TPathId>(&id)) { desc = Descriptions.FindPtr(*pathId); } @@ -1123,9 +1123,9 @@ private: TDescription* desc = nullptr; - if (const TString* path = std::get_if<TString>(&it->second)) { + if (const TString* path = std::get_if<TString>(&it->second)) { desc = Descriptions.FindPtr(*path); - } else if (const TPathId* pathId = std::get_if<TPathId>(&it->second)) { + } else if (const TPathId* pathId = std::get_if<TPathId>(&it->second)) { desc = Descriptions.FindPtr(*pathId); } @@ -1174,9 +1174,9 @@ private: TDescription* desc = nullptr; - if (const TString* path = std::get_if<TString>(&it->second)) { + if (const TString* path = std::get_if<TString>(&it->second)) { desc = Descriptions.FindPtr(*path); - } else if (const TPathId* pathId = std::get_if<TPathId>(&it->second)) { + } else if (const TPathId* pathId = std::get_if<TPathId>(&it->second)) { desc = Descriptions.FindPtr(*pathId); } @@ -1221,9 +1221,9 @@ private: auto& info = *record.AddSubscribers(); ActorIdToProto(subscriber, info.MutableActorId()); - if (const TString* path = std::get_if<TString>(&id)) { + if (const TString* path = std::get_if<TString>(&id)) { info.SetPath(*path); - } else if (const TPathId* pathId = std::get_if<TPathId>(&id)) { + } else if (const TPathId* pathId = std::get_if<TPathId>(&id)) { info.MutablePathId()->SetOwnerId(pathId->OwnerId); info.MutablePathId()->SetLocalPathId(pathId->LocalPathId); } @@ -1274,9 +1274,9 @@ private: const auto id = it->second; ++it; - if (const TString* path = std::get_if<TString>(&id)) { + if (const TString* path = std::get_if<TString>(&id)) { Unsubscribe(subscriber, *path); - } else if (const TPathId* pathId = std::get_if<TPathId>(&id)) { + } else if (const TPathId* pathId = std::get_if<TPathId>(&id)) { Unsubscribe(subscriber, *pathId); } } @@ -1329,7 +1329,7 @@ public: private: THashMap<ui64, TPopulatorInfo> Populators; TDoubleIndexedMap<TString, TPathId, TDescription, TMerger, THashMap, TMap> Descriptions; - TMap<TActorId, std::variant<TString, TPathId>, TActorId::TOrderedCmp> Subscribers; + TMap<TActorId, std::variant<TString, TPathId>, TActorId::TOrderedCmp> Subscribers; }; // TReplica diff --git a/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp b/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp index 855553cddc..eedcfea5ef 100644 --- a/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp @@ -47,7 +47,7 @@ struct TSchemeShard::TTxDeleteTabletReply : public TSchemeShard::TRwTxBase { } // "Forget" the deleted shard - if (Self->ShardInfos.contains(ShardIdx)) { + if (Self->ShardInfos.contains(ShardIdx)) { auto tabletType = Self->ShardInfos[ShardIdx].TabletType; switch (tabletType) { case ETabletType::DataShard: diff --git a/ydb/core/tx/schemeshard/schemeshard__init.cpp b/ydb/core/tx/schemeshard/schemeshard__init.cpp index 650506549e..a795a18085 100644 --- a/ydb/core/tx/schemeshard/schemeshard__init.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__init.cpp @@ -2815,7 +2815,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { TString name = rowset.GetValue<Schema::StoragePools::PoolName>(); TString kind = rowset.GetValue<Schema::StoragePools::PoolKind>(); - Y_VERIFY(Self->SubDomains.contains(pathId)); + Y_VERIFY(Self->SubDomains.contains(pathId)); Self->SubDomains[pathId]->AddStoragePool(TStoragePool(name, kind)); if (!rowset.Next()) @@ -2835,7 +2835,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { TString name = rowset.GetValue<Schema::StoragePoolsAlterData::PoolName>(); TString kind = rowset.GetValue<Schema::StoragePoolsAlterData::PoolKind>(); - Y_VERIFY(Self->SubDomains.contains(pathId)); + Y_VERIFY(Self->SubDomains.contains(pathId)); auto subdomainInfo = Self->SubDomains[pathId]; Y_VERIFY(subdomainInfo->GetAlter()); subdomainInfo->GetAlter()->AddStoragePool(TStoragePool(name, kind)); @@ -3017,7 +3017,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { Y_VERIFY(fs); { - fs->AlterConfig = MakeHolder<NKikimrFileStore::TConfig>(); + fs->AlterConfig = MakeHolder<NKikimrFileStore::TConfig>(); auto cfg = rowset.GetValue<Schema::FileStoreAlters::Config>(); bool parseOk = ParseFromStringNoSizeLimit(*fs->AlterConfig, cfg); Y_VERIFY(parseOk); @@ -3088,7 +3088,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { TKesusInfo::TPtr kesus = it->second; Y_VERIFY(kesus); { - kesus->AlterConfig.Reset(new Ydb::Coordination::Config); + kesus->AlterConfig.Reset(new Ydb::Coordination::Config); bool parseOk = ParseFromStringNoSizeLimit(*kesus->AlterConfig, config); Y_VERIFY(parseOk); kesus->AlterVersion = version; @@ -3155,7 +3155,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { } if (txState.TxType == TTxState::TxCreateSubDomain) { - Y_VERIFY(Self->SubDomains.contains(txState.TargetPathId)); + Y_VERIFY(Self->SubDomains.contains(txState.TargetPathId)); auto subDomainInfo = Self->SubDomains.at(txState.TargetPathId); if (txState.State <= TTxState::Propose) { Y_VERIFY(subDomainInfo->GetAlter()); @@ -3362,7 +3362,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { } for (TTxState::TShardOperation& shardOp : txState->Shards) { if (shardOp.Operation == TTxState::CreateParts) { - Y_VERIFY(shardIdxToRangeEnd.contains(shardOp.Idx)); + Y_VERIFY(shardIdxToRangeEnd.contains(shardOp.Idx)); shardOp.RangeEnd = shardIdxToRangeEnd.at(shardOp.Idx); } } diff --git a/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp b/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp index 76e7318249..1cca83ad18 100644 --- a/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp @@ -6,7 +6,7 @@ #include <ydb/core/tx/tx_proxy/proxy.h> #include <library/cpp/html/pcdata/pcdata.h> -#include <util/string/cast.h> +#include <util/string/cast.h> static ui64 TryParseTabletId(TStringBuf tabletIdParam) { if (tabletIdParam.StartsWith("0x")) @@ -874,7 +874,7 @@ private: << "'>" << shardIdx <<"</a>"; } TABLED() { - if (Self->ShardInfos.contains(shardIdx)) { + if (Self->ShardInfos.contains(shardIdx)) { TTabletId tabletId = Self->ShardInfos.FindPtr(shardIdx)->TabletID; str << "<a href='../tablets?" << TCgi::TabletID.AsCgiParam(tabletId) @@ -1282,7 +1282,7 @@ private: } void OutputShardInfoPageByShardIdx(TShardIdx shardIdx, TStringStream& str) const { HTML(str) { - if (!Self->ShardInfos.contains(shardIdx)) { + if (!Self->ShardInfos.contains(shardIdx)) { H4() { str << "No shard info for shard idx " << shardIdx; } @@ -1293,7 +1293,7 @@ private: const TShardInfo& shard = Self->ShardInfos[shardIdx]; - if (!Self->PathsById.contains(shard.PathId)) { + if (!Self->PathsById.contains(shard.PathId)) { H4() { str << "No path item path id " << shard.PathId; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp index ee2a3fb3e5..5ca359cbea 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp @@ -267,9 +267,9 @@ private: case TTxState::CreateParts: return MakeHolder<TCreateParts>(OperationId); case TTxState::ConfigureParts: - return MakeHolder<TConfigureParts>(OperationId); + return MakeHolder<TConfigureParts>(OperationId); case TTxState::Propose: - return MakeHolder<TPropose>(OperationId); + return MakeHolder<TPropose>(OperationId); default: return nullptr; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp index 38e5f74777..6a6c39711b 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp @@ -362,7 +362,7 @@ public: return result; } - kesus->AlterConfig.Reset(new Ydb::Coordination::Config); + kesus->AlterConfig.Reset(new Ydb::Coordination::Config); kesus->AlterConfig->CopyFrom(kesus->Config); kesus->AlterConfig->MergeFrom(*alterConfig); kesus->AlterVersion = kesus->Version + 1; diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp index 4ba51deb84..7bcaef3447 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp @@ -228,9 +228,9 @@ private: switch(state) { case TTxState::Waiting: case TTxState::DeleteParts: - return MakeHolder<TDeleteParts>(OperationId); + return MakeHolder<TDeleteParts>(OperationId); case TTxState::Propose: - return MakeHolder<TPropose>(OperationId); + return MakeHolder<TPropose>(OperationId); default: return nullptr; } diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h index 2e5710c3d3..723c7f181e 100644 --- a/ydb/core/tx/schemeshard/schemeshard_info_types.h +++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h @@ -2000,7 +2000,7 @@ struct TFileStoreInfo : public TSimpleRefCount<TFileStoreInfo> { Y_VERIFY(!AlterConfig); Y_VERIFY(!AlterVersion); - AlterConfig = MakeHolder<NKikimrFileStore::TConfig>(); + AlterConfig = MakeHolder<NKikimrFileStore::TConfig>(); AlterConfig->CopyFrom(alterConfig); Y_VERIFY(!AlterConfig->GetBlockSize()); diff --git a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp index 3789d3af1b..538a8c9b4f 100644 --- a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp @@ -777,7 +777,7 @@ THolder<TEvSchemeShard::TEvDescribeSchemeResultBuilder> TPathDescriber::Describe pathStr, Self->TabletID(), pathId - )); + )); Result->Record.SetStatus(status); Result->Record.SetReason(explain); diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp index 6f999b268b..8c6e7492ce 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp @@ -2035,7 +2035,7 @@ namespace NSchemeShardUT_Private { TTestActorRuntimeBase::TEventObserver SetSuppressObserver(TTestActorRuntime &runtime, TVector<THolder<IEventHandle> > &suppressed, ui32 type) { return runtime.SetObserverFunc([&suppressed, type](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { if (ev->GetTypeRewrite() == type) { - suppressed.push_back(std::move(ev)); + suppressed.push_back(std::move(ev)); return TTestActorRuntime::EEventAction::DROP; } return TTestActorRuntime::EEventAction::PROCESS; diff --git a/ydb/core/tx/sequenceshard/ut_sequenceshard.cpp b/ydb/core/tx/sequenceshard/ut_sequenceshard.cpp index 9e082db7c6..c5cb6995e6 100644 --- a/ydb/core/tx/sequenceshard/ut_sequenceshard.cpp +++ b/ydb/core/tx/sequenceshard/ut_sequenceshard.cpp @@ -12,7 +12,7 @@ namespace NSequenceShard { // first time creation must succeed { auto createResult = ctx.CreateSequence( - MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); + MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); UNIT_ASSERT_VALUES_EQUAL(createResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvCreateSequenceResult::SUCCESS); } @@ -20,7 +20,7 @@ namespace NSequenceShard { // second time we must get an expected error { auto createResult = ctx.CreateSequence( - MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); + MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); UNIT_ASSERT_VALUES_EQUAL(createResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvCreateSequenceResult::SEQUENCE_ALREADY_EXISTS); } @@ -176,7 +176,7 @@ namespace NSequenceShard { // create a sequence { auto createResult = ctx.CreateSequence( - MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); + MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); UNIT_ASSERT_VALUES_EQUAL(createResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvCreateSequenceResult::SUCCESS); } @@ -195,7 +195,7 @@ namespace NSequenceShard { // retry creating a sequence { auto createResult = ctx.CreateSequence( - MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); + MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); UNIT_ASSERT_VALUES_EQUAL(createResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvCreateSequenceResult::PIPE_OUTDATED); } @@ -224,7 +224,7 @@ namespace NSequenceShard { // retry of create sequence must fail even after reboot { auto createResult = ctx.CreateSequence( - MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); + MakeHolder<TEvSequenceShard::TEvCreateSequence>(TPathId(123, 42))); UNIT_ASSERT_VALUES_EQUAL(createResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvCreateSequenceResult::PIPE_OUTDATED); } @@ -280,7 +280,7 @@ namespace NSequenceShard { // we would use the same path id and different tablets { auto restoreResult = ctx.RestoreSequence( - MakeHolder<TEvSequenceShard::TEvRestoreSequence>(TPathId(123, 43), freezeRecord)); + MakeHolder<TEvSequenceShard::TEvRestoreSequence>(TPathId(123, 43), freezeRecord)); UNIT_ASSERT_VALUES_EQUAL(restoreResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvRestoreSequenceResult::SUCCESS); } @@ -297,7 +297,7 @@ namespace NSequenceShard { // restoring again must fail, since sequence was active and may have changed its values { auto restoreResult = ctx.RestoreSequence( - MakeHolder<TEvSequenceShard::TEvRestoreSequence>(TPathId(123, 43), freezeRecord)); + MakeHolder<TEvSequenceShard::TEvRestoreSequence>(TPathId(123, 43), freezeRecord)); UNIT_ASSERT_VALUES_EQUAL(restoreResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvRestoreSequenceResult::SEQUENCE_ALREADY_ACTIVE); } @@ -330,7 +330,7 @@ namespace NSequenceShard { // restore over redirected sequence { auto restoreResult = ctx.RestoreSequence( - MakeHolder<TEvSequenceShard::TEvRestoreSequence>(TPathId(123, 42), freezeRecord)); + MakeHolder<TEvSequenceShard::TEvRestoreSequence>(TPathId(123, 42), freezeRecord)); UNIT_ASSERT_VALUES_EQUAL(restoreResult->Record.GetStatus(), NKikimrTxSequenceShard::TEvRestoreSequenceResult::SUCCESS); } diff --git a/ydb/core/tx/tx_proxy/datareq.cpp b/ydb/core/tx/tx_proxy/datareq.cpp index af48b42d60..26697b988e 100644 --- a/ydb/core/tx/tx_proxy/datareq.cpp +++ b/ydb/core/tx/tx_proxy/datareq.cpp @@ -1402,7 +1402,7 @@ void TDataReq::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr &ev, TMap<TString, size_t> colNames; for (size_t i = 0; i < ReadTableRequest->Columns.size(); ++i) { auto &col = ReadTableRequest->Columns[i]; - if (colNames.contains(col.Name)) { + if (colNames.contains(col.Name)) { const TString errorExplanation = "duplicated columns are not supported: " + col.Name; IssueManager.RaiseIssue(MakeIssue(NKikimrIssues::TIssuesIds::GENERIC_RESOLVE_ERROR, errorExplanation)); UnresolvedKeys.push_back(errorExplanation); @@ -1445,7 +1445,7 @@ void TDataReq::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr &ev, ++no; if (projection) { - if (colNames.contains(col.Name)) { + if (colNames.contains(col.Name)) { ReadTableRequest->Columns[colNames[col.Name]] = col; colNames.erase(col.Name); } @@ -1510,8 +1510,8 @@ void TDataReq::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr &ev, return Die(ctx); } - ReadTableRequest->KeyDesc.Reset(new TKeyDesc(res.TableId, range, TKeyDesc::ERowOperation::Read, - keyTypes, columns)); + ReadTableRequest->KeyDesc.Reset(new TKeyDesc(res.TableId, range, TKeyDesc::ERowOperation::Read, + keyTypes, columns)); ReadTableRequest->KeySpace.Initialize(ReadTableRequest->Ordered, keyTypes, range); WallClockResolveStarted = Now(); @@ -2681,7 +2681,7 @@ void TDataReq::FinishShardStream(TEvDataShard::TEvProposeTransactionResult::TPtr auto &rec = ev->Get()->Record; auto shard = rec.GetOrigin(); - Y_VERIFY_DEBUG(ReadTableRequest->StreamingShards.contains(shard)); + Y_VERIFY_DEBUG(ReadTableRequest->StreamingShards.contains(shard)); ReadTableRequest->StreamingShards.erase(shard); if (ReadTableRequest->KeySpace.IsFull() diff --git a/ydb/core/tx/tx_proxy/encrypted_storage_ut.cpp b/ydb/core/tx/tx_proxy/encrypted_storage_ut.cpp index aee1540004..670cc01f09 100644 --- a/ydb/core/tx/tx_proxy/encrypted_storage_ut.cpp +++ b/ydb/core/tx/tx_proxy/encrypted_storage_ut.cpp @@ -31,8 +31,8 @@ public: Server = new Tests::TServer(Settings); - Client = MakeHolder<Tests::TClient>(GetSettings()); - Tenants = MakeHolder<Tests::TTenants>(Server); + Client = MakeHolder<Tests::TClient>(GetSettings()); + Tenants = MakeHolder<Tests::TTenants>(Server); SetLogging(); InitRoot(); diff --git a/ydb/core/tx/tx_proxy/proxy_ut_helpers.h b/ydb/core/tx/tx_proxy/proxy_ut_helpers.h index 846b0cf568..ae354e0d69 100644 --- a/ydb/core/tx/tx_proxy/proxy_ut_helpers.h +++ b/ydb/core/tx/tx_proxy/proxy_ut_helpers.h @@ -104,8 +104,8 @@ public: Server = new Tests::TServer(Settings); - Client = MakeHolder<Tests::TClient>(GetSettings()); - Tenants = MakeHolder<Tests::TTenants>(Server); + Client = MakeHolder<Tests::TClient>(GetSettings()); + Tenants = MakeHolder<Tests::TTenants>(Server); SetLogging(); InitRoot(); @@ -203,8 +203,8 @@ public: Server = new Tests::TServer(Settings); - Client = MakeHolder<Tests::TClient>(GetSettings()); - Tenants = MakeHolder<Tests::TTenants>(Server); + Client = MakeHolder<Tests::TClient>(GetSettings()); + Tenants = MakeHolder<Tests::TTenants>(Server); SetLogging(); InitRoot(); diff --git a/ydb/core/tx/tx_proxy/schemereq.cpp b/ydb/core/tx/tx_proxy/schemereq.cpp index 923fe381ae..bc86fc8661 100644 --- a/ydb/core/tx/tx_proxy/schemereq.cpp +++ b/ydb/core/tx/tx_proxy/schemereq.cpp @@ -11,7 +11,7 @@ #include <ydb/library/aclib/aclib.h> #include <library/cpp/actors/core/hfunc.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NKikimr { namespace NTxProxy { diff --git a/ydb/core/util/queue_inplace.h b/ydb/core/util/queue_inplace.h index e0a5803e1e..e3bf903cd1 100644 --- a/ydb/core/util/queue_inplace.h +++ b/ydb/core/util/queue_inplace.h @@ -38,7 +38,7 @@ public: } struct TPtrCleanDestructor { - static inline void Destroy(TQueueInplace<T, TSize> *x) noexcept { + static inline void Destroy(TQueueInplace<T, TSize> *x) noexcept { while (const T *head = x->Head()) { delete *head; x->Pop(); @@ -48,7 +48,7 @@ public: }; struct TCleanDestructor { - static inline void Destroy(TQueueInplace<T, TSize> *x) noexcept { + static inline void Destroy(TQueueInplace<T, TSize> *x) noexcept { while (x->Head()) { x->Pop(); } @@ -60,7 +60,7 @@ public: } }; - void Push(const T &x) noexcept { + void Push(const T &x) noexcept { ++Size; if (WritePosition != TChunk::EntriesCount) { WriteTo->Entries[WritePosition] = x; @@ -74,7 +74,7 @@ public: } } - void Push(T &&x) noexcept { + void Push(T &&x) noexcept { ++Size; if (WritePosition != TChunk::EntriesCount) { WriteTo->Entries[WritePosition] = std::move(x); diff --git a/ydb/core/util/tracking_alloc.h b/ydb/core/util/tracking_alloc.h index 96855506ac..3862768c8a 100644 --- a/ydb/core/util/tracking_alloc.h +++ b/ydb/core/util/tracking_alloc.h @@ -25,25 +25,25 @@ public: template<typename U> friend class TTrackingAllocator; - TTrackingAllocator() noexcept + TTrackingAllocator() noexcept : std::allocator<T>() , Allocated(new size_t(0)) { } - TTrackingAllocator(const TSimpleSharedPtr<size_t>& allocated) noexcept + TTrackingAllocator(const TSimpleSharedPtr<size_t>& allocated) noexcept : std::allocator<T>() , Allocated(allocated) { } - TTrackingAllocator(const TTrackingAllocator& a) noexcept + TTrackingAllocator(const TTrackingAllocator& a) noexcept : std::allocator<T>(a) , Allocated(a.Allocated) { } - TTrackingAllocator(TTrackingAllocator&& a) noexcept + TTrackingAllocator(TTrackingAllocator&& a) noexcept : std::allocator<T>(std::move(static_cast<std::allocator<T>&&>(a))) , Allocated(a.Allocated) { @@ -51,20 +51,20 @@ public: } template <class U> - TTrackingAllocator(const TTrackingAllocator<U>& a) noexcept + TTrackingAllocator(const TTrackingAllocator<U>& a) noexcept : std::allocator<T>(a) , Allocated(a.Allocated) { } - TTrackingAllocator& operator=(const TTrackingAllocator& a) noexcept + TTrackingAllocator& operator=(const TTrackingAllocator& a) noexcept { Allocated = a.Allocated; std::allocator<T>::operator=(a); return *this; } - TTrackingAllocator& operator=(TTrackingAllocator&& a) noexcept + TTrackingAllocator& operator=(TTrackingAllocator&& a) noexcept { Allocated = a.Allocated; a.Allocated = nullptr; @@ -72,7 +72,7 @@ public: return *this; } - ~TTrackingAllocator() { + ~TTrackingAllocator() { } pointer allocate(size_type n, const void* hint = nullptr) { diff --git a/ydb/core/wrappers/s3_wrapper.cpp b/ydb/core/wrappers/s3_wrapper.cpp index b0fe378e21..623488d4e3 100644 --- a/ydb/core/wrappers/s3_wrapper.cpp +++ b/ydb/core/wrappers/s3_wrapper.cpp @@ -127,7 +127,7 @@ class TS3Wrapper: public TActor<TS3Wrapper>, private TS3User { } virtual THolder<IEventBase> MakeResponse(const typename TEvResponse::TOutcome& outcome) const { - return MakeHolder<TEvResponse>(outcome); + return MakeHolder<TEvResponse>(outcome); } private: @@ -194,9 +194,9 @@ class TS3Wrapper: public TActor<TS3Wrapper>, private TS3User { protected: THolder<IEventBase> MakeResponse(const typename TEvResponse::TOutcome& outcome) const override { if (outcome.IsSuccess()) { - return MakeHolder<TEvResponse>(outcome, std::move(Buffer)); + return MakeHolder<TEvResponse>(outcome, std::move(Buffer)); } else { - return MakeHolder<TEvResponse>(outcome); + return MakeHolder<TEvResponse>(outcome); } } diff --git a/ydb/core/yql_testlib/yql_testlib.cpp b/ydb/core/yql_testlib/yql_testlib.cpp index 35838c40f6..e032dda0fd 100644 --- a/ydb/core/yql_testlib/yql_testlib.cpp +++ b/ydb/core/yql_testlib/yql_testlib.cpp @@ -154,7 +154,7 @@ namespace Tests { void TYqlServer::Initialize() { ResumeYqlExecutionPromise = NThreading::NewPromise<void>(); - Runtime.Reset(new TTestActorRuntime(StaticNodes() + DynamicNodes(), true)); + Runtime.Reset(new TTestActorRuntime(StaticNodes() + DynamicNodes(), true)); Runtime->SetupMonitoring(); Runtime->SetLogBackend(GetSettings().LogBackend); diff --git a/ydb/core/yql_testlib/yql_testlib.h b/ydb/core/yql_testlib/yql_testlib.h index 39176df699..7ceb986727 100644 --- a/ydb/core/yql_testlib/yql_testlib.h +++ b/ydb/core/yql_testlib/yql_testlib.h @@ -33,7 +33,7 @@ public: protected: void Initialize(); - TAutoPtr<IThreadPool> YqlQueue; + TAutoPtr<IThreadPool> YqlQueue; NThreading::TPromise<void> ResumeYqlExecutionPromise; }; diff --git a/ydb/library/schlab/mon/mon.cpp b/ydb/library/schlab/mon/mon.cpp index fc06b412ae..376185437d 100644 --- a/ydb/library/schlab/mon/mon.cpp +++ b/ydb/library/schlab/mon/mon.cpp @@ -72,7 +72,7 @@ private: void InputConfig(const IMonHttpRequest& request, IOutputStream& out) { TGuard<TMutex> guard(EmuMutex); - JsonConfig = TString(request.GetPostContent()); + JsonConfig = TString(request.GetPostContent()); IsRunning = false; out << HTTPOKHTML; } diff --git a/ydb/library/yql/ast/yql_ast.cpp b/ydb/library/yql/ast/yql_ast.cpp index 16e521d901..34d715f822 100644 --- a/ydb/library/yql/ast/yql_ast.cpp +++ b/ydb/library/yql/ast/yql_ast.cpp @@ -327,7 +327,7 @@ namespace { } if (unescapeResult != EUnescapeResult::OK) { - AddError(TString(UnescapeResultToString(unescapeResult))); + AddError(TString(UnescapeResultToString(unescapeResult))); return nullptr; } @@ -359,7 +359,7 @@ namespace { } if (unescapeResult != EUnescapeResult::OK) { - AddError(TString(UnescapeResultToString(unescapeResult))); + AddError(TString(UnescapeResultToString(unescapeResult))); return nullptr; } @@ -436,7 +436,7 @@ namespace { } Y_NO_INLINE void Indent(IOutputStream& out, ui32 indentation) { - char* whitespaces = reinterpret_cast<char*>(alloca(indentation)); + char* whitespaces = reinterpret_cast<char*>(alloca(indentation)); memset(whitespaces, ' ', indentation); out.Write(whitespaces, indentation); } diff --git a/ydb/library/yql/ast/yql_expr.cpp b/ydb/library/yql/ast/yql_expr.cpp index 82f6c5812a..1bb1ff10b5 100644 --- a/ydb/library/yql/ast/yql_expr.cpp +++ b/ydb/library/yql/ast/yql_expr.cpp @@ -2646,7 +2646,7 @@ bool ValidateName(TPosition position, TStringBuf name, TStringBuf descr, TExprCo if (name.size() > 16_KB) { ctx.AddError(TIssue(position, TStringBuilder() << - TString(descr).to_title() << " name length must be less than " << 16_KB)); + TString(descr).to_title() << " name length must be less than " << 16_KB)); return false; } @@ -2940,7 +2940,7 @@ size_t TExprContext::GetHash(TPositionHandle p) const { YQL_ENSURE(p.Handle < Positions.size()); const TPosition& pos = Positions[p.Handle]; - size_t h = ComputeHash(pos.File); + size_t h = ComputeHash(pos.File); h = CombineHashes(h, NumericHash(pos.Row)); return CombineHashes(h, NumericHash(pos.Column)); } diff --git a/ydb/library/yql/ast/yql_expr.h b/ydb/library/yql/ast/yql_expr.h index d6eb544f9a..593edc9ffb 100644 --- a/ydb/library/yql/ast/yql_expr.h +++ b/ydb/library/yql/ast/yql_expr.h @@ -42,7 +42,7 @@ #define ENSURE_NOT_FROZEN_CTX \ YQL_ENSURE(!Frozen, "Change in frozen expr context."); #else - #define ENSURE_NOT_DELETED Y_VERIFY_DEBUG(!Dead(), "Access to dead node # %lu: %d '%s'", UniqueId_, (int)Type_, TString(ContentUnchecked()).data()); + #define ENSURE_NOT_DELETED Y_VERIFY_DEBUG(!Dead(), "Access to dead node # %lu: %d '%s'", UniqueId_, (int)Type_, TString(ContentUnchecked()).data()); #define ENSURE_NOT_FROZEN Y_VERIFY_DEBUG(!Frozen()); #define ENSURE_NOT_FROZEN_CTX Y_VERIFY_DEBUG(!Frozen); #endif @@ -1395,7 +1395,7 @@ public: template <class TKey> bool IsCallable(const THashSet<TKey>& names) const { ENSURE_NOT_DELETED - return Type() == TExprNode::Callable && names.contains(Content()); + return Type() == TExprNode::Callable && names.contains(Content()); } bool IsCallable() const { diff --git a/ydb/library/yql/ast/yql_type_string.cpp b/ydb/library/yql/ast/yql_type_string.cpp index af9af93259..ecbcd67cbb 100644 --- a/ydb/library/yql/ast/yql_type_string.cpp +++ b/ydb/library/yql/ast/yql_type_string.cpp @@ -725,7 +725,7 @@ private: if (name.empty()) { return AddError("Empty name is not allowed"); - } else if (members.contains(name)) { + } else if (members.contains(name)) { return AddError("Member name duplication"); } diff --git a/ydb/library/yql/core/common_opt/yql_co_extr_members.cpp b/ydb/library/yql/core/common_opt/yql_co_extr_members.cpp index 215a1e9f69..966c2e4885 100644 --- a/ydb/library/yql/core/common_opt/yql_co_extr_members.cpp +++ b/ydb/library/yql/core/common_opt/yql_co_extr_members.cpp @@ -527,7 +527,7 @@ TExprNode::TPtr ApplyExtractMembersToCalcOverWindow(const TExprNode::TPtr& node, auto outputStructType = node->GetTypeAnn()->Cast<TListExprType>()->GetItemType()->Cast<TStructExprType>(); TSet<TStringBuf> toDrop; for (const auto& out : outputStructType->GetItems()) { - if (!outMembers.contains(out->GetName())) { + if (!outMembers.contains(out->GetName())) { toDrop.insert(out->GetName()); } } @@ -636,7 +636,7 @@ TExprNode::TPtr ApplyExtractMembersToCalcOverWindow(const TExprNode::TPtr& node, // keep input fields for (const auto& in : inputStructType->GetItems()) { - if (outMembers.contains(in->GetName()) && !payloadFields.contains(in->GetName())) { + if (outMembers.contains(in->GetName()) && !payloadFields.contains(in->GetName())) { usedFields.insert(in->GetName()); } } @@ -697,7 +697,7 @@ TExprNode::TPtr ApplyExtractMembersToAggregate(const TExprNode::TPtr& node, cons // many columns bool hasColumns = false; for (const auto& col : handler.ColumnName().Ref().Children()) { - if (outMembers.contains(col->Content())) { + if (outMembers.contains(col->Content())) { hasColumns = true; break; } @@ -708,7 +708,7 @@ TExprNode::TPtr ApplyExtractMembersToAggregate(const TExprNode::TPtr& node, cons continue; } } else { - if (!outMembers.contains(handler.ColumnName().Ref().Content())) { + if (!outMembers.contains(handler.ColumnName().Ref().Content())) { // drop handler continue; } diff --git a/ydb/library/yql/core/common_opt/yql_co_flow1.cpp b/ydb/library/yql/core/common_opt/yql_co_flow1.cpp index 728838dc8e..55a8ea3d34 100644 --- a/ydb/library/yql/core/common_opt/yql_co_flow1.cpp +++ b/ydb/library/yql/core/common_opt/yql_co_flow1.cpp @@ -2099,7 +2099,7 @@ void RegisterCoFlowCallables1(TCallableOptimizerMap& map) { for (ui32 index = 1; index < innerVisit.ChildrenSize(); ++index) { if (innerVisit.Child(index)->IsAtom()) { const auto itemIndex = innerVisit.Child(index)->Content(); - defInnerIndicies.erase(TString(itemIndex)); + defInnerIndicies.erase(TString(itemIndex)); ++index; auto lambda = innerVisit.ChildPtr(index); if (auto var = TMaybeNode<TCoVariant>(lambda->Child(1))) { @@ -2120,14 +2120,14 @@ void RegisterCoFlowCallables1(TCallableOptimizerMap& map) { } } - if (innerLambdas.contains(defOutIndex)) { + if (innerLambdas.contains(defOutIndex)) { return node; } for (ui32 index = 1; index < node->ChildrenSize(); ++index) { if (node->Child(index)->IsAtom()) { const auto itemIndex = node->Child(index)->Content(); - if (!innerLambdas.contains(itemIndex) && defOutIndex != itemIndex) { + if (!innerLambdas.contains(itemIndex) && defOutIndex != itemIndex) { return node; } } diff --git a/ydb/library/yql/core/common_opt/yql_co_flow2.cpp b/ydb/library/yql/core/common_opt/yql_co_flow2.cpp index 88f9140031..adfadb4cfe 100644 --- a/ydb/library/yql/core/common_opt/yql_co_flow2.cpp +++ b/ydb/library/yql/core/common_opt/yql_co_flow2.cpp @@ -265,7 +265,7 @@ TExprNode::TPtr SingleInputPredicatePushdownOverEquiJoin(TExprNode::TPtr equiJoi // check whether some used fields are not aliased bool onlyKeys = true; for (auto& x : usedFields) { - if (!aliases.contains(TString(x))) { + if (!aliases.contains(TString(x))) { onlyKeys = false; break; } @@ -283,7 +283,7 @@ TExprNode::TPtr SingleInputPredicatePushdownOverEquiJoin(TExprNode::TPtr equiJoi for (auto field : labels.Inputs[i].EnumerateAllColumns()) { if (auto aliasSet = aliases.FindPtr(field)) { for (auto alias : *aliasSet) { - if (usedFields.contains(alias)) { + if (usedFields.contains(alias)) { coveredKeys.insert(TString(alias)); aliasedKeys[i].insert({ field, TString(alias) }); } @@ -422,7 +422,7 @@ TExprNode::TPtr FlatMapOverEquiJoin(const TCoFlatMapBase& node, TExprContext& ct } for (auto& x : structType->GetItems()) { - if (!usedFields.contains(x->GetName())) { + if (!usedFields.contains(x->GetName())) { // new drops auto name = x->GetName(); if (auto renamed = reversedRenameMap.FindPtr(name)) { @@ -630,7 +630,7 @@ TExprNode::TPtr FlatMapSubsetFields(const TCoFlatMapBase& node, TExprContext& ct TExprNode::TListType fieldNodes; for (auto& item : itemStructType->GetItems()) { - if (usedFields.contains(item->GetName())) { + if (usedFields.contains(item->GetName())) { fieldNodes.push_back(ctx.NewAtom(node.Pos(), item->GetName())); } } @@ -825,11 +825,11 @@ TExprNode::TPtr FuseEquiJoins(const TExprNode::TPtr& node, ui32 upstreamIndex, T return node; } - if (downstreamLabels.contains(label->Content())) { + if (downstreamLabels.contains(label->Content())) { // fix conflict for labels for (ui32 suffix = 1;; ++suffix) { auto newName = TString::Join(label->Content(), "_", ToString(suffix)); - if (!downstreamLabels.contains(newName) && !upstreamLabels.contains(newName)) { + if (!downstreamLabels.contains(newName) && !upstreamLabels.contains(newName)) { upstreamTablesRename.insert({ TString(label->Content()) , newName }); break; } @@ -2000,7 +2000,7 @@ void RegisterCoFlowCallables2(TCallableOptimizerMap& map) { TVector<const TItemExprType*> subsetItems; for (const auto& item : structType->GetItems()) { - if (usedFields.contains(item->GetName())) { + if (usedFields.contains(item->GetName())) { subsetItems.push_back(item); } } @@ -2083,7 +2083,7 @@ void RegisterCoFlowCallables2(TCallableOptimizerMap& map) { TVector<const TItemExprType*> subsetItems; for (const auto& item : structType->GetItems()) { - if (usedFields.contains(item->GetName())) { + if (usedFields.contains(item->GetName())) { subsetItems.push_back(item); } } @@ -2154,7 +2154,7 @@ void RegisterCoFlowCallables2(TCallableOptimizerMap& map) { TVector<const TItemExprType*> subsetItems; for (const auto& item : structType->GetItems()) { - if (lambdaSubset.contains(item->GetName())) { + if (lambdaSubset.contains(item->GetName())) { subsetItems.push_back(item); } } diff --git a/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h b/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h index 0974e8d2d3..63135fb331 100644 --- a/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h +++ b/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h @@ -7,7 +7,7 @@ #include <util/generic/vector.h> #include <util/generic/strbuf.h> #include <util/system/yassert.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <functional> #include <iterator> diff --git a/ydb/library/yql/core/extract_predicate/extract_predicate_impl.cpp b/ydb/library/yql/core/extract_predicate/extract_predicate_impl.cpp index e2c16395b7..4a59dc5008 100644 --- a/ydb/library/yql/core/extract_predicate/extract_predicate_impl.cpp +++ b/ydb/library/yql/core/extract_predicate/extract_predicate_impl.cpp @@ -1608,7 +1608,7 @@ TPredicateRangeExtractor::TBuildResult TPredicateRangeExtractor::BuildComputeNod } // namespace NDetail IPredicateRangeExtractor::TPtr MakePredicateRangeExtractor(const TPredicateExtractorSettings& settings) { - return MakeHolder<NDetail::TPredicateRangeExtractor>(settings); + return MakeHolder<NDetail::TPredicateRangeExtractor>(settings); } } // namespace NYql diff --git a/ydb/library/yql/core/facade/yql_facade.cpp b/ydb/library/yql/core/facade/yql_facade.cpp index b74abc1c34..0a5890b00d 100644 --- a/ydb/library/yql/core/facade/yql_facade.cpp +++ b/ydb/library/yql/core/facade/yql_facade.cpp @@ -1302,15 +1302,15 @@ TTypeAnnotationContextPtr TProgram::BuildTypeAnnotationContext(const TString& us } TVector<TString> resultProviderDataSources; - if (providerNames.contains(YtProviderName)) { + if (providerNames.contains(YtProviderName)) { resultProviderDataSources.push_back(TString(YtProviderName)); } - if (providerNames.contains(KikimrProviderName)) { + if (providerNames.contains(KikimrProviderName)) { resultProviderDataSources.push_back(TString(KikimrProviderName)); } - if (providerNames.contains(RtmrProviderName)) { + if (providerNames.contains(RtmrProviderName)) { resultProviderDataSources.push_back(TString(RtmrProviderName)); } diff --git a/ydb/library/yql/core/file_storage/file_storage.cpp b/ydb/library/yql/core/file_storage/file_storage.cpp index 631adbc688..e24afa7f71 100644 --- a/ydb/library/yql/core/file_storage/file_storage.cpp +++ b/ydb/library/yql/core/file_storage/file_storage.cpp @@ -49,7 +49,7 @@ public: auto numThreads = params.GetThreads(); if (1 == numThreads) { - MtpQueue.Reset(new TFakeThreadPool()); + MtpQueue.Reset(new TFakeThreadPool()); } else { MtpQueue.Reset(new TSimpleThreadPool(TThreadPoolParams{"FileStorage"})); } @@ -295,7 +295,7 @@ private: std::vector<IDownloaderPtr> Downloaders; TUrlMapper Mapper; TAtomic QueueStarted; - THolder<IThreadPool> MtpQueue; + THolder<IThreadPool> MtpQueue; TMultiResourceLock MultiResourceLock; }; diff --git a/ydb/library/yql/core/file_storage/file_storage_ut.cpp b/ydb/library/yql/core/file_storage/file_storage_ut.cpp index 5103fdd31d..d935179f73 100644 --- a/ydb/library/yql/core/file_storage/file_storage_ut.cpp +++ b/ydb/library/yql/core/file_storage/file_storage_ut.cpp @@ -11,7 +11,7 @@ #include <util/stream/file.h> #include <util/system/tempfile.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> using namespace NYql; using namespace NThreading; diff --git a/ydb/library/yql/core/file_storage/storage_ut.cpp b/ydb/library/yql/core/file_storage/storage_ut.cpp index 4229abd219..393701499b 100644 --- a/ydb/library/yql/core/file_storage/storage_ut.cpp +++ b/ydb/library/yql/core/file_storage/storage_ut.cpp @@ -73,7 +73,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { Y_UNIT_TEST(ParallelPut) { THolder<TStorage> storage = MakeHolder<TStorage>(10, 100); - TThreadPool queue; + TThreadPool queue; queue.Start(10); TVector<TFuture<TFileLinkPtr>> res; diff --git a/ydb/library/yql/core/services/yql_plan.cpp b/ydb/library/yql/core/services/yql_plan.cpp index 4d7cfffaf5..4d91399239 100644 --- a/ydb/library/yql/core/services/yql_plan.cpp +++ b/ydb/library/yql/core/services/yql_plan.cpp @@ -142,7 +142,7 @@ void WriteProviders(const TString& tag, const TProviderInfoMap& providers, NYson } ui32 FillLevels(THashMap<ui32, TLevelContext>& basicNodesMap, ui32 current, THashSet<ui32>& visited) { - if (visited.contains(current)) { + if (visited.contains(current)) { return 0; } @@ -436,7 +436,7 @@ public: } auto inputKey = TPinKey{ input.ProviderId, input.PinId, TBasicNode::EType::Input }; - if (allInputs.contains(inputKey)) { + if (allInputs.contains(inputKey)) { continue; } @@ -460,7 +460,7 @@ public: } auto outputKey = TPinKey{ output.ProviderId, output.PinId, TBasicNode::EType::Output }; - if (allOutputs.contains(outputKey)) { + if (allOutputs.contains(outputKey)) { continue; } diff --git a/ydb/library/yql/core/type_ann/type_ann_core.cpp b/ydb/library/yql/core/type_ann/type_ann_core.cpp index 5846e6cb10..8b2ac835d6 100644 --- a/ydb/library/yql/core/type_ann/type_ann_core.cpp +++ b/ydb/library/yql/core/type_ann/type_ann_core.cpp @@ -1440,7 +1440,7 @@ namespace NTypeAnnImpl { "Duplicate flatten alias found: " << alias)); return IGraphTransformer::TStatus::Error; } - if (flattenByColumns.contains(alias)) { + if (flattenByColumns.contains(alias)) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(columnNameNode->Pos()), TStringBuilder() << "Collision between alias and column name: " << alias)); return IGraphTransformer::TStatus::Error; @@ -1455,7 +1455,7 @@ namespace NTypeAnnImpl { "Duplicate flatten field found: " << columnName)); return IGraphTransformer::TStatus::Error; } - if (aliases.contains(columnName)) { + if (aliases.contains(columnName)) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(columnNameNode->Pos()), TStringBuilder() << "Collision between alias and column name: " << columnName)); return IGraphTransformer::TStatus::Error; @@ -1473,7 +1473,7 @@ namespace NTypeAnnImpl { const auto& fieldName = field->GetName(); auto flattenIter = flattenByColumns.find(fieldName); if (flattenIter == flattenByColumns.end()) { - if (aliases.contains(fieldName)) { + if (aliases.contains(fieldName)) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(structObj->Pos()), TStringBuilder() << "Conflict flatten alias and column name: '" << fieldName << "'")); return IGraphTransformer::TStatus::Error; @@ -3340,7 +3340,7 @@ namespace NTypeAnnImpl { bool hasMissingMembers = false; for (auto& x : expectedMembers) { - if (!foundMembers.contains(x.first)) { + if (!foundMembers.contains(x.first)) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Pos()), TStringBuilder() << "Missing member: " << x.first)); hasMissingMembers = true; } @@ -7251,7 +7251,7 @@ template <NKikimr::NUdf::EDataSlot DataSlot> } for (ui32 i = tupleSize; i < type->GetArgumentsSize() - type->GetOptionalArgumentsCount(); ++i) { - if (!usedIndices.contains(i)) { + if (!usedIndices.contains(i)) { const auto& arg = type->GetArguments()[i]; if (arg.Name.empty()) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Child(2)->Pos()), TStringBuilder() << "Argument # " << (i + 1) @@ -13277,10 +13277,10 @@ template <NKikimr::NUdf::EDataSlot DataSlot> AllNames.insert(func.first); } - AllNames.insert(TString(CommitName)); - AllNames.insert(TString(ReadName)); - AllNames.insert(TString(WriteName)); - AllNames.insert(TString(ConfigureName)); + AllNames.insert(TString(CommitName)); + AllNames.insert(TString(ReadName)); + AllNames.insert(TString(WriteName)); + AllNames.insert(TString(ConfigureName)); AllNames.insert("Apply"); } diff --git a/ydb/library/yql/core/type_ann/type_ann_join.cpp b/ydb/library/yql/core/type_ann/type_ann_join.cpp index 18516a8ab8..792093ced8 100644 --- a/ydb/library/yql/core/type_ann/type_ann_join.cpp +++ b/ydb/library/yql/core/type_ann/type_ann_join.cpp @@ -622,7 +622,7 @@ namespace NTypeAnnImpl { return IGraphTransformer::TStatus::Error; } - if (!fullColumns.contains(child->Content())) { + if (!fullColumns.contains(child->Content())) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(child->Pos()), TStringBuilder() << "Unknown column: " << child->Content())); return IGraphTransformer::TStatus::Error; } @@ -750,7 +750,7 @@ namespace NTypeAnnImpl { for (const auto& child : input->Child(2)->Children()) { const auto pos = GetFieldPosition(inputItemType, child->Content()); auto inputColumnType = GetFieldType(inputItemType, *pos); - if (requiredColumns.contains(child->Content())) { + if (requiredColumns.contains(child->Content())) { inputColumnType = inputColumnType->template Cast<TOptionalExprType>()->GetItemType(); } @@ -763,7 +763,7 @@ namespace NTypeAnnImpl { for (const auto& child : input->Child(3)->Children()) { const auto pos = GetFieldPosition(inputItemType, child->Content()); auto inputColumnType = GetFieldType(inputItemType, *pos); - if (requiredColumns.contains(child->Content())) { + if (requiredColumns.contains(child->Content())) { inputColumnType = inputColumnType->template Cast<TOptionalExprType>()->GetItemType(); } diff --git a/ydb/library/yql/core/yql_expr_csee.cpp b/ydb/library/yql/core/yql_expr_csee.cpp index b0e7525521..ff249dbe78 100644 --- a/ydb/library/yql/core/yql_expr_csee.cpp +++ b/ydb/library/yql/core/yql_expr_csee.cpp @@ -383,7 +383,7 @@ namespace { // compare pointers due to intern if (left.Content().data() != right.Content().data()) { - if (const auto res = left.Content().compare(right.Content())) { + if (const auto res = left.Content().compare(right.Content())) { return res; } } @@ -396,7 +396,7 @@ namespace { // compare pointers due to intern if (left.Content().data() != right.Content().data()) { - if (const auto res = left.Content().compare(right.Content())) { + if (const auto res = left.Content().compare(right.Content())) { return res; } } diff --git a/ydb/library/yql/core/yql_graph_transformer.h b/ydb/library/yql/core/yql_graph_transformer.h index 60d87727dd..79f1437a74 100644 --- a/ydb/library/yql/core/yql_graph_transformer.h +++ b/ydb/library/yql/core/yql_graph_transformer.h @@ -277,7 +277,7 @@ private: template <typename TFunctor> THolder<IGraphTransformer> CreateFunctorTransformer(TFunctor functor) { - return MakeHolder<TFunctorTransformer<TFunctor>>(std::move(functor)); + return MakeHolder<TFunctorTransformer<TFunctor>>(std::move(functor)); } typedef std::function<IGraphTransformer::TStatus(const TExprNode::TPtr&, TExprNode::TPtr&, TExprContext&)> TAsyncTransformCallback; diff --git a/ydb/library/yql/core/yql_join.cpp b/ydb/library/yql/core/yql_join.cpp index 9a9ded7a32..e695a5e1dc 100644 --- a/ydb/library/yql/core/yql_join.cpp +++ b/ydb/library/yql/core/yql_join.cpp @@ -2,7 +2,7 @@ #include "yql_expr_type_annotation.h" #include "yql_opt_utils.h" -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/join.h> namespace NYql { @@ -1110,7 +1110,7 @@ TMap<TStringBuf, TVector<TStringBuf>> UpdateUsedFieldsInRenameMap( } for (auto& item : structType->GetItems()) { - bool needRemove = !usedFields.contains(item->GetName()); + bool needRemove = !usedFields.contains(item->GetName()); if (auto renamed = reversedRenameMap.FindPtr(item->GetName())) { if (needRemove) { if (newRenameMap[*renamed].empty()) { diff --git a/ydb/library/yql/core/yql_type_annotation.cpp b/ydb/library/yql/core/yql_type_annotation.cpp index 9f50af3b63..f4a195e2d4 100644 --- a/ydb/library/yql/core/yql_type_annotation.cpp +++ b/ydb/library/yql/core/yql_type_annotation.cpp @@ -246,7 +246,7 @@ bool TModuleResolver::AddFromFile(const TStringBuf& file, TExprContext& ctx, ui1 } auto moduleName = TModuleResolver::NormalizeModuleName(TString(file)); - if (GetModule(moduleName) || Libs.contains(moduleName)) { + if (GetModule(moduleName) || Libs.contains(moduleName)) { auto it = Libs.find(moduleName); if (it != Libs.end() && it->second.contains(packageVersion)) { // TODO (YQL-7170): find better fix diff --git a/ydb/library/yql/core/yql_udf_index.cpp b/ydb/library/yql/core/yql_udf_index.cpp index bbd6b30781..b3c36ca8d3 100644 --- a/ydb/library/yql/core/yql_udf_index.cpp +++ b/ydb/library/yql/core/yql_udf_index.cpp @@ -79,7 +79,7 @@ TUdfIndex::TUdfIndex(const TMap<TString, TResourceInfo::TPtr>& resources) } bool TUdfIndex::ContainsModule(const TString& moduleName) const { - return Resources_.contains(moduleName); + return Resources_.contains(moduleName); } bool TUdfIndex::ContainsAnyModule(const TSet<TString>& modules) const { diff --git a/ydb/library/yql/core/yql_udf_index.h b/ydb/library/yql/core/yql_udf_index.h index 51f768d9de..d329ece2e5 100644 --- a/ydb/library/yql/core/yql_udf_index.h +++ b/ydb/library/yql/core/yql_udf_index.h @@ -1,7 +1,7 @@ #pragma once #include "yql_udf_resolver.h" -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/map.h> #include <util/generic/maybe.h> #include <util/generic/set.h> @@ -57,8 +57,8 @@ struct TDownloadLink { size_t Hash() const { return CombineHashes( - CombineHashes((size_t)IsUrl, ComputeHash(Path)), - ComputeHash(Md5) + CombineHashes((size_t)IsUrl, ComputeHash(Path)), + ComputeHash(Md5) ); } }; diff --git a/ydb/library/yql/core/yql_user_data.h b/ydb/library/yql/core/yql_user_data.h index fadc8f79cf..834d6cb962 100644 --- a/ydb/library/yql/core/yql_user_data.h +++ b/ydb/library/yql/core/yql_user_data.h @@ -71,7 +71,7 @@ public: struct THash { size_t operator()(const TUserDataKey& key) { auto type = static_cast<size_t>(key.Type_); - return CombineHashes(type, ComputeHash(key.Alias_)); + return CombineHashes(type, ComputeHash(key.Alias_)); } }; diff --git a/ydb/library/yql/core/yql_user_data_storage.cpp b/ydb/library/yql/core/yql_user_data_storage.cpp index 1a9d725d27..1a7a63314b 100644 --- a/ydb/library/yql/core/yql_user_data_storage.cpp +++ b/ydb/library/yql/core/yql_user_data_storage.cpp @@ -66,7 +66,7 @@ bool TUserDataStorage::ContainsUserDataBlock(const TStringBuf& name) const { } bool TUserDataStorage::ContainsUserDataBlock(const TUserDataKey& key) const { - return UserData_.contains(key); + return UserData_.contains(key); } const TUserDataBlock& TUserDataStorage::GetUserDataBlock(const TUserDataKey& key) const { @@ -357,7 +357,7 @@ NThreading::TFuture<std::function<TUserDataTable()>> FreezeUserDataTableIfNeeded for (auto func : futures) { std::pair<TUserDataKey, TUserDataBlock> p = func.GetValue()(); - Y_ENSURE(files.contains(p.first)); + Y_ENSURE(files.contains(p.first)); files[p.first].FrozenFile = p.second.FrozenFile; } diff --git a/ydb/library/yql/dq/common/dq_common.cpp b/ydb/library/yql/dq/common/dq_common.cpp index 865ed134a8..350836b011 100644 --- a/ydb/library/yql/dq/common/dq_common.cpp +++ b/ydb/library/yql/dq/common/dq_common.cpp @@ -1,7 +1,7 @@ #include "dq_common.h" IOutputStream& operator<<(IOutputStream& stream, const NYql::NDq::TTxId& txId) { - std::visit([&stream](auto arg) { + std::visit([&stream](auto arg) { stream << arg; }, txId); return stream; diff --git a/ydb/library/yql/dq/common/dq_common.h b/ydb/library/yql/dq/common/dq_common.h index 71cc7be6cb..2cca468f05 100644 --- a/ydb/library/yql/dq/common/dq_common.h +++ b/ydb/library/yql/dq/common/dq_common.h @@ -7,7 +7,7 @@ namespace NYql::NDq { -using TTxId = std::variant<ui64, TString>; +using TTxId = std::variant<ui64, TString>; using TLogFunc = std::function<void(const TString& message)>; diff --git a/ydb/library/yql/minikql/codegen/codegen.cpp b/ydb/library/yql/minikql/codegen/codegen.cpp index 6e4096af22..c70eb61bb2 100644 --- a/ydb/library/yql/minikql/codegen/codegen.cpp +++ b/ydb/library/yql/minikql/codegen/codegen.cpp @@ -448,7 +448,7 @@ public: modulePassManager = std::make_unique<llvm::legacy::PassManager>(); modulePassManager->add(llvm::createInternalizePass([&](const llvm::GlobalValue& gv) -> bool { auto name = TString(gv.getName().str()); - return ExportedSymbols->contains(name); + return ExportedSymbols->contains(name); })); modulePassManager->add(llvm::createGlobalDCEPass()); @@ -613,7 +613,7 @@ public: } void LoadBitCode(TStringBuf bitcode, TStringBuf uniqId) override { - if (uniqId && LoadedModules_.contains(uniqId)) { + if (uniqId && LoadedModules_.contains(uniqId)) { return; } llvm::SMDiagnostic error; diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload.cpp index c481a5815e..8a1b2437ac 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload.cpp @@ -18,7 +18,7 @@ void TraverseGraph(const NUdf::TUnboxedValue* roots, ui32 rootCount, TVector<NUd continue; } auto* ptr = value.AsBoxed().Get(); - if (dedup.contains(ptr)) { + if (dedup.contains(ptr)) { continue; } dedup.insert(ptr); @@ -35,7 +35,7 @@ void TraverseGraph(const NUdf::TUnboxedValue* roots, ui32 rootCount, TVector<NUd continue; } auto* ptr = value.AsBoxed().Get(); - if (dedup.contains(ptr)) { + if (dedup.contains(ptr)) { continue; } dedup.insert(ptr); diff --git a/ydb/library/yql/minikql/computation/mkql_validate_impl.h b/ydb/library/yql/minikql/computation/mkql_validate_impl.h index c4e10ac4b1..f6f4f5239c 100644 --- a/ydb/library/yql/minikql/computation/mkql_validate_impl.h +++ b/ydb/library/yql/minikql/computation/mkql_validate_impl.h @@ -1,5 +1,5 @@ #pragma once -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NKikimr { namespace NMiniKQL { diff --git a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_compare.h b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_compare.h index 8d865b86d9..0a8c47a223 100644 --- a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_compare.h +++ b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_compare.h @@ -94,9 +94,9 @@ struct TSelectArithmeticBinaryWithTimezone : public TArithmeticConstraintsBinary template<NUdf::EDataSlot Slot> int CompareCustoms(NUdf::TUnboxedValuePod lhs, NUdf::TUnboxedValuePod rhs) { - const TStringBuf lhsBuf = lhs.AsStringRef(); - const TStringBuf rhsBuf = rhs.AsStringRef(); - return lhsBuf.compare(rhsBuf); + const TStringBuf lhsBuf = lhs.AsStringRef(); + const TStringBuf rhsBuf = rhs.AsStringRef(); + return lhsBuf.compare(rhsBuf); } template<NUdf::EDataSlot Slot> diff --git a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_countbits.cpp b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_countbits.cpp index 725148683e..3f26bdacef 100644 --- a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_countbits.cpp +++ b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_countbits.cpp @@ -1,6 +1,6 @@ #include "mkql_builtins_impl.h" -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> namespace NKikimr { namespace NMiniKQL { diff --git a/ydb/library/yql/minikql/mkql_function_registry.cpp b/ydb/library/yql/minikql/mkql_function_registry.cpp index d3545ad138..c862be51f7 100644 --- a/ydb/library/yql/minikql/mkql_function_registry.cpp +++ b/ydb/library/yql/minikql/mkql_function_registry.cpp @@ -291,7 +291,7 @@ public: } bool IsLoadedUdfModule(const TStringBuf& moduleName) const override { - return UdfModules_.contains(moduleName); + return UdfModules_.contains(moduleName); } THashSet<TString> GetAllModuleNames() const override { diff --git a/ydb/library/yql/minikql/mkql_program_builder.cpp b/ydb/library/yql/minikql/mkql_program_builder.cpp index 47ae6e4c8f..ae386f28f2 100644 --- a/ydb/library/yql/minikql/mkql_program_builder.cpp +++ b/ydb/library/yql/minikql/mkql_program_builder.cpp @@ -241,7 +241,7 @@ std::string_view ScriptTypeAsStr(EScriptType type) { } EScriptType ScriptTypeFromStr(std::string_view str) { - TString lowerStr = TString(str); + TString lowerStr = TString(str); lowerStr.to_lower(); #define MKQL_SCRIPT_TYPE_FROM_STR(name, value, lowerName) \ if (lowerStr == #lowerName) return EScriptType::name; diff --git a/ydb/library/yql/minikql/pack_num.h b/ydb/library/yql/minikql/pack_num.h index e48fb78cad..0e14f12b34 100644 --- a/ydb/library/yql/minikql/pack_num.h +++ b/ydb/library/yql/minikql/pack_num.h @@ -24,7 +24,7 @@ Y_FORCE_INLINE size_t GetPack32Length(ui32 value) { } } -[[nodiscard]] Y_FORCE_INLINE size_t Pack32(ui32 value, char* buffer) { +[[nodiscard]] Y_FORCE_INLINE size_t Pack32(ui32 value, char* buffer) { if (value < 0x80) { buffer[0] = value << 0x1; return 1; @@ -44,7 +44,7 @@ Y_FORCE_INLINE size_t GetPack32Length(ui32 value) { } } -[[nodiscard]] Y_FORCE_INLINE size_t Unpack32(const char* buffer, size_t length, ui32& value) { +[[nodiscard]] Y_FORCE_INLINE size_t Unpack32(const char* buffer, size_t length, ui32& value) { if (Y_UNLIKELY(!length)) { return 0; } @@ -103,7 +103,7 @@ Y_FORCE_INLINE size_t GetPack64Length(ui64 value) { } } -[[nodiscard]] Y_FORCE_INLINE size_t Pack64(ui64 value, char* buffer) { +[[nodiscard]] Y_FORCE_INLINE size_t Pack64(ui64 value, char* buffer) { if (value < 0x80) { buffer[0] = value << 1; return 1; @@ -139,7 +139,7 @@ Y_FORCE_INLINE size_t GetPack64Length(ui64 value) { } } -[[nodiscard]] Y_FORCE_INLINE size_t Unpack64(const char* buffer, size_t length, ui64& value) { +[[nodiscard]] Y_FORCE_INLINE size_t Unpack64(const char* buffer, size_t length, ui64& value) { if (Y_UNLIKELY(!length)) { return 0; } diff --git a/ydb/library/yql/providers/common/config/yql_configuration_transformer.cpp b/ydb/library/yql/providers/common/config/yql_configuration_transformer.cpp index 9fbd44acb3..a1a9b8e7c6 100644 --- a/ydb/library/yql/providers/common/config/yql_configuration_transformer.cpp +++ b/ydb/library/yql/providers/common/config/yql_configuration_transformer.cpp @@ -53,7 +53,7 @@ IGraphTransformer::TStatus TProviderConfigurationTransformer::DoTransform(TExprN if (!EnsureAtom(*ds->Child(1), ctx)) { return nullptr; } - auto clusterName = TString(ds->Child(1)->Content()); + auto clusterName = TString(ds->Child(1)->Content()); if (!EnsureMinArgsCount(*node, 3, ctx)) { return nullptr; @@ -76,7 +76,7 @@ IGraphTransformer::TStatus TProviderConfigurationTransformer::DoTransform(TExprN return nullptr; } - auto name = TString(node->Child(3)->Content()); + auto name = TString(node->Child(3)->Content()); if (name.StartsWith('_')) { ctx.AddError(TIssue(ctx.GetPosition(node->Child(3)->Pos()), TStringBuilder() << "Failed to override system setting: " << name)); @@ -93,7 +93,7 @@ IGraphTransformer::TStatus TProviderConfigurationTransformer::DoTransform(TExprN return nullptr; } - value = TString(node->Child(4)->Content()); + value = TString(node->Child(4)->Content()); } if (!HandleAttr(node->Child(3)->Pos(), clusterName, name, value, ctx)) { @@ -108,7 +108,7 @@ IGraphTransformer::TStatus TProviderConfigurationTransformer::DoTransform(TExprN return nullptr; } - auto credAlias = TString(node->Child(3)->Content()); + auto credAlias = TString(node->Child(3)->Content()); if (!HandleAuth(node->Child(3)->Pos(), clusterName, credAlias, ctx)) { return nullptr; } diff --git a/ydb/library/yql/providers/common/config/yql_dispatch.cpp b/ydb/library/yql/providers/common/config/yql_dispatch.cpp index 4e6df45a8f..460462e1d6 100644 --- a/ydb/library/yql/providers/common/config/yql_dispatch.cpp +++ b/ydb/library/yql/providers/common/config/yql_dispatch.cpp @@ -97,7 +97,7 @@ bool TSettingDispatcher::Dispatch(const TString& cluster, const TString& name, c if (!handler->IsRuntime()) { ythrow yexception() << "Static setting " << name.Quote() << " cannot be set for specific cluster"; } - if (!ValidClusters.contains(cluster)) { + if (!ValidClusters.contains(cluster)) { TStringBuilder nearClusterMsg; for (auto& item: ValidClusters) { if (NLevenshtein::Distance(cluster, item) < DefaultMistypeDistance) { diff --git a/ydb/library/yql/providers/common/config/yql_dispatch.h b/ydb/library/yql/providers/common/config/yql_dispatch.h index 7389cbf082..4f06713119 100644 --- a/ydb/library/yql/providers/common/config/yql_dispatch.h +++ b/ydb/library/yql/providers/common/config/yql_dispatch.h @@ -215,7 +215,7 @@ public: TSettingHandlerImpl& Enum(std::initializer_list<TType> list) { THashSet<TType> allowed(list); Validators_.push_back([allowed = std::move(allowed)](const TString&, TType value) { - if (!allowed.contains(value)) { + if (!allowed.contains(value)) { throw yexception() << "Value " << value << " is not in set of allowed values: " << JoinSeq(TStringBuf(","), allowed); } }); diff --git a/ydb/library/yql/providers/common/gateway/yql_provider_gateway.h b/ydb/library/yql/providers/common/gateway/yql_provider_gateway.h index c4b498e9a1..13a82b9260 100644 --- a/ydb/library/yql/providers/common/gateway/yql_provider_gateway.h +++ b/ydb/library/yql/providers/common/gateway/yql_provider_gateway.h @@ -10,7 +10,7 @@ namespace NCommon { class TOperationResult { public: - [[nodiscard]] + [[nodiscard]] bool Success() const { return Status_ == TIssuesIds::SUCCESS; }; const EYqlIssueCode& Status() const { return Status_; } const TIssues& Issues() const { return Issues_; } diff --git a/ydb/library/yql/providers/common/metrics/metrics_registry.cpp b/ydb/library/yql/providers/common/metrics/metrics_registry.cpp index 1fb7bdcbba..7b02f97f1d 100644 --- a/ydb/library/yql/providers/common/metrics/metrics_registry.cpp +++ b/ydb/library/yql/providers/common/metrics/metrics_registry.cpp @@ -248,7 +248,7 @@ private: auto collector = NMonitoring::ExplicitHistogram(bounds).Release(); auto histogram = group->GetNamedHistogram( label.GetName(), label.GetValue(), - THolder(collector)); + THolder(collector)); Histograms.insert(std::make_pair(histogram, collector)); Histograms[histogram]->Collect(*histSnapshot); } else { diff --git a/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp b/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp index dd1f162d78..f2e43e2982 100644 --- a/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp +++ b/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp @@ -219,7 +219,7 @@ std::pair<TLayout, ui16> CutTimezone(const std::string_view& atom) { } // namespace bool TMkqlCallableCompilerBase::HasCallable(const std::string_view& name) const { - return Callables.contains(name); + return Callables.contains(name); } void TMkqlCallableCompilerBase::AddCallable(const std::string_view& name, TCompiler compiler) { diff --git a/ydb/library/yql/providers/common/transform/yql_exec.h b/ydb/library/yql/providers/common/transform/yql_exec.h index 0f134e5688..629ac703d6 100644 --- a/ydb/library/yql/providers/common/transform/yql_exec.h +++ b/ydb/library/yql/providers/common/transform/yql_exec.h @@ -22,7 +22,7 @@ public: TStatusCallbackPair CallbackTransform(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx); bool CanExec(const TExprNode& node) const { - return Handlers.contains(node.Content()); + return Handlers.contains(node.Content()); } protected: diff --git a/ydb/library/yql/providers/common/transform/yql_lazy_init.h b/ydb/library/yql/providers/common/transform/yql_lazy_init.h index fa2408e9ae..ed4af7dea2 100644 --- a/ydb/library/yql/providers/common/transform/yql_lazy_init.h +++ b/ydb/library/yql/providers/common/transform/yql_lazy_init.h @@ -19,7 +19,7 @@ public: { } - T* Get() const noexcept { + T* Get() const noexcept { if (!Value) { Value = Factory(); } diff --git a/ydb/library/yql/providers/common/transform/yql_optimize.cpp b/ydb/library/yql/providers/common/transform/yql_optimize.cpp index ef29baa8ff..b05265e7f6 100644 --- a/ydb/library/yql/providers/common/transform/yql_optimize.cpp +++ b/ydb/library/yql/providers/common/transform/yql_optimize.cpp @@ -184,7 +184,7 @@ TOptimizeTransformerBase::TFilter TOptimizeTransformerBase::Or(std::initializer_ } void TOptimizeTransformerBase::AddHandler(size_t step, TFilter filter, TStringBuf optName, THandler handler) { - if (DisabledOpts.contains(optName)) { + if (DisabledOpts.contains(optName)) { return; } diff --git a/ydb/library/yql/providers/common/transform/yql_visit.h b/ydb/library/yql/providers/common/transform/yql_visit.h index 5e6212579e..6ea7c332ab 100644 --- a/ydb/library/yql/providers/common/transform/yql_visit.h +++ b/ydb/library/yql/providers/common/transform/yql_visit.h @@ -24,7 +24,7 @@ public: TStatus DoTransform(TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) final; bool CanParse(const TExprNode& node) const { - return Handlers.contains(node.Content()); + return Handlers.contains(node.Content()); } protected: diff --git a/ydb/library/yql/providers/common/udf_resolve/yql_simple_udf_resolver.cpp b/ydb/library/yql/providers/common/udf_resolve/yql_simple_udf_resolver.cpp index 3aac3487c0..fb8101e2da 100644 --- a/ydb/library/yql/providers/common/udf_resolve/yql_simple_udf_resolver.cpp +++ b/ydb/library/yql/providers/common/udf_resolve/yql_simple_udf_resolver.cpp @@ -63,7 +63,7 @@ public: if (import->Modules) { bool needLibrary = false; for (auto& m : *import->Modules) { - if (requiredModules.contains(m)) { + if (requiredModules.contains(m)) { needLibrary = true; break; } diff --git a/ydb/library/yql/providers/config/yql_config_provider.cpp b/ydb/library/yql/providers/config/yql_config_provider.cpp index 6952e96cf0..1a2804b80d 100644 --- a/ydb/library/yql/providers/config/yql_config_provider.cpp +++ b/ydb/library/yql/providers/config/yql_config_provider.cpp @@ -168,7 +168,7 @@ namespace { } bool CanParse(const TExprNode& node) override { - if (ConfigProviderFunctions().contains(node.Content()) || + if (ConfigProviderFunctions().contains(node.Content()) || node.Content() == ConfigureName) { return MatchCategory(node); @@ -373,7 +373,7 @@ namespace { } bool CanExecute(const TExprNode& node) override { - if (ConfigProviderFunctions().contains(node.Content()) || + if (ConfigProviderFunctions().contains(node.Content()) || node.Content() == ConfigureName) { return MatchCategory(node); diff --git a/ydb/library/yql/providers/dq/service/interconnect_helpers.cpp b/ydb/library/yql/providers/dq/service/interconnect_helpers.cpp index bef368a961..a1c520cb14 100644 --- a/ydb/library/yql/providers/dq/service/interconnect_helpers.cpp +++ b/ydb/library/yql/providers/dq/service/interconnect_helpers.cpp @@ -82,7 +82,7 @@ namespace NYql::NDqs { } setup->ExecutorsCount = threads.size(); - setup->Executors.Reset(new TAutoPtr<IExecutorPool>[setup->ExecutorsCount]); + setup->Executors.Reset(new TAutoPtr<IExecutorPool>[setup->ExecutorsCount]); for (ui32 i = 0; i < setup->ExecutorsCount; ++i) { setup->Executors[i] = new TBasicExecutorPool( i, diff --git a/ydb/library/yql/providers/dq/worker_manager/local_worker_manager.cpp b/ydb/library/yql/providers/dq/worker_manager/local_worker_manager.cpp index 5ecf0a4a85..d362b8c5bc 100644 --- a/ydb/library/yql/providers/dq/worker_manager/local_worker_manager.cpp +++ b/ydb/library/yql/providers/dq/worker_manager/local_worker_manager.cpp @@ -257,7 +257,7 @@ private: computeActorType, Options.TaskRunnerActorFactory)); } else { - actor.Reset(CreateWorkerActor( + actor.Reset(CreateWorkerActor( Options.RuntimeData, traceId, Options.TaskRunnerActorFactory, diff --git a/ydb/library/yql/providers/pq/provider/yql_pq_dq_integration.cpp b/ydb/library/yql/providers/pq/provider/yql_pq_dq_integration.cpp index ea67ffd422..899362a3d9 100644 --- a/ydb/library/yql/providers/pq/provider/yql_pq_dq_integration.cpp +++ b/ydb/library/yql/providers/pq/provider/yql_pq_dq_integration.cpp @@ -261,7 +261,7 @@ private: } THolder<IDqIntegration> CreatePqDqIntegration(const TPqState::TPtr& state) { - return MakeHolder<TPqDqIntegration>(state); + return MakeHolder<TPqDqIntegration>(state); } } diff --git a/ydb/library/yql/providers/result/provider/yql_result_provider.cpp b/ydb/library/yql/providers/result/provider/yql_result_provider.cpp index 13bfd5e0f7..130bdca3e1 100644 --- a/ydb/library/yql/providers/result/provider/yql_result_provider.cpp +++ b/ydb/library/yql/providers/result/provider/yql_result_provider.cpp @@ -845,7 +845,7 @@ namespace { for (auto& source : Config->Types.DataSources) { syncList.clear(); if (source->CanBuildResult(node, syncList)) { - foundDataSource = TString(source->GetName()); + foundDataSource = TString(source->GetName()); break; } } @@ -892,7 +892,7 @@ namespace { } bool CanParse(const TExprNode& node) override { - return ResultProviderFunctions().contains(node.Content()) || node.Content() == ConfigureName; + return ResultProviderFunctions().contains(node.Content()) || node.Content() == ConfigureName; } void FillModifyCallables(THashSet<TStringBuf>& callables) override { diff --git a/ydb/library/yql/providers/s3/provider/yql_s3_dq_integration.cpp b/ydb/library/yql/providers/s3/provider/yql_s3_dq_integration.cpp index 539272add6..3d65692e30 100644 --- a/ydb/library/yql/providers/s3/provider/yql_s3_dq_integration.cpp +++ b/ydb/library/yql/providers/s3/provider/yql_s3_dq_integration.cpp @@ -153,7 +153,7 @@ private: } THolder<IDqIntegration> CreateS3DqIntegration(TS3State::TPtr state) { - return MakeHolder<TS3DqIntegration>(state); + return MakeHolder<TS3DqIntegration>(state); } } diff --git a/ydb/library/yql/providers/solomon/provider/yql_solomon_dq_integration.cpp b/ydb/library/yql/providers/solomon/provider/yql_solomon_dq_integration.cpp index 773c960991..4af755d5f5 100644 --- a/ydb/library/yql/providers/solomon/provider/yql_solomon_dq_integration.cpp +++ b/ydb/library/yql/providers/solomon/provider/yql_solomon_dq_integration.cpp @@ -152,7 +152,7 @@ private: } THolder<IDqIntegration> CreateSolomonDqIntegration(const TSolomonState::TPtr& state) { - return MakeHolder<TSolomonDqIntegration>(state); + return MakeHolder<TSolomonDqIntegration>(state); } } diff --git a/ydb/library/yql/providers/ydb/provider/yql_ydb_dq_integration.cpp b/ydb/library/yql/providers/ydb/provider/yql_ydb_dq_integration.cpp index ecb85e824b..333dc4b7e2 100644 --- a/ydb/library/yql/providers/ydb/provider/yql_ydb_dq_integration.cpp +++ b/ydb/library/yql/providers/ydb/provider/yql_ydb_dq_integration.cpp @@ -152,7 +152,7 @@ private: } THolder<IDqIntegration> CreateYdbDqIntegration(TYdbState::TPtr state) { - return MakeHolder<TYdbDqIntegration>(state); + return MakeHolder<TYdbDqIntegration>(state); } } diff --git a/ydb/library/yql/public/issue/yql_issue.cpp b/ydb/library/yql/public/issue/yql_issue.cpp index 3b89156874..3ed0acafc4 100644 --- a/ydb/library/yql/public/issue/yql_issue.cpp +++ b/ydb/library/yql/public/issue/yql_issue.cpp @@ -106,7 +106,7 @@ void WalkThroughIssues(const TIssue& topIssue, bool leafOnly, std::function<void namespace { Y_NO_INLINE void Indent(IOutputStream& out, ui32 indentation) { - char* whitespaces = reinterpret_cast<char*>(alloca(indentation)); + char* whitespaces = reinterpret_cast<char*>(alloca(indentation)); memset(whitespaces, ' ', indentation); out.Write(whitespaces, indentation); } diff --git a/ydb/library/yql/public/issue/yql_issue.h b/ydb/library/yql/public/issue/yql_issue.h index 7b97674c9d..02db0fe647 100644 --- a/ydb/library/yql/public/issue/yql_issue.h +++ b/ydb/library/yql/public/issue/yql_issue.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/types.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/maybe.h> #include <util/generic/vector.h> #include <util/generic/string.h> @@ -158,9 +158,9 @@ public: return CombineHashes( CombineHashes( (size_t)CombineHashes(IntHash(Position.Row), IntHash(Position.Column)), - ComputeHash(Position.File) + ComputeHash(Position.File) ), - (size_t)CombineHashes((size_t)IntHash(static_cast<int>(IssueCode)), ComputeHash(Message))); + (size_t)CombineHashes((size_t)IntHash(static_cast<int>(IssueCode)), ComputeHash(Message))); } TIssue& SetCode(TIssueCode id, ESeverity severity) { diff --git a/ydb/library/yql/public/udf/support/udf_support.cpp b/ydb/library/yql/public/udf/support/udf_support.cpp index d1e7adbc20..92e0541a92 100644 --- a/ydb/library/yql/public/udf/support/udf_support.cpp +++ b/ydb/library/yql/public/udf/support/udf_support.cpp @@ -50,7 +50,7 @@ namespace NUdf { typedef void(*TBackTraceCallback)(); static TBackTraceCallback BackTraceCallback; -static void UdfBackTraceFn(IOutputStream*, void* const*, size_t) { +static void UdfBackTraceFn(IOutputStream*, void* const*, size_t) { BackTraceCallback(); } diff --git a/ydb/library/yql/public/udf/udf_type_ops.h b/ydb/library/yql/public/udf/udf_type_ops.h index 4b2446c8fd..fa4bdc39e2 100644 --- a/ydb/library/yql/public/udf/udf_type_ops.h +++ b/ydb/library/yql/public/udf/udf_type_ops.h @@ -3,7 +3,7 @@ #include "udf_types.h" #include "udf_value.h" -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/digest/numeric.h> namespace NYql { @@ -51,7 +51,7 @@ inline THashType GetFloatHash(const TUnboxedValuePod& value) { } inline THashType GetStringHash(const TUnboxedValuePod& value) { - return THash<TStringBuf>{}(value.AsStringRef()); + return THash<TStringBuf>{}(value.AsStringRef()); } template <typename T, std::enable_if_t<std::is_integral<T>::value>* = nullptr> @@ -226,9 +226,9 @@ inline int CompareFloats(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rh } inline int CompareStrings(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { - const TStringBuf lhsBuf = lhs.AsStringRef(); - const TStringBuf rhsBuf = rhs.AsStringRef(); - return lhsBuf.compare(rhsBuf); + const TStringBuf lhsBuf = lhs.AsStringRef(); + const TStringBuf rhsBuf = rhs.AsStringRef(); + return lhsBuf.compare(rhsBuf); } template <typename T, std::enable_if_t<std::is_integral<T>::value>* = nullptr> @@ -412,7 +412,7 @@ inline bool EquateFloats(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rh inline bool EquateStrings(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { const auto& lhsBuf = lhs.AsStringRef(); const auto& rhsBuf = rhs.AsStringRef(); - return lhsBuf == rhsBuf; + return lhsBuf == rhsBuf; } template <typename T, std::enable_if_t<std::is_integral<T>::value>* = nullptr> diff --git a/ydb/library/yql/sql/v0/builtin.cpp b/ydb/library/yql/sql/v0/builtin.cpp index a0945f9d05..70150ce974 100644 --- a/ydb/library/yql/sql/v0/builtin.cpp +++ b/ydb/library/yql/sql/v0/builtin.cpp @@ -746,7 +746,7 @@ TNodePtr GetDataTypeStringNode(TContext& ctx, TCallNode& node, unsigned argNum, TNodePtr dataTypeNode; if (typeStringPtr) { TString typeString = NormalizeTypeString(*typeStringPtr); - if (!AvailableDataTypes.contains(typeString)) { + if (!AvailableDataTypes.contains(typeString)) { ctx.Error(typeStringNode->GetPos()) << "Bad type string: '" << typeString << "'. " << errMsgFunc(); return {}; } @@ -823,7 +823,7 @@ public: TNodePtr TryBuildDataType(TPosition pos, const TString& stringType) { auto normStringType = NormalizeTypeString(stringType); - if (!AvailableDataTypes.contains(normStringType)) { + if (!AvailableDataTypes.contains(normStringType)) { return {}; } return new TYqlDataType(pos, {BuildLiteralRawString(pos, normStringType)}); @@ -1409,7 +1409,7 @@ public: if (src) { src->AllColumns(); } - } else if (ctx.Settings.ModuleMapping.contains(Module)) { + } else if (ctx.Settings.ModuleMapping.contains(Module)) { Node = Y("bind", Module + "_module", Q(Name)); if (src) { src->AllColumns(); @@ -2213,7 +2213,7 @@ TNodePtr BuildBuiltinFunc(TContext& ctx, TPosition pos, TString name, const TVec } TString moduleResource; - if (ctx.Settings.ModuleMapping.contains(ns)) { + if (ctx.Settings.ModuleMapping.contains(ns)) { moduleResource = ctx.Settings.ModuleMapping.at(ns); } @@ -2339,10 +2339,10 @@ TNodePtr BuildBuiltinFunc(TContext& ctx, TPosition pos, TString name, const TVec } else if (scriptType != NKikimr::NMiniKQL::EScriptType::Unknown) { auto scriptName = NKikimr::NMiniKQL::ScriptTypeAsStr(scriptType); - return new TScriptUdf(pos, TString(scriptName), name, args); + return new TScriptUdf(pos, TString(scriptName), name, args); } else if (ns.empty()) { auto type = NormalizeTypeString(normalizedName); - if (AvailableDataTypes.contains(type)) { + if (AvailableDataTypes.contains(type)) { return new TYqlData(pos, type, args); } diff --git a/ydb/library/yql/sql/v0/context.cpp b/ydb/library/yql/sql/v0/context.cpp index a3a9013f2b..eff8ee07c9 100644 --- a/ydb/library/yql/sql/v0/context.cpp +++ b/ydb/library/yql/sql/v0/context.cpp @@ -276,7 +276,7 @@ bool TContext::DeclareVariable(const TString& varName, const TNodePtr& typeNode) bool TContext::AddExports(const TVector<TString>& symbols) { for (const auto& symbol: symbols) { - if (Exports.contains(symbol)) { + if (Exports.contains(symbol)) { Error() << "Duplicate export symbol: " << symbol; return false; } diff --git a/ydb/library/yql/sql/v0/context.h b/ydb/library/yql/sql/v0/context.h index 45f40fae61..84b24c68ae 100644 --- a/ydb/library/yql/sql/v0/context.h +++ b/ydb/library/yql/sql/v0/context.h @@ -72,7 +72,7 @@ namespace NSQLTranslationV0 { if (!provider) { if (Settings.AssumeYdbOnClusterWithSlash && cluster.StartsWith('/')) { normalizedClusterName = cluster; - return TString(NYql::KikimrProviderName); + return TString(NYql::KikimrProviderName); } return Nothing(); } diff --git a/ydb/library/yql/sql/v0/join.cpp b/ydb/library/yql/sql/v0/join.cpp index 78f5affb49..e4dae13c29 100644 --- a/ydb/library/yql/sql/v0/join.cpp +++ b/ydb/library/yql/sql/v0/join.cpp @@ -141,7 +141,7 @@ public: const size_t n = JoinOps.size(); TString what(Sources[n]->GetLabel()); static const TSet<TString> noRightSourceJoinOps = {"LeftOnly", "LeftSemi"}; - for (size_t nn = n; nn > 0 && noRightSourceJoinOps.contains(JoinOps[nn-1]); --nn) { + for (size_t nn = n; nn > 0 && noRightSourceJoinOps.contains(JoinOps[nn-1]); --nn) { what = Sources[nn-1]->GetLabel(); } const TString with(Sources[n + 1]->GetLabel()); @@ -398,7 +398,7 @@ bool TJoinBase::DoInit(TContext& ctx, ISource* src) { const TSet<TString> allowedJoinOps = {"Inner", "Left", "Right", "Full", "LeftOnly", "RightOnly", "Exclusion", "LeftSemi", "RightSemi", "Cross"}; for (auto& opName: JoinOps) { - if (!allowedJoinOps.contains(opName)) { + if (!allowedJoinOps.contains(opName)) { ctx.Error(Pos) << "Invalid join op: " << opName; return false; } @@ -436,7 +436,7 @@ bool TJoinBase::DoInit(TContext& ctx, ISource* src) { } } for (idx = 0; idx < Sources.size(); ++idx) { - if (!joinedSources.contains(idx)) { + if (!joinedSources.contains(idx)) { ctx.Error(Sources[idx]->GetPos()) << "Source: " << Sources[idx]->GetLabel() << " was not used in join expressions"; return false; } diff --git a/ydb/library/yql/sql/v0/node.cpp b/ydb/library/yql/sql/v0/node.cpp index 57f0c6a561..69e716d25a 100644 --- a/ydb/library/yql/sql/v0/node.cpp +++ b/ydb/library/yql/sql/v0/node.cpp @@ -720,10 +720,10 @@ void TColumns::Merge(const TColumns& columns) { SetAll(); } else { for (auto& c: columns.List) { - if (columns.Real.contains(c)) { + if (columns.Real.contains(c)) { Add(&c, false, false); } - if (columns.Artificial.contains(c)) { + if (columns.Artificial.contains(c)) { Add(&c, false, true); } } @@ -755,7 +755,7 @@ void TColumns::SetAll() { } bool TColumns::IsColumnPossible(TContext& ctx, const TString& name) { - if (All || Real.contains(name) || Artificial.contains(name)) { + if (All || Real.contains(name) || Artificial.contains(name)) { return true; } if (QualifiedAll) { @@ -1105,7 +1105,7 @@ bool ISource::AddExpressions(TContext& ctx, const TVector<TNodePtr>& expressions ctx.Error(expr->GetPos()) << "Duplicate alias found: " << alias << " in " << exprSeat << " section"; return false; } - if (names.contains(alias)) { + if (names.contains(alias)) { ctx.Error(expr->GetPos()) << "Collision between alias and column name: " << alias << " in " << exprSeat << " section"; return false; } @@ -1120,7 +1120,7 @@ bool ISource::AddExpressions(TContext& ctx, const TVector<TNodePtr>& expressions ctx.Error(expr->GetPos()) << "Duplicate column name found: " << columnName << " in " << exprSeat << " section"; return false; } - if (!alias && ExprAliases.contains(columnName)) { + if (!alias && ExprAliases.contains(columnName)) { ctx.Error(expr->GetPos()) << "Collision between alias and column name: " << columnName << " in " << exprSeat << " section"; return false; } @@ -1261,7 +1261,7 @@ bool ISource::IsCompositeSource() const { } bool ISource::IsGroupByColumn(const TString& column) const { - return GroupKeys.contains(column); + return GroupKeys.contains(column); } bool ISource::IsFlattenByColumns() const { diff --git a/ydb/library/yql/sql/v0/query.cpp b/ydb/library/yql/sql/v0/query.cpp index 7752b28b01..d375e7a1f3 100644 --- a/ydb/library/yql/sql/v0/query.cpp +++ b/ydb/library/yql/sql/v0/query.cpp @@ -389,17 +389,17 @@ public: auto fields = Y("Void"); auto source = Y("DataSource", BuildQuotedAtom(Pos, service), BuildQuotedAtom(Pos, tr.Cluster)); auto options = tr.Options ? Q(tr.Options) : Q(Y()); - Add(Y("let", "x", keys->Y(TString(ReadName), "world", source, keys, fields, options))); + Add(Y("let", "x", keys->Y(TString(ReadName), "world", source, keys, fields, options))); if (service != YtProviderName) { if (InSubquery) { ctx.Error() << "Using of system '" << service << "' is not allowed in SUBQUERY"; return false; } - Add(Y("let", "world", Y(TString(LeftName), "x"))); + Add(Y("let", "world", Y(TString(LeftName), "x"))); } - Add(Y("let", tr.RefName, Y(TString(RightName), "x"))); + Add(Y("let", tr.RefName, Y(TString(RightName), "x"))); ctx.UsedClusters.insert(tr.Cluster); } return TAstListNode::DoInit(ctx, src); @@ -449,7 +449,7 @@ public: } for (auto& keyColumn : PkColumns) { - if (!columnsSet.contains(keyColumn.Name)) { + if (!columnsSet.contains(keyColumn.Name)) { ctx.Error(keyColumn.Pos) << "Undefined column: " << keyColumn.Name; return false; } @@ -549,8 +549,8 @@ public: Add("block", Q(Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.ServiceName(ctx)), BuildQuotedAtom(Pos, Table.Cluster))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) ))); ctx.UsedClusters.insert(Table.Cluster); @@ -642,8 +642,8 @@ public: Add("block", Q(Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.ServiceName(ctx)), BuildQuotedAtom(Pos, Table.Cluster))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) ))); ctx.UsedClusters.insert(Table.Cluster); @@ -686,8 +686,8 @@ public: Add("block", Q(Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.ServiceName(ctx)), BuildQuotedAtom(Pos, Table.Cluster))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(Y(Q(Y(Q("mode"), Q("drop"))))))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(Y(Q(Y(Q("mode"), Q("drop"))))))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) ))); ctx.UsedClusters.insert(Table.Cluster); @@ -780,8 +780,8 @@ public: Add("block", Q((Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.ServiceName(ctx)), BuildQuotedAtom(Pos, Table.Cluster))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Label, Q(options))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Label, Q(options))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) )))); ctx.UsedClusters.insert(Table.Cluster); @@ -862,7 +862,7 @@ public: TPtr ProduceOperation(TContext& ctx, const TString& sinkName, const TString& service) override { Y_UNUSED(ctx); Y_UNUSED(service); - return Y("let", "world", Y(TString(CommitName), "world", sinkName)); + return Y("let", "world", Y(TString(CommitName), "world", sinkName)); } }; @@ -881,7 +881,7 @@ public: return nullptr; } - return Y("let", "world", Y(TString(CommitName), "world", sinkName, Q(Y(Q(Y(Q("mode"), Q("rollback"))))))); + return Y("let", "world", Y(TString(CommitName), "world", sinkName, Q(Y(Q(Y(Q("mode"), Q("rollback"))))))); } }; @@ -901,13 +901,13 @@ public: bool DoInit(TContext& ctx, ISource* src) override { auto block(Y( Y("let", "result_sink", Y("DataSink", Q(TString(ResultProviderName)))), - Y("let", "world", Y(TString(WriteName), "world", "result_sink", Y("Key"), Label, Q(Settings))) + Y("let", "world", Y(TString(WriteName), "world", "result_sink", Y("Key"), Label, Q(Settings))) )); if (ctx.PragmaAutoCommit) { block = L(block, Y("let", "world", CommitClusters)); } - block = L(block, Y("return", Y(TString(CommitName), "world", "result_sink"))); + block = L(block, Y("return", Y(TString(CommitName), "world", "result_sink"))); Add("block", Q(block)); return TAstListNode::DoInit(ctx, src); } @@ -965,7 +965,7 @@ public: } for (auto& nodes: ctx.NamedNodes) { - if (src || ctx.Exports.contains(nodes.first)) { + if (src || ctx.Exports.contains(nodes.first)) { auto& node = nodes.second.top(); ctx.PushBlockShortcuts(); if (!node->Init(ctx, src)) { @@ -975,7 +975,7 @@ public: node = ctx.GroundBlockShortcutsForExpr(node); // Some constants may be used directly by YQL code and need to be translated without reference from SQL AST - if (node->IsConstant() || ctx.Exports.contains(nodes.first)) { + if (node->IsConstant() || ctx.Exports.contains(nodes.first)) { Add(Y("let", BuildAtom(node->GetPos(), nodes.first), node)); } } @@ -986,18 +986,18 @@ public: auto resultSink = Y("DataSink", BuildQuotedAtom(Pos, TString(ResultProviderName))); for (const auto& warningPragma : ctx.WarningPolicy.GetRules()) { - Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, + Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, BuildQuotedAtom(Pos, "Warning"), BuildQuotedAtom(Pos, warningPragma.GetPattern()), BuildQuotedAtom(Pos, to_lower(ToString(warningPragma.GetAction())))))); } if (ctx.ResultSizeLimit > 0) { - Add(Y("let", "world", Y(TString(ConfigureName), "world", resultSink, + Add(Y("let", "world", Y(TString(ConfigureName), "world", resultSink, BuildQuotedAtom(Pos, "SizeLimit"), BuildQuotedAtom(Pos, ToString(ctx.ResultSizeLimit))))); } if (!ctx.PragmaPullUpFlatMapOverJoin) { - Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, + Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, BuildQuotedAtom(Pos, "DisablePullUpFlatMapOverJoin")))); } } @@ -1092,7 +1092,7 @@ public: } Node = Y(); - Node = L(Node, AstNode(TString(ConfigureName))); + Node = L(Node, AstNode(TString(ConfigureName))); Node = L(Node, AstNode(TString(TStringBuf("world")))); Node = L(Node, datasource); diff --git a/ydb/library/yql/sql/v0/select.cpp b/ydb/library/yql/sql/v0/select.cpp index ef47023be1..0832e3306c 100644 --- a/ydb/library/yql/sql/v0/select.cpp +++ b/ydb/library/yql/sql/v0/select.cpp @@ -998,7 +998,7 @@ public: } bool IsGroupByColumn(const TString& column) const override { - return GroupingCols.contains(column); + return GroupingCols.contains(column); } const TSet<TString>& GetGroupingCols() const { @@ -1924,7 +1924,7 @@ public: } for (const auto& column: columns) { hint <<= 1; - if (!GroupByColumns.contains(column)) { + if (!GroupByColumns.contains(column)) { hint += 1; } } diff --git a/ydb/library/yql/sql/v0/sql.cpp b/ydb/library/yql/sql/v0/sql.cpp index b028fc0439..b972a6868c 100644 --- a/ydb/library/yql/sql/v0/sql.cpp +++ b/ydb/library/yql/sql/v0/sql.cpp @@ -21,7 +21,7 @@ #include <util/generic/set.h> #include <util/string/ascii.h> #include <util/string/cast.h> -#include <util/string/reverse.h> +#include <util/string/reverse.h> #include <util/string/split.h> #include <util/string/hex.h> #include <util/string/join.h> @@ -1939,7 +1939,7 @@ TNodePtr TSqlExpression::SubExpr(const TRule_xor_subexpr& node) { } } if (madeIncrement) { - ReverseInPlace(upperBound); + ReverseInPlace(upperBound); const auto& between = BuildBinaryOp( pos, "And", @@ -3328,7 +3328,7 @@ TWindowSpecificationPtr TSqlSelect::WindowSpecification(const TRule_window_speci bool TSqlSelect::WindowDefenition(const TRule_window_definition& rule, TWinSpecs& winSpecs) { const TString windowName = Id(rule.GetRule_new_window_name1().GetRule_window_name1().GetRule_id1(), *this); - if (winSpecs.contains(windowName)) { + if (winSpecs.contains(windowName)) { Ctx.Error() << "Unable to declare window with same name: " << windowName; return false; } @@ -3724,7 +3724,7 @@ const TGroupByClause::TGroupingSetFeatures& TGroupByClause::Features() const { } bool TGroupByClause::AddAlias(const TString& label, const TNodePtr& node) { - if (Aliases().contains(label)) { + if (Aliases().contains(label)) { Ctx.Error() << "Duplicated aliases not allowed"; Ctx.IncrementMonCounter("sql_errors", "GroupByDuplicateAliases"); return false; diff --git a/ydb/library/yql/sql/v1/builtin.cpp b/ydb/library/yql/sql/v1/builtin.cpp index 43ef1243f1..12324fc1c8 100644 --- a/ydb/library/yql/sql/v1/builtin.cpp +++ b/ydb/library/yql/sql/v1/builtin.cpp @@ -1005,7 +1005,7 @@ TNodePtr GetDataTypeStringNode(TContext& ctx, TCallNode& node, unsigned argNum, TNodePtr dataTypeNode; if (typeStringPtr) { TString typeString = NormalizeTypeString(*typeStringPtr); - if (!AvailableDataTypes.contains(typeString)) { + if (!AvailableDataTypes.contains(typeString)) { ctx.Error(typeStringNode->GetPos()) << "Bad type string: '" << typeString << "'. " << errMsgFunc(); return {}; } @@ -2023,7 +2023,7 @@ public: if (src) { src->AllColumns(); } - } else if (ctx.Settings.ModuleMapping.contains(Module)) { + } else if (ctx.Settings.ModuleMapping.contains(Module)) { Node = Y("bind", Module + "_module", Q(Name)); if (src) { src->AllColumns(); @@ -2909,7 +2909,7 @@ TNodePtr BuildBuiltinFunc(TContext& ctx, TPosition pos, TString name, const TVec } TString moduleResource; - if (ctx.Settings.ModuleMapping.contains(ns)) { + if (ctx.Settings.ModuleMapping.contains(ns)) { moduleResource = ctx.Settings.ModuleMapping.at(ns); } @@ -3072,7 +3072,7 @@ TNodePtr BuildBuiltinFunc(TContext& ctx, TPosition pos, TString name, const TVec return BuildUdf(ctx, pos, nameSpace, name, makeUdfArgs()); } else if (scriptType != NKikimr::NMiniKQL::EScriptType::Unknown) { auto scriptName = NKikimr::NMiniKQL::ScriptTypeAsStr(scriptType); - return new TScriptUdf(pos, TString(scriptName), name, args); + return new TScriptUdf(pos, TString(scriptName), name, args); } else if (ns.empty()) { if (auto simpleType = LookupSimpleTypeBySqlAlias(normalizedName, ctx.FlexibleTypes)) { const auto type = ToString(*simpleType); diff --git a/ydb/library/yql/sql/v1/context.h b/ydb/library/yql/sql/v1/context.h index 8951757486..18dbd81cfe 100644 --- a/ydb/library/yql/sql/v1/context.h +++ b/ydb/library/yql/sql/v1/context.h @@ -130,7 +130,7 @@ namespace NSQLTranslationV1 { if (!provider) { if (Settings.AssumeYdbOnClusterWithSlash && cluster.StartsWith('/')) { normalizedClusterName = cluster; - return TString(NYql::KikimrProviderName); + return TString(NYql::KikimrProviderName); } return Nothing(); } diff --git a/ydb/library/yql/sql/v1/join.cpp b/ydb/library/yql/sql/v1/join.cpp index 29f5b3ec4b..1ffc9d91bc 100644 --- a/ydb/library/yql/sql/v1/join.cpp +++ b/ydb/library/yql/sql/v1/join.cpp @@ -146,7 +146,7 @@ public: const size_t n = JoinOps.size(); TString what(Sources[n]->GetLabel()); static const TSet<TString> noRightSourceJoinOps = {"LeftOnly", "LeftSemi"}; - for (size_t nn = n; nn > 0 && noRightSourceJoinOps.contains(JoinOps[nn-1]); --nn) { + for (size_t nn = n; nn > 0 && noRightSourceJoinOps.contains(JoinOps[nn-1]); --nn) { what = Sources[nn-1]->GetLabel(); } const TString with(Sources[n + 1]->GetLabel()); @@ -426,7 +426,7 @@ bool TJoinBase::DoInit(TContext& ctx, ISource* initSrc) { const TSet<TString> allowedJoinOps = {"Inner", "Left", "Right", "Full", "LeftOnly", "RightOnly", "Exclusion", "LeftSemi", "RightSemi", "Cross"}; for (auto& opName: JoinOps) { - if (!allowedJoinOps.contains(opName)) { + if (!allowedJoinOps.contains(opName)) { ctx.Error(Pos) << "Invalid join op: " << opName; return false; } @@ -464,7 +464,7 @@ bool TJoinBase::DoInit(TContext& ctx, ISource* initSrc) { } } for (idx = 0; idx < Sources.size(); ++idx) { - if (!joinedSources.contains(idx)) { + if (!joinedSources.contains(idx)) { ctx.Error(Sources[idx]->GetPos()) << "Source: " << Sources[idx]->GetLabel() << " was not used in join expressions"; return false; } diff --git a/ydb/library/yql/sql/v1/node.cpp b/ydb/library/yql/sql/v1/node.cpp index 870bbd9cc7..17c7fb0363 100644 --- a/ydb/library/yql/sql/v1/node.cpp +++ b/ydb/library/yql/sql/v1/node.cpp @@ -900,10 +900,10 @@ void TColumns::Merge(const TColumns& columns) { SetAll(); } else { for (auto& c: columns.List) { - if (columns.Real.contains(c)) { + if (columns.Real.contains(c)) { Add(&c, false, false); } - if (columns.Artificial.contains(c)) { + if (columns.Artificial.contains(c)) { Add(&c, false, true); } } @@ -935,7 +935,7 @@ void TColumns::SetAll() { } bool TColumns::IsColumnPossible(TContext& ctx, const TString& name) { - if (All || Real.contains(name) || Artificial.contains(name)) { + if (All || Real.contains(name) || Artificial.contains(name)) { return true; } if (QualifiedAll) { @@ -1346,7 +1346,7 @@ bool ISource::AddExpressions(TContext& ctx, const TVector<TNodePtr>& expressions ctx.Error(expr->GetPos()) << "Duplicate alias found: " << alias << " in " << exprSeat << " section"; return false; } - if (names.contains(alias)) { + if (names.contains(alias)) { ctx.Error(expr->GetPos()) << "Collision between alias and column name: " << alias << " in " << exprSeat << " section"; return false; } @@ -1515,7 +1515,7 @@ bool ISource::IsCompositeSource() const { } bool ISource::IsGroupByColumn(const TString& column) const { - return GroupKeys.contains(column); + return GroupKeys.contains(column); } bool ISource::IsFlattenByColumns() const { diff --git a/ydb/library/yql/sql/v1/query.cpp b/ydb/library/yql/sql/v1/query.cpp index 725356b9f5..410474d3d7 100644 --- a/ydb/library/yql/sql/v1/query.cpp +++ b/ydb/library/yql/sql/v1/query.cpp @@ -531,17 +531,17 @@ public: auto fields = Y("Void"); auto source = Y("DataSource", BuildQuotedAtom(Pos, tr.Service), Scoped->WrapCluster(tr.Cluster, ctx)); auto options = tr.Options ? Q(tr.Options) : Q(Y()); - Add(Y("let", "x", keys->Y(TString(ReadName), "world", source, keys, fields, options))); + Add(Y("let", "x", keys->Y(TString(ReadName), "world", source, keys, fields, options))); if (tr.Service != YtProviderName) { if (InSubquery) { ctx.Error() << "Using of system '" << tr.Service << "' is not allowed in SUBQUERY"; return false; } - Add(Y("let", "world", Y(TString(LeftName), "x"))); + Add(Y("let", "world", Y(TString(LeftName), "x"))); } - Add(Y("let", tr.RefName, Y(TString(RightName), "x"))); + Add(Y("let", tr.RefName, Y(TString(RightName), "x"))); } return TAstListNode::DoInit(ctx, src); } @@ -589,7 +589,7 @@ public: } for (auto& keyColumn : Params.PkColumns) { - if (!columnsSet.contains(keyColumn.Name)) { + if (!columnsSet.contains(keyColumn.Name)) { ctx.Error(keyColumn.Pos) << "Undefined column: " << keyColumn.Name; return false; } @@ -795,8 +795,8 @@ public: Add("block", Q(Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.Service), Scoped->WrapCluster(Table.Cluster, ctx))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) ))); return TAstListNode::DoInit(ctx, src); @@ -995,8 +995,8 @@ public: Add("block", Q(Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.Service), Scoped->WrapCluster(Table.Cluster, ctx))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(opts))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) ))); return TAstListNode::DoInit(ctx, src); @@ -1035,8 +1035,8 @@ public: Add("block", Q(Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.Service), Scoped->WrapCluster(Table.Cluster, ctx))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(Y(Q(Y(Q("mode"), Q("drop"))))))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(Y(Q(Y(Q("mode"), Q("drop"))))))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) ))); return TAstListNode::DoInit(ctx, FakeSource.Get()); @@ -1453,8 +1453,8 @@ public: Add("block", Q((Y( Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Table.Service), Scoped->WrapCluster(Table.Cluster, ctx))), - Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Label, Q(options))), - Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) + Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Label, Q(options))), + Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world")) )))); return TAstListNode::DoInit(ctx, src); @@ -1549,13 +1549,13 @@ public: bool DoInit(TContext& ctx, ISource* src) override { auto block(Y( Y("let", "result_sink", Y("DataSink", Q(TString(ResultProviderName)))), - Y("let", "world", Y(TString(WriteName), "world", "result_sink", Y("Key"), Label, Q(Settings))) + Y("let", "world", Y(TString(WriteName), "world", "result_sink", Y("Key"), Label, Q(Settings))) )); if (ctx.PragmaAutoCommit) { block = L(block, Y("let", "world", CommitClusters)); } - block = L(block, Y("return", Y(TString(CommitName), "world", "result_sink"))); + block = L(block, Y("return", Y(TString(CommitName), "world", "result_sink"))); Add("block", Q(block)); return TAstListNode::DoInit(ctx, src); } @@ -1641,18 +1641,18 @@ public: auto resultSink = Y("DataSink", BuildQuotedAtom(Pos, TString(ResultProviderName))); for (const auto& warningPragma : ctx.WarningPolicy.GetRules()) { - Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, + Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, BuildQuotedAtom(Pos, "Warning"), BuildQuotedAtom(Pos, warningPragma.GetPattern()), BuildQuotedAtom(Pos, to_lower(ToString(warningPragma.GetAction())))))); } if (ctx.ResultSizeLimit > 0) { - Add(Y("let", "world", Y(TString(ConfigureName), "world", resultSink, + Add(Y("let", "world", Y(TString(ConfigureName), "world", resultSink, BuildQuotedAtom(Pos, "SizeLimit"), BuildQuotedAtom(Pos, ToString(ctx.ResultSizeLimit))))); } if (!ctx.PragmaPullUpFlatMapOverJoin) { - Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, + Add(Y("let", "world", Y(TString(ConfigureName), "world", configSource, BuildQuotedAtom(Pos, "DisablePullUpFlatMapOverJoin")))); } @@ -1807,7 +1807,7 @@ public: } Node = Y(); - Node = L(Node, AstNode(TString(ConfigureName))); + Node = L(Node, AstNode(TString(ConfigureName))); Node = L(Node, AstNode(TString(TStringBuf("world")))); Node = L(Node, datasource); diff --git a/ydb/library/yql/sql/v1/select.cpp b/ydb/library/yql/sql/v1/select.cpp index 2841f05a5b..0d9ff076f5 100644 --- a/ydb/library/yql/sql/v1/select.cpp +++ b/ydb/library/yql/sql/v1/select.cpp @@ -1314,7 +1314,7 @@ public: bool IsGroupByColumn(const TString& column) const override { YQL_ENSURE(!GroupingCols.empty()); - return GroupingCols.contains(column); + return GroupingCols.contains(column); } const TSet<TString>& GetGroupingCols() const { @@ -2415,7 +2415,7 @@ public: } for (const auto& column: columns) { hint <<= 1; - if (!GroupByColumns.contains(column)) { + if (!GroupByColumns.contains(column)) { hint += 1; } } diff --git a/ydb/library/yql/sql/v1/sql.cpp b/ydb/library/yql/sql/v1/sql.cpp index ab5a864788..87bbb078ff 100644 --- a/ydb/library/yql/sql/v1/sql.cpp +++ b/ydb/library/yql/sql/v1/sql.cpp @@ -29,7 +29,7 @@ #include <util/generic/ylimits.h> #include <util/string/ascii.h> #include <util/string/cast.h> -#include <util/string/reverse.h> +#include <util/string/reverse.h> #include <util/string/split.h> #include <util/string/hex.h> #include <util/string/join.h> @@ -7001,7 +7001,7 @@ TWindowSpecificationPtr TSqlTranslation::WindowSpecification(const TRule_window_ bool TSqlSelect::WindowDefinition(const TRule_window_definition& rule, TWinSpecs& winSpecs) { const TString windowName = Id(rule.GetRule_new_window_name1().GetRule_window_name1().GetRule_an_id_window1(), *this); - if (winSpecs.contains(windowName)) { + if (winSpecs.contains(windowName)) { Ctx.Error() << "Unable to declare window with same name: " << windowName; return false; } @@ -7444,7 +7444,7 @@ const TGroupByClause::TGroupingSetFeatures& TGroupByClause::Features() const { } bool TGroupByClause::AddAlias(const TString& label, const TNodePtr& node) { - if (Aliases().contains(label)) { + if (Aliases().contains(label)) { Ctx.Error() << "Duplicated aliases not allowed"; Ctx.IncrementMonCounter("sql_errors", "GroupByDuplicateAliases"); return false; diff --git a/ydb/library/yql/udfs/common/string/string_udf.cpp b/ydb/library/yql/udfs/common/string/string_udf.cpp index c468215090..1ea7b0b755 100644 --- a/ydb/library/yql/udfs/common/string/string_udf.cpp +++ b/ydb/library/yql/udfs/common/string/string_udf.cpp @@ -3,11 +3,11 @@ #include <ydb/library/yql/public/udf/udf_value_builder.h> #include <library/cpp/charset/codepage.h> -#include <library/cpp/deprecated/split/split_iterator.h> +#include <library/cpp/deprecated/split/split_iterator.h> #include <library/cpp/html/pcdata/pcdata.h> #include <library/cpp/string_utils/base64/base64.h> #include <library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h> -#include <library/cpp/string_utils/quote/quote.h> +#include <library/cpp/string_utils/quote/quote.h> #include <util/charset/wide.h> #include <util/generic/vector.h> @@ -16,8 +16,8 @@ #include <util/string/escape.h> #include <util/string/hex.h> #include <util/string/join.h> -#include <util/string/reverse.h> -#include <util/string/split.h> +#include <util/string/reverse.h> +#include <util/string/split.h> #include <util/string/strip.h> #include <util/string/subst.h> #include <util/string/util.h> @@ -52,7 +52,7 @@ namespace { const TString input(args[0].AsStringRef()); \ try { \ TUtf16String wide = UTF8ToWide(input); \ - function(wide); \ + function(wide); \ return valueBuilder->NewString(WideToUTF8(wide)); \ } catch (yexception&) { \ return TUnboxedValue(); \ @@ -166,7 +166,7 @@ namespace { XX(HasSuffixIgnoreCase, AsciiHasSuffixIgnoreCase) #define STROKA_UDF_MAP(XX) \ - XX(Reverse, ReverseInPlace) + XX(Reverse, ReverseInPlace) #define IS_ASCII_UDF_MAP(XX) \ XX(IsAscii) \ diff --git a/ydb/library/yql/udfs/common/topfreq/topfreq_udf_ut.cpp b/ydb/library/yql/udfs/common/topfreq/topfreq_udf_ut.cpp index c6f6ecab72..76502f89f0 100644 --- a/ydb/library/yql/udfs/common/topfreq/topfreq_udf_ut.cpp +++ b/ydb/library/yql/udfs/common/topfreq/topfreq_udf_ut.cpp @@ -25,7 +25,7 @@ namespace NYql { , Env_(Alloc_) { MutableFunctionRegistry_->AddModule("", "TopFreq", NUdf::CreateTopFreqModule()); - PgmBuidler_.Reset(new TProgramBuilder(Env_, *MutableFunctionRegistry_)); + PgmBuidler_.Reset(new TProgramBuilder(Env_, *MutableFunctionRegistry_)); } TProgramBuilder& GetProgramBuilder() { diff --git a/ydb/library/yql/utils/actor_log/log.h b/ydb/library/yql/utils/actor_log/log.h index 08d525d28b..bd35e0ca16 100644 --- a/ydb/library/yql/utils/actor_log/log.h +++ b/ydb/library/yql/utils/actor_log/log.h @@ -53,7 +53,7 @@ public: class TLogWrapReceive: public NActors::TDecorator { public: TLogWrapReceive(NActors::IActor* actor, const TString& sessionId, int component = NKikimrServices::YQL_PROXY) - : NActors::TDecorator(THolder(actor)) + : NActors::TDecorator(THolder(actor)) , SessionId(sessionId) , Component(component) { } diff --git a/ydb/library/yql/utils/backtrace/backtrace.cpp b/ydb/library/yql/utils/backtrace/backtrace.cpp index f9487f6671..8dfa81f8ad 100644 --- a/ydb/library/yql/utils/backtrace/backtrace.cpp +++ b/ydb/library/yql/utils/backtrace/backtrace.cpp @@ -95,14 +95,14 @@ void KikimrBacktraceFormatImpl(IOutputStream* out) { void* array[300]; const size_t s = BackTrace(array, Y_ARRAY_SIZE(array)); - KikimrBacktraceFormatImpl(out, array, s); + KikimrBacktraceFormatImpl(out, array, s); } -void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize) { +void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize) { using namespace llvm; using namespace symbolize; - TRawOStreamProxy outStream(*out); + TRawOStreamProxy outStream(*out); THashMap<TString, TDllInfo> dlls; #ifdef _linux_ dl_iterate_phdr(DlIterCallback, &dlls); diff --git a/ydb/library/yql/utils/backtrace/backtrace.h b/ydb/library/yql/utils/backtrace/backtrace.h index 487547e63b..6ba58ee19d 100644 --- a/ydb/library/yql/utils/backtrace/backtrace.h +++ b/ydb/library/yql/utils/backtrace/backtrace.h @@ -1,11 +1,11 @@ #pragma once -#include <util/system/types.h> - +#include <util/system/types.h> + class IOutputStream; void KikimrBacktraceFormatImpl(IOutputStream* out); -void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize); +void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize); void KikimrBackTrace(); void EnableKikimrBacktraceFormat(); void PrintBacktraceToStderr(int signum); diff --git a/ydb/library/yql/utils/debug_info.cpp b/ydb/library/yql/utils/debug_info.cpp index ff56166695..25eb2c0af8 100644 --- a/ydb/library/yql/utils/debug_info.cpp +++ b/ydb/library/yql/utils/debug_info.cpp @@ -33,7 +33,7 @@ void SetCurrentOperationId(const char* operationId) { } else { threadName = operationId; } - TThread::SetCurrentThreadName(threadName); + TThread::SetCurrentThreadName(threadName); } long GetRunnigThreadsCount() { diff --git a/ydb/library/yql/utils/multi_resource_lock_ut.cpp b/ydb/library/yql/utils/multi_resource_lock_ut.cpp index 0af9cea3ff..e4e38a9018 100644 --- a/ydb/library/yql/utils/multi_resource_lock_ut.cpp +++ b/ydb/library/yql/utils/multi_resource_lock_ut.cpp @@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(TMultiResourceLock) { TVector<TVector<int>> workersData; workersData.resize(workersCount); - TAdaptiveThreadPool queue; + TAdaptiveThreadPool queue; queue.Start(0); TVector<NThreading::TFuture<void>> workers; diff --git a/ydb/library/yql/utils/resetable_setting.h b/ydb/library/yql/utils/resetable_setting.h index 0112105a3b..b508d805b3 100644 --- a/ydb/library/yql/utils/resetable_setting.h +++ b/ydb/library/yql/utils/resetable_setting.h @@ -37,16 +37,16 @@ public: const TSet& GetValueSet() const { YQL_ENSURE(IsSet()); - return std::get<TSet>(*Value); + return std::get<TSet>(*Value); } const TReset& GetValueReset() const { YQL_ENSURE(!IsSet()); - return std::get<TReset>(*Value); + return std::get<TReset>(*Value); } private: - TMaybe<std::variant<TSet, TReset>> Value; + TMaybe<std::variant<TSet, TReset>> Value; }; template <typename S, typename R> diff --git a/ydb/public/lib/deprecated/client/grpc_client.cpp b/ydb/public/lib/deprecated/client/grpc_client.cpp index dbf808ef75..008e184d5c 100644 --- a/ydb/public/lib/deprecated/client/grpc_client.cpp +++ b/ydb/public/lib/deprecated/client/grpc_client.cpp @@ -240,7 +240,7 @@ namespace NKikimr { bool IsStreamTag(void *tag) { with_lock (Mutex) { - return StreamTags.contains(tag); + return StreamTags.contains(tag); } } diff --git a/ydb/public/lib/ydb_cli/dump/restore_impl.cpp b/ydb/public/lib/ydb_cli/dump/restore_impl.cpp index 74f4ffd18c..952861a7bc 100644 --- a/ydb/public/lib/ydb_cli/dump/restore_impl.cpp +++ b/ydb/public/lib/ydb_cli/dump/restore_impl.cpp @@ -332,8 +332,8 @@ TRestoreResult TRestoreClient::RestoreData(const TFsPath& fsPath, const TString& switch (settings.Mode_) { case TRestoreSettings::EMode::Yql: case TRestoreSettings::EMode::BulkUpsert: { - accumulator.Reset(CreateCompatAccumulator(dbPath, desc, settings)); - writer.Reset(CreateCompatWriter(dbPath, TableClient, accumulator.Get(), settings)); + accumulator.Reset(CreateCompatAccumulator(dbPath, desc, settings)); + writer.Reset(CreateCompatWriter(dbPath, TableClient, accumulator.Get(), settings)); break; } @@ -345,8 +345,8 @@ TRestoreResult TRestoreClient::RestoreData(const TFsPath& fsPath, const TString& return Result<TRestoreResult>(std::move(descResult)); } - accumulator.Reset(CreateImportDataAccumulator(desc, *actualDesc, settings)); - writer.Reset(CreateImportDataWriter(dbPath, desc, ImportClient, TableClient, accumulator.Get(), settings)); + accumulator.Reset(CreateImportDataAccumulator(desc, *actualDesc, settings)); + writer.Reset(CreateImportDataWriter(dbPath, desc, ImportClient, TableClient, accumulator.Get(), settings)); break; } diff --git a/ydb/public/lib/ydb_cli/dump/restore_import_data.cpp b/ydb/public/lib/ydb_cli/dump/restore_import_data.cpp index 817aa76eea..627de32c94 100644 --- a/ydb/public/lib/ydb_cli/dump/restore_import_data.cpp +++ b/ydb/public/lib/ydb_cli/dump/restore_import_data.cpp @@ -29,7 +29,7 @@ namespace { class TValue { struct TSpecialType { bool operator<(const TSpecialType&) const { - return false; // to make std::variant's comparator happy + return false; // to make std::variant's comparator happy } }; @@ -91,14 +91,14 @@ public: ui64 MemSize() const { switch (GetType()) { case EType::String: - return sizeof(Value) + std::get<TString>(Value).size(); + return sizeof(Value) + std::get<TString>(Value).size(); default: return sizeof(Value); } } private: - std::variant< + std::variant< TInf, TNull, TString, diff --git a/ydb/public/sdk/cpp/client/ydb_coordination/coordination.cpp b/ydb/public/sdk/cpp/client/ydb_coordination/coordination.cpp index 7a99c95214..f6cfee95b1 100644 --- a/ydb/public/sdk/cpp/client/ydb_coordination/coordination.cpp +++ b/ydb/public/sdk/cpp/client/ydb_coordination/coordination.cpp @@ -761,7 +761,7 @@ private: void DoSemaphoreSendOp(TSemaphoreState* state, TIntrusivePtr<TSemaphoreOp> op) { Y_VERIFY(IsWriteAllowed()); Y_VERIFY(op->ReqId > 0); - Y_VERIFY(!state->WaitingOps.contains(op->ReqId)); + Y_VERIFY(!state->WaitingOps.contains(op->ReqId)); SemaphoreByReqId[op->ReqId] = state; state->WaitingOps[op->ReqId] = op; state->LastSentOp = op; diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/write_session.h b/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/write_session.h index 324550bb02..762864ece4 100644 --- a/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/write_session.h +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/write_session.h @@ -308,7 +308,7 @@ public: // Empty maybe - block till all work is done. Otherwise block at most at closeTimeout duration. bool Close(TDuration closeTimeout = TDuration::Max()) override; - TWriterCounters::TPtr GetCounters() override {Y_FAIL("Unimplemented"); } //ToDo - unimplemented; + TWriterCounters::TPtr GetCounters() override {Y_FAIL("Unimplemented"); } //ToDo - unimplemented; ~TWriteSession(); // will not call close - destroy everything without acks diff --git a/ydb/public/sdk/cpp/client/ydb_table/table.cpp b/ydb/public/sdk/cpp/client/ydb_table/table.cpp index 610fec3884..e2193453c2 100644 --- a/ydb/public/sdk/cpp/client/ydb_table/table.cpp +++ b/ydb/public/sdk/cpp/client/ydb_table/table.cpp @@ -4511,7 +4511,7 @@ TTtlSettings::TTtlSettings(const Ydb::Table::DateTypeColumnModeSettings& mode, u } const TDateTypeColumnModeSettings& TTtlSettings::GetDateTypeColumn() const { - return std::get<TDateTypeColumnModeSettings>(Mode_); + return std::get<TDateTypeColumnModeSettings>(Mode_); } TTtlSettings::TTtlSettings(const TString& columnName, EUnit columnUnit, const TDuration& expireAfter) @@ -4525,7 +4525,7 @@ TTtlSettings::TTtlSettings(const Ydb::Table::ValueSinceUnixEpochModeSettings& mo } const TValueSinceUnixEpochModeSettings& TTtlSettings::GetValueSinceUnixEpoch() const { - return std::get<TValueSinceUnixEpochModeSettings>(Mode_); + return std::get<TValueSinceUnixEpochModeSettings>(Mode_); } void TTtlSettings::SerializeTo(Ydb::Table::TtlSettings& proto) const { @@ -4561,7 +4561,7 @@ TAlterTtlSettings::EAction TAlterTtlSettings::GetAction() const { } const TTtlSettings& TAlterTtlSettings::GetTtlSettings() const { - return std::get<TTtlSettings>(Action_); + return std::get<TTtlSettings>(Action_); } class TAlterTtlSettingsBuilder::TImpl { diff --git a/ydb/public/sdk/cpp/client/ydb_table/table.h b/ydb/public/sdk/cpp/client/ydb_table/table.h index 42d21d2fec..4422094794 100644 --- a/ydb/public/sdk/cpp/client/ydb_table/table.h +++ b/ydb/public/sdk/cpp/client/ydb_table/table.h @@ -263,7 +263,7 @@ public: const TDuration& GetRunInterval() const; private: - std::variant< + std::variant< TDateTypeColumnModeSettings, TValueSinceUnixEpochModeSettings > Mode_; diff --git a/ydb/services/cms/cms_ut.cpp b/ydb/services/cms/cms_ut.cpp index 7d5234715e..bbdb611000 100644 --- a/ydb/services/cms/cms_ut.cpp +++ b/ydb/services/cms/cms_ut.cpp @@ -418,7 +418,7 @@ Y_UNIT_TEST_SUITE(TGRpcCmsTest) { UNIT_ASSERT(res); UNIT_ASSERT_VALUES_EQUAL(result.storage_units_size(), poolKinds.size()); for (auto &pool : result.storage_units()) { - UNIT_ASSERT(poolKinds.contains(pool.kind())); + UNIT_ASSERT(poolKinds.contains(pool.kind())); UNIT_ASSERT_VALUES_EQUAL(pool.labels().size(), 2); UNIT_ASSERT_VALUES_EQUAL(pool.labels().at("disk_type"), "ROT"); UNIT_ASSERT_VALUES_EQUAL(pool.labels().at("erasure"), "none"); @@ -429,7 +429,7 @@ Y_UNIT_TEST_SUITE(TGRpcCmsTest) { THashSet<TString> zones = {{TString("dc-1"), TString("any")}}; UNIT_ASSERT_VALUES_EQUAL(result.availability_zones_size(), zones.size()); for (auto &zone: result.availability_zones()) { - UNIT_ASSERT(zones.contains(zone.name())); + UNIT_ASSERT(zones.contains(zone.name())); if (zone.name() == "dc-1") { UNIT_ASSERT_VALUES_EQUAL(zone.labels().size(), 2); UNIT_ASSERT_VALUES_EQUAL(zone.labels().at("fixed_data_center"), "DC-1"); @@ -451,7 +451,7 @@ Y_UNIT_TEST_SUITE(TGRpcCmsTest) { UNIT_ASSERT_VALUES_EQUAL(unit.kind(), "slot"); UNIT_ASSERT_VALUES_EQUAL(unit.allowed_availability_zones_size(), unitZones.size()); for (auto &zone : unit.allowed_availability_zones()) { - UNIT_ASSERT(unitZones.contains(zone)); + UNIT_ASSERT(unitZones.contains(zone)); unitZones.erase(zone); } UNIT_ASSERT_VALUES_EQUAL(unit.labels().size(), 2); diff --git a/ydb/services/kesus/grpc_service.cpp b/ydb/services/kesus/grpc_service.cpp index c5826b6627..1a900f3cba 100644 --- a/ydb/services/kesus/grpc_service.cpp +++ b/ydb/services/kesus/grpc_service.cpp @@ -698,5 +698,5 @@ void NKikimr::NGRpcService::TGRpcRequestProxy::Handle( NKikimr::NGRpcService::TEvCoordinationSessionRequest::TPtr& ev, const NActors::TActorContext& ctx) { - ctx.Register(new NKikimr::NKesus::TGRpcSessionActor(std::move(ev->Release()))); + ctx.Register(new NKikimr::NKesus::TGRpcSessionActor(std::move(ev->Release()))); } diff --git a/ydb/services/persqueue_v1/grpc_pq_actor.h b/ydb/services/persqueue_v1/grpc_pq_actor.h index 65c8aca1db..250114fdd1 100644 --- a/ydb/services/persqueue_v1/grpc_pq_actor.h +++ b/ydb/services/persqueue_v1/grpc_pq_actor.h @@ -848,7 +848,7 @@ private: void Handle(TEvTabletPipe::TEvClientConnected::TPtr& ev, const NActors::TActorContext& ctx); void Handle(TEvTabletPipe::TEvClientDestroyed::TPtr& ev, const NActors::TActorContext& ctx); - [[nodiscard]] bool ProcessBalancerDead(const ui64 tabletId, const NActors::TActorContext& ctx); // returns false if actor died + [[nodiscard]] bool ProcessBalancerDead(const ui64 tabletId, const NActors::TActorContext& ctx); // returns false if actor died void HandlePoison(TEvPQProxy::TEvDieCommand::TPtr& ev, const NActors::TActorContext& ctx); void HandleWakeup(const NActors::TActorContext& ctx); diff --git a/ydb/services/persqueue_v1/grpc_pq_read_actor.cpp b/ydb/services/persqueue_v1/grpc_pq_read_actor.cpp index 654edfcfcd..d724380978 100644 --- a/ydb/services/persqueue_v1/grpc_pq_read_actor.cpp +++ b/ydb/services/persqueue_v1/grpc_pq_read_actor.cpp @@ -1292,7 +1292,7 @@ void TReadSessionActor::Handle(TEvTabletPipe::TEvClientConnected::TPtr& ev, cons } bool TReadSessionActor::ActualPartitionActor(const TActorId& part) { - return ActualPartitionActors.contains(part); + return ActualPartitionActors.contains(part); } diff --git a/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h b/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h index 2933d1f3a1..4e03305e0a 100644 --- a/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h +++ b/ydb/services/persqueue_v1/ut/persqueue_test_fixture.h @@ -78,7 +78,7 @@ namespace NKikimr::NPersQueueTests { NYdb::TDriverConfig driverCfg; driverCfg.SetEndpoint(TStringBuilder() << "localhost:" << Server->GrpcPort).SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)).SetDatabase("/Root"); YdbDriver.reset(new NYdb::TDriver(driverCfg)); - PersQueueClient = MakeHolder<NYdb::NPersQueue::TPersQueueClient>(*YdbDriver); + PersQueueClient = MakeHolder<NYdb::NPersQueue::TPersQueueClient>(*YdbDriver); } void EnablePQLogs(const TVector<NKikimrServices::EServiceKikimr> services, diff --git a/ydb/services/ydb/ydb_index_table_ut.cpp b/ydb/services/ydb/ydb_index_table_ut.cpp index 3c31f43a5a..6a25647e0e 100644 --- a/ydb/services/ydb/ydb_index_table_ut.cpp +++ b/ydb/services/ydb/ydb_index_table_ut.cpp @@ -9,7 +9,7 @@ #include "ydb_common_ut.h" -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <ydb/public/api/grpc/ydb_table_v1.grpc.pb.h> diff --git a/ydb/services/ydb/ydb_table_ut.cpp b/ydb/services/ydb/ydb_table_ut.cpp index 4861c06b92..f631731c20 100644 --- a/ydb/services/ydb/ydb_table_ut.cpp +++ b/ydb/services/ydb/ydb_table_ut.cpp @@ -17,7 +17,7 @@ #include <library/cpp/grpc/client/grpc_client_low.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> using namespace NYdb; using namespace NYdb::NTable; @@ -398,9 +398,9 @@ Y_UNIT_TEST_SUITE(YdbYqlClient) { UNIT_ASSERT_EQUAL(sessionResponse.GetStatus(), EStatus::SUCCESS); } }; - IThreadFactory* pool = SystemThreadFactory(); + IThreadFactory* pool = SystemThreadFactory(); - TVector<TAutoPtr<IThreadFactory::IThread>> threads; + TVector<TAutoPtr<IThreadFactory::IThread>> threads; threads.resize(nThreads); for (int i = 0; i < nThreads; i++) { threads[i] = pool->Run(job); @@ -444,9 +444,9 @@ Y_UNIT_TEST_SUITE(YdbYqlClient) { sessions[i] = sessionResponse.GetSession(); } }; - IThreadFactory* pool = SystemThreadFactory(); + IThreadFactory* pool = SystemThreadFactory(); - TVector<TAutoPtr<IThreadFactory::IThread>> threads; + TVector<TAutoPtr<IThreadFactory::IThread>> threads; threads.resize(nThreads); for (int i = 0; i < nThreads; i++) { threads[i] = pool->Run(job); @@ -515,9 +515,9 @@ Y_UNIT_TEST_SUITE(YdbYqlClient) { TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())); } }; - IThreadFactory* pool = SystemThreadFactory(); + IThreadFactory* pool = SystemThreadFactory(); - TVector<TAutoPtr<IThreadFactory::IThread>> threads; + TVector<TAutoPtr<IThreadFactory::IThread>> threads; threads.resize(nThreads); for (int i = 0; i < nThreads; i++) { threads[i] = pool->Run(job); diff --git a/ydb/services/ydb/ydb_ut.cpp b/ydb/services/ydb/ydb_ut.cpp index 2d37063079..e7d54377a7 100644 --- a/ydb/services/ydb/ydb_ut.cpp +++ b/ydb/services/ydb/ydb_ut.cpp @@ -3525,7 +3525,7 @@ void CheckTableSettings(const TKikimrWithGrpcAndRootSchema &server, auto *reflection = resp.GetReflection(); reflection->ListFields(resp, &fields); for (auto field : fields) - if (!affectedFields.contains(field->number())) + if (!affectedFields.contains(field->number())) reflection->ClearField(&resp, field); UNIT_ASSERT_VALUES_EQUAL(resp.DebugString(), expected.DebugString()); @@ -4520,7 +4520,7 @@ Y_UNIT_TEST_SUITE(TTableProfileTests) { { UNIT_ASSERT_VALUES_EQUAL(array.size(), expected.size()); for (auto &val : array) { - UNIT_ASSERT(expected.contains(val)); + UNIT_ASSERT(expected.contains(val)); expected.erase(val); } } @@ -4546,7 +4546,7 @@ Y_UNIT_TEST_SUITE(TTableProfileTests) { { UNIT_ASSERT_VALUES_EQUAL(labels.size(), expected.size()); for (auto &pr : labels) { - UNIT_ASSERT(expected.contains(pr.first)); + UNIT_ASSERT(expected.contains(pr.first)); UNIT_ASSERT_VALUES_EQUAL(expected.at(pr.first), pr.second); expected.erase(pr.first); } |