File: Countries.cpp

package info (click to toggle)
w-scan-cpp 0~20230121-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,008 kB
  • sloc: ansic: 69,193; cpp: 9,599; makefile: 1,149; perl: 862; python: 74; sh: 70
file content (57 lines) | stat: -rw-r--r-- 1,551 bytes parent folder | download | duplicates (2)
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;
}