OpenZWave Library  1.5.0
Localization.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Localization.h
4 //
5 // Localization for CC and Value Classes
6 //
7 // Copyright (c) 2018 Justin Hammond <justin@dynam.ac>
8 //
9 // SOFTWARE NOTICE AND LICENSE
10 //
11 // This file is part of OpenZWave.
12 //
13 // OpenZWave is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published
15 // by the Free Software Foundation, either version 3 of the License,
16 // or (at your option) any later version.
17 //
18 // OpenZWave is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25 //
26 //-----------------------------------------------------------------------------
27 
28 #ifndef VALUEHELP_H
29 #define VALUEHELP_H
30 
31 #include <cstdio>
32 #include <string>
33 #include <map>
34 #include "Defs.h"
35 #include "Driver.h"
37 
38 namespace OpenZWave
39 {
40 
42 {
43 public:
44  LabelLocalizationEntry (uint16 _index, uint32 _pos = -1);
46  void AddLabel(string label, string lang = "");
47  uint64 GetIdx();
48  string GetLabel(string lang);
49 
50 private:
51  uint8 m_index;
52  uint32 m_pos;
53  map<string, string> m_Label;
54  string m_defaultLabel;
55 };
56 
57 
59 {
60 public:
61  ValueLocalizationEntry ( uint8 _commandClass, uint16 _index, uint32 _pos = -1 );
63 
64  }
65  uint64 GetIdx();
66  string GetHelpText(string lang);
67  void AddHelp(string HelpText, string lang = "");
68  string GetLabelText(string lang);
69  void AddLabel(string Label, string lang = "");
70 
71 private:
72  uint8 m_commandClass;
73  uint16 m_index;
74  uint32 m_pos;
75  map<string, string> m_HelpText;
76  map<string, string> m_LabelText;
77  string m_DefaultHelpText;
78  string m_DefaultLabelText;
79 };
80 
81 
82 
84 {
85  //-----------------------------------------------------------------------------
86  // Construction
87  //-----------------------------------------------------------------------------
88 private:
89  Localization();
90  ~Localization();
91 
92  static void ReadXML();
93  static void ReadXMLLabel(uint8 ccID, const TiXmlElement *labelElement, const string Language);
94  static void ReadXMLValue(uint8 ccID, const TiXmlElement *valueElement, const string Language);
95  static void ReadXMLVIDLabel(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *labelElement, const string Language);
96  static void ReadXMLVIDHelp(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *helpElement, const string Language);
97  static uint64 GetValueKey (uint8 _commandClass, uint16 _index, uint32 _pos = -1);
98 public:
99  static Localization* Get();
100  void SetupValue(Value *value);
102  string GetSelectedLang() { return Localization::m_selectedLang;};
103  //-----------------------------------------------------------------------------
104  // Instance Functions
105  //-----------------------------------------------------------------------------
106 private:
107  static Localization* m_instance;
108  static map<int64,ValueLocalizationEntry*> m_valueLocalizationMap;
109  static map<uint8,LabelLocalizationEntry*> m_commandClassLocalizationMap;
110  static string m_selectedLang;
111 
112 
113 };
114 
115 };
116 #endif // VALUEHELP_H
string GetSelectedLang()
Definition: Localization.h:102
Definition: Bitfield.h:34
unsigned short uint16
Definition: Defs.h:93
~ValueLocalizationEntry()
Definition: Localization.h:62
ValueLocalizationEntry(uint8 _commandClass, uint16 _index, uint32 _pos=-1)
Definition: Localization.cpp:89
Definition: Localization.h:58
string GetHelpText(string lang)
Definition: Localization.cpp:113
Base class for all Z-Wave command classes.
Definition: CommandClass.h:54
uint64 GetIdx()
Definition: Localization.cpp:106
string GetLabelText(string lang)
Definition: Localization.cpp:137
void SetupCommandClass(CommandClass *cc)
Definition: Localization.cpp:352
~LabelLocalizationEntry()
Definition: Localization.h:45
uint64 GetIdx()
Definition: Localization.cpp:69
Definition: Localization.h:41
void AddLabel(string label, string lang="")
Definition: Localization.cpp:58
unsigned int uint32
Definition: Defs.h:96
static Localization * Get()
Definition: Localization.cpp:368
LabelLocalizationEntry(uint16 _index, uint32 _pos=-1)
Definition: Localization.cpp:44
void SetupValue(Value *value)
Definition: Localization.cpp:324
Definition: Ref.h:46
Implements COMMAND_CLASS_LANGUAGE (0x89), a Z-Wave device command class.
Definition: Language.h:40
Base class for values associated with a node.
Definition: Value.h:48
void AddLabel(string Label, string lang="")
Definition: Localization.cpp:147
void AddHelp(string HelpText, string lang="")
Definition: Localization.cpp:125
string GetLabel(string lang)
Definition: Localization.cpp:77
Definition: Localization.h:83
unsigned char uint8
Definition: Defs.h:90