| 20 | namespace |
| 21 | { |
| 22 | bool 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 | |
| 58 | void SaveToXml(std::list<editor::Note> const & notes, pugi::xml_document & xml, uint32_t const uploadedNotesCount) |
| 59 | { |
no test coverage detected