| 1 |
/* |
| 2 |
* Copyright (C) 2012-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "WeatherManager.h" |
| 12 |
|
| 13 |
#include <map> |
| 14 |
#include <string> |
| 15 |
|
| 16 |
class CWeatherJob : public CJob |
| 17 |
{ |
| 18 |
public: |
| 19 |
explicit CWeatherJob(int location); |
| 20 |
|
| 21 |
bool DoWork() override; |
| 22 |
|
| 23 |
const CWeatherInfo &GetInfo() const; |
| 24 |
private: |
| 25 |
static std::string ConstructPath(std::string in); |
| 26 |
void LocalizeOverview(std::string &str); |
| 27 |
void LocalizeOverviewToken(std::string &str); |
| 28 |
void LoadLocalizedToken(); |
| 29 |
static int ConvertSpeed(int speed); |
| 30 |
|
| 31 |
void SetFromProperties(); |
| 32 |
|
| 33 |
/*! \brief Formats a celsius temperature into a string based on the users locale |
| 34 |
\param text the string to format |
| 35 |
\param temp the temperature (in degrees celsius). |
| 36 |
*/ |
| 37 |
static void FormatTemperature(std::string &text, double temp); |
| 38 |
|
| 39 |
struct ci_less |
| 40 |
{ |
| 41 |
// case-independent (ci) compare_less binary function |
| 42 |
struct nocase_compare |
| 43 |
{ |
| 44 |
bool operator() (const unsigned char& c1, const unsigned char& c2) const { |
| 45 |
return tolower(c1) < tolower(c2); |
| 46 |
} |
| 47 |
}; |
| 48 |
bool operator()(const std::string & s1, const std::string & s2) const { |
| 49 |
return std::lexicographical_compare |
| 50 |
(s1.begin(), s1.end(), |
| 51 |
s2.begin(), s2.end(), |
| 52 |
nocase_compare()); |
| 53 |
} |
| 54 |
}; |
| 55 |
|
| 56 |
std::map<std::string, int, ci_less> m_localizedTokens; |
| 57 |
typedef std::map<std::string, int, ci_less>::const_iterator ilocalizedTokens; |
| 58 |
|
| 59 |
CWeatherInfo m_info; |
| 60 |
int m_location; |
| 61 |
|
| 62 |
static bool m_imagesOkay; |
| 63 |
}; |