Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
hdicorePreferences.h
Go to the documentation of this file.
1
7#ifndef __HDI_CORE_PREFERENCES__
8#define __HDI_CORE_PREFERENCES__
9
10#include <memory>
11#include <vector>
12
13#include "hdicorePathStyle.h"
14
15namespace hdi
16{
17 #if defined(HDI_CORE_AIP_MODE)
18 namespace aip
19 {
20 class Preferences;
21 }
22 #elif defined(HDI_CORE_PSP_MODE)
23 namespace psp
24 {
25 class Preferences;
26 }
27 #endif
28
29 namespace core
30 {
31 class Color;
32 class Font;
33 class Point;
34 class Rect;
35 class Size;
36
37 class PrefData;
38 class ArrayPref;
39 class BoolPref;
40 class ColorPref;
41 class DictionaryPref;
42 class FontPref;
43 class NumberPref;
44 class PointPref;
45 class RectPref;
46 class SizePref;
47 class StringPref;
48
49 #if defined(HDI_CORE_AIP_MODE)
50 class ArtboardPoint;
51 class ArtboardRect;
52 class ArtColor;
53 class TransformMatrix;
54
55 class ArtboardPointPref;
56 class ArtboardRectPref;
57 class ArtColorPref;
58 class DashStylePref;
59 class DashStyleMapPref;
60 class FillStylePref;
61 class FillStyleMapPref;
62 class PathStylePref;
63 class PathStyleMapPref;
64 class StrokeStylePref;
65 class StrokeStyleMapPref;
66 class TransformMatrixPref;
67 #endif
68 // HDI_CORE_AIP_MODE
69
74 {
75 public:
76 typedef std::vector< std::shared_ptr<PrefData> > PrefDataVector;
77
90 {
91 public:
99 Iterator(const Iterator& iter_);
100
107
118
127 bool operator==(const Iterator& rhs_) const;
128
137 bool operator!=(const Iterator& rhs_) const;
138
147
156
165
174
183 bool atEnd() const;
184
192 std::string key() const;
193
201 std::unique_ptr<PrefData> value() const;
202
203
204 private:
205 // Only Preferences can construct a new Iterator object
206 friend class Preferences;
207
211 void* __data;
212
218 Iterator();
219
227 explicit Iterator(const Preferences& set_);
228 };
229
230 typedef std::unique_ptr<Iterator> IteratorUP;
231 typedef std::shared_ptr<Iterator> IteratorSP;
232 typedef std::weak_ptr<Iterator> IteratorWP;
233
246
254 Preferences(const Preferences& prefs_);
255
261 virtual ~Preferences();
262
272 virtual Preferences& operator=(const Preferences& rhs_);
273
281 virtual bool isEmpty() const;
282
295 static bool load(const std::string& path_, Preferences& prefs__);
296
312 virtual bool reload(const std::string& path_);
313
322 virtual bool save(const std::string& path_) const;
323
331 virtual uint64_t saveCount() const;
332
345 virtual bool addPref(const PrefData& pref_);
346
359 virtual bool getPref(const std::string& key_, std::unique_ptr<PrefData>& pref__) const;
360
369 virtual bool removePref(const PrefData& pref_);
370
386 virtual Iterator begin() const;
387
398 virtual bool getArrayPref(const std::string& key_, ArrayPref& array__) const;
399
417 const std::string& key_,
418 const PrefDataVector* elements_,
419 ArrayPref& array__
420 );
421
422 #if defined(HDI_CORE_AIP_MODE)
433 virtual bool getArtboardPointPref(const std::string& key_, ArtboardPointPref& abp__) const;
434
448 const std::string& key_,
449 const ArtboardPoint& default_,
450 ArtboardPointPref& abp__
451 );
452
463 virtual bool getArtboardRectPref(const std::string& key_, ArtboardRectPref& abr__) const;
464
478 const std::string& key_,
479 const ArtboardRect& default_,
480 ArtboardRectPref& abr__
481 );
482
493 virtual bool getArtColorPref(const std::string& key_, ArtColorPref& ac__) const;
494
508 const std::string& key_,
509 const ArtColor& default_,
510 ArtColorPref& ac__
511 );
512 #endif
513 // HDI_CORE_AIP_MODE
514
525 virtual bool getBoolPref(const std::string& key_, BoolPref& b__) const;
526
539 virtual bool getOrCreateBoolPref(const std::string& key_, const bool default_, BoolPref& b__);
540
551 virtual bool getColorPref(const std::string& key_, ColorPref& c__) const;
552
565 virtual bool getOrCreateColorPref(const std::string& key_, const Color& default_, ColorPref& c__);
566
567 #if defined(HDI_CORE_AIP_MODE)
578 virtual bool getDashStylePref(const std::string& key_, DashStylePref& ds__);
579
594 const std::string& key_,
595 const DashStyle& default_,
596 DashStylePref& ds__
597 );
598
609 virtual bool getDashStyleMapPref(const std::string& key_, DashStyleMapPref& ds__);
610
625 const std::string& key_,
626 const DashStyle::Map& default_,
627 DashStyleMapPref& ds__
628 );
629 #endif
630 // HDI_CORE_AIP_MODE
631
642 virtual bool getDictPref(const std::string& key_, DictionaryPref& dict__) const;
643
662 const std::string& key_,
663 const PrefDataVector* members_,
664 DictionaryPref& dict__
665 );
666
667 #if defined(HDI_CORE_AIP_MODE)
678 virtual bool getFillStylePref(const std::string& key_, FillStylePref& fs__);
679
694 const std::string& key_,
695 const FillStyle& default_,
696 FillStylePref& fs__
697 );
698
709 virtual bool getFillStyleMapPref(const std::string& key_, FillStyleMapPref& fs__);
710
725 const std::string& key_,
726 const FillStyle::Map& default_,
727 FillStyleMapPref& fs__
728 );
729 #endif
730 // HDI_CORE_AIP_MODE
731
742 virtual bool getFontPref(const std::string& key_, FontPref& font__) const;
743
758 const std::string& key_,
759 const Font& defaultFont_,
760 const double defaultSize_,
761 FontPref& font__
762 );
763
764 #if defined(HDI_CORE_AIP_MODE)
775 virtual bool getTransformMatrixPref(const std::string& key_, TransformMatrixPref& tm__) const;
776
790 const std::string& key_,
791 const TransformMatrix& default_,
793 );
794 #endif
795 // HDI_CORE_AIP_MODE
796
807 virtual bool getNumberPref(const std::string& key_, NumberPref& n__) const;
808
821 virtual bool getOrCreateIntPref(const std::string& key_, const int64_t default_, NumberPref& n__);
822
835 virtual bool getOrCreateFloatPref(const std::string& key_, const double default_, NumberPref& n__);
836
837 #if defined(HDI_CORE_AIP_MODE)
848 virtual bool getPathStylePref(const std::string& key_, PathStylePref& ps__);
849
864 const std::string& key_,
865 const PathStyle& default_,
866 PathStylePref& ps__
867 );
868
879 virtual bool getPathStyleMapPref(const std::string& key_, PathStyleMapPref& ps__);
880
895 const std::string& key_,
896 const PathStyle::Map& default_,
897 PathStyleMapPref& ps__
898 );
899 #endif
900 // HDI_CORE_AIP_MODE
901
912 virtual bool getPointPref(const std::string& key_, PointPref& p__) const;
913
926 virtual bool getOrCreatePointPref(const std::string& key_, const Point& default_, PointPref& p__);
927
938 virtual bool getRectPref(const std::string& key_, RectPref& r__) const;
939
952 virtual bool getOrCreateRectPref(const std::string& key_, const Rect& default_, RectPref& r__);
953
964 virtual bool getSizePref(const std::string& key_, SizePref& s__) const;
965
978 virtual bool getOrCreateSizePref(const std::string& key_, const Size& default_, SizePref& s__);
979
990 virtual bool getStringPref(const std::string& key_, StringPref& str__) const;
991
1005 const std::string& key_,
1006 const std::string& default_,
1007 StringPref& str__
1008 );
1009
1010 #if defined(HDI_CORE_AIP_MODE)
1021 virtual bool getStrokeStylePref(const std::string& key_, StrokeStylePref& ss__);
1022
1037 const std::string& key_,
1038 const StrokeStyle& default_,
1039 StrokeStylePref& ss__
1040 );
1041
1052 virtual bool getStrokeStyleMapPref(const std::string& key_, StrokeStyleMapPref& ss__);
1053
1068 const std::string& key_,
1069 const StrokeStyle::Map& default_,
1070 StrokeStyleMapPref& ss__
1071 );
1072 #endif
1073 // HDI_CORE_AIP_MODE
1074
1082 virtual int32_t versionNumber() const;
1083
1092 virtual bool setVersionNumber(const int32_t version_);
1093
1101 virtual std::string versionString() const;
1102
1111 virtual bool setVersionString(const std::string& version_);
1112
1113
1114 protected:
1118 void* __data;
1119
1120 #if defined(HDI_CORE_AIP_MODE)
1126 Preferences(const aip::Preferences&);
1127 #elif defined(HDI_CORE_PSP_MODE)
1133 Preferences(const psp::Preferences&);
1134 #endif
1135 };
1136
1137 typedef std::unique_ptr<Preferences> PreferencesUP;
1138 typedef std::shared_ptr<Preferences> PreferencesSP;
1139 typedef std::weak_ptr<Preferences> PreferencesWP;
1140 }
1141}
1142
1143#endif
1144// __HDI_CORE_PREFERENCES__
Acts as an array-style container to store any other persistent data types, including arrays and dicti...
Definition: hdicoreArrayPref.h:60
Describes the color of art on the artboard.
Definition: hdicoreArtColor.h:40
Allows for storage of art colors.
Definition: hdicoreArtColorPref.h:23
Describes a point on the Illustrator artboard.
Definition: hdicoreArtboardPoint.h:31
Allows for storage of 2D artboard points.
Definition: hdicoreArtboardPointPref.h:23
Describes a rectangular area on the Illustrator artboard.
Definition: hdicoreArtboardRect.h:28
Allows for storage of artboard rects/bounds.
Definition: hdicoreArtboardRectPref.h:23
Allows for storage of bools.
Definition: hdicoreBoolPref.h:20
Describes an RGB color, with opacity, typically for UI purposes.
Definition: hdicoreColor.h:32
Allows for storage of colors.
Definition: hdicoreColorPref.h:21
Acts as a DashStyle value map, indicating which values are "known".
Definition: hdicorePathStyle.h:33
Describes the dash styling of a path.
Definition: hdicorePathStyle.h:22
Allows for storage of dash style maps.
Definition: hdicoreDashStyleMapPref.h:28
Allows for storage of dash styles.
Definition: hdicoreDashStylePref.h:28
Acts as a dictionary-style container to store any other persistent data types, including arrays and d...
Definition: hdicoreDictionaryPref.h:60
Acts as a FillStyle value map, indicating which values are "known".
Definition: hdicorePathStyle.h:153
Describes the fill styling of a path.
Definition: hdicorePathStyle.h:147
Allows for storage of fill style maps.
Definition: hdicoreFillStyleMapPref.h:28
Allows for storage of fill styles.
Definition: hdicoreFillStylePref.h:28
Font class to allow for easy font manipulation.
Definition: hdicoreFont.h:183
Allows for storage of font faces and sizes.
Definition: hdicoreFontPref.h:22
Allows for the storage of numbers.
Definition: hdicoreNumberPref.h:20
Acts as a StrokeStyle value map, indicating which values are "known".
Definition: hdicorePathStyle.h:448
Describes all styling attributes of a path.
Definition: hdicorePathStyle.h:442
Allows for storage of path style maps.
Definition: hdicorePathStyleMapPref.h:23
Allows for storage of path styles.
Definition: hdicorePathStylePref.h:23
Describes a point in the 2-dimensional (x,y) coordinate system, typically in an Illustrator document ...
Definition: hdicorePoint.h:38
Allows for storage of 2D points.
Definition: hdicorePointPref.h:21
Base class for persistent data objects, stored via JSON.
Definition: hdicorePrefData.h:25
Allows for iteration through the members of a Preferences object, a la std::vector iteration.
Definition: hdicorePreferences.h:90
~Iterator()
Destructs an Iterator object.
Iterator operator--(int)
Postfix decrement operator for reverse iteration.
bool atEnd() const
Determines whether iteration should stop; works well as the conditional in a for() loop.
Iterator operator++(int)
Postfix increment operator for forward iteration.
Iterator & operator--()
Prefix decrement operator for reverse iteration.
Iterator & operator=(const Iterator &rhs_)
Assigns one Iterator object to another.
bool operator!=(const Iterator &rhs_) const
Tests whether a given Iterator object is not the same as another.
bool operator==(const Iterator &rhs_) const
Tests whether a given Iterator object is the same as another.
std::string key() const
Gets the current member's key as pointed to by the iterator.
Iterator & operator++()
Prefix increment operator for forward iteration.
Iterator(const Iterator &iter_)
Constructs an Iterator object from an existing Iterator object (copy constructor)
std::unique_ptr< PrefData > value() const
Gets the current member's value as pointed to by the iterator.
Aids in preference storage by reading/writing the JSON data in a given file.
Definition: hdicorePreferences.h:74
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 ...
virtual uint64_t saveCount() const
Gets the save count of the prefs file.
Preferences()
Constructs an empty Preferences object.
virtual bool getStrokeStylePref(const std::string &key_, StrokeStylePref &ss__)
Gets a persistent stroke style object 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,...
virtual bool getFontPref(const std::string &key_, FontPref &font__) const
Gets a font 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 w...
virtual bool getArtboardRectPref(const std::string &key_, ArtboardRectPref &abr__) const
Gets an artboard rect pref 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 ...
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 ane...
virtual bool getOrCreateTransformMatrixPref(const std::string &key_, const TransformMatrix &default_, TransformMatrixPref &tm__)
Similar to getTransformMatrixPref(), except that, if the pref does not already exist,...
virtual bool getDictPref(const std::string &key_, DictionaryPref &dict__) const
Gets a dictionary pref from the prefs data tree.
virtual bool getTransformMatrixPref(const std::string &key_, TransformMatrixPref &tm__) const
Gets a transform matrix 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 wi...
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 wi...
virtual bool getStringPref(const std::string &key_, StringPref &str__) const
Gets a string pref from the prefs data tree.
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 ...
virtual bool isEmpty() const
Gets whether the target Preferences object is empty (constructed with the default ctor)
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 wi...
virtual bool getArtColorPref(const std::string &key_, ArtColorPref &ac__) const
Gets an art color pref from the prefs data tree.
virtual bool getNumberPref(const std::string &key_, NumberPref &n__) const
Gets a number pref 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,...
virtual bool getFillStyleMapPref(const std::string &key_, FillStyleMapPref &fs__)
Gets a persistent fill style map 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 ...
virtual bool getPathStylePref(const std::string &key_, PathStylePref &ps__)
Gets a persistent path style object from the prefs data tree.
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.
Preferences(const aip::Preferences &)
Internal use only.
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,...
virtual bool getColorPref(const std::string &key_, ColorPref &c__) const
Gets a color 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 ...
virtual Iterator begin() const
Gets an iterator for the Preferences object.
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 getPointPref(const std::string &key_, PointPref &p__) const
Gets a point 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 wi...
virtual bool getBoolPref(const std::string &key_, BoolPref &b__) const
Gets a bool pref from the prefs data tree.
virtual bool addPref(const PrefData &pref_)
Adds a preference object into the prefs data tree, such that when the prefs are written the individua...
virtual bool getDashStyleMapPref(const std::string &key_, DashStyleMapPref &ds__)
Gets a persistent dash style map object from the prefs data tree.
virtual bool save(const std::string &path_) const
Writes JSON preferences data to a file.
Preferences(const Preferences &prefs_)
Constructs a new Preferences object from an existing Preferences object (copy constructor)
virtual bool setVersionNumber(const int32_t version_)
Sets the number version for the preferences data.
virtual bool getArtboardPointPref(const std::string &key_, ArtboardPointPref &abp__) const
Gets an artboard point pref from the prefs data tree.
virtual bool getFillStylePref(const std::string &key_, FillStylePref &fs__)
Gets a persistent fill style object from the prefs data tree.
virtual bool getRectPref(const std::string &key_, RectPref &r__) const
Gets a rect pref from the prefs data tree.
virtual bool removePref(const PrefData &pref_)
Removes a preference 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,...
static bool load(const std::string &path_, Preferences &prefs__)
Convenience method to create a Preferences object from JSON data in a file.
virtual bool getPathStyleMapPref(const std::string &key_, PathStyleMapPref &ps__)
Gets a persistent path style map object 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 wi...
virtual bool getOrCreateArtboardRectPref(const std::string &key_, const ArtboardRect &default_, ArtboardRectPref &abr__)
Similar to getArtboardRectPref(), except that, if the pref does not already exist,...
void * __data
Private implementation data.
Definition: hdicorePreferences.h:1118
virtual bool getDashStylePref(const std::string &key_, DashStylePref &ds__)
Gets a persistent dash style object from the prefs data tree.
virtual int32_t versionNumber() const
Gets the number version for the preferences data.
virtual bool getArrayPref(const std::string &key_, ArrayPref &array__) const
Gets an array 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 w...
virtual ~Preferences()
Destructs a Preferences object.
virtual bool getStrokeStyleMapPref(const std::string &key_, StrokeStyleMapPref &ss__)
Gets a persistent stroke 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,...
virtual bool getOrCreateStrokeStylePref(const std::string &key_, const StrokeStyle &default_, StrokeStylePref &ss__)
Similar to getStrokeStylePref(), except that, if the member does not already exist,...
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 ...
virtual Preferences & operator=(const Preferences &rhs_)
Assigns one Preferences object to another.
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 w...
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 i...
Contains Point and Size objects to describe a rectangle that exists at a specific point of given dime...
Definition: hdicoreRect.h:34
Allows for storage of rects/bounds.
Definition: hdicoreRectPref.h:21
Contains a width and height for a rectangular shape.
Definition: hdicoreSize.h:25
Allows for storage of 2D sizes.
Definition: hdicoreSizePref.h:21
Allows for the storage of strings.
Definition: hdicoreStringPref.h:20
Acts as a StrokeStyle value map, indicating which values are "known".
Definition: hdicorePathStyle.h:287
Describes the stroke styling of a path.
Definition: hdicorePathStyle.h:260
Allows for storage of stroke style maps.
Definition: hdicoreStrokeStyleMapPref.h:28
Allows for storage of stroke styles.
Definition: hdicoreStrokeStylePref.h:28
Allows for 2-dimensional transformations in a single application via matrix math.
Definition: hdicoreTransformMatrix.h:34
Allows for storage of transformation matrices.
Definition: hdicoreTransformMatrixPref.h:23
Header file for path style-related classes.