-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCountries.cpp
57 lines (51 loc) · 1.51 KB
/
Countries.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/******************************************************************************
* w_scan_cpp - a dtv channel scanner based on VDR (www.tvdr.de) and it's
* Plugins.
*
* See the README file for copyright information and how to reach the author.
*****************************************************************************/
#include <sstream>
#include "Countries.h"
#include "Helpers.h"
#include "CmdOpts.h"
int CountryId = 0;
std::vector<std::string> CountryIdValues;
std::vector<std::string> CountryNames;
void InitCountries(cPlugin* wirbelscan) {
std::stringstream ss;
std::string line;
int code;
ss << *wirbelscan->SVDRPCommand("LSTC", nullptr, code);
while(std::getline(ss, line)) {
auto items = SplitStr(line, ':');
if (items.size() != 3) continue;
CountryIdValues.push_back (items[1]);
CountryNames.push_back(items[2]);
}
}
std::string CountryArgs(void) {
std::string result;
for(auto s:CountryIdValues) {
if (result.empty())
result += s;
else
result += "," + s;
}
return result;
}
bool PrintCountries(void) {
std::stringstream ss;
for(size_t i = 0; i < CountryIdValues.size(); i++)
std::cout << " "
<< CountryIdValues[i]
<< " "
<< CountryNames[i]
<< std::endl;
WirbelscanSetup.HelpText = true;
return true;
}
int GetCountryId(std::string IdValue) {
for(size_t i = 0; i < CountryIdValues.size(); i++)
if (CountryIdValues[i] == IdValue) return i;
return -1;
}