OSDN Git Service

Merge with stable
[winmerge-jp/winmerge-jp.git] / Src / ProjectFile.h
1 /////////////////////////////////////////////////////////////////////////////
2 //    License (GPLv2+):
3 //    This program is free software; you can redistribute it and/or modify
4 //    it under the terms of the GNU General Public License as published by
5 //    the Free Software Foundation; either version 2 of the License, or
6 //    (at your option) any later version.
7 //
8 //    This program is distributed in the hope that it will be useful, but
9 //    WITHOUT ANY WARRANTY; without even the implied warranty of
10 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //    General Public License for more details.
12 //
13 //    You should have received a copy of the GNU General Public License
14 //    along with this program; if not, write to the Free Software
15 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /////////////////////////////////////////////////////////////////////////////
17 /** 
18  * @file  ProjectFile.h
19  *
20  * @brief Declaration file ProjectFile class
21  */
22 #pragma once
23
24 #include "UnicodeString.h"
25 #include "PathContext.h"
26
27 /**
28  * @brief Class for handling project files.
29  *
30  * This class loads and saves project files. Expat parser and SCEW wrapper for
31  * expat are used for XML parsing. We use UTF-8 encoding so Unicode paths are
32  * supported.
33  */
34 class ProjectFile
35 {
36         friend class ProjectFileHandler;
37 public:
38         ProjectFile();
39         bool Read(const String& path);
40         bool Save(const String& path) const;
41         
42         bool HasLeft() const;
43         bool HasMiddle() const;
44         bool HasRight() const;
45         bool HasFilter() const;
46         bool HasSubfolders() const;
47
48         String GetLeft(bool * pReadOnly = NULL) const;
49         bool GetLeftReadOnly() const;
50         String GetMiddle(bool * pReadOnly = NULL) const;
51         bool GetMiddleReadOnly() const;
52         String GetMiddle() const;
53         String GetRight(bool * pReadOnly = NULL) const;
54         bool GetRightReadOnly() const;
55         String GetFilter() const;
56         int GetSubfolders() const;
57
58         void SetLeft(const String& sLeft, const bool * pReadOnly = NULL);
59         void SetMiddle(const String& sMiddle, const bool * pReadOnly = NULL);
60         void SetRight(const String& sRight, const bool * pReadOnly = NULL);
61         void SetFilter(const String& sFilter);
62         void SetSubfolders(int iSubfolder);
63
64         void GetPaths(PathContext& files, bool & bSubFolders) const;
65         void SetPaths(const PathContext& files, bool bSubFolders = false);
66
67         static const String PROJECTFILE_EXT;
68
69 private:
70         PathContext m_paths;
71         bool m_bHasLeft; /**< Has left path? */
72         bool m_bHasMiddle; /**< Has middle path? */
73         bool m_bHasRight; /**< Has right path? */
74         bool m_bHasFilter; /**< Has filter? */
75         String m_filter; /**< Filter name or mask */
76         bool m_bHasSubfolders; /**< Has subfolders? */
77         int m_subfolders; /**< Are subfolders included (recursive scan) */
78         bool m_bLeftReadOnly; /**< Is left path opened as read-only */
79         bool m_bMiddleReadOnly; /**< Is middle path opened as read-only */
80         bool m_bRightReadOnly; /**< Is right path opened as read-only */
81 };