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

Method load

src/common/Bundle.cpp:38–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void Bundle::load(const std::string& path) {
39 std::string untranslated;
40 std::string translated;
41 char buffer[1024];
42
43 std::ifstream poStrm(path.c_str());
44 if (!poStrm.good()) {
45 return;
46 }
47
48 poStrm.getline(buffer, 1024);
49 while (poStrm.good()) {
50 std::string line = buffer;
51 std::string data;
52 TLineType type = parseLine(line, data);
53 if (type == tMSGID) {
54 if (untranslated.length() > 0) {
55 mappings.erase(untranslated);
56 mappings.insert(std::pair<std::string, std::string>(untranslated, translated));
57 }
58 untranslated = data;
59 translated.resize(0);
60 }
61 else if (type == tMSGSTR) {
62 if (untranslated.length() > 0) {
63 translated = data;
64 }
65 }
66 else if (type == tAPPEND) {
67 if (untranslated.length() > 0) {
68 translated += data;
69 }
70 }
71 else if (type == tERROR) {
72
73 }
74
75
76 poStrm.getline(buffer, 1024);
77 }
78
79 if ((untranslated.length() > 0) && (translated.length() > 0)) {
80 mappings.erase(untranslated);
81 mappings.insert(std::pair<std::string, std::string>(untranslated, translated));
82 }
83}
84
85Bundle::TLineType Bundle::parseLine(const std::string& line, std::string& data) const {
86 int startPos, endPos;

Callers 3

loadCollisionManagerMethod · 0.45
checkCollisionManagerMethod · 0.45
getBundleMethod · 0.45

Calls 5

parseLineFunction · 0.85
c_strMethod · 0.80
lengthMethod · 0.45
insertMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected