inline bool isValidUuid()

in tensorpipe/common/strings.h [51:71]


inline bool isValidUuid(const std::string& uuid) {
  // Check it's in this format:
  // aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
  // |0   |5   |10  |15  |20  |25  |30  |35
  if (uuid.size() != 36) {
    return false;
  }
  for (int i = 0; i < uuid.size(); i++) {
    if (i == 8 || i == 13 || i == 18 || i == 23) {
      if (uuid[i] != '-') {
        return false;
      }
    } else {
      if (!((uuid[i] >= '0' && uuid[i] <= '9') ||
            (uuid[i] >= 'a' && uuid[i] <= 'f'))) {
        return false;
      }
    }
  }
  return true;
}