Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
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>

Public Types

typedef std::vector< PrefData * > PrefDataVector
 

Public Member Functions

 Preferences ()
 Constructs an empty Preferences object. More...
 
 Preferences (const Preferences &prefs_)
 Constructs a new Preferences object from an existing Preferences object (copy constructor) More...
 
virtual ~Preferences ()
 Destructs a Preferences object. More...
 
virtual Preferencesoperator= (const Preferences &rhs_)
 Assigns one Preferences object to another. More...
 
virtual bool isEmpty () const
 Gets whether the target Preferences object is empty (constructed with the default ctor) More...
 
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) More...
 
virtual bool save (const std::string &path_) const
 Writes JSON preferences data to a file. More...
 
virtual uint64_t saveCount () const
 Gets the save count of the prefs file. More...
 
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. More...
 
virtual bool getPref (const std::string &key_, std::auto_ptr< PrefData > &pref__) const
 Gets a single preference object from the prefs data tree. More...
 
virtual bool removePref (const PrefData &pref_)
 Removes a preference from the prefs data tree. More...
 
virtual bool getArrayPref (const std::string &key_, ArrayPref &array__) const
 Gets an array pref from the prefs data tree. More...
 
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. More...
 
virtual bool getArtboardPointPref (const std::string &key_, ArtboardPointPref &abp__) const
 Gets an artboard point pref from the prefs data tree. More...
 
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. More...
 
virtual bool getArtboardRectPref (const std::string &key_, ArtboardRectPref &abr__) const
 Gets an artboard rect pref from the prefs data tree. More...
 
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. More...
 
virtual bool getArtColorPref (const std::string &key_, ArtColorPref &ac__) const
 Gets an art color pref from the prefs data tree. More...
 
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. More...
 
virtual bool getBoolPref (const std::string &key_, BoolPref &b__) const
 Gets a bool pref from the prefs data tree. More...
 
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. More...
 
virtual bool getColorPref (const std::string &key_, ColorPref &c__) const
 Gets a color pref from the prefs data tree. More...
 
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. More...
 
virtual bool getDashStylePref (const std::string &key_, DashStylePref &ds__)
 Gets a persistent dash style object from the prefs data tree. More...
 
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. More...
 
virtual bool getDashStyleMapPref (const std::string &key_, DashStyleMapPref &ds__)
 Gets a persistent dash style map object from the prefs data tree. More...
 
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. More...
 
virtual bool getDictPref (const std::string &key_, DictionaryPref &dict__) const
 Gets a dictionary pref from the prefs data tree. More...
 
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. More...
 
virtual bool getFillStylePref (const std::string &key_, FillStylePref &fs__)
 Gets a persistent fill style object from the prefs data tree. More...
 
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. More...
 
virtual bool getFillStyleMapPref (const std::string &key_, FillStyleMapPref &fs__)
 Gets a persistent fill style map object from the prefs data tree. More...
 
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. More...
 
virtual bool getFontPref (const std::string &key_, FontPref &font__) const
 Gets a font pref from the prefs data tree. More...
 
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. More...
 
virtual bool getTransformMatrixPref (const std::string &key_, TransformMatrixPref &tm__) const
 Gets a transform matrix pref from the prefs data tree. More...
 
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. More...
 
virtual bool getNumberPref (const std::string &key_, NumberPref &n__) const
 Gets a number pref from the prefs data tree. More...
 
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. More...
 
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. More...
 
virtual bool getPathStylePref (const std::string &key_, PathStylePref &ps__)
 Gets a persistent path style object from the prefs data tree. More...
 
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. More...
 
virtual bool getPathStyleMapPref (const std::string &key_, PathStyleMapPref &ps__)
 Gets a persistent path style map object from the prefs data tree. More...
 
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. More...
 
virtual bool getPointPref (const std::string &key_, PointPref &p__) const
 Gets a point pref from the prefs data tree. More...
 
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. More...
 
virtual bool getRectPref (const std::string &key_, RectPref &r__) const
 Gets a rect pref from the prefs data tree. More...
 
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. More...
 
virtual bool getSizePref (const std::string &key_, SizePref &s__) const
 Gets a size pref from the prefs data tree. More...
 
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. More...
 
virtual bool getStringPref (const std::string &key_, StringPref &str__) const
 Gets a string pref from the prefs data tree. More...
 
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. More...
 
virtual bool getStrokeStylePref (const std::string &key_, StrokeStylePref &ss__)
 Gets a persistent stroke style object from the prefs data tree. More...
 
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. More...
 
virtual bool getStrokeStyleMapPref (const std::string &key_, StrokeStyleMapPref &ss__)
 Gets a persistent stroke style map object from the prefs data tree. More...
 
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. More...
 
virtual int32_t versionNumber () const
 Gets the number version for the preferences data. More...
 
virtual bool setVersionNumber (const int32_t version_)
 Sets the number version for the preferences data. More...
 
virtual std::string versionString () const
 Gets the version string for the preferences data. More...
 
virtual bool setVersionString (const std::string &version_)
 Sets the version string for the preferences data. More...
 

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. More...
 

Protected Member Functions

 Preferences (const plugin::Preferences &)
 Internal use only. More...
 

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

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).
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
virtual hdi::core::Preferences::~Preferences ( )
virtual

Destructs a Preferences object.

Author
GW
Date
09/2013
hdi::core::Preferences::Preferences ( const plugin::Preferences &  )
protected

Internal use only.

Author
GW
Date
09/2013

Member Function Documentation

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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
Warning
The returned ArrayPref object does not assume responsibility of the memory for the elements_ container.
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
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
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
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
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
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
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
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.
Warning
The returned DictionaryPref object does not assume responsibility of the memory for the members_ container.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
virtual bool hdi::core::Preferences::getPref ( const std::string &  key_,
std::auto_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.
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
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
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
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
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
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
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
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.
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
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!
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
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
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
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
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
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
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