Loading...
Searching...
No Matches
juce_PropertiesFile.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API PropertiesFile : public PropertySet,
public ChangeBroadcaster,
private Timer
{
public:
//==============================================================================
enum StorageFormat
{
storeAsBinary,
storeAsCompressedBinary,
storeAsXML
};
//==============================================================================
struct JUCE_API Options
{
Options();
String applicationName;
String filenameSuffix;
String folderName;
String osxLibrarySubFolder;
bool commonToAllUsers;
bool ignoreCaseOfKeyNames;
bool doNotSave;
int millisecondsBeforeSaving;
StorageFormat storageFormat;
InterProcessLock* processLock;
File getDefaultFile() const;
};
//==============================================================================
explicit PropertiesFile (const Options& options);
PropertiesFile (const File& file,
const Options& options);
~PropertiesFile() override;
//==============================================================================
bool isValidFile() const noexcept { return loadedOk; }
//==============================================================================
bool saveIfNeeded();
bool save();
bool needsToBeSaved() const;
void setNeedsToBeSaved (bool needsToBeSaved);
bool reload();
//==============================================================================
const File& getFile() const noexcept { return file; }
protected:
void propertyChanged() override;
private:
//==============================================================================
File file;
Options options;
bool loadedOk = false, needsWriting = false;
using ProcessScopedLock = const std::unique_ptr<InterProcessLock::ScopedLockType>;
InterProcessLock::ScopedLockType* createProcessLock() const;
void timerCallback() override;
bool saveAsXml();
bool saveAsBinary();
bool loadAsXml();
bool loadAsBinary();
bool loadAsBinary (InputStream&);
bool writeToStream (OutputStream&);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertiesFile)
};
} // namespace juce
juce::ChangeBroadcaster::ChangeBroadcaster
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
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::PropertiesFile
PropertiesFile(const Options &options)
Definition juce_PropertiesFile.cpp:122
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::PropertySet
PropertySet(bool ignoreCaseOfKeyNames=false)
Definition juce_PropertySet.cpp:26
juce::String
Definition juce_String.h:53
juce::Timer::Timer
Timer() noexcept
Definition juce_Timer.cpp:293
juce::PropertiesFile::Options
Definition juce_PropertiesFile.h:61
juce::PropertiesFile::Options::Options
Options()
Definition juce_PropertiesFile.cpp:41
juce::PropertiesFile::Options::storageFormat
StorageFormat storageFormat
Definition juce_PropertiesFile.h:134
juce::PropertiesFile::Options::getDefaultFile
File getDefaultFile() const
Definition juce_PropertiesFile.cpp:51
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