aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrureggaeton <rureggaeton@yandex-team.ru>2022-02-10 16:52:06 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:52:06 +0300
commit91bfae66f7b3d41b1f6b7beddec5d2d114ceb597 (patch)
treec9566e0c255b2db3b4669cf277a0baba9c660f74
parentc6c60f8a1120937fbf449f6d47c8df1595a5df66 (diff)
downloadydb-91bfae66f7b3d41b1f6b7beddec5d2d114ceb597.tar.gz
Restoring authorship annotation for <rureggaeton@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--util/generic/guid.cpp120
-rw-r--r--util/generic/guid.h10
-rw-r--r--util/generic/guid_ut.cpp26
3 files changed, 78 insertions, 78 deletions
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp
index 8b907457bc..69004896bf 100644
--- a/util/generic/guid.cpp
+++ b/util/generic/guid.cpp
@@ -73,20 +73,20 @@ TString CreateGuidAsString() {
return TGUID::Create().AsGuidString();
}
-static bool GetDigit(const char c, ui32& digit) {
- digit = 0;
- if ('0' <= c && c <= '9') {
- digit = c - '0';
- } else if ('a' <= c && c <= 'f') {
- digit = c - 'a' + 10;
- } else if ('A' <= c && c <= 'F') {
- digit = c - 'A' + 10;
- } else {
- return false; // non-hex character
- }
- return true;
-}
-
+static bool GetDigit(const char c, ui32& digit) {
+ digit = 0;
+ if ('0' <= c && c <= '9') {
+ digit = c - '0';
+ } else if ('a' <= c && c <= 'f') {
+ digit = c - 'a' + 10;
+ } else if ('A' <= c && c <= 'F') {
+ digit = c - 'A' + 10;
+ } else {
+ return false; // non-hex character
+ }
+ return true;
+}
+
bool GetGuid(const TStringBuf s, TGUID& result) {
size_t partId = 0;
ui64 partValue = 0;
@@ -107,8 +107,8 @@ bool GetGuid(const TStringBuf s, TGUID& result) {
}
ui32 digit = 0;
- if (!GetDigit(c, digit)) {
- return false;
+ if (!GetDigit(c, digit)) {
+ return false;
}
partValue = partValue * 16 + digit;
@@ -138,49 +138,49 @@ TGUID GetGuid(const TStringBuf s) {
return TGUID();
}
-
+
bool GetUuid(const TStringBuf s, TGUID& result) {
- if (s.size() != 36) {
- return false;
- }
-
- size_t partId = 0;
- ui64 partValue = 0;
- size_t digitCount = 0;
-
- for (size_t i = 0; i < s.size(); ++i) {
- const char c = s[i];
-
- if (c == '-') {
- if (i != 8 && i != 13 && i != 18 && i != 23) {
- return false;
- }
- continue;
- }
-
- ui32 digit = 0;
- if (!GetDigit(c, digit)) {
- return false;
- }
-
- partValue = partValue * 16 + digit;
-
- if (++digitCount == 8) {
- result.dw[partId++] = partValue;
- digitCount = 0;
- }
- }
- return true;
-}
-
-// Parses GUID from uuid and checks that it's valid.
-// In case of error returns TGUID().
+ if (s.size() != 36) {
+ return false;
+ }
+
+ size_t partId = 0;
+ ui64 partValue = 0;
+ size_t digitCount = 0;
+
+ for (size_t i = 0; i < s.size(); ++i) {
+ const char c = s[i];
+
+ if (c == '-') {
+ if (i != 8 && i != 13 && i != 18 && i != 23) {
+ return false;
+ }
+ continue;
+ }
+
+ ui32 digit = 0;
+ if (!GetDigit(c, digit)) {
+ return false;
+ }
+
+ partValue = partValue * 16 + digit;
+
+ if (++digitCount == 8) {
+ result.dw[partId++] = partValue;
+ digitCount = 0;
+ }
+ }
+ return true;
+}
+
+// Parses GUID from uuid and checks that it's valid.
+// In case of error returns TGUID().
TGUID GetUuid(const TStringBuf s) {
- TGUID result;
-
- if (GetUuid(s, result)) {
- return result;
- }
-
- return TGUID();
-}
+ TGUID result;
+
+ if (GetUuid(s, result)) {
+ return result;
+ }
+
+ return TGUID();
+}
diff --git a/util/generic/guid.h b/util/generic/guid.h
index 2bf6c8ad99..8c7e1bf33e 100644
--- a/util/generic/guid.h
+++ b/util/generic/guid.h
@@ -70,10 +70,10 @@ TString GetGuidAsString(const TGUID& g);
TString CreateGuidAsString();
TGUID GetGuid(TStringBuf s);
bool GetGuid(TStringBuf s, TGUID& result);
-
-/**
-* Functions for correct parsing RFC4122 GUID, which described in
-* https://en.wikipedia.org/wiki/Universally_unique_identifier
-**/
+
+/**
+* Functions for correct parsing RFC4122 GUID, which described in
+* https://en.wikipedia.org/wiki/Universally_unique_identifier
+**/
TGUID GetUuid(TStringBuf s);
bool GetUuid(TStringBuf s, TGUID& result);
diff --git a/util/generic/guid_ut.cpp b/util/generic/guid_ut.cpp
index 048354ff39..0a9c2b6e08 100644
--- a/util/generic/guid_ut.cpp
+++ b/util/generic/guid_ut.cpp
@@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
{TGUID(), "1--1-1"},
{TGUID(), "1-1"}, // unexpected end
{TGUID(), "1-1-"},
- {TGUID(), "1-1-1"},
+ {TGUID(), "1-1-1"},
{TGUID(), "1-1-1-"},
{TGUID(), "1-1-1-1-"},
{TGUID(), "1-1-1-1-1"},
@@ -79,21 +79,21 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 0xADE, 3, 4)), "1-ade-3-4");
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 0xDEAD)), "1-2-3-dead");
}
-
+
Y_UNIT_TEST(Test5) {
- const TTest tests[] = {
- {TGUID(), "1-1-1-1-1"},
+ const TTest tests[] = {
+ {TGUID(), "1-1-1-1-1"},
{TGUID(), "00000001-0001-0001-0001-00000000001-"},
- {Construct(0x10000001U, 0x10011001U, 0x10011001U, 0x10000001U), "10000001-1001-1001-1001-100110000001"},
- {Construct(0x550e8400U, 0xe29b41d4U, 0xa7164466U, 0x55440000U), "550e8400-e29b-41d4-a716-446655440000"},
- {Construct(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU), "ffffffff-ffff-ffff-ffff-ffffffffffff"},
- {TGUID(), "ffffffff-ffffff-ff-ffff-ffffffffffff"},
+ {Construct(0x10000001U, 0x10011001U, 0x10011001U, 0x10000001U), "10000001-1001-1001-1001-100110000001"},
+ {Construct(0x550e8400U, 0xe29b41d4U, 0xa7164466U, 0x55440000U), "550e8400-e29b-41d4-a716-446655440000"},
+ {Construct(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU), "ffffffff-ffff-ffff-ffff-ffffffffffff"},
+ {TGUID(), "ffffffff-ffffff-ff-ffff-ffffffffffff"},
{TGUID(), "ffffffff-ffff-ffff-ff-ffffffffffffff"}};
-
- for (const auto& t : tests) {
- UNIT_ASSERT_EQUAL(t.G, GetUuid(t.S));
- }
- }
+
+ for (const auto& t : tests) {
+ UNIT_ASSERT_EQUAL(t.G, GetUuid(t.S));
+ }
+ }
Y_UNIT_TEST(DoubleConvert) {
/**