summaryrefslogtreecommitdiff
path: root/xml/function.h
blob: afc3465440c06a9bd33243d1c0dd2cd9971703a7 (plain)
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
/*
 *  $Id: function.h,v 1.5 2005/01/05 19:32:43 lordjaxom Exp $
 */

#ifndef VDR_TEXT2SKIN_XML_FUNCTION_H
#define VDR_TEXT2SKIN_XML_FUNCTION_H

#include "xml/string.h"
#include <string>

#define STRING    0x01000000
#define NUMBER    0x02000000
#define INTERNAL  0x04000000

#define MAXPARAMETERS 512

class cxFunction {
public:
	enum eType {
		undefined_function,

		string     = STRING,
		number     = NUMBER,

		fun_not    = INTERNAL + 1,
		fun_and    = INTERNAL + 2,
		fun_or     = INTERNAL + 3,
		fun_eq     = INTERNAL + 4,
		fun_file   = INTERNAL + 5,
		fun_trans  = INTERNAL + 6,
		fun_plugin = INTERNAL + 7
	};

	static const std::string False;
	static const std::string True;
	
private:
	cxSkin     *mSkin;
	eType       mType;
	cxString    mString;
	int         mNumber;
	cxFunction *mParams[MAXPARAMETERS];
	uint        mNumParams;
	
protected:
	cxType FunFile  (const cxType &Param) const;
	cxType FunPlugin(const cxType &Param) const;

public:
	cxFunction(cxSkin *Skin);
	cxFunction(const cxString &String);
	cxFunction(const cxFunction &Src);
	~cxFunction();

	bool Parse(const std::string &Text);
	cxType Evaluate(void) const;

	void SetListIndex(uint Index, int Tab);
};

inline void cxFunction::SetListIndex(uint Index, int Tab)
{
	mString.SetListIndex(Index, Tab);
	for (uint i = 0; i < mNumParams; ++i)
		mParams[i]->SetListIndex(Index, Tab);
}

#endif // VDR_TEXT2SKIN_XML_FUNCTION_H