aboutsummaryrefslogtreecommitdiff
path: root/libcontextprovider/value_compare.vala
blob: ea1b7730a85ce28de3008c46761f26f86e68cc59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using GLib;

namespace ContextProvider {

	/* All because GValue SUCKS. bring on GVariant */
	internal bool value_compare (Value? v1, Value? v2) {
		if (v1 == null && v2 == null)
			return true;
		if (v1 == null || v2 == null)
			return false;
		if (v1.type() == typeof(int) && v2.type() == typeof(int))
			return (v1.get_int() == v2.get_int());
		if (v1.type() == typeof(double) && v2.type() == typeof(double))
			return (v1.get_double() == v2.get_double());
		if (v1.type() == typeof(bool) && v2.type() == typeof(bool))
			return (v1.get_boolean() == v2.get_boolean());
		if (v1.type() == typeof(string) && v2.type() == typeof(string))
			return (v1.get_string() == v2.get_string());
		return false;
	}
}