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

Function LoadFromXml

libs/editor/editor_notes.cpp:22–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace
21{
22bool LoadFromXml(pugi::xml_document const & xml, std::list<editor::Note> & notes, uint32_t & uploadedNotesCount)
23{
24 uint64_t notesCount;
25 auto const root = xml.child("notes");
26 if (!strings::to_uint64(root.attribute("uploadedNotesCount").value(), notesCount))
27 {
28 LOG(LERROR, ("Can't read uploadedNotesCount from file."));
29 uploadedNotesCount = 0;
30 }
31 else
32 {
33 uploadedNotesCount = static_cast<uint32_t>(notesCount);
34 }
35
36 for (auto const & xNode : root.select_nodes("note"))
37 {
38 ms::LatLon latLon;
39
40 auto const node = xNode.node();
41 auto const lat = node.attribute("lat");
42 if (!lat || !strings::to_double(lat.value(), latLon.m_lat))
43 continue;
44
45 auto const lon = node.attribute("lon");
46 if (!lon || !strings::to_double(lon.value(), latLon.m_lon))
47 continue;
48
49 auto const text = node.attribute("text");
50 if (!text)
51 continue;
52
53 notes.emplace_back(latLon, text.value());
54 }
55 return true;
56}
57
58void SaveToXml(std::list<editor::Note> const & notes, pugi::xml_document & xml, uint32_t const uploadedNotesCount)
59{

Callers 1

LoadFunction · 0.85

Calls 4

to_uint64Function · 0.85
to_doubleFunction · 0.50
valueMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected