Audacity 3.2.0
FileConfig.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FileConfig.h
6
7 Leland Lucius
8
9**********************************************************************/
10
11#ifndef __AUDACITY_WIDGETS_FILECONFIG__
12#define __AUDACITY_WIDGETS_FILECONFIG__
13
14#include <memory>
15
16#include <wx/defs.h>
17#include <wx/fileconf.h>
18#include "Identifier.h"
19
20class PREFERENCES_API FileConfig : public wxConfigBase
21{
22public:
23 FileConfig(const wxString& appName = wxEmptyString,
24 const wxString& vendorName = wxEmptyString,
25 const wxString& localFilename = wxEmptyString,
26 const wxString& globalFilename = wxEmptyString,
27 long style = wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_GLOBAL_FILE,
28 const wxMBConv& conv = wxConvAuto());
29 void Init();
30 virtual ~FileConfig();
31
32 virtual void SetPath(const wxString& strPath) wxOVERRIDE;
33 virtual const wxString& GetPath() const wxOVERRIDE;
34 virtual bool GetFirstGroup(wxString& str, long& lIndex) const wxOVERRIDE;
35 virtual bool GetNextGroup(wxString& str, long& lIndex) const wxOVERRIDE;
36 virtual bool GetFirstEntry(wxString& str, long& lIndex) const wxOVERRIDE;
37 virtual bool GetNextEntry(wxString& str, long& lIndex) const wxOVERRIDE;
38 virtual size_t GetNumberOfEntries(bool bRecursive = false) const wxOVERRIDE;
39 virtual size_t GetNumberOfGroups(bool bRecursive = false) const wxOVERRIDE;
40 virtual bool HasGroup(const wxString& strName) const wxOVERRIDE;
41 virtual bool HasEntry(const wxString& strName) const wxOVERRIDE;
42 virtual bool Flush(bool bCurrentOnly = false) wxOVERRIDE;
43 virtual bool RenameEntry(const wxString& oldName, const wxString& newName) wxOVERRIDE;
44 virtual bool RenameGroup(const wxString& oldName, const wxString& newName) wxOVERRIDE;
45 virtual bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = true) wxOVERRIDE;
46 virtual bool DeleteGroup(const wxString& key) wxOVERRIDE;
47 virtual bool DeleteAll() wxOVERRIDE;
48
49 // Set and Get values of the version major/minor/micro keys in audacity.cfg when Audacity first opens
50 void SetVersionKeysInit( int major, int minor, int micro)
51 {
52 mVersionMajorKeyInit = major;
53 mVersionMinorKeyInit = minor;
54 mVersionMicroKeyInit = micro;
55 }
56 void GetVersionKeysInit( int& major, int& minor, int& micro) const
57 {
58 major = mVersionMajorKeyInit;
59 minor = mVersionMinorKeyInit;
60 micro = mVersionMicroKeyInit;
61 }
62
63protected:
64 virtual bool DoReadString(const wxString& key, wxString *pStr) const wxOVERRIDE;
65 virtual bool DoReadLong(const wxString& key, long *pl) const wxOVERRIDE;
66#if wxUSE_BASE64
67 virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const wxOVERRIDE;
68#endif // wxUSE_BASE64
69
70 virtual bool DoWriteString(const wxString& key, const wxString& szValue) wxOVERRIDE;
71 virtual bool DoWriteLong(const wxString& key, long lValue) wxOVERRIDE;
72#if wxUSE_BASE64
73 virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) wxOVERRIDE;
74#endif // wxUSE_BASE64
75
76protected:
79 virtual void Warn();
80
81 const FilePath &GetFilePath() const { return mLocalFilename; }
82
83private:
84 const wxString mAppName;
85 const wxString mVendorName;
86 const wxString mLocalFilename;
87 const wxString mGlobalFilename;
88 const long mStyle;
89 std::unique_ptr<wxMBConv> mConv;
90
91 std::unique_ptr<wxFileConfig> mConfig;
92
93 // values of the version major/minor/micro keys in audacity.cfg
94 // when Audacity first opens
95 int mVersionMajorKeyInit{};
96 int mVersionMinorKeyInit{};
97 int mVersionMicroKeyInit{};
98
99 bool mDirty;
100};
101
102#endif
103
static const AudacityProject::AttachedObjects::RegisteredFactory key
#define str(a)
wxString FilePath
Definition: Project.h:20
const wxString mVendorName
Definition: FileConfig.h:85
void GetVersionKeysInit(int &major, int &minor, int &micro) const
Definition: FileConfig.h:56
bool mDirty
Definition: FileConfig.h:99
void SetVersionKeysInit(int major, int minor, int micro)
Definition: FileConfig.h:50
const FilePath & GetFilePath() const
Definition: FileConfig.h:81
const wxString mGlobalFilename
Definition: FileConfig.h:87
const long mStyle
Definition: FileConfig.h:88
const wxString mAppName
Definition: FileConfig.h:84
std::unique_ptr< wxMBConv > mConv
Definition: FileConfig.h:89
std::unique_ptr< wxFileConfig > mConfig
Definition: FileConfig.h:91
const wxString mLocalFilename
Definition: FileConfig.h:86