MCPcopy Create free account
hub / github.com/comaps/comaps / SetCuisine

Method SetCuisine

libs/editor/xml_feature.cpp:300–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void XMLFeature::SetCuisine(string cuisine)
301{
302 auto const findAndErase = [&cuisine](std::string_view s)
303 {
304 size_t const i = cuisine.find(s);
305 if (i != std::string_view::npos)
306 {
307 size_t from = 0;
308 size_t sz = s.size();
309 if (i > 0)
310 {
311 from = i - 1;
312 ASSERT_EQUAL(cuisine[from], ';', ());
313 ++sz;
314 }
315 else if (cuisine.size() > sz)
316 {
317 ASSERT_EQUAL(cuisine[sz], ';', ());
318 ++sz;
319 }
320
321 cuisine.erase(from, sz);
322 return true;
323 }
324 return false;
325 };
326
327 if (findAndErase(kVegan))
328 SetTagValue(kDietVegan, kYes);
329 else
330 RemoveTag(kDietVegan);
331
332 if (findAndErase(kVegetarian))
333 SetTagValue(kDietVegetarian, kYes);
334 else
335 RemoveTag(kDietVegetarian);
336
337 if (!cuisine.empty())
338 SetTagValue(kCuisine, cuisine);
339 else
340 RemoveTag(kCuisine);
341}
342/// @}
343
344time_t XMLFeature::GetModificationTime() const

Callers 2

ToXMLFunction · 0.80
UNIT_TESTFunction · 0.80

Calls 4

findMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64