MCPcopy Create free account
hub / github.com/catboost/catboost / GetUuid

Function GetUuid

util/generic/guid.cpp:142–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142bool GetUuid(const TStringBuf s, TGUID& result) {
143 if (s.size() != 36) {
144 return false;
145 }
146
147 size_t partId = 0;
148 ui64 partValue = 0;
149 size_t digitCount = 0;
150
151 for (size_t i = 0; i < s.size(); ++i) {
152 const char c = s[i];
153
154 if (c == '-') {
155 if (i != 8 && i != 13 && i != 18 && i != 23) {
156 return false;
157 }
158 continue;
159 }
160
161 ui32 digit = 0;
162 if (!GetDigit(c, digit)) {
163 return false;
164 }
165
166 partValue = partValue * 16 + digit;
167
168 if (++digitCount == 8) {
169 result.dw[partId++] = partValue;
170 digitCount = 0;
171 }
172 }
173 return true;
174}
175
176// Parses GUID from uuid and checks that it's valid.
177// In case of error returns TGUID().

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 3

GetDigitFunction · 0.85
TGUIDClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected