// ItemProps.h: interface for the CItemPropsa class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ITEMPROPS_H__9AB4F30A_87F4_42DB_9A29_95B54A903370__INCLUDED_)
#define AFX_ITEMPROPS_H__9AB4F30A_87F4_42DB_9A29_95B54A903370__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//////////////////////////////////////////////////////////////////////

#define FONTID_DEFAULT              "Normal"
#define ICONID_DEFAULT              "Main"

//////////////////////////////////////////////////////////////////////

#define STR_SELF                    "@"
#define STR_SELF_SYMB               '@'

#define STR_PID_TYPE                "t"
#define STR_PID_ATTRS               "at"
#define STR_PID_ICON                "i"
#define STR_PID_FONT                "f"
#define STR_PID_TIPTEXT             "tt"
#define STR_PID_VISIBLE             "visible"
#define STR_PID_ENABLE              "enable"
#define STR_PID_HIDDEN              "hidden"
#define STR_PID_DISABLED            "disabled"
#define STR_PID_CHECKED             "checked"
#define STR_PID_CLICKABLE           "clickable"
#define STR_PID_ONINIT              "oninit"
#define STR_PID_ONCLICK             "onclick"
#define STR_PID_ONRCLICK            "onrclick"
#define STR_PID_ONSELECT            "onselect"
#define STR_PID_ONCHANGING          "onchanging"
#define STR_PID_ONCHANGE            "onchange"
#define STR_PID_ONOK                "onok"
#define STR_PID_ONCLOSE             "onclose"
#define STR_PID_ONAPPLY             "onapply"
#define STR_PID_HOTLIGHT            "hotlight"
#define STR_PID_UNDERLINEOFF        "underlineoff"
#define STR_PID_TEXT                "text"
#define STR_PID_SIZE                "sz"
#define STR_PID_RESIZE              "rs"
#define STR_PID_LOCK                "lock"
#define STR_PID_DEFAULT             "default"
#define STR_PID_BORDER              "b"
#define STR_PID_BACKGND             "bg"
#define STR_PID_ALIGN               "a"
#define STR_PID_ICONALIGN           "ia"
#define STR_PID_TEXTALIGN           "ta"
#define STR_PID_OFFSET              "xy"
#define STR_PID_MARGINS             "mg"
#define STR_PID_SEPPOS              "sep"
#define STR_PID_VALALIGN            "va"
#define STR_PID_VALUE               "v"
#define STR_PID_NOBINDHIDE          "nobindhide"
#define STR_PID_ALIAS               "alias"
#define STR_PID_HELP                "h"
#define STR_PID_LOCKBUTTON          "lb"
#define STR_PID_SINGLELINE          "singleline"
#define STR_PID_ANIMATE             "animate"
#define STR_PID_ORDER               "order"
#define STR_PID_TABGROUP            "tabgroup"
#define STR_PID_INDEX               "index"
#define STR_PID_ENUM                "enum"
#define STR_PID_NOBORDER            "noborder"
#define STR_PID_FIXSTYLE            "fixstyle"
#define STR_PID_BODY                "body"
#define STR_PID_USEFOR              "use"
#define STR_PID_NOPARENTDISABLE     "noparentdisable"
#define STR_PID_IFLASTNOEXTEND      "iflastnoextend"
#define STR_PID_SORTED              "sorted"
#define STR_PID_REMEMBERDATA        "rememberdata"
#define STR_PID_READONLY            "readonly"
#define STR_PID_VSCROLL             "vscroll"
#define STR_PID_HSCROLL             "hscroll"
#define STR_PID_TRANSPARENT         "transparent"
#define STR_PID_NOFOCUS             "nofocus"
#define STR_PID_NOACTIVATE          "noactivate"
#define STR_PID_CHECKED             "checked"
#define STR_PID_NOHEADER            "noheader"
#define STR_PID_SINGLESEL           "singlesel"
#define STR_PID_TRISTATE            "tristate"
#define STR_PID_BITS                "bits"
#define STR_PID_NUMLIM              "nl"
#define STR_PID_PASSWORD            "password"
#define STR_PID_PASSWORDSET         "passwordset"
#define STR_PID_PASSWORDSETEX       "passwordsetex"
#define STR_PID_NUM                 "number"
#define STR_PID_COMPRESS            "compress"
#define STR_PID_COMPRESSPATH        "compresspath"
#define STR_PID_MULTILINE           "multiline"
#define STR_PID_NOSCROLL            "noscroll"
#define STR_PID_AUTOSCROLL          "autoscroll"
#define STR_PID_VERTICAL            "vertical"
#define STR_PID_FIXEDCOLUMNS        "fixcol"
#define STR_PID_DROPLINES           "dl"
#define STR_PID_FILTER              "flt"
#define STR_PID_NOTRIM              "notrim"
#define STR_PID_RALIGN              "ralign"
#define STR_PID_FIELD               "fld"
#define STR_PID_AUTOCOMPLETE        "autocomplete"
#define STR_PID_HIDEEXPANDED        "hideexpanded"
#define STR_PID_HIDECOLLAPSED       "hidecollapsed"
#define STR_PID_BUTTONLIKE          "btnlike"
#define STR_PID_CHECKBOXLIKE        "chklike"
#define STR_PID_RADIOLIKE           "radiolike"
#define STR_PID_DELAY               "delay"
#define STR_PID_BIND_PROPS          "bp"
#define STR_PID_EXT                 "ext"
#define STR_PID_EXTPRM              "extprm"
#define STR_PID_SUBST               "subst"
#define STR_PID_TEXTSUBST           STR_PID_TEXT STR_PID_SUBST
#define STR_PID_TIPTEXTSUBST        STR_PID_TIPTEXT STR_PID_SUBST
#define STR_PID_NAMESPACE           "ns"
#define STR_PID_BUTTONS             "btns"
#define STR_PID_WORKAREA            "workarea"
#define STR_PID_DYNSHOW             "dynshow"
#define STR_PID_CHARTPROPS          "cprops"
#define STR_PID_PARAMS              "prm"
#define STR_PID_SHEETPAGES          "sheetpages"
#define STR_PID_DEBUG               "debug"
#define STR_PID_CHARTREFRESH        "refresh"
#define STR_PID_CHARTREPORT         "report"
#define STR_PID_EDIT                "edit"

#define STR_SID_POLICYLB            "PolicyLockButton"
#define STR_SID_POLICYLBLINE        "PolicyLockButtonForLine"
#define STR_SID_POLICYLBGROUP       "PolicyLockButtonForGroup"

#define ENUM_DEFNAME		        "default"
#define ENUM_STREMPTY               "<empty>"

#define MAX_4B_DIGIT_STRSIZE        12 // max lenof("4294967295") + lenof(-) + 1
#define MAX_4B_DIGIT_STRHEXSIZE     9  // max lenof("FFFFFFFF") + 1
#define MAX_8B_DIGIT_STRSIZE        21 // max lenof("18446744073709551615") + 1
#define MAX_8B_DIGIT_STRHEXSIZE     17 // max lenof("FFFFFFFFFFFFFFFF") + 1
#define MAX_FLOAT_STRSIZE           50

#define MBCS_UTF8_SEP               0x7

tQWORD  GetIntFromString(LPCSTR strVal, tTYPE_ID eReqType = tid_QWORD);
void    GetStringFromInt(tQWORD nVal, tString& strVal, tTYPE_ID eReqType = tid_QWORD);
tString GetPlainText(LPCSTR strProp);

bool    _kav_isspace(unsigned char c);
bool    _kav_iscsym(unsigned char c);

//////////////////////////////////////////////////////////////////////
// CItemPropVals

#define IPV_F_APPEND	0x01
#define IPV_F_SINGLE	0x02
#define IPV_F_VOIDPROP	0x04
#define IPV_F_MOVE		0x08

class CItemPropVals : protected cVector<tString, cSimpleMover<tString> >
{
public:
	virtual int      Count() const;
	virtual LPCSTR   GetName();
	virtual tString& Get(tDWORD nIdx = 0, bool bCreate = false);
	virtual LPCSTR   GetStr(tDWORD nIdx = 0);
	virtual bool     GetBool(tDWORD nIdx = 0);
	virtual tQWORD   GetLong(tDWORD nIdx = 0);
	virtual void     Del(tDWORD nIdx = 0);
	virtual tString  Pop(tDWORD nIdx = 0);
	virtual bool     IsValid();
	virtual bool     IsEmpty();
	virtual bool     IsExist(LPCSTR strName);
	virtual bool     IsEqual(const CItemPropVals& v);
	virtual tSIZE_T  Parse(LPCSTR strVals, tDWORD nFlags = 0 /*IPV_F_...*/, bool bValsOnly = false);
	virtual LPCSTR   DeParse(tString& strProp = TOR_tString, LPCSTR strName = NULL, bool bValsOnly = false);
	virtual void     Assign(CItemPropVals& v, tDWORD nFlags = 0 /*IPV_F_...*/);
	virtual void     Set(tDWORD nIdx, LPCSTR str = NULL);

public:
	friend class CItemProps;

	CItemPropVals(LPCSTR strVals = NULL);
	
protected:
	void     _Parse(LPCSTR strVals, tSIZE_T nLen, tDWORD nFlags /*IPV_F_...*/);
	void     _Trim(LPCSTR& strBegin, LPCSTR& strEnd);

private:
	static tString	m_void;
	tString			m_name;
};

//////////////////////////////////////////////////////////////////////
// CItemProps

typedef cVector<CItemPropVals, cSimpleMover<CItemPropVals> > CItemPropsBase;

class CItemProps : protected CItemPropsBase
{
public:
	friend class CItemPropVals;
	CItemProps(LPCSTR strProps = NULL, tString& str = TOR_tString, LPCSTR * pstrPropsIncl = NULL, tDWORD nFlags = 0 /*IPV_F_...*/) { Parse(strProps, str, pstrPropsIncl, nFlags); }

	virtual void           Destroy();
	virtual CItemProps&    Parse(LPCSTR strProps, tString& str = TOR_tString, LPCSTR * pstrPropsIncl = NULL, tDWORD nFlags = 0 /*IPV_F_...*/);
	virtual LPCSTR         DeParse(tString& strProps = TOR_tString, tDWORD nFlags = 0 /*IPV_F_...*/);
	virtual void           Clear();
	virtual CItemPropVals& Get(LPCSTR strName, bool bCreate = false);
	virtual CItemPropVals& GetByIdx(tDWORD nIdx) const;
	virtual tDWORD         GetIdx(CItemPropVals& prp) const;
	virtual bool           Del(LPCSTR strName);
	virtual bool           DelByIdx(tDWORD nIdx);
	virtual int            Count() const;
	virtual CItemProps&    Assign(CItemProps& p, tDWORD nFlags = 0 /*IPV_F_...*/);
	
private:
	bool           _IsPropAvlbl(LPCSTR * pstrPropsIncl, LPCSTR strName);

	static CItemPropVals m_void;
};

//////////////////////////////////////////////////////////////////////

#endif // !defined(AFX_ITEMPROPS_H__9AB4F30A_87F4_42DB_9A29_95B54A903370__INCLUDED_)
