summaryrefslogtreecommitdiff
path: root/shared/nm-glib-aux/nm-enum-utils.h
blob: e58dda3efd83e7ddff7a4e5e8a1b9e7ce65b0f99 (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
// SPDX-License-Identifier: LGPL-2.1+
/* NetworkManager -- Network link manager
 *
 * (C) Copyright 2017 Red Hat, Inc.
 */

#ifndef __NM_ENUM_UTILS_H__
#define __NM_ENUM_UTILS_H__

/*****************************************************************************/

typedef struct _NMUtilsEnumValueInfo {
	/* currently, this is only used for _nm_utils_enum_from_str_full() to
	 * declare additional aliases for values. */
	const char *nick;
	int value;
} NMUtilsEnumValueInfo;

char *_nm_utils_enum_to_str_full (GType type,
                                  int value,
                                  const char *sep,
                                  const NMUtilsEnumValueInfo *value_infos);
gboolean _nm_utils_enum_from_str_full (GType type,
                                       const char *str,
                                       int *out_value,
                                       char **err_token,
                                       const NMUtilsEnumValueInfo *value_infos);

const char **_nm_utils_enum_get_values (GType type, int from, int to);

/*****************************************************************************/

#endif /* __NM_ENUM_UTILS_H__ */