MCPcopy Create free account
hub / github.com/apache/thrift / validate_uuid

Method validate_uuid

compiler/cpp/src/thrift/parse/t_const_value.h:215–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213 t_const_value_type valType_;
214
215 void validate_uuid(std::string & uuid) const {
216 const std::string HEXCHARS = std::string("0123456789ABCDEFabcdef");
217
218 // we also allow for usual "Windows GUID" format "{01234567-9012-4567-9012-456789012345}"
219 if ((uuid.length() == 38) && ('{' == uuid[0]) && ('}' == uuid[37])) {
220 uuid = uuid.substr(1, 36);
221 }
222
223 // canonical format "01234567-9012-4567-9012-456789012345" expected
224 bool valid = (uuid.length() == 36);
225 for (size_t i = 0; valid && (i < uuid.length()); ++i) {
226 switch(i) {
227 case 8:
228 case 13:
229 case 18:
230 case 23:
231 if(uuid[i] != '-') {
232 valid = false;
233 }
234 break;
235 default:
236 if(HEXCHARS.find(uuid[i]) == std::string::npos) {
237 valid = false;
238 }
239 break;
240 }
241 }
242
243 if( ! valid) {
244 throw "invalid uuid " + uuid;
245 }
246 }
247};
248
249#endif

Callers

nothing calls this directly

Calls 4

stringFunction · 0.85
findMethod · 0.80
lengthMethod · 0.65
substrMethod · 0.45

Tested by

no test coverage detected