JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::ApplicationProperties Class Reference

Manages a collection of properties. More...

#include <juce_ApplicationProperties.h>

Collaboration diagram for juce::ApplicationProperties:

Public Member Functions

 ApplicationProperties ()
 Creates an ApplicationProperties object. More...
 
 ~ApplicationProperties ()
 Destructor. More...
 
void closeFiles ()
 Flushes and closes both files if they are open. More...
 
PropertiesFilegetCommonSettings (bool returnUserPropsIfReadOnly)
 Returns the common settings file. More...
 
const PropertiesFile::OptionsgetStorageParameters () const noexcept
 Returns the current storage parameters. More...
 
PropertiesFilegetUserSettings ()
 Returns the user settings file. More...
 
bool saveIfNeeded ()
 Saves both files if they need to be saved. More...
 
void setStorageParameters (const PropertiesFile::Options &options)
 Gives the object the information it needs to create the appropriate properties files. More...
 

Private Member Functions

void openFiles ()
 

Private Attributes

std::unique_ptr< PropertiesFilecommonProps
 
int commonSettingsAreReadOnly = 0
 
PropertiesFile::Options options
 
std::unique_ptr< PropertiesFileuserProps
 

Detailed Description

Manages a collection of properties.

This is a slightly higher-level wrapper for managing PropertiesFile objects.

It holds two different PropertiesFile objects internally, one for user-specific settings (stored in your user directory), and one for settings that are common to all users (stored in a folder accessible to all users).

The class manages the creation of these files on-demand, allowing access via the getUserSettings() and getCommonSettings() methods.

After creating an instance of an ApplicationProperties object, you should first of all call setStorageParameters() to tell it the parameters to use to create its files.

See also
PropertiesFile

{DataStructures}

Constructor & Destructor Documentation

◆ ApplicationProperties()

juce::ApplicationProperties::ApplicationProperties ( )

Creates an ApplicationProperties object.

Before using it, you must call setStorageParameters() to give it the info it needs to create the property files.

◆ ~ApplicationProperties()

juce::ApplicationProperties::~ApplicationProperties ( )

Destructor.

Member Function Documentation

◆ closeFiles()

void juce::ApplicationProperties::closeFiles ( )

Flushes and closes both files if they are open.

This flushes any pending changes to disk with PropertiesFile::saveIfNeeded() and closes both files. They will then be re-opened the next time getUserSettings() or getCommonSettings() is called.

◆ getCommonSettings()

PropertiesFile* juce::ApplicationProperties::getCommonSettings ( bool  returnUserPropsIfReadOnly)

Returns the common settings file.

The first time this is called, it will create and load the properties file.

Parameters
returnUserPropsIfReadOnlyif this is true, and the common properties file is read-only (e.g. because the user doesn't have permission to write to shared files), then this will return the user settings instead, (like getUserSettings() would do). This is handy if you'd like to write a value to the common settings, but if that's no possible, then you'd rather write to the user settings than none at all. If returnUserPropsIfReadOnly is false, this method will always return the common settings, even if any changes to them can't be saved.
See also
getUserSettings

◆ getStorageParameters()

const PropertiesFile::Options& juce::ApplicationProperties::getStorageParameters ( ) const
inlinenoexcept

Returns the current storage parameters.

See also
setStorageParameters

◆ getUserSettings()

PropertiesFile* juce::ApplicationProperties::getUserSettings ( )

Returns the user settings file.

The first time this is called, it will create and load the properties file.

Note that when you search the user PropertiesFile for a value that it doesn't contain, the common settings are used as a second-chance place to look. This is done via the PropertySet::setFallbackPropertySet() method - by default the common settings are set to the fallback for the user settings.

See also
getCommonSettings

◆ openFiles()

void juce::ApplicationProperties::openFiles ( )
private

◆ saveIfNeeded()

bool juce::ApplicationProperties::saveIfNeeded ( )

Saves both files if they need to be saved.

See also
PropertiesFile::saveIfNeeded

◆ setStorageParameters()

void juce::ApplicationProperties::setStorageParameters ( const PropertiesFile::Options options)

Gives the object the information it needs to create the appropriate properties files.

See the PropertiesFile::Options class for details about what options you need to set.

Member Data Documentation

◆ commonProps

std::unique_ptr<PropertiesFile> juce::ApplicationProperties::commonProps
private

◆ commonSettingsAreReadOnly

int juce::ApplicationProperties::commonSettingsAreReadOnly = 0
private

◆ options

PropertiesFile::Options juce::ApplicationProperties::options
private

◆ userProps

std::unique_ptr<PropertiesFile> juce::ApplicationProperties::userProps
private

The documentation for this class was generated from the following file: