aboutsummaryrefslogtreecommitdiffstats
path: root/include/components/name.hpp
blob: 423a4844ef599254c162119a4e6b722b76f7bd43 (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
#ifndef COMPONENTS_NAME_HPP_
#define COMPONENTS_NAME_HPP_

#include "base.hpp"

#include <string>

struct Name : public Component {
	Name(std::string n = "")
		: name(n) {}
	Name(XMLElement* imp, XMLElement* def) {
		fromXML(imp, def);
	}

	std::string name;

	void fromXML(XMLElement* imp, XMLElement* def) final {
		auto n = imp->Attribute("name");

		// TODO check def's nullness	
		name = n != nullptr ? n : def->Attribute("value");
	}
};
#endif // COMPONENTS_NAME_HPP_