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

Static Public Member Functions

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

Protected Member Functions

void * __impl () const
 Internal use only. More...
 
 PrefData (plugin::PersistentData *&)
 Internal use only. More...
 

Protected Attributes

void * _data
 Private implementation data.
 

Friends

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

Detailed Description

Base class for persistent data objects, stored via JSON.

Constructor & Destructor Documentation

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)
hdi::core::PrefData::PrefData ( const PrefData data_)

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

Author
GW
Date
09/2013
Parameters
data_Existing PrefData object
Note
This method should not be called directly; subclasses should overload it
virtual hdi::core::PrefData::~PrefData ( )
virtual

Destructs a PrefData object.

Author
GW
Date
09/2013
hdi::core::PrefData::PrefData ( plugin::PersistentData *&  )
protected

Internal use only.

Author
GW
Date
09/2013

Member Function Documentation

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

Internal use only.

Author
GW
Date
09/2013
virtual PrefData* hdi::core::PrefData::clone ( ) const
pure virtual
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::StrokeStyleMapPref, hdi::core::StrokeStylePref, hdi::core::PathStyleMapPref, and hdi::core::PathStylePref.

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
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.
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.
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).
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.
static std::auto_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
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.
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.