MCPcopy Create free account
hub / github.com/DFHack/dfhack / split_string

Function split_string

library/MiscUtils.cpp:199–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199bool split_string(std::vector<std::string> *out,
200 const std::string &str, const std::string &separator, bool squash_empty)
201{
202 out->clear();
203
204 size_t start = 0, pos;
205
206 if (!separator.empty())
207 {
208 while ((pos = str.find(separator,start)) != std::string::npos)
209 {
210 if (pos > start || !squash_empty)
211 out->push_back(str.substr(start, pos-start));
212 start = pos + separator.size();
213 }
214 }
215
216 if (start < str.size() || !squash_empty)
217 out->push_back(str.substr(start));
218
219 return out->size() > 1;
220}
221
222std::string join_strings(const std::string &separator, const std::vector<std::string> &items)
223{

Callers 15

findMethod · 0.85
findMethod · 0.85
parseMethod · 0.85
load_zone_assignmentsFunction · 0.85
load_associationsFunction · 0.85
load_noble_mapFunction · 0.85
get_constraintFunction · 0.85
select_caste_matFunction · 0.85
select_plant_growthFunction · 0.85

Calls 4

clearMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected