summaryrefslogtreecommitdiff
path: root/xml/type.h
blob: 14e7cca0649594234046fe99c4006cd77def328c (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
/*
 *  $Id: type.h,v 1.3 2004/12/08 17:13:26 lordjaxom Exp $
 */

#ifndef VDR_TEXT2SKIN_XML_TYPE_H
#define VDR_TEXT2SKIN_XML_TYPE_H

#include <stdio.h>
#include <string>

class cxType {
public:
	enum eType {
		string,
		number,
		boolean
	};

private:
	eType       mType;
	std::string mString;
	int         mNumber;

public:
	cxType(const char *String): mType(string), mString(String ?: "") {}
	cxType(std::string String): mType(string), mString(String) {}
	cxType(int Number): mType(number), mNumber(Number) {}
	cxType(time_t Number): mType(number), mNumber(Number) {}
	cxType(bool Value): mType(boolean), mNumber(Value ? 1 : 0) {}
	cxType(const cxType &Src): mType(Src.mType), mString(Src.mString), mNumber(Src.mNumber) {}

	const std::string &String(void);
	int                Number(void) const;

	operator std::string () { return String(); }
	operator int         () { return Number(); }
	operator bool        () { return Number(); }
};

inline int cxType::Number(void) const { 
	return mType == number ? mNumber : 0;
}

#endif // VDR_TEXT2SKIN_XML_TYPE_H