Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
hdi::core::Preferences Class Reference

Aids in preference storage by reading/writing the JSON data in a given file. More...

#include <hdicorePreferences.h>

Classes

class  Iterator
 Allows for iteration through the members of a Preferences object, a la std::vector iteration. More...
 

Public Types

typedef std::vector< std::shared_ptr< PrefData > > PrefDataVector
 
typedef std::unique_ptr< IteratorIteratorUP
 
typedef std::shared_ptr< IteratorIteratorSP
 
typedef std::weak_ptr< IteratorIteratorWP
 

Public Member Functions

 Preferences ()
 Constructs an empty Preferences object.
 
 Preferences (const Preferences &prefs_)
 Constructs a new Preferences object from an existing Preferences object (copy constructor)
 
virtual ~Preferences ()
 Destructs a Preferences object.
 
virtual Preferencesoperator= (const Preferences &rhs_)
 Assigns one Preferences object to another.
 
virtual bool isEmpty () const
 Gets whether the target Preferences object is empty (constructed with the default ctor)
 
virtual bool reload (const std::string &path_)
 Reloads the preferences data from disk (as it is kept in memory at runtime, this might be necessary if another process or plugin manipulates the file)
 
virtual bool save (const std::string &path_) const
 Writes JSON preferences data to a file.
 
virtual uint64_t saveCount () const
 Gets the save count of the prefs file.
 
virtual bool addPref (const PrefData &pref_)
 Adds a preference object into the prefs data tree, such that when the prefs are written the individual pref data will be present.
 
virtual bool getPref (const std::string &key_, std::unique_ptr< PrefData > &pref__) const
 Gets a single preference object from the prefs data tree.
 
virtual bool removePref (const PrefData &pref_)
 Removes a preference from the prefs data tree.
 
virtual Iterator begin () const
 Gets an iterator for the Preferences object.
 
virtual bool getArrayPref (const std::string &key_, ArrayPref &array__) const
 Gets an array pref from the prefs data tree.
 
virtual bool getOrCreateArrayPref (const std::string &key_, const PrefDataVector *elements_, ArrayPref &array__)
 Similar to getArrayPref(), except that, if the pref does not already exist, it will be created anew with a series of default elements.
 
virtual bool getArtboardPointPref (const std::string &key_, ArtboardPointPref &abp__) const
 Gets an artboard point pref from the prefs data tree.
 
virtual bool getOrCreateArtboardPointPref (const std::string &key_, const ArtboardPoint &default_, ArtboardPointPref &abp__)
 Similar to getArtboardPointPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getArtboardRectPref (const std::string &key_, ArtboardRectPref &abr__) const
 Gets an artboard rect pref from the prefs data tree.
 
virtual bool getOrCreateArtboardRectPref (const std::string &key_, const ArtboardRect &default_, ArtboardRectPref &abr__)
 Similar to getArtboardRectPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getArtColorPref (const std::string &key_, ArtColorPref &ac__) const
 Gets an art color pref from the prefs data tree.
 
virtual bool getOrCreateArtColorPref (const std::string &key_, const ArtColor &default_, ArtColorPref &ac__)
 Similar to getArtColorPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getBoolPref (const std::string &key_, BoolPref &b__) const
 Gets a bool pref from the prefs data tree.
 
virtual bool getOrCreateBoolPref (const std::string &key_, const bool default_, BoolPref &b__)
 Similar to getBoolPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getColorPref (const std::string &key_, ColorPref &c__) const
 Gets a color pref from the prefs data tree.
 
virtual bool getOrCreateColorPref (const std::string &key_, const Color &default_, ColorPref &c__)
 Similar to getColorPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getDashStylePref (const std::string &key_, DashStylePref &ds__)
 Gets a persistent dash style object from the prefs data tree.
 
virtual bool getOrCreateDashStylePref (const std::string &key_, const DashStyle &default_, DashStylePref &ds__)
 Similar to getDashStylePref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getDashStyleMapPref (const std::string &key_, DashStyleMapPref &ds__)
 Gets a persistent dash style map object from the prefs data tree.
 
virtual bool getOrCreateDashStyleMapPref (const std::string &key_, const DashStyle::Map &default_, DashStyleMapPref &ds__)
 Similar to getDashStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getDictPref (const std::string &key_, DictionaryPref &dict__) const
 Gets a dictionary pref from the prefs data tree.
 
virtual bool getOrCreateDictPref (const std::string &key_, const PrefDataVector *members_, DictionaryPref &dict__)
 Similar to getDictPref(), except that, if the pref does not already exist, it will be created anew with a series of default members.
 
virtual bool getFillStylePref (const std::string &key_, FillStylePref &fs__)
 Gets a persistent fill style object from the prefs data tree.
 
virtual bool getOrCreateFillStylePref (const std::string &key_, const FillStyle &default_, FillStylePref &fs__)
 Similar to getFillStylePref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getFillStyleMapPref (const std::string &key_, FillStyleMapPref &fs__)
 Gets a persistent fill style map object from the prefs data tree.
 
virtual bool getOrCreateFillStyleMapPref (const std::string &key_, const FillStyle::Map &default_, FillStyleMapPref &fs__)
 Similar to getFillStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getFontPref (const std::string &key_, FontPref &font__) const
 Gets a font pref from the prefs data tree.
 
virtual bool getOrCreateFontPref (const std::string &key_, const Font &defaultFont_, const double defaultSize_, FontPref &font__)
 Similar to getFontPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getTransformMatrixPref (const std::string &key_, TransformMatrixPref &tm__) const
 Gets a transform matrix pref from the prefs data tree.
 
virtual bool getOrCreateTransformMatrixPref (const std::string &key_, const TransformMatrix &default_, TransformMatrixPref &tm__)
 Similar to getTransformMatrixPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getNumberPref (const std::string &key_, NumberPref &n__) const
 Gets a number pref from the prefs data tree.
 
virtual bool getOrCreateIntPref (const std::string &key_, const int64_t default_, NumberPref &n__)
 Similar to getNumberPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getOrCreateFloatPref (const std::string &key_, const double default_, NumberPref &n__)
 Similar to getNumberPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getPathStylePref (const std::string &key_, PathStylePref &ps__)
 Gets a persistent path style object from the prefs data tree.
 
virtual bool getOrCreatePathStylePref (const std::string &key_, const PathStyle &default_, PathStylePref &ps__)
 Similar to getPathStylePref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getPathStyleMapPref (const std::string &key_, PathStyleMapPref &ps__)
 Gets a persistent path style map object from the prefs data tree.
 
virtual bool getOrCreatePathStyleMapPref (const std::string &key_, const PathStyle::Map &default_, PathStyleMapPref &ps__)
 Similar to getPathStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getPointPref (const std::string &key_, PointPref &p__) const
 Gets a point pref from the prefs data tree.
 
virtual bool getOrCreatePointPref (const std::string &key_, const Point &default_, PointPref &p__)
 Similar to getPointPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getRectPref (const std::string &key_, RectPref &r__) const
 Gets a rect pref from the prefs data tree.
 
virtual bool getOrCreateRectPref (const std::string &key_, const Rect &default_, RectPref &r__)
 Similar to getRectPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getSizePref (const std::string &key_, SizePref &s__) const
 Gets a size pref from the prefs data tree.
 
virtual bool getOrCreateSizePref (const std::string &key_, const Size &default_, SizePref &s__)
 Similar to getSizePref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getStringPref (const std::string &key_, StringPref &str__) const
 Gets a string pref from the prefs data tree.
 
virtual bool getOrCreateStringPref (const std::string &key_, const std::string &default_, StringPref &str__)
 Similar to getStringPref(), except that, if the pref does not already exist, it will be created anew with a default value.
 
virtual bool getStrokeStylePref (const std::string &key_, StrokeStylePref &ss__)
 Gets a persistent stroke style object from the prefs data tree.
 
virtual bool getOrCreateStrokeStylePref (const std::string &key_, const StrokeStyle &default_, StrokeStylePref &ss__)
 Similar to getStrokeStylePref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual bool getStrokeStyleMapPref (const std::string &key_, StrokeStyleMapPref &ss__)
 Gets a persistent stroke style map object from the prefs data tree.
 
virtual bool getOrCreateStrokeStyleMapPref (const std::string &key_, const StrokeStyle::Map &default_, StrokeStyleMapPref &ss__)
 Similar to getStrokeStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.
 
virtual int32_t versionNumber () const
 Gets the number version for the preferences data.
 
virtual bool setVersionNumber (const int32_t version_)
 Sets the number version for the preferences data.
 
virtual std::string versionString () const
 Gets the version string for the preferences data.
 
virtual bool setVersionString (const std::string &version_)
 Sets the version string for the preferences data.
 

Static Public Member Functions

static bool load (const std::string &path_, Preferences &prefs__)
 Convenience method to create a Preferences object from JSON data in a file.
 

Protected Member Functions

 Preferences (const aip::Preferences &)
 Internal use only.
 

Protected Attributes

void * __data
 Private implementation data.
 

Detailed Description

Aids in preference storage by reading/writing the JSON data in a given file.

Constructor & Destructor Documentation

◆ Preferences() [1/3]

hdi::core::Preferences::Preferences ( )

Constructs an empty Preferences object.

Author
GW
Date
09/2013
Note
To test if a Preferences object is empty, call isEmpty() on it
Empty Preferences objects do not relate to any actual preferences file; they are designed to be "receivers" of some other Preferences object via the overloaded assignment operator. Empty Preferences objects are useless until such time (though it is safe to call any of their methods).

◆ Preferences() [2/3]

hdi::core::Preferences::Preferences ( const Preferences prefs_)

Constructs a new Preferences object from an existing Preferences object (copy constructor)

Author
GW
Date
09/2013
Parameters
prefs_Existing Preferences object

◆ ~Preferences()

virtual hdi::core::Preferences::~Preferences ( )
virtual

Destructs a Preferences object.

Author
GW
Date
09/2013

◆ Preferences() [3/3]

hdi::core::Preferences::Preferences ( const aip::Preferences &  )
protected

Internal use only.

Author
GW
Date
09/2013

Member Function Documentation

◆ addPref()

virtual bool hdi::core::Preferences::addPref ( const PrefData pref_)
virtual

Adds a preference object into the prefs data tree, such that when the prefs are written the individual pref data will be present.

Author
GW
Date
09/2013
Parameters
pref_New preference to add into the top-level of the prefs data tree
Returns
true if the pref was added, or false otherwise
Note
The pref is added to the top-most level of the prefs data tree, with any children of its own appearing underneath the pref_ member.

◆ begin()

virtual Iterator hdi::core::Preferences::begin ( ) const
virtual

Gets an iterator for the Preferences object.

Author
GW
Date
05/2018
Returns
An Iterator object, for iterating through the target's members
// Here's an example, iterating through the children of prefs:
for(hdi::core::Preferences::Iterator iter = prefs.begin(); !iter.atEnd(); ++iter)
{
// do stuff with iter.key() or iter.value()
}
Allows for iteration through the members of a Preferences object, a la std::vector iteration.
Definition: hdicorePreferences.h:90
bool atEnd() const
Determines whether iteration should stop; works well as the conditional in a for() loop.

◆ getArrayPref()

virtual bool hdi::core::Preferences::getArrayPref ( const std::string &  key_,
ArrayPref array__ 
) const
virtual

Gets an array pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the array to get from the top-level and return as a neatly-packed PrefData subclass
array__Return-by-reference for the array pref identified by key_
Returns
true if the array could be acquired, false otherwise

◆ getArtboardPointPref()

virtual bool hdi::core::Preferences::getArtboardPointPref ( const std::string &  key_,
ArtboardPointPref abp__ 
) const
virtual

Gets an artboard point pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the artboard point to get from the top-level and return as a neatly-packed PrefData subclass
abp__Return-by-reference for the artboard point pref identified by key_
Returns
true if the artboard point could be acquired, false otherwise

◆ getArtboardRectPref()

virtual bool hdi::core::Preferences::getArtboardRectPref ( const std::string &  key_,
ArtboardRectPref abr__ 
) const
virtual

Gets an artboard rect pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the artboard rect to get from the top-level and return as a neatly-packed PrefData subclass
abr__Return-by-reference for the artboard rect pref identified by key_
Returns
true if the artboard rect could be acquired, false otherwise

◆ getArtColorPref()

virtual bool hdi::core::Preferences::getArtColorPref ( const std::string &  key_,
ArtColorPref ac__ 
) const
virtual

Gets an art color pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the art color to get from the top-level and return as a neatly- packed PrefData subclass
ac__Return-by-reference for the art color pref identified by key_
Returns
true if the art color could be acquired, false otherwise

◆ getBoolPref()

virtual bool hdi::core::Preferences::getBoolPref ( const std::string &  key_,
BoolPref b__ 
) const
virtual

Gets a bool pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the bool to get from the top-level and return as a neatly- packed PrefData subclass
b__Return-by-reference for the bool pref identified by key_
Returns
true if the bool could be acquired, false otherwise

◆ getColorPref()

virtual bool hdi::core::Preferences::getColorPref ( const std::string &  key_,
ColorPref c__ 
) const
virtual

Gets a color pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the color to get from the top-level and return as a neatly- packed PrefData subclass
c__Return-by-reference for the color pref identified by key_
Returns
true if the color could be acquired, false otherwise

◆ getDashStyleMapPref()

virtual bool hdi::core::Preferences::getDashStyleMapPref ( const std::string &  key_,
DashStyleMapPref ds__ 
)
virtual

Gets a persistent dash style map object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the dash style map to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the dash style map member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getDashStylePref()

virtual bool hdi::core::Preferences::getDashStylePref ( const std::string &  key_,
DashStylePref ds__ 
)
virtual

Gets a persistent dash style object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the dash style to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the dash style member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getDictPref()

virtual bool hdi::core::Preferences::getDictPref ( const std::string &  key_,
DictionaryPref dict__ 
) const
virtual

Gets a dictionary pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the dictionary to get from the top-level and return as a neatly-packed PrefData subclass
dict__Return-by-reference for the dictionary pref identified by key_
Returns
true if the dictionary could be acquired, false otherwise

◆ getFillStyleMapPref()

virtual bool hdi::core::Preferences::getFillStyleMapPref ( const std::string &  key_,
FillStyleMapPref fs__ 
)
virtual

Gets a persistent fill style map object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the fill style map to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the fill style map member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getFillStylePref()

virtual bool hdi::core::Preferences::getFillStylePref ( const std::string &  key_,
FillStylePref fs__ 
)
virtual

Gets a persistent fill style object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the fill style to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the fill style member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getFontPref()

virtual bool hdi::core::Preferences::getFontPref ( const std::string &  key_,
FontPref font__ 
) const
virtual

Gets a font pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the font to get from the top-level and return as a neatly- packed PrefData subclass
font__Return-by-reference for the font pref identified by key_
Returns
true if the font could be acquired, false otherwise

◆ getNumberPref()

virtual bool hdi::core::Preferences::getNumberPref ( const std::string &  key_,
NumberPref n__ 
) const
virtual

Gets a number pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the number to get from the top-level and return as a neatly- packed PrefData subclass
n__Return-by-reference for the number pref identified by key_
Returns
true if the number could be acquired, false otherwise

◆ getOrCreateArrayPref()

virtual bool hdi::core::Preferences::getOrCreateArrayPref ( const std::string &  key_,
const PrefDataVector *  elements_,
ArrayPref array__ 
)
virtual

Similar to getArrayPref(), except that, if the pref does not already exist, it will be created anew with a series of default elements.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the array to get from the top-level and return as a neatly- packed PrefData subclass
elements_Default elements for the array, in case it didn't already exist (NULL, or an empty vector, for none)
array__Return-by-reference for the array pref identified by key_
Returns
true if the array could be acquired or created, false otherwise
Note
The order of the default elements in the array will match that of the passed elements_ argument.

◆ getOrCreateArtboardPointPref()

virtual bool hdi::core::Preferences::getOrCreateArtboardPointPref ( const std::string &  key_,
const ArtboardPoint default_,
ArtboardPointPref abp__ 
)
virtual

Similar to getArtboardPointPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the artboard point to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
abp__Return-by-reference for the artboard point pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateArtboardRectPref()

virtual bool hdi::core::Preferences::getOrCreateArtboardRectPref ( const std::string &  key_,
const ArtboardRect default_,
ArtboardRectPref abr__ 
)
virtual

Similar to getArtboardRectPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the artboard rect to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
abr__Return-by-reference for the artboard rect pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateArtColorPref()

virtual bool hdi::core::Preferences::getOrCreateArtColorPref ( const std::string &  key_,
const ArtColor default_,
ArtColorPref ac__ 
)
virtual

Similar to getArtColorPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the art color to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
ac__Return-by-reference for the art color pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateBoolPref()

virtual bool hdi::core::Preferences::getOrCreateBoolPref ( const std::string &  key_,
const bool  default_,
BoolPref b__ 
)
virtual

Similar to getBoolPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the bool to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
b__Return-by-reference for the bool pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateColorPref()

virtual bool hdi::core::Preferences::getOrCreateColorPref ( const std::string &  key_,
const Color default_,
ColorPref c__ 
)
virtual

Similar to getColorPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the color to get from the top-level and return as a neatly- packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
c__Return-by-reference for the color pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateDashStyleMapPref()

virtual bool hdi::core::Preferences::getOrCreateDashStyleMapPref ( const std::string &  key_,
const DashStyle::Map default_,
DashStyleMapPref ds__ 
)
virtual

Similar to getDashStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the dash style map to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the dash style map member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreateDashStylePref()

virtual bool hdi::core::Preferences::getOrCreateDashStylePref ( const std::string &  key_,
const DashStyle default_,
DashStylePref ds__ 
)
virtual

Similar to getDashStylePref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the dash style to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the dash style member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreateDictPref()

virtual bool hdi::core::Preferences::getOrCreateDictPref ( const std::string &  key_,
const PrefDataVector *  members_,
DictionaryPref dict__ 
)
virtual

Similar to getDictPref(), except that, if the pref does not already exist, it will be created anew with a series of default members.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the dictionary to get from the top-level and return as a neatly-packed PrefData subclass
members_Default members for the dictionary, in case it didn't already exist (NULL, or an empty vector, for none)
dict__Return-by-reference for the dictionary pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise
Note
The names of the members in the dictionary will match that of the individual members in the passed members_ argument. Provided members with identical names may case undefined behavior.

◆ getOrCreateFillStyleMapPref()

virtual bool hdi::core::Preferences::getOrCreateFillStyleMapPref ( const std::string &  key_,
const FillStyle::Map default_,
FillStyleMapPref fs__ 
)
virtual

Similar to getFillStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the fill style map to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the fill style map member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreateFillStylePref()

virtual bool hdi::core::Preferences::getOrCreateFillStylePref ( const std::string &  key_,
const FillStyle default_,
FillStylePref fs__ 
)
virtual

Similar to getFillStylePref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the fill style to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the fill style member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreateFloatPref()

virtual bool hdi::core::Preferences::getOrCreateFloatPref ( const std::string &  key_,
const double  default_,
NumberPref n__ 
)
virtual

Similar to getNumberPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the number to get from the top-level and return as a neatly-packed PrefData subclass
default_Default double value for the pref, in case it didn't already exist
n__Return-by-reference for the number pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateFontPref()

virtual bool hdi::core::Preferences::getOrCreateFontPref ( const std::string &  key_,
const Font defaultFont_,
const double  defaultSize_,
FontPref font__ 
)
virtual

Similar to getFontPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the font to get from the top-level and return as a neatly-packed PrefData subclass
defaultFont_Default font for the pref, in case it didn't already exist
defaultSize_Default size for the pref, in case it didn't already exist
font__Return-by-reference for the font pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateIntPref()

virtual bool hdi::core::Preferences::getOrCreateIntPref ( const std::string &  key_,
const int64_t  default_,
NumberPref n__ 
)
virtual

Similar to getNumberPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the number to get from the top-level and return as a neatly-packed PrefData subclass
default_Default integer value for the pref, in case it didn't already exist
n__Return-by-reference for the number pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreatePathStyleMapPref()

virtual bool hdi::core::Preferences::getOrCreatePathStyleMapPref ( const std::string &  key_,
const PathStyle::Map default_,
PathStyleMapPref ps__ 
)
virtual

Similar to getPathStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the path style map to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the path style map member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreatePathStylePref()

virtual bool hdi::core::Preferences::getOrCreatePathStylePref ( const std::string &  key_,
const PathStyle default_,
PathStylePref ps__ 
)
virtual

Similar to getPathStylePref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the path style to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the path style member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreatePointPref()

virtual bool hdi::core::Preferences::getOrCreatePointPref ( const std::string &  key_,
const Point default_,
PointPref p__ 
)
virtual

Similar to getPointPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the point to get from the top-level and return as a neatly- packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
p__Return-by-reference for the point pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateRectPref()

virtual bool hdi::core::Preferences::getOrCreateRectPref ( const std::string &  key_,
const Rect default_,
RectPref r__ 
)
virtual

Similar to getRectPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the rect to get from the top-level and return as a neatly- packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
r__Return-by-reference for the rect pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateSizePref()

virtual bool hdi::core::Preferences::getOrCreateSizePref ( const std::string &  key_,
const Size default_,
SizePref s__ 
)
virtual

Similar to getSizePref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the size to get from the top-level and return as a neatly- packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
s__Return-by-reference for the size pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateStringPref()

virtual bool hdi::core::Preferences::getOrCreateStringPref ( const std::string &  key_,
const std::string &  default_,
StringPref str__ 
)
virtual

Similar to getStringPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the string to get from the top-level and return as a neatly-packed PrefData subclass
default_Default UTF-8 value for the pref, in case it didn't already exist
str__Return-by-reference for the string pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getOrCreateStrokeStyleMapPref()

virtual bool hdi::core::Preferences::getOrCreateStrokeStyleMapPref ( const std::string &  key_,
const StrokeStyle::Map default_,
StrokeStyleMapPref ss__ 
)
virtual

Similar to getStrokeStyleMapPref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the stroke style map to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the stroke style map member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreateStrokeStylePref()

virtual bool hdi::core::Preferences::getOrCreateStrokeStylePref ( const std::string &  key_,
const StrokeStyle default_,
StrokeStylePref ss__ 
)
virtual

Similar to getStrokeStylePref(), except that, if the member does not already exist, it will be created anew with a default value.

Author
GW
Date
11/2015
Parameters
key_UTF8 name/key of the stroke style to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the member, in case it didn't already exist
c__Return-by-reference for the stroke style member identified by key_ (or created anew)
Returns
true if the member could be acquired or created, false otherwise

◆ getOrCreateTransformMatrixPref()

virtual bool hdi::core::Preferences::getOrCreateTransformMatrixPref ( const std::string &  key_,
const TransformMatrix default_,
TransformMatrixPref tm__ 
)
virtual

Similar to getTransformMatrixPref(), except that, if the pref does not already exist, it will be created anew with a default value.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the matrix to get from the top-level and return as a neatly-packed PrefData subclass
default_Default value for the pref, in case it didn't already exist
tm__Return-by-reference for the transform matrix pref identified by key_
Returns
true if the pref could be acquired or created, false otherwise

◆ getPathStyleMapPref()

virtual bool hdi::core::Preferences::getPathStyleMapPref ( const std::string &  key_,
PathStyleMapPref ps__ 
)
virtual

Gets a persistent path style map object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the path style map to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the path style map member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getPathStylePref()

virtual bool hdi::core::Preferences::getPathStylePref ( const std::string &  key_,
PathStylePref ps__ 
)
virtual

Gets a persistent path style object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the path style to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the path style member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getPointPref()

virtual bool hdi::core::Preferences::getPointPref ( const std::string &  key_,
PointPref p__ 
) const
virtual

Gets a point pref from the prefs data tree.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the point to get from the top-level and return as a neatly- packed PrefData subclass
p__Return-by-reference for the point pref identified by key_
Returns
true if the point could be acquired, false otherwise

◆ getPref()

virtual bool hdi::core::Preferences::getPref ( const std::string &  key_,
std::unique_ptr< PrefData > &  pref__ 
) const
virtual

Gets a single preference object from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_Name of the member to get from the top-level of the prefs data tree, as UTF-8
pref__Return-by-reference for the preference found with the given name
Returns
true if the preference could be found, false otherwise
Note
The type of the returned object can be determined from its dataType() method, such that correct casting can be accomplished.

◆ getRectPref()

virtual bool hdi::core::Preferences::getRectPref ( const std::string &  key_,
RectPref r__ 
) const
virtual

Gets a rect pref from the prefs data tree.

Author
GW
Date
05/2012
Parameters
key_UTF-8 name/key of the rect to get from the top-level and return as a neatly- packed PrefData subclass
r__Return-by-reference for the rectangle pref identified by key_
Returns
true if the rectangle could be acquired, false otherwise

◆ getSizePref()

virtual bool hdi::core::Preferences::getSizePref ( const std::string &  key_,
SizePref s__ 
) const
virtual

Gets a size pref from the prefs data tree.

Author
GW
Date
05/2011
Parameters
key_UTF-8 name/key of the size to get from the top-level and return as a neatly- packed PrefData subclass
s__Return-by-reference for the size pref identified by key_
Returns
true if the size could be acquired, false otherwise

◆ getStringPref()

virtual bool hdi::core::Preferences::getStringPref ( const std::string &  key_,
StringPref str__ 
) const
virtual

Gets a string pref from the prefs data tree.

Author
GW
Date
05/2011
Parameters
key_UTF-8 name/key of the string to get from the top-level and return as a neatly- packed PrefData subclass
str__Return-by-reference for the string pref identified by key_
Returns
true if the string could be acquired, false otherwise

◆ getStrokeStyleMapPref()

virtual bool hdi::core::Preferences::getStrokeStyleMapPref ( const std::string &  key_,
StrokeStyleMapPref ss__ 
)
virtual

Gets a persistent stroke style map object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the stroke style map to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the stroke style map member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getStrokeStylePref()

virtual bool hdi::core::Preferences::getStrokeStylePref ( const std::string &  key_,
StrokeStylePref ss__ 
)
virtual

Gets a persistent stroke style object from the prefs data tree.

Author
GW
Date
11/2015
Parameters
key_UTF-8 name/key of the stroke style to get from the top-level and return as a neatly-packed PrefData subclass
ds__Return-by-reference for the stroke style member identified by key_
Returns
true if the member could be acquired, false otherwise

◆ getTransformMatrixPref()

virtual bool hdi::core::Preferences::getTransformMatrixPref ( const std::string &  key_,
TransformMatrixPref tm__ 
) const
virtual

Gets a transform matrix pref from the prefs data tree.

Author
GW
Date
09/2013
Parameters
key_UTF-8 name/key of the matrix to get from the top-level and return as a neatly- packed PrefData subclass
tm__Return-by-reference for the transform matrix pref identified by key_
Returns
true if the transform matrix could be acquired, false otherwise

◆ isEmpty()

virtual bool hdi::core::Preferences::isEmpty ( ) const
virtual

Gets whether the target Preferences object is empty (constructed with the default ctor)

Author
GW
Date
09/2013
Returns
true if the target Preferences object is empty, false otherwise

◆ load()

static bool hdi::core::Preferences::load ( const std::string &  path_,
Preferences prefs__ 
)
static

Convenience method to create a Preferences object from JSON data in a file.

Author
GW
Date
09/2013
Parameters
path_Path to the preferences file, as UTF-8
prefs__Return-by-reference for the Preferences object for the file located at path_
Returns
true if the file could be created (if necessary) and if the Preferences object was acquired, false otherwise
Note
The file need not exist before calling this method.

◆ operator=()

virtual Preferences & hdi::core::Preferences::operator= ( const Preferences rhs_)
virtual

Assigns one Preferences object to another.

Author
GW
Date
09/2013
Parameters
rhs_Existing Preferences object to copy values from
Returns
The target Preferences object, but with its values updated to match that of the rhs_ argument

◆ reload()

virtual bool hdi::core::Preferences::reload ( const std::string &  path_)
virtual

Reloads the preferences data from disk (as it is kept in memory at runtime, this might be necessary if another process or plugin manipulates the file)

Author
GW
Date
01/2016
Parameters
path_Path to the preferences file, as UTF-8
Returns
true if the prefs could be reloaded from disk, false otherwise
Warning
Any previously acquired PrefData object from the target will become invalid after this method has finished (as the internal data is necessarily destroyed and recreated as part of reloading).
Note
The given path, in most circumstances, should be the same as given to the load() method!

◆ removePref()

virtual bool hdi::core::Preferences::removePref ( const PrefData pref_)
virtual

Removes a preference from the prefs data tree.

Author
GW
Date
09/2013
Parameters
pref_Object for the pref to remove from the top-level of the prefs data tree
Returns
true if the pref is removed successfully, false otherwise

◆ save()

virtual bool hdi::core::Preferences::save ( const std::string &  path_) const
virtual

Writes JSON preferences data to a file.

Author
GW
Date
09/2013
Parameters
path_Path to the preferences file, as UTF-8
Returns
true if the save operation is successful, false otherwise

◆ saveCount()

virtual uint64_t hdi::core::Preferences::saveCount ( ) const
virtual

Gets the save count of the prefs file.

Author
GW
Date
09/2013
Returns
The number of times the prefs file has been saved

◆ setVersionNumber()

virtual bool hdi::core::Preferences::setVersionNumber ( const int32_t  version_)
virtual

Sets the number version for the preferences data.

Author
GW
Date
09/2013
Parameters
version_New number version value
Returns
true if the number is successfully updated, or false otherwise

◆ setVersionString()

virtual bool hdi::core::Preferences::setVersionString ( const std::string &  version_)
virtual

Sets the version string for the preferences data.

Author
GW
Date
09/2013
Parameters
version_New string version value
Returns
true if the string is successfully updated, or false otherwise

◆ versionNumber()

virtual int32_t hdi::core::Preferences::versionNumber ( ) const
virtual

Gets the number version for the preferences data.

Author
GW
Date
09/2013
Returns
Stored version number, or 0 if none

◆ versionString()

virtual std::string hdi::core::Preferences::versionString ( ) const
virtual

Gets the version string for the preferences data.

Author
GW
Date
09/2013
Returns
Stored version string, or "" if none