/**
* @file XTPSyntaxEditLexClass.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(__XTPSYNTAXEDITLEXCLASS_H__)
# define __XTPSYNTAXEDITLEXCLASS_H__
/** @endcond */
# if _MSC_VER > 1000
# pragma once
# endif // _MSC_VER > 1000
# include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h"
// #pragma warning(disable: 4097 4786)
/**
* @brief
* XTPSyntaxEditLexAnalyser namespace is used group text parser
* classes, separate them from others and to make class names shorter
* without risk to be duplicated.
*/
/** @cond */
namespace XTPSyntaxEditLexAnalyser
/** @endcond */
{
struct XTP_EDIT_LEXPROPINFO;
/**
* @brief
* CXTPSyntaxEditLexVariable class is used to represent lexical variables.
* In the class schema variables begins from symbol \@.
* Standard variables are: \@alpha, \@digit, \@HexDigit, \@specs, \@EOL.
* @see
* Classes schema syntax.
*/
class _XTP_EXT_CLASS CXTPSyntaxEditLexVariable
{
public:
/**
* @brief
* Default object constructor.
*/
CXTPSyntaxEditLexVariable();
/**
* @brief
* Default object destructor.
*/
virtual ~CXTPSyntaxEditLexVariable();
/**
* @brief
* XTPSyntaxEditLexVarID type defines the constants used to identify
* standard lexical variables: \@alpha, \@digit, \@HexDigit,
* \@specs, \@EOL.
* @details
* values from 0 to 100 are reserved.
* for custom variables IDs please use values bigger than 100
* @see
* CXTPSyntaxEditLexVariable::m_nVarID
*/
enum XTPSyntaxEditLexVarID
{
xtpEditVarID_Unknown = 0, /**< Undefined value. */
xtpEditVarID_alpha = 1, /**< ID for lex variable - \@alpha */
xtpEditVarID_digit = 2, /**< ID for lex variable - \@digit */
xtpEditVarID_HexDigit = 3, /**< ID for lex variable - \@HexDigit*/
xtpEditVarID_specs = 4, /**< ID for lex variable - \@specs */
xtpEditVarID_EOL = 5, /**< ID for lex variable - \@EOL */
};
/**
* @brief
* XTPSyntaxEditLexVarFlags type defines the constants used to
* specify additional lex variable properties.
* @details
* values from 0 to 0xFFFF are reserved.
* for custom flags please use values bigger than 0xFFFF
* @see
* CXTPSyntaxEditLexVariable::m_nVarFlags.
*/
enum XTPSyntaxEditLexVarFlags
{
xtpEditVarfNot = 0x001, /**< specify NOT operation for the lex variable. */
};
int m_nVarID; /**< Lex variable identifier. */
CString m_strVar; /**< Lex variable. */
int m_nVarFlags; /**< Additional lex variable properties (flags). */
/**
* @brief
* Copy operator.
* @param rSrc [in] Constant reference to the source object.
* @return
* Constant reference to the destination object.
* @details
* This operator fill object members using source object
* values.
* @see
* Operator copy (=) in C++.
*/
const CXTPSyntaxEditLexVariable& operator=(const CXTPSyntaxEditLexVariable& rSrc);
/**
* @brief
* Set object members using string lex variable
* representation.
* @param pcszVarName [in] string lex variable representation (with
* flags). Like "@alpha" or "@digit:not".
* @return
* TRUE if successful, otherwise FALSE.
* @details
* This method parse specified string and determine
* standard lex variable ID and additional flags.
* @see
* CXTPSyntaxEditLexVariable::GetVarID()
*/
virtual BOOL SetVariable(LPCTSTR pcszVarName);
/**
* @brief
* Equal-to operator.
* @param rSrc [in] Constant reference to the other object.
* @return
* It returns TRUE if both operands have the same value;
* otherwise, it returns FALSE.
* @details
* This operator determine are objects equal.
* @see
* Equality Operators in C++.
*/
BOOL operator==(const CXTPSyntaxEditLexVariable& rSrc) const;
/**
* @brief
* Determine standard lex variable ID using string lex
* variable representation.
* @param pcszVarName [in] string lex variable representation (without
* flags). Like "@alpha" or "@digit".
* @return
* xtpEditVarID_Unknown if fails, otherwise, if successful,
* other value from enum XTPSyntaxEditLexVarID.
* @details
* This method determine standard lex variable ID using
* specified string.
* @see
* CXTPSyntaxEditLexVariable::XTPSyntaxEditLexVarID type,
* CXTPSyntaxEditLexVariable::SetVariable()
*/
static int AFX_CDECL GetVarID(LPCTSTR pcszVarName);
/**
* @brief
* This method is used to get lex variable chars.
* @param nVarID [in] A value from CXTPSyntaxEditLexVariable::XTPSyntaxEditLexVarID enum.
* @param rarVarData [out] A reference to CStringArray to get data.
* @return
* TRUE if successful, otherwise FALSE.
* @see
* CXTPSyntaxEditLexVariable::XTPSyntaxEditLexVarID
*/
static BOOL AFX_CDECL GetVariableData(int nVarID, CStringArray& rarVarData);
protected:
/**
* @brief
* Initialize internal Lex variable name to ID map.
* @details
* This method initialize internal Lex variable name to
* ID map if it is not yet initialized.
* @return
* @see
* CXTPSyntaxEditLexVariable::s_mapVar2ID,
* CXTPSyntaxEditLexVariable::s_bVarMapInitialized()
*/
static void AFX_CDECL InitStandartVarsIfNeed();
static CMapStringToPtr s_mapVar2ID; /**< Lex variable name to ID map. */
static BOOL s_bVarMapInitialized; /**< Is initialized state of the lex variable name to ID map.
*/
};
/**
* @brief Enumerates types of values which supported by CXTPSyntaxEditLexVariant class.
* @see CXTPSyntaxEditLexVariant
*/
enum XTPSyntaxEditLexVariantType
{
xtpEditLVT_Unknown = 0, /**< designates unknown type of value */
xtpEditLVT_className = 0x0001, /**< designates value of lex class name (or class names array)
type */
xtpEditLVT_classPtr = 0x0002, /**< designates value of lex class Pointer type */
xtpEditLVT_LVArrayPtr = 0x0004, /**< designates value of LexVariants array Pointer type */
xtpEditLVT_valInt = 0x0100, /**< designates value of integer type */
xtpEditLVT_valStr = 0x0200, /**< designates value of character string (or string array) type */
xtpEditLVT_valVar = 0x0400, /**< designates value of lex variable */
};
/**
* @brief
* CXTPSyntaxEditLexVariant provides functionality to manipulate Lexical Analyzer's
* related variant type.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
class _XTP_EXT_CLASS CXTPSyntaxEditLexVariant : public CXTPCmdTarget
{
public:
/**
* @brief
* Object constructor.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant();
/**
* @brief
* Object constructor.
* @param rSrc [in] Initialize new object using other
* LexVariant object.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(const CXTPSyntaxEditLexVariant& rSrc);
/**
* @brief
* Object constructor.
* @param pClass [in] Set new object type to xtpEditLVT_classPtr ,
* and initialize m_ptrClass member
* using specified pointer. InternalAddRef()
* is called for the pClass object.
* InternalRelease() will be called in the destructor.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(CXTPSyntaxEditLexClass* pClass);
/**
* @brief
* Object constructor.
* @param pLVArray [in] Set new object type to xtpEditLVT_LVArrayPtr ,
* and initialize m_ptrLVArrayPtr
* member using specified pointer. If
* bWithAddRef parameter value is TRUE
* InternalAddRef() is called for the
* pLVArray object.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(CXTPSyntaxEditLexVariantPtrArray* pLVArray);
/**
* @brief
* Object constructor.
* @param rSrcVar [in] Set new object type to xtpEditLVT_valVar ,
* and initialize m_Variable
* member using specified object.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(const CXTPSyntaxEditLexVariable& rSrcVar);
/**
* @brief
* Object constructor.
* @param pcszStr [in] Set new object type to eType
* parameter value, and initialize
* m_arStrVals[0] member using
* specified string.
* eType parameter value should be
* a string type: xtpEditLVT_valStr ,
* xtpEditLVT_className .
* @param eType : [in] Object type value from XTPSyntaxEditLexVariantType.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(LPCTSTR pcszStr, int eType = xtpEditLVT_valStr);
/**
* @brief
* Object constructor.
* @param pArStrVals [in] Set new object type to xtpEditLVT_valStr ,
* and initialize m_arStrVals
* member using specified pointer.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(const CStringArray* pArStrVals);
/**
* @brief
* Object constructor.
* @param nValue [in] Set new object type to xtpEditLVT_valInt ,
* and initialize m_nValue
* member using specified value.
* @details
* Construct an empty object, or initialize it using
* specified parameters.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexClass, CXTPSyntaxEditLexVariable,
* CXTPSyntaxEditLexVariantPtrArray
*/
CXTPSyntaxEditLexVariant(int nValue);
/**
* @brief
* Default object destructor.
*/
virtual ~CXTPSyntaxEditLexVariant();
int m_nObjType; /**< Object type value from XTPSyntaxEditLexVariantType. */
CXTPSyntaxEditLexClassPtr m_ptrClass; /**< Value storage for type xtpEditLVT_classPtr
*/
CXTPSyntaxEditLexVariantPtrArray* m_ptrLVArrayPtr; /**< Value storage for type
xtpEditLVT_LVArrayPtr */
int m_nValue; /**< Value storage for type xtpEditLVT_valInt */
CStringArray m_arStrVals; /**< Value storage for types xtpEditLVT_className ,
xtpEditLVT_valStr */
CXTPSyntaxEditLexVariable m_Variable; /**< Value storage for type xtpEditLVT_valVar */
/**
* @brief
* Copy operator.
* @param rSrc [in] Constant reference to the source object.
* @return
* Constant reference to the destination object.
* @details
* This operator fill object members using source object values.
* @see
* Operator copy (=) in C++.
*/
const CXTPSyntaxEditLexVariant& operator=(const CXTPSyntaxEditLexVariant& rSrc);
/**
* @brief
* Copy operator.
* @param nVal [in] Value to be stored in the lex variant object.
* @return
* Constant reference to the destination object.
* @details
* This operator sets the object type to xtpEditLVT_valInt ,
* and initialize m_nValue member using specified value.
* @see
* Operator copy (=) in C++.
*/
const CXTPSyntaxEditLexVariant& operator=(int nVal);
/**
* @brief
* Copy operator.
* @param rSrcVar [in] Value to be stored in the lex variant object.
* @return
* Constant reference to the destination object.
* @details
* This operator sets the object type to xtpEditLVT_valVar ,
* and initialize m_Variable member using specified
* object.
* @see
* Operator copy (=) in C++.
*/
const CXTPSyntaxEditLexVariant& operator=(const CXTPSyntaxEditLexVariable& rSrcVar);
/**
* @brief
* Equal-to operator.
* @param rSrc [in] Constant reference to the other object.
* @return
* It returns TRUE if both operands have the same value;
* otherwise, it returns FALSE.
* @details
* This operator determine are objects equal.
* @see
* Equality Operators in C++.
*/
BOOL operator==(const CXTPSyntaxEditLexVariant& rSrc) const;
/**
* @brief
* Set object members using string lex variable
* representation.
* @param pcszVarName [in] string lex variable representation (with
* flags). Like "@alpha" or "@digit:not".
* @return
* TRUE if successful, otherwise FALSE.
* @details
* This method sets the object type to xtpEditLVT_valVar ,
* and initialize m_Variable member using
* specified string lex variable representation.
* @see
* CXTPSyntaxEditLexVariable::SetVariable()
*/
virtual BOOL SetVariable(LPCTSTR pcszVarName);
/**
* @brief
* Is variant object contains string(s).
* @return
* TRUE if object is string type: xtpEditLVT_valStr ,
* xtpEditLVT_className , otherwise - FALSE.
* @details
* Call this method to determine is object has a string type. In
* this case m_arStrVals member is used to access data.
* @see
* XTPSyntaxEditLexVariantType, CXTPSyntaxEditLexVariant::m_arStrVals.
*/
virtual BOOL IsStrType() const;
/**
* @brief
* Get string for the string type variant object.
* @return
* Value of m_arStrVals[0] if object is string type,
* otherwise - empty string.
* @details
* Call this method to get first string stored in the object (
* m_arStrVals[0] member value).
* @see
* CXTPSyntaxEditLexVariant::IsStrType(), XTPSyntaxEditLexVariantType,
* CXTPSyntaxEditLexVariant::m_arStrVals.
*/
virtual LPCTSTR GetStr() const;
/**
* @brief
* Clone variant object.
* @return
* Pointer to the new object.
* @details
* Create a new CXTPSyntaxEditLexVariant object using new operator and
* initialize it using this object. New object reference counter is
* initialized by 1. InternalRelease() should be called to delete
* unused object.
*/
virtual CXTPSyntaxEditLexVariant* Clone() const;
# ifdef _DEBUG
/**
* @brief
* Print stored object value(s) to the trace.
* @param dc A reference to CDumpContext object.
* @details
* Used for debug only.
*/
void Dump(CDumpContext& dc) const;
# endif
};
/**
* @brief
* CXTPSyntaxEditLexOnScreenParseCnt provides context data storage for
* OnScreen iterated parsing process.
* @see
* CXTPSyntaxEditLexClass, CXTPSyntaxEditLexTextSchema
*/
class _XTP_EXT_CLASS CXTPSyntaxEditLexOnScreenParseCnt
{
public:
/**
* @brief
* Default object constructor.
*/
CXTPSyntaxEditLexOnScreenParseCnt();
/**
* @brief
* Default object destructor.
*/
virtual ~CXTPSyntaxEditLexOnScreenParseCnt();
int m_nRowStart; /**< Start row for parse. */
int m_nRowEnd; /**< End row for parse. */
CXTPSyntaxEditLexTextBlockPtr m_ptrTBLast; /**< Latest found text block. */
};
/**
* @brief
* Enumerates parent class relation for the Lex Class object.
* @see
* CXTPSyntaxEditLexClass::CXTPSyntaxEditParent.
*/
enum XTPSyntaxEditLexClass_OptParent
{
xtpEditOptParent_Unknown = 0, /**< Undefined value.*/
xtpEditOptParent_Default = -1, /**< Use default relation value.*/
xtpEditOptParent_file = 1, /**< Lex Class is the top in classes hierarchy: level file.*/
xtpEditOptParent_direct = 2, /**< Lex Class can be child of specified parent class only
directly.*/
xtpEditOptParent_dyn = 3, /**< Lex Class can be child of specified parent class dynamically. (no
only directly, but child of child of child ...) */
};
/**
* @brief
* Enumerates children classes relation for the Lex Class object.
* @see
* CXTPSyntaxEditLexClass::CXTPSyntaxEditChildren
*/
enum XTPSyntaxEditLexClass_OptChildren
{
xtpEditOptChildren_Unknown = 0, /**< Undefined value. */
xtpEditOptChildren_No = 1, /**< Lex Class cannot have children. */
xtpEditOptChildren_Any =
2, /**< Lex Class have children specified by their 'parent' property */
xtpEditOptChildren_List = 3, /**< Lex Class can have only children from list and specified by
their 'parent' property. */
};
/**
* Class schema (public) attributes
*/
static const TCHAR XTPLEX_ATTR_TXTPREFIX[] = _T("txt:"); /**< Text properties (like color, bold,
...) attributes prefix. */
static const TCHAR XTPLEX_ATTR_COLORPREFIX[] = _T("txt:color"); /**< Prefix of properties which
value is color. */
static const TCHAR XTPLEX_ATTR_TXT_COLORFG[] = _T("txt:colorFG"); /**< Text color */
static const TCHAR XTPLEX_ATTR_TXT_COLORBK[] = _T("txt:colorBK"); /**< Text back ground color */
static const TCHAR XTPLEX_ATTR_TXT_COLORSELFG[] = _T("txt:colorSelFG"); /**< Selected text color */
static const TCHAR XTPLEX_ATTR_TXT_COLORSELBK[] = _T("txt:colorSelBK"); /**< Selected text back
ground color */
static const TCHAR XTPLEX_ATTR_TXT_BOLD[] = _T("txt:Bold"); /**< Text font Bold flag. */
static const TCHAR XTPLEX_ATTR_TXT_ITALIC[] = _T("txt:Italic"); /**< Text font Italic flag. */
static const TCHAR XTPLEX_ATTR_TXT_UNDERLINE[] = _T("txt:Underline"); /**< Text font Underline flag.
*/
static const TCHAR XTPLEX_ATTR_CASESENSITIVE[] = _T("CaseSensitive"); /**< Lex Class CaseSensitive
flag. */
static const TCHAR XTPLEX_ATTR_COLLAPSABLE[] = _T("Collapsable"); /**< Lex Class Collapsable flag.
*/
static const TCHAR XTPLEX_ATTR_COLLAPSEDTEXT[] = _T("CollapsedText"); /**< Collapsed Lex Class mark
text. (like [..]) */
static const TCHAR XTPLEX_ATTR_PARSEONSCREEN[] = _T("ParseOnScreen"); /**< Parse Lex Class only for
screen drawing. */
static const TCHAR XTPLEX_ATTR_RESTARTRUNLOOP[] =
_T("RestartRunLoop"); /**< if set to 1 - run children loop will be restarted from the beginning
when class ended, otherwise next child class will run. */
static const TCHAR XTPLEX_ATTR_ENDCLASSPARENT[] =
_T("End:Class:Parent"); /**< if set to 'this' the end block must have this class as parent. */
static const TCHAR XTPLEX_ATTR_RECURRENCEDEPTH[] = _T("RecurrenceDepth"); /**< define depth of the
recurrence blocks. */
static const TCHAR XTPLEX_ATTR_DISPLAYNAME[] = _T("DisplayName"); /**< Friendly name to display in
options dialog. */
// Global attributes
static const TCHAR XTPLEX_ATTRG_FIRSTPARSEINSEPARATETHREAD[] =
_T("global:FirstParseInSeparateThread"); /**< {0,1} default=1 */
static const TCHAR XTPLEX_ATTRG_EDITREPARCEINSEPARATETHREAD[] =
_T("global:EditReparceInSeparateThread"); /**< {0,1} default=1 */
static const TCHAR XTPLEX_ATTRG_CONFIGCHANGEDREPARCEINSEPARATETHREAD[] =
_T("global:ConfigChangedReparceInSeparateThread"); /**< {0,1} default=1 */
static const TCHAR XTPLEX_ATTRG_EDITREPARCETIMEOUT_MS[] =
_T("global:EditReparceTimeout_ms"); /**< time out for start reparse after last key was pressed.
*/
static const TCHAR XTPLEX_ATTRG_MAXBACKPARSEOFFSET[] =
_T("global:MaxBackParseOffset"); /**< maximum back buffer size. Some times parser look back for
the text from current position. */
static const TCHAR XTPLEX_ATTRG_ONSCREENSCHCACHELIFETIME_SEC[] =
_T("global:OnScreenSchCacheLifeTime_sec"); /**< default= 180 sec; -1 and 0 means infinite; time
out for on screen parsed pieces of text. for
memory using optimization. */
static const TCHAR XTPLEX_ATTRG_PARSERTHREADIDLELIFETIME_SEC[] =
_T("global:ParserThreadIdleLifeTime_sec"); /**< default=60 sec; -1 and 0 means infinite; time
out for existing of parser thread when parser idle
(no parse requests). */
// internal attributes
static const TCHAR XTPLEX_ATTRCLASSID[] = _T("ClassID"); /**< Lex Class ID, unique for the classes
tree. */
/**
* @brief
* CXTPSyntaxEditLexClass class is used to represent lexical block of text
* definition and to parse text.
* @see
* CXTPSyntaxEditLexClassSchema, CXTPSyntaxEditLexObj_SpecCollT.
*/
class _XTP_EXT_CLASS CXTPSyntaxEditLexClass
: public CXTPCmdTarget
, protected CXTPSyntaxEditLexObj_SpecCollT<
CXTPSyntaxEditLexObj_Previous, CXTPSyntaxEditLexObj_Start, CXTPSyntaxEditLexObj_End,
CXTPSyntaxEditLexObj_Token, CXTPSyntaxEditLexObj_Skip, CXTPSyntaxEditLexObj_ActiveTags>
{
public:
/**
* @brief
* CXTPSyntaxEditLexClass::TBase is the base collection type for
* CXTPSyntaxEditLexClass. It is used to access base members and types.
* @see
* CXTPSyntaxEditLexClassSchema, CXTPSyntaxEditLexObj_SpecCollT.
*/
typedef CXTPSyntaxEditLexObj_SpecCollT<
CXTPSyntaxEditLexObj_Previous, CXTPSyntaxEditLexObj_Start, CXTPSyntaxEditLexObj_End,
CXTPSyntaxEditLexObj_Token, CXTPSyntaxEditLexObj_Skip, CXTPSyntaxEditLexObj_ActiveTags>
TBase;
/**
* @brief
* Default object constructor.
*/
CXTPSyntaxEditLexClass();
/**
* @brief
* Default object destructor.
*/
virtual ~CXTPSyntaxEditLexClass();
/** @cond */
protected:
XTP_EDIT_LEX_CLASS_OBJ_MEMBER(0, m_previous); /**< 'previous' Lex Class property
collection. */
XTP_EDIT_LEX_CLASS_OBJ_MEMBER(1, m_start); /**< 'start' Lex Class property collection. */
XTP_EDIT_LEX_CLASS_OBJ_MEMBER(2, m_end); /**< 'end' Lex Class property collection. */
XTP_EDIT_LEX_CLASS_OBJ_MEMBER(3, m_token); /**< 'token' Lex Class property collection. */
XTP_EDIT_LEX_CLASS_OBJ_MEMBER(4, m_skip); /**< 'skip' Lex Class property collection. */
// internal objects
XTP_EDIT_LEX_CLASS_OBJ_MEMBER(5, m_ActiveTags); /**< Active Tags collection. Just only these
tags can start or end current and children
Lex Class(es). */
/** @endcond */
int m_nActiv_EndTags_Offset; /**< First index of end active tags set in the Active Tags
collection (m_ActiveTags member). */
friend class CXTPSyntaxEditLexClass_file;
friend class CXTPSyntaxEditLexClassSchema;
friend class CXTPSyntaxEditLexTextSchema;
friend class CXTPSyntaxEditLexParser;
public:
/**
* @brief
* Get object property by property name.
* @param pcszPropName [in] Property name.
* @return
* Smart pointer to CXTPSyntaxEditLexVariant object with type xtpEditLVT_LVArrayPtr.
* @details
* Property names are parent collection (TBase) sub-objects names;
* like "start:tag", "token:start:separators", ... For details see
* Classes schema syntax and CXTPSyntaxEditLexClass::TBase.
* @see
* CXTPSyntaxEditLexClass::TBase, Classes schema syntax.
*/
virtual CXTPSyntaxEditLexVariantPtr PropV(LPCTSTR pcszPropName);
/**
* @brief
* Get Lex Class name.
* @return
* Lex Class name.
* @details
* Lex Class name is specified in classes schema file by 'name'
* property.
* @see
* Classes schema syntax.
*/
virtual CString GetClassName() const;
/**
* @brief
* Is Lex Class case sensitive.
* @return
* "CaseSensitive" attribute value..
* @details
* Use this method instead of GetAttribute() to fast access
* "CaseSensitive" attribute value.
* @see
* GetAttribute(), XTPLEX_ATTR_CASESENSITIVE, Classes schema syntax.
*/
virtual BOOL IsCaseSensitive();
/**
* @brief
* Is Lex Class Collapsable.
* @return
* "Collapsable" attribute value..
* @details
* Use this method instead of GetAttribute() to fast access
* "Collapsable" attribute value.
* @see
* GetAttribute(), XTPLEX_ATTR_COLLAPSABLE, Classes schema syntax.
*/
virtual int IsCollapsable();
/**
* @brief
* Is Lex Class Collapsable.
* @param rTB [out] Pointer to the classes array.
* @details
* Use this method instead of GetAttribute() to fast access
* "Collapsable" attribute value.
* @see
* GetAttribute(), XTPLEX_ATTR_COLLAPSABLE, Classes schema syntax.
*/
virtual void GetTextAttributes(XTP_EDIT_TEXTBLOCK& rTB);
/**
* @brief
* Close Lex Class.
* @details
* Kill All relations between this class and parent and children.
* Close children classes. Clear internal collections. Close() must
* be called as first step in destroy object procedure. The second
* step is InternalRelease() call.
* @see
* CXTPSyntaxEditLexClass::CloseClasses()
*/
virtual void Close();
/**
* @brief
* Close specified Lex Classes.
* @param pArClasses [in] Pointer to the classes array.
* @details
* Call Close() method for every Lex Class in the specified array.
* Remove all objects from the array.
* @return
* @see
* CXTPSyntaxEditLexClass::Close()
*/
static void AFX_CDECL CloseClasses(CXTPSyntaxEditLexClassPtrArray* pArClasses);
/**
* @brief
* Get Lex Class attribute by attribute name.
* @param strName [in] Attribute name.
* @param bDyn [in] If FALSE attribute value is searched only in
* this class attribute collection;
* If TRUE attribute value is searched in this
* class attribute collection at the first and, if
* value is not finded, it is searched in parent(s)
* class(es) attribute collection(s).
* @return
* Attribute value or NULL or default value.
* @details
* Call this method to access Lex Classes attributes,
* like "txt:colorFG", ...
* @see
* XTPLEX_ATTR_*, SetAttribute(), Classes schema syntax.
*/
virtual CXTPSyntaxEditLexVariantPtr GetAttribute(LPCTSTR strName, BOOL bDyn) const;
/**
* @brief
* Get Lex Class attribute by attribute name.
* @param strName [in] Attribute name.
* @param bDyn [in] If FALSE attribute value is searched only in
* this class attribute collection;
* If TRUE attribute value is searched in this
* class attribute collection at the first and, if
* value is not finded, it is searched in parent(s)
* class(es) attribute collection(s).
* @param bDefault [in] Default BOOL value.
* @return
* Attribute value or NULL or default value.
* @details
* Call this method to access Lex Classes attributes,
* like "txt:colorFG", ...
* @see
* XTPLEX_ATTR_*, SetAttribute(), Classes schema syntax.
*/
virtual BOOL GetAttribute_BOOL(LPCTSTR strName, BOOL bDyn, BOOL bDefault = FALSE) const;
/**
* @brief
* Get Lex Class attribute by attribute name.
* @param strName [in] Attribute name.
* @param bDyn [in] If FALSE attribute value is searched only in
* this class attribute collection;
* If TRUE attribute value is searched in this
* class attribute collection at the first and, if
* value is not finded, it is searched in parent(s)
* class(es) attribute collection(s).
* @param nDefault [in] Default int value.
* @return
* Attribute value or NULL or default value.
* @details
* Call this method to access Lex Classes attributes,
* like "txt:colorFG", ...
* @see
* XTPLEX_ATTR_*, SetAttribute(), Classes schema syntax.
*/
virtual int GetAttribute_int(LPCTSTR strName, BOOL bDyn, int nDefault = 0) const;
protected:
/**
* @brief
* Sets Lex Class attribute.
* @param strName [in] Attribute name.
* @param rVal [in] Attribute value.
* @details
* Call this method to set Lex Class attributes, like "txt:colorFG",
* ...
* @see
* XTPLEX_ATTR_*, GetAttribute(), Classes schema syntax.
*/
virtual void SetAttribute(CString strName, const CXTPSyntaxEditLexVariant& rVal);
/**
* @brief
* Get specified children for the Lex Class.
* @return
* A pointer to lex class pointer array.
* @details
* Call this method(s) to get pointer to the array which contains
* children classes.
* @see
* GetChildren(), GetChildrenDyn(), GetChildrenSelfRef().
*/
virtual CXTPSyntaxEditLexClassPtrArray* GetChildren();
/**
* @brief
* Get specified children for the Lex Class.
* @return
* A pointer to lex class pointer array.
* @details
* Call this method(s) to get pointer to the array which contains
* children classes.
* @see
* GetChildren(), GetChildrenDyn(), GetChildrenSelfRef().
*/
virtual CXTPSyntaxEditLexClassPtrArray* GetChildrenDyn();
/**
* @brief
* Get specified children for the Lex Class.
* @return
* A pointer to lex class pointer array.
* @details
* Call this method(s) to get pointer to the array which contains
* children classes.
* @see
* GetChildren(), GetChildrenDyn(), GetChildrenSelfRef().
*/
virtual CXTPSyntaxEditLexClassPtrArray* GetChildrenSelfRef();
/**
* @brief
* Get active tags for the Lex Class.
* @return
* A pointer to lex object active tags object.
*/
virtual CXTPSyntaxEditLexObj_ActiveTags* GetActiveTags();
/**
* @brief
* This function does the parsing.
* @param pTxtIter The text iterator.
* @param pTxtSch The text schema.
* @param rPtrTxtBlock The text block.
* @param pOnScreenRunCnt On screen parse context.
* @return
* A XTPSyntaxEditLexParseResult value.
*/
virtual int RunParse(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock,
CXTPSyntaxEditLexOnScreenParseCnt* pOnScreenRunCnt = NULL);
# ifdef _DEBUG
/**
* @brief
* Trace parsed lex classes. Write debug info to debug window.
* @param dc [in] A reference to CDumpContext object.
* @param pcszOffset [in] user defined text.
*/
void DumpOffset(CDumpContext& dc, LPCTSTR pcszOffset);
# endif
protected:
/** @cond */
virtual BOOL SetProp_ProcessSpecials(const XTP_EDIT_LEXPROPINFO* pPropDesc, BOOL& rbProcessed);
virtual BOOL SetProp_ProcessSpecObjects(const XTP_EDIT_LEXPROPINFO* pPropDesc,
BOOL& rbProcessed);
virtual BOOL SetProp_ProcessAttributes(const XTP_EDIT_LEXPROPINFO* pPropDesc,
BOOL& rbProcessed);
virtual BOOL ParseValues(const XTP_EDIT_LEXPROPINFO* pPropDesc,
CXTPSyntaxEditLexVariantPtrArray* pLVArray);
virtual BOOL IsQuoted(CString strValue, CString* pstrUnQuotedVal = NULL);
virtual BOOL IsVar(CString strValue, CString* pstrVarVal = NULL);
virtual void SortTags();
virtual BOOL Run_Previous(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock,
CXTPSyntaxEditLexOnScreenParseCnt* pOnScreenRunCnt = NULL);
virtual int Run_Start(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock,
CXTPSyntaxEditLexOnScreenParseCnt* pOnScreenRunCnt = NULL);
virtual int Run_Skip(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock);
virtual int Run_End(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock,
CXTPSyntaxEditLexOnScreenParseCnt* pOnScreenRunCnt = NULL);
virtual int Run_Token(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock);
virtual BOOL Run_TokenSeparators(CString strToken, CTextIter* pTxtIter,
CXTPSyntaxEditLexTextSchema* pTxtSch, CString& rstrSeparator1,
CString& rstrSeparator2);
virtual BOOL Run_Tags(CTextIter* pIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexVariantPtrArray* pLVTags, CString& rstrTagVal,
BOOL bParseDirection_Back = FALSE);
static BOOL AFX_CDECL Run_Tags1(CTextIter* pIter, CXTPSyntaxEditLexVariantPtrArray* pLVTags,
CString& rstrTagVal, BOOL bCaseSensitive,
BOOL bParseDirection_Back = FALSE);
static BOOL AFX_CDECL Run_Tags2(CTextIter* pIter, CXTPSyntaxEditLexVariant* pVTags,
CString& rstrTagVal, BOOL bCaseSensitive,
BOOL bParseDirection_Back = FALSE);
virtual BOOL Run_PrevClass(CXTPSyntaxEditLexTextBlock** ppPrevTB,
CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexVariantPtrArray* pLVPrevClasses, int nDepth,
XTP_EDIT_LINECOL* pMinPrevPos = NULL,
CXTPSyntaxEditLexTextBlock* pPrevForParentBlockOnly = NULL,
CXTPSyntaxEditLexOnScreenParseCnt* pOnScreenRunCnt = NULL);
static BOOL AFX_CDECL StrCmp(LPCTSTR pcszStr1, LPCTSTR pcszStr2, int nLen, BOOL bCaseSensitive);
static BOOL AFX_CDECL StrCmpEQ(LPCTSTR pcszStr1, LPCTSTR pcszStr2, int nLen,
BOOL bCaseSensitive, BOOL bParseDirection_Back = FALSE);
static BOOL AFX_CDECL StrVarCmpEQ(LPCTSTR pcszStr, const CXTPSyntaxEditLexVariable& lexVar,
CString& rstrValue, BOOL bParseDirection_Back = FALSE);
virtual BOOL SetProp(const XTP_EDIT_LEXPROPINFO* pPropDesc);
virtual BOOL AddChild(CXTPSyntaxEditLexClass* pChild, BOOL bDyn);
const CXTPSyntaxEditLexClass& operator=(const CXTPSyntaxEditLexClass& rSrc);
virtual void CopyFrom(const CXTPSyntaxEditLexClass* pSrc);
virtual CXTPSyntaxEditLexClass* Clone(CXTPSyntaxEditLexClassSchema* pOwnerSch = NULL);
virtual void CopyAttributes(const CXTPSyntaxEditLexClass* pSrcAttrClass,
LPCTSTR pcszAttrPrefix = NULL);
virtual void RemoveAttributes(LPCTSTR pcszAttrPrefix = NULL);
virtual void GetParentOpt(int& rnOpt, CStringArray& rArData) const;
virtual void GetChildrenOpt(int& rnOpt, CStringArray& rArData) const;
virtual CXTPSyntaxEditLexVariantPtrArray* BuildActiveTags(int& rnStartCount);
virtual CXTPSyntaxEditLexClass* FindParent(LPCTSTR pcszClassName);
/**
* @brief Fast (cached) access to "RestartRunLoop" attribute value.
* @details If set to 1 - run children loop will be restarted from
* the beginning when class ended, otherwise next child
* class will run.
* Default value is 1.
* @return "RestartRunLoop" attribute value.
* @see GetAttribute(), XTPLEX_ATTR_RESTARTRUNLOOP,
* Classes schema syntax.
*/
virtual BOOL IsRestartRunLoop();
virtual BOOL IsEndClassParent_this();
/** @endcond */
protected:
/** @cond */
class CXTPSyntaxEditParent
{
public:
XTPSyntaxEditLexClass_OptParent eOpt;
CXTPSyntaxEditLexClassPtr ptrDirect;
CStringArray arClassNames;
void Clear()
{
eOpt = xtpEditOptParent_Unknown;
ptrDirect = NULL;
arClassNames.RemoveAll();
}
};
class CXTPSyntaxEditChildren
{
public:
XTPSyntaxEditLexClass_OptChildren eOpt;
CStringArray arClassNames;
void Clear()
{
eOpt = xtpEditOptChildren_Any;
arClassNames.RemoveAll();
}
};
CString m_strClassName;
CXTPSyntaxEditParent m_Parent;
CXTPSyntaxEditChildren m_Children;
/** @endcond */
protected:
/** @cond */
CXTPSyntaxEditLexClassPtrArray m_arChildrenClasses;
CXTPSyntaxEditLexClassPtrArray m_arDynChildrenClasses;
CXTPSyntaxEditLexClassPtrArray m_arChildrenSelfRefClasses;
CMap
m_mapAttributes;
/** @endcond */
private:
// Cached attributes
virtual void ClearAttributesCache();
int m_bCaseSensitive_Cached;
int m_nCollapsable_Cached;
int m_bRestartRunLoop_Cached;
int m_bEndClassParent_this_Cached;
XTP_EDIT_TEXTBLOCK m_txtAttr_cached;
BOOL m_bTxtAttr_cached;
};
/** @cond */
class _XTP_EXT_CLASS CXTPSyntaxEditLexClass_file : public CXTPSyntaxEditLexClass
{
public:
CXTPSyntaxEditLexClass_file();
virtual ~CXTPSyntaxEditLexClass_file();
virtual CXTPSyntaxEditLexVariantPtr PropV(LPCTSTR propName);
protected:
virtual int RunParse(CTextIter* pTxtIter, CXTPSyntaxEditLexTextSchema* pTxtSch,
CXTPSyntaxEditLexTextBlockPtr& rPtrTxtBlock,
CXTPSyntaxEditLexOnScreenParseCnt* pOnScreenRunCnt = NULL);
virtual CXTPSyntaxEditLexClass* Clone(CXTPSyntaxEditLexClassSchema* pOwnerSch = NULL);
BOOL InternalInitExts(BOOL bReInit = FALSE);
BOOL TestExt(LPCTSTR pcszExt) const;
protected:
BOOL m_bExtInitialized;
CStringArray m_arExt;
};
/** @endcond */
////////////////////////////////////////////////////////////////////////////
/** @cond */
AFX_INLINE int CXTPSyntaxEditLexClass::StrCmp(LPCTSTR pcszStr1, LPCTSTR pcszStr2, int nLen,
BOOL bCaseSensitive)
{
if (bCaseSensitive)
{
return _tcsncmp(pcszStr1, pcszStr2, XTPToSizeTChecked(nLen));
}
return _tcsnicmp(pcszStr1, pcszStr2, XTPToSizeTChecked(nLen));
}
/** @endcond */
AFX_INLINE CString CXTPSyntaxEditLexClass::GetClassName() const
{
return m_strClassName;
}
AFX_INLINE CXTPSyntaxEditLexObj_ActiveTags* CXTPSyntaxEditLexClass::GetActiveTags()
{
return &m_ActiveTags;
}
AFX_INLINE int CXTPSyntaxEditLexClass::GetAttribute_int(LPCTSTR strName, BOOL bDyn,
int nDefault) const
{
CXTPSyntaxEditLexVariantPtr ptrAttrVal = GetAttribute(strName, bDyn);
_ASSERTE(!ptrAttrVal || !!ptrAttrVal && ptrAttrVal->m_nObjType == xtpEditLVT_valInt);
if (!!ptrAttrVal && ptrAttrVal->m_nObjType == xtpEditLVT_valInt)
{
return ptrAttrVal->m_nValue;
}
return nDefault;
}
AFX_INLINE BOOL CXTPSyntaxEditLexClass::GetAttribute_BOOL(LPCTSTR strName, BOOL bDyn,
BOOL bDefault) const
{
int nVal = GetAttribute_int(strName, bDyn, -1);
_ASSERTE(nVal == -1 || nVal == 0 || nVal == 1);
return (nVal == -1) ? bDefault : (nVal != 0);
}
/** @cond */
AFX_INLINE BOOL CXTPSyntaxEditLexClass::IsRestartRunLoop()
{
if (m_bRestartRunLoop_Cached < 0)
{
m_bRestartRunLoop_Cached = GetAttribute_BOOL(XTPLEX_ATTR_RESTARTRUNLOOP, FALSE, TRUE);
}
return m_bRestartRunLoop_Cached;
}
/** @endcond */
} // namespace XTPSyntaxEditLexAnalyser
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
/** @cond */
#endif // !defined(__XTPSYNTAXEDITLEXCLASS_H__)
/** @endcond */