/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef NESTED_SETTINGS_H_ #define NESTED_SETTINGS_H_ #include /** * NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS. * Instead of being backed by a JSON file on disk, it loads and stores to its parent. */ class NESTED_SETTINGS : public JSON_SETTINGS { public: NESTED_SETTINGS( const std::string& aName, int aSchemaVersion, JSON_SETTINGS* aParent, const std::string& aPath, nlohmann::json aDefault = nlohmann::json( {} ) ); virtual ~NESTED_SETTINGS(); /** * Loads the JSON document from the parent and then calls Load() * @param aDirectory */ virtual void LoadFromFile( const std::string& aDirectory = "" ) override; /** * Calls Store() and then saves the JSON document contents into the parent JSON_SETTINGS * @param aDirectory is ignored */ virtual void SaveToFile( const std::string& aDirectory = "" ) override; private: /// A pointer to the parent object to load and store from JSON_SETTINGS* m_parent; /// The path (in pointer format) of where to store this document in the parent std::string m_path; }; #endif