LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
smartsexprfile.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_SMARTSEXPRFILE_H
21 #define LIBREPCB_SMARTSEXPRFILE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "smartfile.h"
27 
28 #include <QtCore>
29 
30 #include <memory>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class SExpression;
38 
39 /*******************************************************************************
40  * Class SmartSExprFile
41  ******************************************************************************/
42 
56 class SmartSExprFile final : public SmartFile {
57  Q_DECLARE_TR_FUNCTIONS(SmartSExprFile)
58 
59 public:
60  // Constructors / Destructor
61  SmartSExprFile() = delete;
62  SmartSExprFile(const SmartSExprFile& other) = delete;
63 
77  SmartSExprFile(const FilePath& filepath, bool restore, bool readOnly)
78  : SmartSExprFile(filepath, restore, readOnly, false) {}
79 
83  ~SmartSExprFile() noexcept;
84 
85  // General Methods
86 
94 
104  void save(const SExpression& domDocument, bool toOriginal);
105 
106  // Operator Overloadings
107  SmartSExprFile& operator=(const SmartSExprFile& rhs) = delete;
108 
109  // Static Methods
110 
124  static SmartSExprFile* create(const FilePath& filepath);
125 
126 private: // Methods
137  SmartSExprFile(const FilePath& filepath, bool restore, bool readOnly,
138  bool create);
139 };
140 
141 /*******************************************************************************
142  * End of File
143  ******************************************************************************/
144 
145 } // namespace librepcb
146 
147 #endif // LIBREPCB_SMARTSEXPRFILE_H
SmartSExprFile(const FilePath &filepath, bool restore, bool readOnly)
The constructor to open an existing S-Expressions file.
Definition: smartsexprfile.h:77
The SmartSExprFile class represents an S-Expressions file and provides methods to load/save DOM trees...
Definition: smartsexprfile.h:56
The abstract SmartFile class represents a file and provides some useful methods to work with that fil...
Definition: smartfile.h:59
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
void save(const SExpression &domDocument, bool toOriginal)
Write the S-Expressions DOM tree to the file system.
Definition: smartsexprfile.cpp:56
static SmartSExprFile * create(const FilePath &filepath)
Create a new S-Expressions file.
Definition: smartsexprfile.cpp:66
SExpression parseFileAndBuildDomTree() const
Open and parse the S-Expressions file and build the whole DOM tree.
Definition: smartsexprfile.cpp:51
~SmartSExprFile() noexcept
The destructor.
Definition: smartsexprfile.cpp:44
The SExpression class.
Definition: sexpression.h:60