diff options
author | babenko <babenko@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
commit | cec37806d8847aa3db53bafc9e251d4aaf325c12 (patch) | |
tree | 4a61c191e93e31d9ab423e258c71ab43550ee3d2 /library/cpp/yt/misc/guid.cpp | |
parent | 58cd0b86ed99a72df22479e26a20bc1c1e57e65e (diff) | |
download | ydb-cec37806d8847aa3db53bafc9e251d4aaf325c12.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt/misc/guid.cpp')
-rw-r--r-- | library/cpp/yt/misc/guid.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/yt/misc/guid.cpp b/library/cpp/yt/misc/guid.cpp index 882787d7a2..f08ca7c99f 100644 --- a/library/cpp/yt/misc/guid.cpp +++ b/library/cpp/yt/misc/guid.cpp @@ -1,13 +1,13 @@ -#include "guid.h" - -#include <util/random/random.h> - -#include <util/string/printf.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - +#include "guid.h" + +#include <util/random/random.h> + +#include <util/string/printf.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + namespace { const ui8 HexDigits1[16] = { @@ -37,23 +37,23 @@ const ui16 HexDigits2[256] = { //////////////////////////////////////////////////////////////////////////////// -TGuid TGuid::Create() -{ - return TGuid(RandomNumber<ui64>(), RandomNumber<ui64>()); -} - -TGuid TGuid::FromString(TStringBuf str) -{ - TGuid guid; - if (!FromString(str, &guid)) { - throw TSimpleException(Sprintf("Error parsing GUID \"%s\"", - TString(str).c_str())); - } - return guid; -} - -bool TGuid::FromString(TStringBuf str, TGuid* result) -{ +TGuid TGuid::Create() +{ + return TGuid(RandomNumber<ui64>(), RandomNumber<ui64>()); +} + +TGuid TGuid::FromString(TStringBuf str) +{ + TGuid guid; + if (!FromString(str, &guid)) { + throw TSimpleException(Sprintf("Error parsing GUID \"%s\"", + TString(str).c_str())); + } + return guid; +} + +bool TGuid::FromString(TStringBuf str, TGuid* result) +{ size_t partId = 3; ui64 partValue = 0; bool isEmptyPart = true; @@ -93,18 +93,18 @@ bool TGuid::FromString(TStringBuf str, TGuid* result) } if (partId != 0 || isEmptyPart) { // x-y or x-y-z- - return false; - } + return false; + } result->Parts32[partId] = static_cast<ui32>(partValue); - return true; -} - + return true; +} + TGuid TGuid::FromStringHex32(TStringBuf str) { TGuid guid; if (!FromStringHex32(str, &guid)) { - throw TSimpleException(Sprintf("Error parsing Hex32 GUID \"%s\"", - TString(str).c_str())); + throw TSimpleException(Sprintf("Error parsing Hex32 GUID \"%s\"", + TString(str).c_str())); } return guid; } @@ -131,7 +131,7 @@ bool TGuid::FromStringHex32(TStringBuf str, TGuid* result) } return digit; }; - + for (size_t j = 0; j < 16; ++j) { result->ReversedParts8[15 - j] = parseChar() * 16 + parseChar(); } @@ -198,6 +198,6 @@ char* WriteGuidToBuffer(char* ptr, TGuid value) return ptr; } -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT |