1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * @brief Declaration file ProjectFile class
9 #include "UnicodeString.h"
10 #include "PathContext.h"
14 friend class ProjectFile;
15 friend class ProjectFileHandler;
19 bool HasMiddle() const;
20 bool HasRight() const;
21 bool HasFilter() const;
22 bool HasSubfolders() const;
24 String GetLeft(bool * pReadOnly = nullptr) const;
25 bool GetLeftReadOnly() const;
26 String GetMiddle(bool * pReadOnly = nullptr) const;
27 bool GetMiddleReadOnly() const;
28 String GetRight(bool * pReadOnly = nullptr) const;
29 bool GetRightReadOnly() const;
30 String GetFilter() const;
31 int GetSubfolders() const;
33 void SetLeft(const String& sLeft, const bool * pReadOnly = nullptr);
34 void SetMiddle(const String& sMiddle, const bool * pReadOnly = nullptr);
35 void SetRight(const String& sRight, const bool * pReadOnly = nullptr);
36 void SetFilter(const String& sFilter);
37 void SetSubfolders(bool bSubfolder);
39 void GetPaths(PathContext& files, bool & bSubFolders) const;
40 void SetPaths(const PathContext& files, bool bSubFolders = false);
44 bool m_bHasLeft; /**< Has left path? */
45 bool m_bHasMiddle; /**< Has middle path? */
46 bool m_bHasRight; /**< Has right path? */
47 bool m_bHasFilter; /**< Has filter? */
48 String m_filter; /**< Filter name or mask */
49 bool m_bHasSubfolders; /**< Has subfolders? */
50 int m_subfolders; /**< Are subfolders included (recursive scan) */
51 bool m_bLeftReadOnly; /**< Is left path opened as read-only */
52 bool m_bMiddleReadOnly; /**< Is middle path opened as read-only */
53 bool m_bRightReadOnly; /**< Is right path opened as read-only */
57 * @brief Class for handling project files.
59 * This class loads and saves project files. Expat parser and SCEW wrapper for
60 * expat are used for XML parsing. We use UTF-8 encoding so Unicode paths are
66 bool Read(const String& path);
67 bool Save(const String& path) const;
68 const std::list<ProjectFileItem>& Items() const { return m_items; };
69 std::list<ProjectFileItem>& Items() { return m_items; }
70 static const String PROJECTFILE_EXT;
72 std::list<ProjectFileItem> m_items;
76 * @brief Returns if left path is defined in project file.
77 * @return true if project file has left path.
79 inline bool ProjectFileItem::HasLeft() const
85 * @brief Returns if middle path is defined.
87 inline bool ProjectFileItem::HasMiddle() const
93 * @brief Returns if right path is defined in project file.
94 * @return true if project file has right path.
96 inline bool ProjectFileItem::HasRight() const
102 * @brief Returns if filter is defined in project file.
103 * @return true if project file has filter.
105 inline bool ProjectFileItem::HasFilter() const
111 * @brief Returns if subfolder is defined in projectfile.
112 * @return true if project file has subfolder definition.
114 inline bool ProjectFileItem::HasSubfolders() const
116 return m_bHasSubfolders;
120 * @brief Returns if left path is specified read-only.
121 * @return true if left path is read-only, false otherwise.
123 inline bool ProjectFileItem::GetLeftReadOnly() const
125 return m_bLeftReadOnly;
129 * @brief Returns if middle path is specified read-only.
131 inline bool ProjectFileItem::GetMiddleReadOnly() const
133 return m_bMiddleReadOnly;
137 * @brief Returns if right path is specified read-only.
138 * @return true if right path is read-only, false otherwise.
140 inline bool ProjectFileItem::GetRightReadOnly() const
142 return m_bRightReadOnly;
146 * @brief Returns filter.
147 * @return Filter string.
149 inline String ProjectFileItem::GetFilter() const
156 * @param [in] sFilter New filter string to set.
158 inline void ProjectFileItem::SetFilter(const String& sFilter)
164 * @brief Returns subfolder included -setting.
165 * @return != 0 if subfolders are included.
167 inline int ProjectFileItem::GetSubfolders() const
173 * @brief set subfolder.
174 * @param [in] iSubfolder New value for subfolder inclusion.
176 inline void ProjectFileItem::SetSubfolders(bool bSubfolder)
178 m_subfolders = bSubfolder ? 1 : 0;
184 * @param [in] paths Files in project
185 * @param [in] bSubFolders If true subfolders included (recursive compare)
187 inline void ProjectFileItem::SetPaths(const PathContext& paths, bool bSubfolders)
190 m_subfolders = bSubfolders;