MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / processIF

Method processIF

plugins/plugin_utils/plugin_HTTP.cpp:1259–1318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1257}
1258
1259void Templateiser::processIF(std::string& code, std::string::const_iterator& inItr, const std::string& str) {
1260 std::string key;
1261
1262 // read the rest of the key
1263 std::string::const_iterator itr = readKey(key, inItr, str);
1264
1265 std::vector<std::string> commandParts = tokenize(key, std::string(" "), 0, 0);
1266 if (commandParts.size() < 2) {
1267 inItr = itr;
1268 return;
1269 }
1270
1271 // check the params
1272 makelower(commandParts[0]);
1273 makelower(commandParts[1]);
1274
1275 if (commandParts[0] != "if") {
1276 inItr = itr;
1277 return;
1278 }
1279
1280 std::string param;
1281 if (commandParts.size() > 2) {
1282 param = commandParts[2];
1283 }
1284
1285 // now get the code for the next section
1286 std::string trueSection, elseSection;
1287
1288 std::vector<std::string> checkKeys;
1289 checkKeys.push_back(format("?else %s", commandParts[1].c_str()));
1290 checkKeys.push_back(format("?end %s", commandParts[1].c_str()));
1291
1292 std::string keyFound;
1293 itr = findNextTag(checkKeys, keyFound, trueSection, itr, str);
1294
1295 if (keyFound == checkKeys[0]) { // we hit an else, so we need to check for it
1296 // it was the else, so go and find the end too
1297 if (itr == str.end()) {
1298 inItr = itr;
1299 return;
1300 }
1301
1302 checkKeys.erase(checkKeys.begin());// kill the else, find the end
1303 itr = findNextTag(checkKeys, keyFound, elseSection, itr, str);
1304 }
1305
1306 // test the if, stuff that dosn't exist is false
1307 if (callIF(commandParts[1], param)) {
1308 std::string newCode;
1309 processTemplate(newCode, trueSection);
1310 code += newCode;
1311 }
1312 else {
1313 std::string newCode;
1314 processTemplate(newCode, elseSection);
1315 code += newCode;
1316 }

Callers

nothing calls this directly

Calls 8

makelowerFunction · 0.85
c_strMethod · 0.80
tokenizeFunction · 0.70
formatFunction · 0.70
sizeMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected