diff options
author | swarmer <swarmer@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
commit | 317da38588b7898a99fd9168571408123350012b (patch) | |
tree | 25eebc31526019ad39a6c1b13f492963d97ba439 /util/system/src_root.h | |
parent | 3b2241461d41d41ba1a706b0750c4f0f55c344f6 (diff) | |
download | ydb-317da38588b7898a99fd9168571408123350012b.tar.gz |
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/src_root.h')
-rw-r--r-- | util/system/src_root.h | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/util/system/src_root.h b/util/system/src_root.h index 4f2d9f5ee6..17bea82be5 100644 --- a/util/system/src_root.h +++ b/util/system/src_root.h @@ -3,8 +3,8 @@ #include "compiler.h" #include "defaults.h" -#include <type_traits> - +#include <type_traits> + namespace NPrivate { struct TStaticBuf { constexpr TStaticBuf(const char* data, unsigned len) noexcept @@ -32,37 +32,37 @@ namespace NPrivate { constexpr TStaticBuf ArcRoot = STATIC_BUF(Y_STRINGIZE(ARCADIA_ROOT)); constexpr TStaticBuf BuildRoot = STATIC_BUF(Y_STRINGIZE(ARCADIA_BUILD_ROOT)); - constexpr Y_FORCE_INLINE bool IsProperPrefix(const TStaticBuf prefix, const TStaticBuf string) noexcept { - if (prefix.Len < string.Len) { - for (unsigned i = prefix.Len; i-- > 0;) { - if (prefix.Data[i] != string.Data[i]) { - return false; - } - } - return true; - } else { - return false; - } - } - - constexpr unsigned RootPrefixLength(const TStaticBuf& f) noexcept { - if (IsProperPrefix(ArcRoot, f)) { - return ArcRoot.Len + 1; + constexpr Y_FORCE_INLINE bool IsProperPrefix(const TStaticBuf prefix, const TStaticBuf string) noexcept { + if (prefix.Len < string.Len) { + for (unsigned i = prefix.Len; i-- > 0;) { + if (prefix.Data[i] != string.Data[i]) { + return false; + } + } + return true; + } else { + return false; + } + } + + constexpr unsigned RootPrefixLength(const TStaticBuf& f) noexcept { + if (IsProperPrefix(ArcRoot, f)) { + return ArcRoot.Len + 1; } - if (IsProperPrefix(BuildRoot, f)) { - return BuildRoot.Len + 1; + if (IsProperPrefix(BuildRoot, f)) { + return BuildRoot.Len + 1; } - return 0; - } - - constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f, unsigned prefixLength) noexcept { - return TStaticBuf(f.Data + prefixLength, f.Len - prefixLength); - } - - //$(SRC_ROOT)/prj/blah.cpp -> prj/blah.cpp - constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f) noexcept { - return StripRoot(f, RootPrefixLength(f)); + return 0; } + + constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f, unsigned prefixLength) noexcept { + return TStaticBuf(f.Data + prefixLength, f.Len - prefixLength); + } + + //$(SRC_ROOT)/prj/blah.cpp -> prj/blah.cpp + constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f) noexcept { + return StripRoot(f, RootPrefixLength(f)); + } } -#define __SOURCE_FILE_IMPL__ ::NPrivate::StripRoot(STATIC_BUF(__FILE__), std::integral_constant<unsigned, ::NPrivate::RootPrefixLength(STATIC_BUF(__FILE__))>::value) +#define __SOURCE_FILE_IMPL__ ::NPrivate::StripRoot(STATIC_BUF(__FILE__), std::integral_constant<unsigned, ::NPrivate::RootPrefixLength(STATIC_BUF(__FILE__))>::value) |