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

Base class for persistent data objects, stored via JSON. More...

#include <hdicorePrefData.h>

Inheritance diagram for hdi::core::PrefData:
Inheritance graph
[legend]

Public Types

enum  Type {
  UnknownType = 0 , ArrayType = 10 , ArtboardPointType = 20 , ArtboardRectType = 30 ,
  ArtColorType = 40 , BoolType = 50 , ColorType = 60 , DashStyleType = 70 ,
  DashStyleMapType = 80 , DictionaryType = 90 , FillStyleType = 100 , FillStyleMapType = 110 ,
  FontType = 120 , NumberType = 130 , PathType = 140 , PathStyleType = 150 ,
  PathStyleMapType = 160 , PointType = 170 , RectType = 180 , SizeType = 190 ,
  StringType = 200 , StrokeStyleType = 210 , StrokeStyleMapType = 220 , TransformMatrixType = 230 ,
  CustomTypeOffset = 10000
}
 Describes the type of the data the PrefData object contains; useful for determining which subclass to cast a PrefData object to.
 

Public Member Functions

 PrefData ()
 Constructs an empty PrefData object.
 
virtual ~PrefData ()
 Destructs a PrefData object.
 
virtual PrefDataoperator= (const PrefData &rhs_)
 Allows one PrefData object to be assigned from another.
 
virtual PrefDataclone () const =0
 Convenience method to clone a PrefData object, taking its subclass type into account for proper memory management.
 
virtual bool isEmpty () const
 Gets whether the target PrefData object is empty (constructed with the default ctor)
 
virtual bool operator== (const PrefData &rhs_) const
 Tests whether a given PrefData object is the same as another.
 
virtual bool operator!= (const PrefData &rhs_) const
 Tests whether a given PrefData object is not the same as another.
 
virtual Type dataType () const
 Gets the type of persistent data.
 
virtual std::string key () const
 Gets the persistent data object's key.
 
virtual void setKey (const std::string &key_)
 Sets the persistent data object's key.
 
virtual std::string stringify () const
 Recursively serializes the target object as a JSON data (sub)tree, returning the appropriate JSON string.
 

Static Public Member Functions

static std::unique_ptr< PrefDataparse (const std::string &jsonStr_)
 Parses the given JSON string to a best-fit representation of PrefData subclass objects in a tree.
 

Protected Member Functions

void * __impl () const
 Internal use only.
 
 PrefData (plat::PersistentData *&)
 Internal use only.
 
 PrefData (const PrefData &data_)
 Constructs a new PrefData object from an existing PrefData object (copy constructor)
 

Protected Attributes

void * _data
 Private implementation data.
 

Friends

plat::PersistentData * __accessImpl (const PrefData &)
 
PrefData__accessCtor (plat::PersistentData *&)
 

Detailed Description

Base class for persistent data objects, stored via JSON.

Constructor & Destructor Documentation

◆ PrefData() [1/3]

hdi::core::PrefData::PrefData ( )

Constructs an empty PrefData object.

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

◆ ~PrefData()

virtual hdi::core::PrefData::~PrefData ( )
virtual

Destructs a PrefData object.

Author
GW
Date
09/2013

◆ PrefData() [2/3]

hdi::core::PrefData::PrefData ( plat::PersistentData *&  )
protected

Internal use only.

Author
GW
Date
09/2013

◆ PrefData() [3/3]

hdi::core::PrefData::PrefData ( const PrefData data_)
protected

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

Author
GW
Date
09/2013
Parameters
data_Existing PrefData object

Member Function Documentation

◆ __impl()

void * hdi::core::PrefData::__impl ( ) const
protected

Internal use only.

Author
GW
Date
09/2013

◆ clone()

virtual PrefData * hdi::core::PrefData::clone ( ) const
pure virtual

◆ dataType()

virtual Type hdi::core::PrefData::dataType ( ) const
virtual

Gets the type of persistent data.

Author
GW
Date
09/2013
Returns
The type of the persistent data
Note
This is useful for knowing how to cast a PrefData object to its proper subclass

Reimplemented in hdi::core::DashStyleMapPref, hdi::core::DashStylePref, hdi::core::FillStyleMapPref, hdi::core::FillStylePref, hdi::core::PathStyleMapPref, hdi::core::PathStylePref, hdi::core::StrokeStyleMapPref, and hdi::core::StrokeStylePref.

◆ isEmpty()

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

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

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

◆ key()

virtual std::string hdi::core::PrefData::key ( ) const
virtual

Gets the persistent data object's key.

Author
GW
Date
09/2013
Returns
The key/name of the persistent data object, as UTF-8
Note
This method will return "" in the case of a persistent data object contained within an ArrayPref object.

◆ operator!=()

virtual bool hdi::core::PrefData::operator!= ( const PrefData rhs_) const
virtual

Tests whether a given PrefData object is not the same as another.

Author
GW
Date
09/2013
Parameters
rhs_PrefData to compare against (righthand side of inequality operator)
Returns
true for the target and rhs_ being different data objects, false otherwise
Note
This overloaded operator does not determine whether the stored values of two PrefData objects are different; rather, it determines whether the data objects themselves have different underlying containers.

◆ operator=()

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

Allows one PrefData object to be assigned from another.

Author
GW
Date
09/2013
Parameters
rhs_Righthand side of the = operator; the object to copy values from
Returns
The target PrefData object, but with its value updated to match that of rhs_
Note
This method will fail in the case that the target and rhs_ are not of the same type (see the dataType() method).

◆ operator==()

virtual bool hdi::core::PrefData::operator== ( const PrefData rhs_) const
virtual

Tests whether a given PrefData object is the same as another.

Author
GW
Date
09/2013
Parameters
rhs_PrefData to compare against (righthand side of equality operator)
Returns
true for the target and rhs_ being the same data object, false otherwise
Note
This overloaded equality operator does not determine whether the stored values of two PrefData objects are the same; rather, it determines whether the data objects themselves have the same underlying container.

◆ parse()

static std::unique_ptr< PrefData > hdi::core::PrefData::parse ( const std::string &  jsonStr_)
static

Parses the given JSON string to a best-fit representation of PrefData subclass objects in a tree.

Author
GW
Date
11/2013
Parameters
jsonStr_JSON-encoded string, as UTF-8, to be parsed into a tree structure of JSON nodes
Returns
The root node of the PrefData subclass object tree, or NULL if none/error

◆ setKey()

virtual void hdi::core::PrefData::setKey ( const std::string &  key_)
virtual

Sets the persistent data object's key.

Author
GW
Date
09/2013
Parameters
key_New key/name for the object, as UTF-8
Note
This value is ignored in the case of a persistent data object contained within an ArrayPref object.

◆ stringify()

virtual std::string hdi::core::PrefData::stringify ( ) const
virtual

Recursively serializes the target object as a JSON data (sub)tree, returning the appropriate JSON string.

Author
GW
Date
09/2013
Returns
The data tree serialized and formatted as a string, as UTF-8
Note
If, at any time, the serializer cannot perform its job, "" (empty string) will be returned.