| 587 | } |
| 588 | |
| 589 | void CodeEditorUI::LoadSnippets() |
| 590 | { |
| 591 | Logger::Get().Log("Loading code snippets"); |
| 592 | |
| 593 | std::string snippetsFileLoc = Settings::Instance().ConvertPath("data/snippets.xml"); |
| 594 | |
| 595 | pugi::xml_document doc; |
| 596 | pugi::xml_parse_result result = doc.load_file(snippetsFileLoc.c_str()); |
| 597 | if (!result) |
| 598 | return; |
| 599 | |
| 600 | m_snippets.clear(); |
| 601 | |
| 602 | pugi::xml_node snippetsList = doc.child("snippets"); |
| 603 | for (pugi::xml_node snippetNode : snippetsList.children("snippet")) { |
| 604 | CodeSnippet snippet; |
| 605 | |
| 606 | snippet.Language = snippetNode.child("language").text().as_string(); |
| 607 | snippet.Display = snippetNode.child("display").text().as_string(); |
| 608 | snippet.Search = snippetNode.child("search").text().as_string(); |
| 609 | snippet.Code = snippetNode.child("code").text().as_string(); |
| 610 | |
| 611 | m_snippets.push_back(snippet); |
| 612 | } |
| 613 | } |
| 614 | void CodeEditorUI::SaveSnippets() |
| 615 | { |
| 616 | pugi::xml_document doc; |
no test coverage detected