summaryrefslogtreecommitdiffstats
blob: 82c839a3464e5f835fc4df2ed95e24bb97cc093c (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
#ifndef ATTRIBUTEMAP_H
#define ATTRIBUTEMAP_H

#include <map>

#include "Swiften/Base/String.h"

namespace Swift {
	class AttributeMap : public std::map<String,String> {
		public:
			AttributeMap() {}

			String getAttribute(const String& attribute) const {
				AttributeMap::const_iterator i = find(attribute);
				if (i == end()) {
					return "";
				}
				else {
					return i->second;
				}
			}

			bool getBoolAttribute(const String& attribute, bool defaultValue = false) const {
				AttributeMap::const_iterator i = find(attribute);
				if (i == end()) {
					return defaultValue;
				}
				else {
					return i->second == "true" || i->second == "1";
				}
			}
	};
}

#endif