foobar2000 SDK  2015-01-14
Functions
playback_control.cpp File Reference

Go to the source code of this file.

Functions

static double parse_time (const char *time)
 
static double parseFraction (const char *fraction)
 

Function Documentation

static double parse_time ( const char *  time)
static

Definition at line 15 of file playback_control.cpp.

15  {
16  unsigned vTotal = 0, vCur = 0;
17  for(;;) {
18  char c = *time++;
19  if (c == 0) return (double) (vTotal + vCur);
20  else if (pfc::char_is_numeric( c ) ) {
21  vCur = vCur * 10 + (unsigned)(c-'0');
22  } else if (c == ':') {
23  if (vCur >= 60) {PFC_ASSERT(!"Invalid input"); return 0; }
24  vTotal += vCur; vCur = 0; vTotal *= 60;
25  } else if (c == '.') {
26  return (double) (vTotal + vCur) + parseFraction(time);
27  } else {
28  PFC_ASSERT(!"Invalid input"); return 0;
29  }
30  }
31 }
static double parseFraction(const char *fraction)
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
static double parseFraction ( const char *  fraction)
static

Definition at line 3 of file playback_control.cpp.

3  {
4  unsigned v = 0, d = 1;
5  while(pfc::char_is_numeric( *fraction) ) {
6  d *= 10;
7  v *= 10;
8  v += (unsigned) ( *fraction - '0' );
9  ++fraction;
10  }
11  PFC_ASSERT( *fraction == 0 );
12  return (double)v / (double)d;
13 }
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99