tagging release
[dasher.git] / Src / Gtk2 / GenerateSchema.cpp
blob26460b5b3071e7085c895026267d1c4b783ecf3f
1 #include "../Common/Common.h"
3 #include "../DasherCore/Parameters.h"
4 #include "../Common/AppSettingsData.h"
6 #include <string>
7 #include <sstream>
8 #include <iostream>
10 enum{ TYPE_BOOL, TYPE_LONG, TYPE_STRING };
12 class CSchema {
13 public:
14 CSchema(const std::string &strKeyName, int iType,
15 const std::string &strDefault, const std::string &strShort,
16 const std::string &strLong);
18 void Dump();
19 private:
20 std::string m_strKeyName;
21 std::string m_strType;
22 std::string m_strDefault;
23 std::string m_strShort;
24 std::string m_strLong;
27 CSchema::CSchema(const std::string &strKeyName, int iType,
28 const std::string &strDefault, const std::string &strShort,
29 const std::string &strLong) {
30 m_strKeyName = strKeyName;
32 switch(iType) {
33 case TYPE_BOOL:
34 m_strType="bool";
35 break;
36 case TYPE_LONG:
37 m_strType="int";
38 break;
39 case TYPE_STRING:
40 m_strType="string";
41 break;
44 m_strDefault = strDefault;
45 m_strShort = strShort;
46 m_strLong = strLong;
49 void CSchema::Dump() {
50 std::cout << "<schema>" << std::endl;
51 std::cout << "<key>/schemas/apps/dasher4/" << m_strKeyName << "</key>" << std::endl;
52 std::cout << "<applyto>/apps/dasher4/" << m_strKeyName << "</applyto>" << std::endl;
53 std::cout << "<owner>dasher</owner>" << std::endl;
54 std::cout << "<type>" << m_strType << "</type>" << std::endl;
55 std::cout << "<default>" << m_strDefault << "</default>" << std::endl;
56 std::cout << "<locale name=\"C\">" << std::endl;
57 std::cout << "<short>" << m_strShort << "</short>" << std::endl;
58 std::cout << "<long>" << m_strLong << "</long>" << std::endl;
59 std::cout << "</locale>" << std::endl;
60 std::cout << "</schema>" << std::endl;
64 int main(int argc, char **argv) {
66 std::cout << "<gconfschemafile>" << std::endl;
67 std::cout << "<schemalist>" << std::endl;
69 for(int i(0); i < NUM_OF_BPS; ++i) {
70 if(boolparamtable[i].persistent) {
71 std::string strDefault;
73 if(boolparamtable[i].defaultValue)
74 strDefault = "TRUE";
75 else
76 strDefault = "FALSE";
78 CSchema oSchema( boolparamtable[i].regName,
79 TYPE_BOOL,
80 strDefault,
81 "",
82 boolparamtable[i].humanReadable );
84 oSchema.Dump();
88 for(int i(0); i < END_OF_APP_BPS - END_OF_SPS; ++i) {
90 if(app_boolparamtable[i].persistent) {
91 std::string strDefault;
93 if(app_boolparamtable[i].bDefaultValue)
94 strDefault = "TRUE";
95 else
96 strDefault = "FALSE";
98 CSchema oSchema( app_boolparamtable[i].regName,
99 TYPE_BOOL,
100 strDefault,
102 app_boolparamtable[i].humanReadable );
104 oSchema.Dump();
108 for(int i(0); i < NUM_OF_LPS; ++i) {
109 if(longparamtable[i].persistent) {
111 std::stringstream ssDefault;
113 ssDefault << longparamtable[i].defaultValue;
116 CSchema oSchema( longparamtable[i].regName,
117 TYPE_LONG,
118 ssDefault.str(),
120 longparamtable[i].humanReadable );
122 oSchema.Dump();
126 for(int i(0); i < END_OF_APP_LPS - END_OF_APP_BPS; ++i) {
127 if(app_longparamtable[i].persistent) {
129 std::stringstream ssDefault;
131 ssDefault << app_longparamtable[i].iDefaultValue;
134 CSchema oSchema( app_longparamtable[i].regName,
135 TYPE_LONG,
136 ssDefault.str(),
138 app_longparamtable[i].humanReadable );
140 oSchema.Dump();
144 for(int i(0); i < NUM_OF_SPS; ++i) {
145 if(stringparamtable[i].persistent) {
146 CSchema oSchema( stringparamtable[i].regName,
147 TYPE_STRING,
148 stringparamtable[i].defaultValue,
150 stringparamtable[i].humanReadable );
152 oSchema.Dump();
156 for(int i(0); i < END_OF_APP_SPS - END_OF_APP_LPS; ++i) {
157 if(app_stringparamtable[i].persistent) {
158 CSchema oSchema( app_stringparamtable[i].regName,
159 TYPE_STRING,
160 app_stringparamtable[i].szDefaultValue,
162 app_stringparamtable[i].humanReadable );
164 oSchema.Dump();
168 std::cout << "</schemalist>" << std::endl;
169 std::cout << "</gconfschemafile>" << std::endl;
171 // struct bp_table {
172 // int key;
173 // char *regName;
174 // bool persistent;
175 // bool defaultValue;
176 // char *humanReadable;
177 // };