diff options
author | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
commit | 28b5c604490094e187494dcc566bd3d7a05a2c25 (patch) | |
tree | 8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/tests/Resourcetest.cc | |
parent | b9134162f9633784d9097df18769a699a62650fe (diff) | |
download | fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.zip fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2 |
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/tests/Resourcetest.cc')
-rw-r--r-- | src/tests/Resourcetest.cc | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/tests/Resourcetest.cc b/src/tests/Resourcetest.cc index 9379663..f82c4b4 100644 --- a/src/tests/Resourcetest.cc +++ b/src/tests/Resourcetest.cc | |||
@@ -41,35 +41,35 @@ enum TestEnum{TEST1, THIS_IS_TRUE, USE_LOVE}; | |||
41 | template<> | 41 | template<> |
42 | void Resource<TestEnum>:: | 42 | void Resource<TestEnum>:: |
43 | setFromString(const char *str) { | 43 | setFromString(const char *str) { |
44 | if (strcasecmp(str, "TEST1")==0) | 44 | if (strcasecmp(str, "TEST1")==0) |
45 | *this = TEST1; | 45 | *this = TEST1; |
46 | else if (strcasecmp(str, "THIS_IS_TRUE")==0) | 46 | else if (strcasecmp(str, "THIS_IS_TRUE")==0) |
47 | *this = THIS_IS_TRUE; | 47 | *this = THIS_IS_TRUE; |
48 | else if (strcasecmp(str, "USE_LOVE")==0) | 48 | else if (strcasecmp(str, "USE_LOVE")==0) |
49 | *this = USE_LOVE; | 49 | *this = USE_LOVE; |
50 | } | 50 | } |
51 | 51 | ||
52 | template<> | 52 | template<> |
53 | void Resource<int>:: | 53 | void Resource<int>:: |
54 | setFromString(const char* strval) { | 54 | setFromString(const char* strval) { |
55 | int val; | 55 | int val; |
56 | if (sscanf(strval, "%d", &val)==1) | 56 | if (sscanf(strval, "%d", &val)==1) |
57 | *this = val; | 57 | *this = val; |
58 | } | 58 | } |
59 | 59 | ||
60 | template<> | 60 | template<> |
61 | void Resource<std::string>:: | 61 | void Resource<std::string>:: |
62 | setFromString(const char *strval) { | 62 | setFromString(const char *strval) { |
63 | *this = strval; | 63 | *this = strval; |
64 | } | 64 | } |
65 | 65 | ||
66 | template<> | 66 | template<> |
67 | void Resource<bool>:: | 67 | void Resource<bool>:: |
68 | setFromString(char const *strval) { | 68 | setFromString(char const *strval) { |
69 | if (strcasecmp(strval, "true")==0) | 69 | if (strcasecmp(strval, "true")==0) |
70 | *this = true; | 70 | *this = true; |
71 | else | 71 | else |
72 | *this = false; | 72 | *this = false; |
73 | } | 73 | } |
74 | 74 | ||
75 | //----------------- | 75 | //----------------- |
@@ -78,29 +78,29 @@ setFromString(char const *strval) { | |||
78 | template<> | 78 | template<> |
79 | std::string Resource<TestEnum>:: | 79 | std::string Resource<TestEnum>:: |
80 | getString() { | 80 | getString() { |
81 | switch (m_value) { | 81 | switch (m_value) { |
82 | case TEST1: | 82 | case TEST1: |
83 | return string("TEST1"); | 83 | return string("TEST1"); |
84 | case THIS_IS_TRUE: | 84 | case THIS_IS_TRUE: |
85 | return string("THIS_IS_TRUE"); | 85 | return string("THIS_IS_TRUE"); |
86 | case USE_LOVE: | 86 | case USE_LOVE: |
87 | return string("USE_LOVE"); | 87 | return string("USE_LOVE"); |
88 | } | 88 | } |
89 | return string(""); | 89 | return string(""); |
90 | } | 90 | } |
91 | 91 | ||
92 | template<> | 92 | template<> |
93 | std::string Resource<bool>:: | 93 | std::string Resource<bool>:: |
94 | getString() { | 94 | getString() { |
95 | return std::string(**this == true ? "true" : "false"); | 95 | return std::string(**this == true ? "true" : "false"); |
96 | } | 96 | } |
97 | 97 | ||
98 | template<> | 98 | template<> |
99 | std::string Resource<int>:: | 99 | std::string Resource<int>:: |
100 | getString() { | 100 | getString() { |
101 | char strval[256]; | 101 | char strval[256]; |
102 | sprintf(strval, "%d", **this); | 102 | sprintf(strval, "%d", **this); |
103 | return std::string(strval); | 103 | return std::string(strval); |
104 | } | 104 | } |
105 | 105 | ||
106 | template<> | 106 | template<> |
@@ -109,32 +109,32 @@ getString() { return **this; } | |||
109 | 109 | ||
110 | int main(int argc, char **argv) { | 110 | int main(int argc, char **argv) { |
111 | 111 | ||
112 | ResourceManager rm; | 112 | ResourceManager rm; |
113 | // resources | 113 | // resources |
114 | Resource<int> val(rm, 123, "session.test", "Session.Test"); | 114 | Resource<int> val(rm, 123, "session.test", "Session.Test"); |
115 | Resource<bool> boolval(rm, true, "session.bool", "Session.Bool"); | 115 | Resource<bool> boolval(rm, true, "session.bool", "Session.Bool"); |
116 | Resource<string> strval(rm, "none", "string", "String"); | 116 | Resource<string> strval(rm, "none", "string", "String"); |
117 | Resource<TestEnum> enumval(rm, TEST1, "enumval", "EnumVal"); | 117 | Resource<TestEnum> enumval(rm, TEST1, "enumval", "EnumVal"); |
118 | 118 | ||
119 | const char *defaultfile_open = "res", | 119 | const char *defaultfile_open = "res", |
120 | *defaultfile_save = "res_save"; | 120 | *defaultfile_save = "res_save"; |
121 | 121 | ||
122 | if (argc>1) { | 122 | if (argc>1) { |
123 | if(!rm.load(argv[1])) | 123 | if(!rm.load(argv[1])) |
124 | cerr<<"Faild to load database: "<<argv[1]<<endl; | 124 | cerr<<"Faild to load database: "<<argv[1]<<endl; |
125 | } else { | 125 | } else { |
126 | if (!rm.load(defaultfile_open)) | 126 | if (!rm.load(defaultfile_open)) |
127 | cerr<<"Faild to load database: "<<defaultfile_open<<endl; | 127 | cerr<<"Faild to load database: "<<defaultfile_open<<endl; |
128 | } | 128 | } |
129 | cerr<<"Value="<<*val<<endl; | 129 | cerr<<"Value="<<*val<<endl; |
130 | cerr<<"boolValue="<<boolval.getString()<<endl; | 130 | cerr<<"boolValue="<<boolval.getString()<<endl; |
131 | cerr<<"strValue="<<*strval<<endl; | 131 | cerr<<"strValue="<<*strval<<endl; |
132 | cerr<<"enumValue="<<enumval.getString()<<endl; | 132 | cerr<<"enumValue="<<enumval.getString()<<endl; |
133 | 133 | ||
134 | if (!rm.save(defaultfile_save)) | 134 | if (!rm.save(defaultfile_save)) |
135 | cerr<<"Faild to save database to file:"<<defaultfile_save<<endl; | 135 | cerr<<"Faild to save database to file:"<<defaultfile_save<<endl; |
136 | 136 | ||
137 | if (!rm.save("I dont exist", "Not me either")) | 137 | if (!rm.save("I dont exist", "Not me either")) |
138 | cerr<<"faild to save and merge database."<<endl; | 138 | cerr<<"faild to save and merge database."<<endl; |
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |