aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/skin/xmlobject.h
blob: 1a45797f6ae1111dab033acf343d91e800bdc61a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef __XMLOBJECT_H
#define __XMLOBJECT_H

#include <bfc/nsguid.h>
#include <bfc/ptrlist.h>
#include <bfc/dispatch.h>
#include <bfc/string/StringW.h>
#include <bfc/wasabi_std.h>

#define XML_ATTRIBUTE_IMPLIED  0
#define XML_ATTRIBUTE_REQUIRED 1

class XmlObject : public Dispatchable
{
public:
	int setXmlParam(const wchar_t *name, const wchar_t *strvalue);
	const wchar_t *getXmlParamValue(int n);
	int getXmlParam(const wchar_t *paramname);

	enum
	{
		SETXMLPARAM=10,
		GETXMLPARAMVALUE=40,
		GETXMLPARAM=50,
	};
};

inline int XmlObject::setXmlParam(const wchar_t *name, const wchar_t *strvalue)
{
	return _call(SETXMLPARAM, 0, name, strvalue);
}

inline const wchar_t *XmlObject::getXmlParamValue(int n)
{
	return _call(GETXMLPARAMVALUE, (const wchar_t *)0, n);
}

inline int XmlObject::getXmlParam(const wchar_t *paramname)
{
	return _call(GETXMLPARAM, 0, paramname);
}

class XmlObjectParam
{

public:

	XmlObjectParam(int xmlhandle, wchar_t *xmlattribute, int xmlattributeid);
	virtual ~XmlObjectParam() {}

	const wchar_t *getXmlAttribute()
	{
		return xmlattributename;
	}
	int getXmlAttributeId()
	{
		return attributeid;
	}
	int getXmlHandle()
	{
		return handle;
	}
	void setLastValue(const wchar_t *val)
	{
		lastvalue = val;
	}
	const wchar_t *getLastValue()
	{
		return lastvalue;
	}

private:
	const wchar_t *xmlattributename;
	StringW lastvalue;
	int attributeid;
	int handle;

};

class XmlObjectParamSort
{
public:
	static inline int compareItem(XmlObjectParam *p1, XmlObjectParam*p2)
	{
		return wcscmp(p1->getXmlAttribute(), p2->getXmlAttribute());
	}
	static inline int compareAttrib(const wchar_t *attrib, XmlObjectParam *item)
	{
		return WCSICMP(attrib, item->getXmlAttribute());
	}
};

struct XMLParamPair
{
	int id;
	wchar_t name[64];
};

class XmlObjectI : public XmlObject
{
public:
	XmlObjectI();
	virtual ~XmlObjectI();

	virtual int setXmlParam(const wchar_t *name, const wchar_t *strvalue); // receives from system
	virtual int setXmlParamById(int xmlhandle, int xmlattributeid, const wchar_t *name, const wchar_t *strvalue); // distributes to inheritors
	virtual const wchar_t *getXmlParamValue(int n);
	virtual int getXmlParam(const wchar_t *paramname);
	const wchar_t *getXmlParamByName(const wchar_t *paramname);
	void addParam(int xmlhandle, XMLParamPair &param, int unused=0);
	//void addXmlParam(int xmlhandle, const wchar_t *xmlattribute, int xmlattributeid);
protected:
	virtual int onUnknownXmlParam(const wchar_t *param, const wchar_t *value);
	int newXmlHandle();
	void hintNumberOfParams(int xmlhandle, int params);

private:
	XmlObjectParam *enumParam(int n)
	{
		return params[n];
	}

	PtrListInsertSorted<XmlObjectParam, XmlObjectParamSort> params;
	int handlepos;

protected:

	RECVS_DISPATCH;
};


#endif