summaryrefslogtreecommitdiffstats
blob: 5e6512e61fec19de05403e003c9144c1bf59edff (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
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#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