All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
STY_Styler Class Reference

#include <STY_Styler.h>

Public Member Functions

 STY_Styler ()
 Styler with an empty tree node. Serves as the root of a tree. More...
 STY_Styler (const STY_StyleSheetHandle &stylesheet)
 Convenience constructor for non-empty root of the tree. More...
 ~STY_Styler ()
 Destructor. More...
bool hasAnyData () const
bool hasStyles () const
bool hasAnyPartialMatchStyles () const
bool isSolo () const
STY_Styler cloneWithSubject (const STY_Subject &subject, UT_WorkBuffer *errors=NULL) const
STY_Styler cloneWithAddedStyleSheet (const STY_StyleSheetHandle &stylesheet) const
STY_Styler cloneWithAddedStyler (const STY_Styler &styler, const STY_TargetHandle &push_target=STY_TargetHandle()) const
STY_Styler cloneWithOverridesRemoved (const STY_OverrideNames *extra_override_names, bool remove_full_matches) const
void getResults (STY_Results &results, const STY_ResultsFilter &filter) const
bool getMaterialDefinition (STY_MaterialProperties &material_properties, const char *material_name) const
void getErrors (UT_WorkBuffer &errors) const
 Get errors generated parsing the style sheet. More...
void saveStyleSheet (UT_StringHolder &stylesheet, bool verbose=false, bool path=false) const
 Saves the style sheet represented by this styler as a JSON string. More...
SYS_FORCE_INLINE void clear ()
SYS_FORCE_INLINE bool isClear ()


class STY_StylerGroup
class sty_PruneWithSubjectTask

Detailed Description

Styler represents a state of style sheets after a sequence of "transformations" that pruned some old entries given the styled subjects and added new style sheets from new sources. These transformations are performed with clone() methods. After that, at any point, any relevant overrides can be obtained with getResults() method. Eg, a new style sheet can be added to the original styler, which returns a newly cloned styler that holds its entries, then these entries can be matched to the subject with clone() method, which will fully match certain entries, partially match some other ones, and reject the remaining ones, returning a newly cloned styler that encodes this match state; finally getResults() can be called on the styler that was cloned last to obtain overrides for the subject with which the it was cloned.

Definition at line 42 of file STY_Styler.h.

Constructor & Destructor Documentation

STY_Styler::STY_Styler ( )

Styler with an empty tree node. Serves as the root of a tree.

STY_Styler::STY_Styler ( const STY_StyleSheetHandle stylesheet)

Convenience constructor for non-empty root of the tree.

STY_Styler::~STY_Styler ( )


Member Function Documentation

SYS_FORCE_INLINE void STY_Styler::clear ( void  )

These are for DefaultClearer below, for use by UT::ArrayMap and UT::ArraySet.

Definition at line 164 of file STY_Styler.h.

STY_Styler STY_Styler::cloneWithAddedStyler ( const STY_Styler styler,
const STY_TargetHandle push_target = STY_TargetHandle() 
) const

Combines this styler with another and returns the result. The provided styler can be essentially concatenated with the current styler by providing an empty push_target. Or the provided styler can be treated as a styler of sub-components of this styler by providing a push_target that indicates which sub-components should be affected by the provided styler.

STY_Styler STY_Styler::cloneWithAddedStyleSheet ( const STY_StyleSheetHandle stylesheet) const

Adds a new style sheet to the styler. Conceptually, the styler pushes the new style sheet onto its own style sheet stack. By design, the entries from that new style sheet have lower priority than the entries from the style sheets already on the stack (which allows parents to reconfigure children). Thus, the overrides from the new style sheet will be used only if old style sheets don't specify these overrides. The resulting values can be querried with getResults().

STY_Styler STY_Styler::cloneWithOverridesRemoved ( const STY_OverrideNames extra_override_names,
bool  remove_full_matches 
) const

Returns a new styler with all styles that override the given categories and properties removed.

STY_Styler STY_Styler::cloneWithSubject ( const STY_Subject subject,
UT_WorkBuffer errors = NULL 
) const

Returns a styler that reflects style sheets entries after processing them with the given subject. The returned styler will contain only the entries whose targets were matched by the given subject, and potentially some new entries supplied by the subject for itself and its children (if the subject exists in some hierarchical structure). This method can be thought of as a "transformation" of the original styler, with the help of the given subject (which prunes some old entries and provides some new ones), that results in a new styler that reflects the new state.

void STY_Styler::getErrors ( UT_WorkBuffer errors) const

Get errors generated parsing the style sheet.

bool STY_Styler::getMaterialDefinition ( STY_MaterialProperties material_properties,
const char *  material_name 
) const

Obtains a material defined inside a style sheet. Returns true if a material by the given name was defined in a style sheet, or false otherwise.

void STY_Styler::getResults ( STY_Results results,
const STY_ResultsFilter filter 
) const

Obtains overrides given the current state of the styler. This method returns overrides from entries whose targets have been previously fully matched by the subjects in the subject hierarchy. It is implemented as a wrapper around the STY_StylerGroup interface. Whenever possible, the Group interface should be used directly to process multiple style sheets in a single pass.

filterAn object that decides what kind of override values the caller is interested in. It filters out overrides that are not needed, and allows in the ones that the caller wants to obtain. Eg, the caller may want only the overrides in the 'materialParameters' category.
bool STY_Styler::hasAnyData ( ) const

Returns true if this styler contains any information at all. This can be either styles or style sheet references.

Definition at line 56 of file STY_Styler.h.

bool STY_Styler::hasAnyPartialMatchStyles ( ) const

Returns true if this styler has any non-full matches at this level. In other words, different child subjects may produce different sets of overrides. If this styler has only full matches (and the child subjects don't add any styles) then regardless of what child subjects are applied, all the styles will match.

Definition at line 73 of file STY_Styler.h.

bool STY_Styler::hasStyles ( ) const

Returns true if this styler may produce override values at this level or for some child subject. This is different than calling getResults and checking for values because getResults requires a full match in order to return a value. This is also slightly more inclusive than hasAnyData because we don't care about referenced style sheets.

Definition at line 65 of file STY_Styler.h.

SYS_FORCE_INLINE bool STY_Styler::isClear ( )

These are for DefaultClearer below, for use by UT::ArrayMap and UT::ArraySet.

Definition at line 169 of file STY_Styler.h.

bool STY_Styler::isSolo ( ) const

Returns true if this styler has at least one stylesheet, and the last stylesheet is marked with the "final" flag, meaning no further styles should be processed.

void STY_Styler::saveStyleSheet ( UT_StringHolder stylesheet,
bool  verbose = false,
bool  path = false 
) const

Saves the style sheet represented by this styler as a JSON string.

Friends And Related Function Documentation

friend class sty_PruneWithSubjectTask

Definition at line 254 of file STY_Styler.h.

friend class STY_StylerGroup

This class needs access to our internal functions for implementation of efficient array-based styler methods.

Definition at line 253 of file STY_Styler.h.

The documentation for this class was generated from the following file: