-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRadioStation.cpp
41 lines (35 loc) · 1.03 KB
/
RadioStation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* RadioStation.cpp
*/
#include "RadioStation.h"
//------------------------------------------------------------------------------
// parse station list from downloaded file
//------------------------------------------------------------------------------
void StationList::parseStations(String lines)
{
int newlineAt, semicolonAt;
String line;
String label, host, path;
numStations = 0;
while (lines.indexOf("\n") != -1)
{
// find first newline
newlineAt = lines.indexOf("\n");
// grab line
line = lines.substring(0, newlineAt);
// shorten string
lines.remove(0, newlineAt+1);
// find first semicolon
semicolonAt = line.indexOf(";");
// grab field
label = line.substring(0, semicolonAt);
label.toCharArray(station[numStations].label, label.length()+1);
// shorten string
line.remove(0, semicolonAt+1);
// repeat for url
line.toCharArray(station[numStations].url, line.length()+1);
numStations++;
if (numStations > MAXSTATIONS)
{ break; }
}
}