summaryrefslogtreecommitdiff
path: root/project2/variables.h
blob: cba303e33367c2f36791d8cdf820bb90623ef978 (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
#ifndef VARIABLES_H
#define VARIABLES_H

#include <boost/shared_ptr.hpp>
#include <glibmm/ustring.h>
#include <libxml++/nodes/element.h>
#include <libxml++/attribute.h>

class VariableImpl {
	public:
		virtual const Glib::ustring & value() const = 0;

	protected:
		VariableImpl(const Glib::ustring & src) : source(src) { }
		const Glib::ustring source;
};


class Variable {
	public:
		typedef boost::shared_ptr<VariableImpl> VariableImplPtr;

		Variable(xmlpp::Attribute *);
		Variable(xmlpp::Element *);
		Variable(const Glib::ustring & s);

		operator const Glib::ustring & () const { return var->value(); }
		const Glib::ustring & operator()() const { return var->value(); }

	private:
		friend class VariableParse;
		static VariableImplPtr create(const Glib::ustring & s);
		VariableImplPtr var;
};

#endif