Kitlist
A list manager for maintaining kit lists
Loading...
Searching...
No Matches
kitlist_base_app.cpp
Go to the documentation of this file.
1/*
2
3 This file is part of Kitlist, a program to maintain a simple list
4 of items and assign items to one or more categories.
5
6 Copyright (C) 2008-2025 Frank Dean
7
8 Kitlist is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 Kitlist is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22#include "kitlist_base_app.hpp"
23#include "kitparser.hpp"
24#include <filesystem>
25
26using namespace std;
27
28const string KitListBaseApp::DEFAULT_FILE_EXTENSION = ".kit";
29
31 filename(),
32 initialized(false)
33{
34 model = unique_ptr<Model>(new Model());
35}
36
38
40{
41 this->filename = filename;
42 try {
43 const filesystem::path p{filename};
44 if (!exists(p)) {
45 throw file_not_found("Path does not exist");
46 }
48 model = kp.parse();
49 model->sort();
50 model->validate();
51 } catch (const std::filesystem::filesystem_error& e) {
52 throw file_not_found("Unable to process file");
53 }
54}
Exception throw when a file is not found.
KitListBaseApp()
Default constructor.
std::string filename
The current filename the Model was loaded from.
virtual void load_file(const std::string &filename)
Loads the specified file.
bool initialized
Indicates that the application has finished it's initialization stage.
std::unique_ptr< Model > model
The application's data model.
static const std::string DEFAULT_FILE_EXTENSION
The application's default filename extension. .kit.
virtual ~KitListBaseApp()
Destructor.
Loads a kitlist from the file system.
Definition kitparser.hpp:43
std::unique_ptr< Model > parse()
Parses the XML, building the data Model.
Definition kitparser.cpp:75
Copyright 2008-2025 Frank Dean