Ejemplo n.º 1
0
static void
filter_testcase (const gchar *path, xmmsv_t *list)
{
	gchar *content, *filename;
	xmmsv_t *dict, *data, *coll;

	g_assert (g_file_get_contents (path, &content, NULL, NULL));
	dict = xmmsv_from_json (content);
	if (dict == NULL) {
		g_error ("Could not parse '%s'!\n", path);
		g_assert_not_reached ();
	}
	g_free (content);

	g_assert (xmmsv_dict_has_key (dict, "medialib"));
	g_assert (xmmsv_dict_has_key (dict, "collection"));
	g_assert (xmmsv_dict_has_key (dict, "specification"));
	g_assert (xmmsv_dict_has_key (dict, "expected"));

	g_assert (xmmsv_dict_get (dict, "collection", &data));
	g_assert (xmmsv_is_type (data, XMMSV_TYPE_DICT));

	coll = xmmsv_coll_from_dict (data);

	xmmsv_dict_set (dict, "collection", coll);
	xmmsv_unref (coll);

	filename = g_path_get_basename (path);
	xmmsv_dict_set_string (dict, "name", filename);
	g_free (filename);

	xmmsv_list_append (list, dict);
	xmmsv_unref (dict);
}
Ejemplo n.º 2
0
/**
 * Parse a Collection from a dict.
 * Each dict contains:
 *  - type, the name of the Collection
 *  - operands, a list of Collections [optional]
 *  - attributes, a dict of attributes [optional]
 *  - idlist, a list of media library id's [optional]
 */
xmmsv_t *
xmmsv_coll_from_string (const char *data)
{
	xmmsv_t *collection;
	xmmsv_t *dict;

	dict = xmmsv_from_json (data);
	collection = parse_collection (dict);
	xmmsv_unref (dict);

	return collection;
}
Ejemplo n.º 3
0
xmmsv_t *
xmmsv_from_xson (const char *spec)
{
	gchar *normalized;
	char *p;
	xmmsv_t *dict;

	normalized = g_strdup (spec);
	for (p = normalized; *p != '\0'; p++) {
		if (*p == '\'') {
			*p = '"';
		}
	}

	dict = xmmsv_from_json (normalized);

	g_free (normalized);

	return dict;
}