JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_PropertiesFile.h
Go to the documentation of this file.
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
26namespace juce
27{
28
29//==============================================================================
45class JUCE_API PropertiesFile : public PropertySet,
46 public ChangeBroadcaster,
47 private Timer
48{
49public:
50 //==============================================================================
51 enum StorageFormat
52 {
53 storeAsBinary,
54 storeAsCompressedBinary,
55 storeAsXML
56 };
57
58 //==============================================================================
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
231protected:
233 void propertyChanged() override;
234
235private:
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
253};
254
255} // namespace juce
Holds a list of ChangeListeners, and sends messages to them when instructed.
Represents a local file or directory.
Definition juce_File.h:45
The base class for streams that read data.
Automatically locks and unlocks an InterProcessLock object.
Acts as a critical section which processes can use to block each other.
The base class for streams that write data to some kind of destination.
Wrapper on a file that stores a list of key/value data pairs.
const File & getFile() const noexcept
Returns the file that's being used.
bool isValidFile() const noexcept
Returns true if this file was created from a valid (or non-existent) file.
A set of named property values, which can be strings, integers, floating point, etc.
The JUCE String class!
Definition juce_String.h:53
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
Structure describing properties file options.
StorageFormat storageFormat
Specifies whether the file should be written as XML, binary, etc.
InterProcessLock * processLock
An optional InterprocessLock object that will be used to prevent multiple threads or processes from w...
String osxLibrarySubFolder
If you're using properties files on a Mac, you must set this value - failure to do so will cause a ru...
String filenameSuffix
The suffix to use for your properties file.
String folderName
The name of a subfolder in which you'd like your properties file to live.
String applicationName
The name of your application - this is used to help generate the path and filename at which the prope...
bool commonToAllUsers
If true, the file will be created in a location that's shared between users.
bool doNotSave
If set to true, this prevents the file from being written to disk.
bool ignoreCaseOfKeyNames
If true, this means that property names are matched in a case-insensitive manner.
int millisecondsBeforeSaving
If this is zero or greater, then after a value is changed, the object will wait for this amount of ti...