| OpenZWave Library 1.6.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"
36 #include "command_classes/CommandClass.h"
37
38 namespace OpenZWave
39 {
40
41 class LabelLocalizationEntry : public Ref
42 {
43 public:
44 LabelLocalizationEntry (uint16 _index, uint32 _pos = -1);
45 ~LabelLocalizationEntry() {}
46 void AddLabel(string label, string lang = "");
47 string GetLabel(string lang);
48 uint64 GetIdx();
49 bool HasLabel(string lang);
50
51 private:
52 uint16 m_index;
53 uint32 m_pos;
54 map<string, string> m_Label;
55 string m_defaultLabel;
56 };
57
58
59 class ValueLocalizationEntry : public Ref
60 {
61 public:
62 ValueLocalizationEntry ( uint8 _commandClass, uint16 _index, uint32 _pos = -1 );
63 ~ValueLocalizationEntry() {
64
65 }
66 uint64 GetIdx();
67 string GetHelp(string lang);
68 void AddHelp(string HelpText, string lang = "");
69 bool HasHelp(string lang);
70 string GetLabel(string lang);
71 void AddLabel(string Label, string lang = "");
72 bool HasLabel(string lang);
73 void AddItemLabel(string label, int32 itemIndex, string lang = "");
74 string GetItemLabel(string lang, int32 itemIndex);
75 bool HasItemLabel(int32 itemIndex, string lang);
76 void AddItemHelp(string label, int32 itemIndex, string lang = "");
77 string GetItemHelp(string lang, int32 itemIndex);
78 bool HasItemHelp(int32 itemIndex, string lang);
79
80
81 private:
82 uint8 m_commandClass;
83 uint16 m_index;
84 uint32 m_pos;
85 map<string, string> m_HelpText;
86 map<string, string> m_LabelText;
87 map<string, map<int32, string> > m_ItemLabelText;
88 map<string, map<int32, string> > m_ItemHelpText;
89 string m_DefaultHelpText;
90 string m_DefaultLabelText;
91 map<int32, string> m_DefaultItemLabelText;
92 map<int32, string> m_DefaultItemHelpText;
93 };
94
95
96
97 class Localization
98 {
99 //-----------------------------------------------------------------------------
100 // Construction
101 //-----------------------------------------------------------------------------
102 private:
103 Localization();
104 ~Localization();
105
106 static void ReadXML();
107 static void ReadCCXMLLabel(uint8 ccID, const TiXmlElement *labelElement);
108 static void ReadXMLValue(uint8 ccID, const TiXmlElement *valueElement);
109 static void ReadXMLVIDItemLabel(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *labelElement);
110 static void ReadGlobalXMLLabel(const TiXmlElement *labelElement);
111 static uint64 GetValueKey (uint8 _commandClass, uint16 _index, uint32 _pos = -1);
112 public:
113 static Localization* Get();
114 void SetupCommandClass(CommandClass *cc);
115 string GetSelectedLang() { return Localization::m_selectedLang;};
116 bool SetValueHelp(uint8 ccID, uint16 indexID, uint32 pos, string help, string lang="");
117 string const GetValueHelp(uint8 ccID, uint16 indexId, uint32 pos);
118 bool SetValueLabel(uint8 ccID, uint16 indexID, uint32 pos, string label, string lang="");
119 string const GetValueLabel(uint8 ccID, uint16 indexId, int32 pos) const;
120 string const GetValueItemLabel(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex) const;
121 bool SetValueItemLabel(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex, string label, string lang="");
122 string const GetValueItemHelp(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex) const;
123 bool SetValueItemHelp(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex, string label, string lang="");
124 string const GetGlobalLabel(string text);
125 bool SetGlobalLabel(string index, string text, string lang);
126 static void ReadXMLVIDLabel(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *labelElement);
127 static void ReadXMLVIDHelp(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *helpElement);
128 bool WriteXMLVIDHelp(uint8 ccID, uint16 indexId, uint32 pos, TiXmlElement *valueElement);
129 //-----------------------------------------------------------------------------
130 // Instance Functions
131 //-----------------------------------------------------------------------------
132 private:
133 static Localization* m_instance;
134 static map<uint64,ValueLocalizationEntry*> m_valueLocalizationMap;
135 static map<uint8,LabelLocalizationEntry*> m_commandClassLocalizationMap;
136 static map<string, LabelLocalizationEntry*> m_globalLabelLocalizationMap;
137 static string m_selectedLang;
138 static uint32 m_revision;
139
140
141 };
142
143 };
144 #endif // VALUEHELP_H
uint32
unsigned int uint32
Definition: Defs.h:95
OpenZWave::Localization::GetGlobalLabel
string const GetGlobalLabel(string text)
Definition: Localization.cpp:746
OpenZWave::ValueLocalizationEntry
Definition: Localization.h:60
OpenZWave::ValueLocalizationEntry::GetItemHelp
string GetItemHelp(string lang, int32 itemIndex)
Definition: Localization.cpp:251
OpenZWave::ValueLocalizationEntry::AddLabel
void AddLabel(string Label, string lang="")
Definition: Localization.cpp:182
OpenZWave::ValueLocalizationEntry::HasLabel
bool HasLabel(string lang)
Definition: Localization.cpp:170
Driver.h
OpenZWave::Localization::SetGlobalLabel
bool SetGlobalLabel(string index, string text, string lang)
Definition: Localization.cpp:758
OpenZWave::Localization::GetSelectedLang
string GetSelectedLang()
Definition: Localization.h:115
OpenZWave::ValueLocalizationEntry::AddItemHelp
void AddItemHelp(string label, int32 itemIndex, string lang="")
Definition: Localization.cpp:236
OpenZWave::CommandClass
Base class for all Z-Wave command classes.
Definition: CommandClass.h:56
uint8
unsigned char uint8
Definition: Defs.h:89
OpenZWave::Localization::Get
static Localization * Get()
Definition: Localization.cpp:807
OpenZWave::Localization::SetValueItemHelp
bool SetValueItemHelp(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex, string label, string lang="")
Definition: Localization.cpp:726
OpenZWave::Localization::SetValueItemLabel
bool SetValueItemLabel(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex, string label, string lang="")
Definition: Localization.cpp:690
OpenZWave::Localization::ReadXMLVIDHelp
static void ReadXMLVIDHelp(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *helpElement)
Definition: Localization.cpp:497
OpenZWave::ValueLocalizationEntry::GetItemLabel
string GetItemLabel(string lang, int32 itemIndex)
Definition: Localization.cpp:208
OpenZWave::ValueLocalizationEntry::ValueLocalizationEntry
ValueLocalizationEntry(uint8 _commandClass, uint16 _index, uint32 _pos=-1)
Definition: Localization.cpp:104
OpenZWave::LabelLocalizationEntry::HasLabel
bool HasLabel(string lang)
Definition: Localization.cpp:92
OpenZWave::Localization::GetValueItemHelp
string const GetValueItemHelp(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex) const
Definition: Localization.cpp:710
OpenZWave::Ref
Definition: Ref.h:47
OpenZWave::ValueLocalizationEntry::AddItemLabel
void AddItemLabel(string label, int32 itemIndex, string lang="")
Definition: Localization.cpp:194
int32
signed int int32
Definition: Defs.h:94
OpenZWave::LabelLocalizationEntry::GetIdx
uint64 GetIdx()
Definition: Localization.cpp:70
OpenZWave::LabelLocalizationEntry::AddLabel
void AddLabel(string label, string lang="")
Definition: Localization.cpp:59
OpenZWave::Localization::ReadXMLVIDLabel
static void ReadXMLVIDLabel(uint8 ccID, uint16 indexId, uint32 pos, const TiXmlElement *labelElement)
Definition: Localization.cpp:469
OpenZWave::Localization::GetValueItemLabel
string const GetValueItemLabel(uint8 ccID, uint16 indexId, int32 pos, int32 itemIndex) const
Definition: Localization.cpp:674
OpenZWave::Localization::SetupCommandClass
void SetupCommandClass(CommandClass *cc)
Definition: Localization.cpp:576
OpenZWave::LabelLocalizationEntry::~LabelLocalizationEntry
~LabelLocalizationEntry()
Definition: Localization.h:45
OpenZWave::LabelLocalizationEntry::GetLabel
string GetLabel(string lang)
Definition: Localization.cpp:78
OpenZWave::ValueLocalizationEntry::GetIdx
uint64 GetIdx()
Definition: Localization.cpp:117
CommandClass.h
OpenZWave::ValueLocalizationEntry::HasHelp
bool HasHelp(string lang)
Definition: Localization.cpp:136
OpenZWave::ValueLocalizationEntry::GetHelp
string GetHelp(string lang)
Definition: Localization.cpp:124
OpenZWave::ValueLocalizationEntry::GetLabel
string GetLabel(string lang)
Definition: Localization.cpp:160
OpenZWave::Localization::SetValueHelp
bool SetValueHelp(uint8 ccID, uint16 indexID, uint32 pos, string help, string lang="")
Definition: Localization.cpp:590
OpenZWave::Localization
Definition: Localization.h:98
OpenZWave::Localization::SetValueLabel
bool SetValueLabel(uint8 ccID, uint16 indexID, uint32 pos, string label, string lang="")
Definition: Localization.cpp:616
OpenZWave::Localization::GetValueLabel
string const GetValueLabel(uint8 ccID, uint16 indexId, int32 pos) const
Definition: Localization.cpp:658
OpenZWave::Localization::WriteXMLVIDHelp
bool WriteXMLVIDHelp(uint8 ccID, uint16 indexId, uint32 pos, TiXmlElement *valueElement)
Definition: Localization.cpp:784
OpenZWave::LabelLocalizationEntry::LabelLocalizationEntry
LabelLocalizationEntry(uint16 _index, uint32 _pos=-1)
Definition: Localization.cpp:47
OpenZWave::Localization::GetValueHelp
string const GetValueHelp(uint8 ccID, uint16 indexId, uint32 pos)
Definition: Localization.cpp:643
Defs.h
OpenZWave::ValueLocalizationEntry::~ValueLocalizationEntry
~ValueLocalizationEntry()
Definition: Localization.h:63
OpenZWave::ValueLocalizationEntry::HasItemLabel
bool HasItemLabel(int32 itemIndex, string lang)
Definition: Localization.cpp:225
uint16
unsigned short uint16
Definition: Defs.h:92
OpenZWave::LabelLocalizationEntry
Definition: Localization.h:42
OpenZWave::ValueLocalizationEntry::AddHelp
void AddHelp(string HelpText, string lang="")
Definition: Localization.cpp:148
OpenZWave
Definition: Bitfield.h:35
OpenZWave::ValueLocalizationEntry::HasItemHelp
bool HasItemHelp(int32 itemIndex, string lang)
Definition: Localization.cpp:273