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

Function Load

libs/editor/editor_notes.cpp:74–108  ·  view source on GitHub ↗

Not thread-safe, use only for initialization.

Source from the content-addressed store, hash-verified

72
73/// Not thread-safe, use only for initialization.
74bool Load(std::string const & fileName, std::list<editor::Note> & notes, uint32_t & uploadedNotesCount)
75{
76 std::string content;
77 try
78 {
79 auto const reader = GetPlatform().GetReader(fileName);
80 reader->ReadAsString(content);
81 }
82 catch (FileAbsentException const &)
83 {
84 // It's normal if no notes file is present.
85 return true;
86 }
87 catch (Reader::Exception const & e)
88 {
89 LOG(LERROR, ("Can't process file.", fileName, e.Msg()));
90 return false;
91 }
92
93 pugi::xml_document xml;
94 if (!xml.load_buffer(content.data(), content.size()))
95 {
96 LOG(LERROR, ("Can't load notes, XML is ill-formed.", content));
97 return false;
98 }
99
100 notes.clear();
101 if (!LoadFromXml(xml, notes, uploadedNotesCount))
102 {
103 LOG(LERROR, ("Can't load notes, file is ill-formed.", content));
104 return false;
105 }
106
107 return true;
108}
109
110/// Not thread-safe, use synchronization.
111bool Save(std::string const & fileName, std::list<editor::Note> const & notes, uint32_t const uploadedNotesCount)

Callers 15

NotesMethod · 0.70
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
WithRoadFunction · 0.50
UNIT_TESTFunction · 0.50
UNIT_TESTFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
SymbolsTextureMethod · 0.50
InvalidateMethod · 0.50
LoadClassificatorFunction · 0.50

Calls 6

LoadFromXmlFunction · 0.85
GetReaderMethod · 0.45
ReadAsStringMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by 15

WithRoadFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
EditorTestMethod · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40