Beispiel #1
0
gint64 *
arv_gc_enumeration_get_available_int_values (ArvGcEnumeration *enumeration, guint *n_values)
{
	gint64 *values;
	const GSList *entries, *iter;
	unsigned int i;

	g_return_val_if_fail (n_values != NULL, NULL);

	*n_values = 0;

	g_return_val_if_fail (ARV_IS_GC_ENUMERATION (enumeration), NULL);

	entries = arv_gc_enumeration_get_entries (enumeration);

	*n_values = 0;
	for (iter = entries; iter != NULL; iter = iter->next)
		if (arv_gc_feature_node_is_available (iter->data))
		    (*n_values)++;

	if (*n_values == 0)
		return NULL;

	values = g_new (gint64, *n_values);
	for (iter = entries, i = 0; iter != NULL; iter = iter->next)
		if (arv_gc_feature_node_is_available (iter->data)) {
			values[i] = arv_gc_enum_entry_get_value (iter->data);
			i++;
		}

	return values;
}
Beispiel #2
0
static gint64
arv_gc_enumeration_get_max_string_length (ArvGcString *gc_string, GError **error)
{
	ArvGcEnumeration *gc_enumeration = ARV_GC_ENUMERATION (gc_string);
	const GSList *entries, *iter;
	gint64 length, max_length = 0;

	entries = arv_gc_enumeration_get_entries (gc_enumeration);
	for (iter = entries; iter != NULL; iter = iter->next) {
		const char *name;

		name = arv_gc_feature_node_get_name (iter->data);
		length = name != NULL ? strlen (name) : 0;
		if (length > max_length)
			max_length = length;
	}

	return max_length;
}
Beispiel #3
0
gint64 *
arv_gc_enumeration_get_available_int_values (ArvGcEnumeration *enumeration, guint *n_values, GError **error)
{
	gint64 *values;
	const GSList *entries, *iter;
	GSList *available_entries = NULL;
	unsigned int i;
	GError *local_error = NULL;

	g_return_val_if_fail (n_values != NULL, NULL);

	*n_values = 0;

	g_return_val_if_fail (ARV_IS_GC_ENUMERATION (enumeration), NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);

	entries = arv_gc_enumeration_get_entries (enumeration);

	*n_values = 0;
	for (iter = entries; iter != NULL; iter = iter->next) {
		gboolean is_available;

		is_available = arv_gc_feature_node_is_available (iter->data, &local_error);

		if (local_error != NULL) {
			g_propagate_error (error, local_error);
			*n_values = 0;
			g_slist_free (available_entries);

			return NULL;
		}

		if (is_available) {
			gboolean is_implemented;

			is_implemented = arv_gc_feature_node_is_implemented (iter->data, &local_error);

			if (local_error != NULL) {
				g_propagate_error (error, local_error);
				*n_values = 0;
				g_slist_free (available_entries);

				return NULL;
			}

			if (is_implemented) {
				(*n_values)++;
				available_entries = g_slist_prepend (available_entries, iter->data);
			}
		}
	}

	if (*n_values == 0) {
		g_slist_free (available_entries);
		return NULL;
	}

	values = g_new (gint64, *n_values);
	for (iter = available_entries, i = 0; iter != NULL; iter = iter->next) {

		values[i] = arv_gc_enum_entry_get_value (iter->data, &local_error);

		if (local_error != NULL) {
			g_propagate_error (error, local_error);
			*n_values = 0;
			g_slist_free (available_entries);
			g_free (values);

			return NULL;
		}
		i++;
	}

	g_slist_free (available_entries);

	return values;
}