vendor/bela/src/belatime/duration.cc
bool ConsumeDurationUnit(const wchar_t **start, const wchar_t *end, Duration *unit) {
  size_t size = end - *start;
  switch (size) {
  case 0:
    return false;
  default:
    switch (**start) {
    case L'n':
      if (*(*start + 1) == L's') {
        *start += 2;
        *unit = Nanoseconds(1);
        return true;
      }
      break;
    case L'u':
      if (*(*start + 1) == L's') {
        *start += 2;
        *unit = Microseconds(1);
        return true;
      }
      break;
    case L'm':
      if (*(*start + 1) == L's') {
        *start += 2;
        *unit = Milliseconds(1);
        return true;
      }
      break;
    default:
      break;
    }
    [[fallthrough]];
  case 1:
    switch (**start) {
    case L's':
      *unit = Seconds(1);
      *start += 1;
      return true;
    case L'm':
      *unit = Minutes(1);
      *start += 1;
      return true;
    case L'h':
      *unit = Hours(1);
      *start += 1;
      return true;
    default:
      return false;
    }
  }
}
// A helper for ParseDuration() that parses a leading unit designator (e.g.,
// ns, us, ms, s, m, h) from the given string and stores the resulting unit
// in "*unit".  The given string pointer is modified to point to the first
// unconsumed char.
A helper for ParseDuration() that parses a leading unit designator  from the given string and stores the resulting unit
in "*unit".  The given string pointer is modified to point to the first
unconsumed char.
A helper for ParseDuration () that parses a leading unit designator from the given string and stores the resulting unit in " * unit " . The given string pointer is modified to point to the first unconsumed char .
bool ConsumeDurationUnit(const wchar_t **start, const wchar_t *end, Duration *unit) {
  size_t size = end - *start;
  switch (size) {
  case 0:
    return false;
  default:
    switch (**start) {
    case L'n':
      if (*(*start + 1) == L's') {
        *start += 2;
        *unit = Nanoseconds(1);
        return true;
      }
      break;
    case L'u':
      if (*(*start + 1) == L's') {
        *start += 2;
        *unit = Microseconds(1);
        return true;
      }
      break;
    case L'm':
      if (*(*start + 1) == L's') {
        *start += 2;
        *unit = Milliseconds(1);
        return true;
      }
      break;
    default:
      break;
    }
    [[fallthrough]];
  case 1:
    switch (**start) {
    case L's':
      *unit = Seconds(1);
      *start += 1;
      return true;
    case L'm':
      *unit = Minutes(1);
      *start += 1;
      return true;
    case L'h':
      *unit = Hours(1);
      *start += 1;
      return true;
    default:
      return false;
    }
  }
}
bool ConsumeDurationUnit ( const wchar_t * * start , const wchar_t * end , Duration * unit ) { size_t size = end - * start ; switch ( size ) { case 0 : return false ; default : switch ( * * start ) { case L' ' : if ( * ( * start + 1 ) == L' ' ) { * start += 2 ; * unit = Nanoseconds ( 1 ) ; return true ; } break ; case L' ' : if ( * ( * start + 1 ) == L' ' ) { * start += 2 ; * unit = Microseconds ( 1 ) ; return true ; } break ; case L' ' : if ( * ( * start + 1 ) == L' ' ) { * start += 2 ; * unit = Milliseconds ( 1 ) ; return true ; } break ; default : break ; } [[ fallthrough ]] ; case 1 : switch ( * * start ) { case L' ' : * unit = Seconds ( 1 ) ; * start += 1 ; return true ; case L' ' : * unit = Minutes ( 1 ) ; * start += 1 ; return true ; case L' ' : * unit = Hours ( 1 ) ; * start += 1 ; return true ; default : return false ; } } }
A helper for ParseDuration() that parses a leading unit designator (e.g.,
ns, us, ms, s, m, h) from the given string and stores the resulting unit
in "*unit".
A helper for ParseDuration () that parses a leading unit designator ( e . g . ns us ms s m h ) from the given string and stores the resulting unit in " * unit " .