shared: add "shared/nm-glib-aux/nm-value-type.h"

Glib has GValue which used for boxing value.

Add NMValueType enum, which has a similar purpose, but it's much more
limited.

- contrary to GValue, the type must be tracked separately from the
  user-data. That is, the "user-data" is only a pointer of appropriate
  type, and the knowledge of the actual NMValueType is kept separately.
  This will be used to have a static list of meta-data that knows the
  value types, but keeping the values independent of this type
  information. With GValue this would not be possible.

- the use case is much more limited. Just support basic integers,
  boolean and strings. Nothing fancy.

Note that we already do something similar at muliple places. See for
example NMVariantAttributeSpec and nm_utils_team_link_watcher_to_string().
These could/should instead use NMValueType.
This commit is contained in:
Thomas Haller 2019-05-10 10:09:54 +02:00
parent efccc2a53c
commit e64fdeeaf6
2 changed files with 24 additions and 0 deletions

View file

@ -358,6 +358,7 @@ shared_nm_glib_aux_libnm_glib_aux_la_SOURCES = \
shared/nm-glib-aux/nm-shared-utils.h \
shared/nm-glib-aux/nm-time-utils.c \
shared/nm-glib-aux/nm-time-utils.h \
shared/nm-glib-aux/nm-value-type.h \
$(NULL)
shared_nm_glib_aux_libnm_glib_aux_la_LDFLAGS = \

View file

@ -0,0 +1,23 @@
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2019 Red Hat, Inc.
*/
#ifndef __NM_VALUE_TYPE_H__
#define __NM_VALUE_TYPE_H__
#endif /* __NM_VALUE_TYPE_H__ */