MCPcopy Create free account
hub / github.com/FlagBrew/PKSM / readFile

Function readFile

external/tools/formTxtConverter.cpp:86–118  ·  view source on GitHub ↗

string, PKHeX line number(s)

Source from the content-addressed store, hash-verified

84
85// string, PKHeX line number(s)
86std::vector<std::pair<std::string, std::vector<int>>> readFile(Lang l)
87{
88 std::vector<std::pair<std::string, std::vector<int>>> ret;
89
90 std::string pkhexName = "text_Forms_" + pkhexLangString(l) + ".txt";
91
92 std::ifstream in(pkhexName);
93 assert(!in.bad());
94
95 std::string tmp;
96 int line = 0;
97 while (std::getline(in, tmp))
98 {
99 tmp = tmp.substr(0, tmp.find('\n'));
100 tmp = tmp.substr(0, tmp.find('\r'));
101 if (!tmp.empty())
102 {
103 auto it = std::find_if(ret.begin(), ret.end(), [&tmp](auto v) { return v.first == tmp; });
104 if (it != ret.end())
105 {
106 it->second.emplace_back(line);
107 }
108 else
109 {
110 ret.emplace_back(tmp, std::vector<int>{{line}});
111 }
112 }
113 line++;
114 }
115
116 in.close();
117 return ret;
118}
119
120void writeFile(Lang l, const std::vector<std::pair<std::string, std::vector<int>>>& array)
121{

Callers 1

mainFunction · 0.85

Calls 5

pkhexLangStringFunction · 0.85
beginMethod · 0.80
emptyMethod · 0.45
endMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected