MCPcopy Create free account
hub / github.com/carlonluca/pot / parseConfigFile

Method parseConfigFile

piomxtextures_src/omxplayer_lib/KeyConfig.cpp:138–182  ·  view source on GitHub ↗

Parses the supplied config file and turns it into a map object. * NOTE: Does not work with certain filepath shortcuts (e.g. ~ as user's home) */

Source from the content-addressed store, hash-verified

136 * NOTE: Does not work with certain filepath shortcuts (e.g. ~ as user's home)
137 */
138map<int, int> KeyConfig::parseConfigFile(string filepath)
139{
140 ifstream config_file(filepath.c_str());
141 map<int,int> keymap;
142 string line;
143
144 while(getline(config_file, line))
145 {
146 string str_action = getActionFromString(line);
147 string key = getKeyFromString(line);
148
149 if(str_action != "" && key != "" && str_action[0] != '#')
150 {
151 int key_action = convertStringToAction(str_action);
152 if(key.substr(0,4) == "left")
153 {
154 keymap[KEY_LEFT] = key_action;
155 }
156 else if(key.substr(0,5) == "right")
157 {
158 keymap[KEY_RIGHT] = key_action;
159 }
160 else if(key.substr(0,2) == "up")
161 {
162 keymap[KEY_UP] = key_action;
163 }
164 else if(key.substr(0,4) == "down")
165 {
166 keymap[KEY_DOWN] = key_action;
167 }
168 else if(key.substr(0,3) == "esc")
169 {
170 keymap[KEY_ESC] = key_action;
171 }
172 else if(key.substr(0,3) == "hex")
173 {
174 const char *hex = key.substr(4).c_str();
175 if (hex)
176 keymap[strtoul(hex,0,0)] = key_action;
177 }
178 else keymap[key[0]] = key_action;
179 }
180 }
181 return keymap;
182}

Callers

nothing calls this directly

Calls 3

getActionFromStringFunction · 0.85
getKeyFromStringFunction · 0.85
convertStringToActionFunction · 0.85

Tested by

no test coverage detected