| 140 | } |
| 141 | |
| 142 | bool 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(). |
no test coverage detected