OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_PropertiesFile.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26 namespace juce
27{
28
29//==============================================================================
45 class JUCE_API PropertiesFile : public PropertySet,
46 public ChangeBroadcaster,
47 private Timer
48{
49 public:
50 //==============================================================================
51 enum StorageFormat
52 {
53 storeAsBinary,
54 storeAsCompressedBinary,
55 storeAsXML
56 };
57
58 //==============================================================================
60 struct JUCE_API Options
61 {
65 Options();
66
69 String applicationName;
70
79 String filenameSuffix;
80
84 String folderName;
85
104 String osxLibrarySubFolder;
105
109 bool commonToAllUsers;
110
115 bool ignoreCaseOfKeyNames;
116
118 bool doNotSave;
119
128 int millisecondsBeforeSaving;
129
134 StorageFormat storageFormat;
135
143 InterProcessLock* processLock;
144
162 File getDefaultFile() const;
163 };
164
165 //==============================================================================
170 explicit PropertiesFile (const Options& options);
171
176 PropertiesFile (const File& file,
177 const Options& options);
178
182 ~PropertiesFile() override;
183
184 //==============================================================================
189 bool isValidFile() const noexcept { return loadedOk; }
190
191 //==============================================================================
200 bool saveIfNeeded();
201
210 bool save();
211
216 bool needsToBeSaved() const;
217
221 void setNeedsToBeSaved (bool needsToBeSaved);
222
224 bool reload();
225
226 //==============================================================================
228 const File& getFile() const noexcept { return file; }
229
230
231 protected:
233 void propertyChanged() override;
234
235 private:
236 //==============================================================================
237 File file;
238 Options options;
239 bool loadedOk = false, needsWriting = false;
240
241 using ProcessScopedLock = const std::unique_ptr<InterProcessLock::ScopedLockType>;
242 InterProcessLock::ScopedLockType* createProcessLock() const;
243
244 void timerCallback() override;
245 bool saveAsXml();
246 bool saveAsBinary();
247 bool loadAsXml();
248 bool loadAsBinary();
249 bool loadAsBinary (InputStream&);
250 bool writeToStream (OutputStream&);
251
252 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertiesFile)
253};
254
255} // namespace juce
juce::ChangeBroadcaster
Definition juce_ChangeBroadcaster.h:35
juce::File
Definition juce_File.h:45
juce::InputStream
Definition juce_InputStream.h:37
juce::InterProcessLock::ScopedLockType
Definition juce_InterProcessLock.h:72
juce::InterProcessLock
Definition juce_InterProcessLock.h:35
juce::OutputStream
Definition juce_OutputStream.h:38
juce::PropertiesFile
Definition juce_PropertiesFile.h:48
juce::PropertiesFile::getFile
const File & getFile() const noexcept
Definition juce_PropertiesFile.h:228
juce::PropertiesFile::isValidFile
bool isValidFile() const noexcept
Definition juce_PropertiesFile.h:189
juce::PropertySet
Definition juce_PropertySet.h:39
juce::String
Definition juce_String.h:53
juce::Timer
Definition juce_Timer.h:52
juce::PropertiesFile::Options
Definition juce_PropertiesFile.h:61
juce::PropertiesFile::Options::storageFormat
StorageFormat storageFormat
Definition juce_PropertiesFile.h:134
juce::PropertiesFile::Options::processLock
InterProcessLock * processLock
Definition juce_PropertiesFile.h:143
juce::PropertiesFile::Options::osxLibrarySubFolder
String osxLibrarySubFolder
Definition juce_PropertiesFile.h:104
juce::PropertiesFile::Options::filenameSuffix
String filenameSuffix
Definition juce_PropertiesFile.h:79
juce::PropertiesFile::Options::folderName
String folderName
Definition juce_PropertiesFile.h:84
juce::PropertiesFile::Options::applicationName
String applicationName
Definition juce_PropertiesFile.h:69
juce::PropertiesFile::Options::commonToAllUsers
bool commonToAllUsers
Definition juce_PropertiesFile.h:109
juce::PropertiesFile::Options::doNotSave
bool doNotSave
Definition juce_PropertiesFile.h:118
juce::PropertiesFile::Options::ignoreCaseOfKeyNames
bool ignoreCaseOfKeyNames
Definition juce_PropertiesFile.h:115
juce::PropertiesFile::Options::millisecondsBeforeSaving
int millisecondsBeforeSaving
Definition juce_PropertiesFile.h:128