/** * @file XTPMarkupStaticExtension.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPMARKUPSTATICEXTENSION_H__) # define __XTPMARKUPSTATICEXTENSION_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPMarkupObject; class CXTPMarkupColor; /** * @brief * A base class for a markup static extension composite object. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtension { protected: /** * @brief * Constructs a composite or property CXTPMarkupStaticExtension instance. * @param lpzName Pointer to an extension name. * @param bProperty TRUE if the object is a property object * (i.e. it cannot be extended with other extensions * and it provides a final value of an extension). */ CXTPMarkupStaticExtension(LPCWSTR lpzName, BOOL bProperty); public: /** * @brief * Constructs a composite CXTPMarkupStaticExtension instance. * @param lpzName Pointer to an extension name. */ CXTPMarkupStaticExtension(LPCWSTR lpzName); /** * @brief * Destroys a CXTPMarkupStaticExtension object, handles cleanup and deallocation. */ virtual ~CXTPMarkupStaticExtension(); /** * @brief * Parses a static extension expression of form Name.Value[.Value[...]]. * where both name and value has to be of form [a-zA-Z\_]+. * @param lpzValue Entire static extension value. * @param lpzSubValue On successful completion, contains a pointer to a * sub-value of the extension object. * @return * TRUE if parsed successfully. */ static BOOL AFX_CDECL Parse(LPCWSTR lpzValue, LPCWSTR& lpzSubValue); /** * @brief * Gets the name of the current extension. * @return * A reference to the name of the current extension. */ LPCWSTR GetName() const; /** * @brief * Determines if the current extension is a property extension. * @return * TRUE if the current extension is a property extension. */ BOOL IsProperty() const; /** * @brief * Extends the current extension object with another sub-extension. * @param pExtension Pointer to a sub-extension object to be added to the * current extension. The sub-extension object will be * deallocated during parent extension destruction. * @param bReplace TRUE to replace an existing extension. The default * value is FALSE. */ void Extend(CXTPMarkupStaticExtension* pExtension, BOOL bReplace = FALSE); /** * @brief * Tries to find an extension by its name or relative path. * @param lpzName Pointer to an extension name or relative path of * form Name[.Name[...]]. * @return * A pointer to an extension if such an extension is found, * otherwise NULL. */ CXTPMarkupStaticExtension* FindExtension(LPCWSTR lpzName) const; /** * @brief * Provides the value of a composite extension object. * @param lpzValue Composite extension value of form Value[.Value[...]]. * @return * A pointer to a markup object that represents the value of the * composite extension object if successful, or NULL if no value is * found. It is the responsibility of the caller to release the object. */ virtual CXTPMarkupObject* ProvideValue(LPCWSTR lpzValue); /** * @brief * Provides the value of a property extension object. * @return * A pointer to a markup object that represents the value of the * property extension object if successful, or NULL if no value is * found. It is the responsibility of the caller to release the object. */ virtual CXTPMarkupObject* ProvideValue(); protected: /** * @brief * A derived implementation can override this method for preparing a property value. */ virtual void OnPrepareValue() { } private: static BOOL AFX_CDECL ValidateExtensionName(LPCWSTR lpzBegin, LPCWSTR lpzEnd); private: BOOL m_bProperty; LPWSTR m_lpzName; CMap m_mapExtensions; }; AFX_INLINE LPCWSTR CXTPMarkupStaticExtension::GetName() const { return m_lpzName; } AFX_INLINE BOOL CXTPMarkupStaticExtension::IsProperty() const { return m_bProperty; } /** * @brief * A convenience base class for all static extension properties. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionProperty : public CXTPMarkupStaticExtension { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param pObject Optional pointer to an initial property value. It is the * responsibility of the class to release the value object instance. */ CXTPMarkupStaticExtensionProperty(LPCWSTR lpzName, CXTPMarkupObject* pObject = NULL); /** * @brief * Destroys a CXTPMarkupStaticExtensionProperty object, handles cleanup * and deallocation. */ ~CXTPMarkupStaticExtensionProperty(); /** * @brief * Obtains the property value. * @return A pointer to the property value or NULL if no value is assigned. */ CXTPMarkupObject* GetValue(); /** * @brief * Sets the property value. * @param pObject Pointer to the property value or NULL. It is the * responsibility of the class to release the value object instance. */ void SetValue(CXTPMarkupObject* pObject); /** * @brief * Provides the value of a property extension object. * @return * A pointer to a markup object that represents the value of the * property extension object if successful, or NULL if no value is * found. It is the responsibility of the caller to release the object. */ virtual CXTPMarkupObject* ProvideValue(); /** * @brief * Provides the value of a composite extension object. * @param lpzValue Composite extension value of form Value[.Value[...]]. * @return * A pointer to a markup object that represents the value of the * composite extension object if successful, or NULL if no value is * found. It is the responsibility of the caller to release the object. */ virtual CXTPMarkupObject* ProvideValue(LPCWSTR lpzValue); protected: CXTPMarkupObject* m_pObject; }; AFX_INLINE CXTPMarkupObject* CXTPMarkupStaticExtensionProperty::GetValue() { return m_pObject; } /** * @brief * A convenience class that represents a string static extension property. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionStringProperty : public CXTPMarkupStaticExtensionProperty { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionStringProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param lpzValue Optional pointer to an initial property value. */ CXTPMarkupStaticExtensionStringProperty(LPCWSTR lpzName, LPCWSTR lpzValue = NULL); /** * @brief * Constructs a CXTPMarkupStaticExtensionStringProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param lpzValue Optional pointer to an initial property value. */ CXTPMarkupStaticExtensionStringProperty(LPCWSTR lpzName, LPCSTR lpzValue = NULL); /** * @brief * Sets the property value. * @param lpzValue Pointer to the property value or NULL. The string will be duplicated. */ void SetValue(LPCWSTR lpzValue); /** * @brief * Sets the property value. * @param lpzValue Pointer to the property value or NULL. The string will be duplicated. */ void SetValue(LPCSTR lpzValue); /** * @brief * Obtains a pointer to a raw object value. * @return * A pointer to a raw object value, or NULL if no value is assigned. */ LPCWSTR GetRawValue() const; }; /** * @brief * A convenience class that represents an integer static extension property. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionIntegerProperty : public CXTPMarkupStaticExtensionProperty { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionIntegerProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param nValue Optional initial property value. */ CXTPMarkupStaticExtensionIntegerProperty(LPCWSTR lpzName, int nValue = 0); /** * @brief * Sets the property value. * @param nValue New property value. */ void SetValue(int nValue); /** * @brief * Gets the property value. * @return * The property value. */ int GetRawValue() const; }; /** * @brief * A convenience class that represents a boolean static extension property. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionBooleanProperty : public CXTPMarkupStaticExtensionProperty { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionBooleanProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param bValue Optional initial property value. */ CXTPMarkupStaticExtensionBooleanProperty(LPCWSTR lpzName, BOOL bValue = FALSE); /** * @brief * Sets the property value. * @param bValue New property value. */ void SetValue(BOOL bValue); /** * @brief * Gets the property value. * @return * The property value. */ BOOL GetRawValue() const; }; /** * @brief * A convenience class that represents a double static extension property. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionDoubleProperty : public CXTPMarkupStaticExtensionProperty { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionDoubleProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param dblValue Optional initial property value. */ CXTPMarkupStaticExtensionDoubleProperty(LPCWSTR lpzName, double dblValue = 0); /** * @brief * Sets the property value. * @param dblValue New property value. */ void SetValue(double dblValue); /** * @brief * Gets the property value. * @return * The property value. */ double GetRawValue() const; }; /** * @brief * A convenience class that represents an RGB color static extension property. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionColorProperty : public CXTPMarkupStaticExtensionProperty { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionColorProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param crValue Optional initial property value. */ CXTPMarkupStaticExtensionColorProperty(LPCWSTR lpzName, COLORREF crValue = RGB(0, 0, 0)); /** * @brief * Constructs a CXTPMarkupStaticExtensionColorProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param crValue Initial property color value. * @param bAlpha Initial property color alpha-channel value. */ CXTPMarkupStaticExtensionColorProperty(LPCWSTR lpzName, COLORREF crValue, BYTE bAlpha); /** * @brief * Sets the property value. * @param crValue New property value. */ void SetValue(COLORREF crValue); /** * @brief * Sets the property value. * @param crValue Initial property color value. * @param bAlpha Initial property color alpha-channel value. */ void SetValue(COLORREF crValue, BYTE bAlpha); /** * @brief * Gets the property value. * @return * The property value. */ COLORREF GetRawValue() const; }; /** * @brief * A convenience class that represents a brush static extension property. */ class _XTP_EXT_CLASS CXTPMarkupStaticExtensionBrushProperty : public CXTPMarkupStaticExtensionProperty { public: /** * @brief * Constructs a CXTPMarkupStaticExtensionBrushProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param crValue Optional initial property value. */ CXTPMarkupStaticExtensionBrushProperty(LPCWSTR lpzName, COLORREF crValue = RGB(0, 0, 0)); /** * @brief * Constructs a CXTPMarkupStaticExtensionBrushProperty with an optional * initial property value. * @param lpzName Static extension property name. * @param crValue Initial property color value. * @param bAlpha Initial property color alpha-channel value. */ CXTPMarkupStaticExtensionBrushProperty(LPCWSTR lpzName, COLORREF crValue, BYTE bAlpha); /** * @brief * Sets the property value. * @param crValue New property value. */ void SetValue(COLORREF crValue); /** * @brief * Sets the property value. * @param crValue Initial property color value. * @param bAlpha Initial property color alpha-channel value. */ void SetValue(COLORREF crValue, BYTE bAlpha); /** * @brief * Gets the property value. * @return * The property value. */ COLORREF GetRawValue() const; }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPMARKUPSTATICEXTENSION_H__) /** @endcond */