PkEnumList

PkEnumList — Common functions to manifulate lists of enumerated types

Synopsis




                    PkEnumListPrivate;
                    PkEnumList;
enum                PkEnumListType;
PkEnumList*         pk_enum_list_new                    (void);
gboolean            pk_enum_list_set_type               (PkEnumList *elist,
                                                         PkEnumListType type);
gboolean            pk_enum_list_from_string            (PkEnumList *elist,
                                                         const gchar *enums);
gchar*              pk_enum_list_to_string              (PkEnumList *elist);
guint               pk_enum_list_size                   (PkEnumList *elist);
guint               pk_enum_list_get_item               (PkEnumList *elist,
                                                         guint item);
gboolean            pk_enum_list_contains               (PkEnumList *elist,
                                                         guint value);
gint                pk_enum_list_contains_priority      (PkEnumList *elist,
                                                         gint value,
                                                         ...);
gboolean            pk_enum_list_append                 (PkEnumList *elist,
                                                         guint value);
gboolean            pk_enum_list_remove                 (PkEnumList *elist,
                                                         guint value);
gboolean            pk_enum_list_print                  (PkEnumList *elist);
gboolean            pk_enum_list_append_multiple        (PkEnumList *elist,
                                                         gint value,
                                                         ...);

Object Hierarchy


  GObject
   +----PkEnumList

Description

This file contains functions that can manage lists of enumerated values of different types. These functions will be much quicker than manipulating strings directly.

Details

PkEnumListPrivate

typedef struct _PkEnumListPrivate PkEnumListPrivate;

Private PkEnumList data


PkEnumList

typedef struct _PkEnumList PkEnumList;


enum PkEnumListType

typedef enum {
	PK_ENUM_LIST_TYPE_ROLE,
	PK_ENUM_LIST_TYPE_GROUP,
	PK_ENUM_LIST_TYPE_FILTER,
	PK_ENUM_LIST_TYPE_STATUS,
	PK_ENUM_LIST_TYPE_UNKNOWN
} PkEnumListType;


pk_enum_list_new ()

PkEnumList*         pk_enum_list_new                    (void);

Returns :


pk_enum_list_set_type ()

gboolean            pk_enum_list_set_type               (PkEnumList *elist,
                                                         PkEnumListType type);

This function sets the type of list. You don't /need/ to use this function, but is required if you print or get the list as we need to know what pk_xxxx_enum_to_text function to use for each part.

elist :

a valid PkEnumList instance

type :

the type of list this should be

Returns :

TRUE if we set the list type

pk_enum_list_from_string ()

gboolean            pk_enum_list_from_string            (PkEnumList *elist,
                                                         const gchar *enums);

Set the list with a seed string. Converting the seed string once allows us to deal with raw enumerated integers, which is often much faster.

elist :

a valid PkEnumList instance

enums :

a text representation of the list, e.g. "search-name;search-details"

Returns :

TRUE if we appended the data

pk_enum_list_to_string ()

gchar*              pk_enum_list_to_string              (PkEnumList *elist);

Converts the enumerated list back to a string.

elist :

a valid PkEnumList instance

Returns :

A string representing the enumerated list, e.g. "search-name;search-details"

pk_enum_list_size ()

guint               pk_enum_list_size                   (PkEnumList *elist);

elist :

a valid PkEnumList instance

Returns :

the size of the enumerated list.

pk_enum_list_get_item ()

guint               pk_enum_list_get_item               (PkEnumList *elist,
                                                         guint item);

elist :

a valid PkEnumList instance

item :

the item number of the list

Returns :

the enum value for this position, or zero if error.

pk_enum_list_contains ()

gboolean            pk_enum_list_contains               (PkEnumList *elist,
                                                         guint value);

Searches the list looking for a specific value.

elist :

a valid PkEnumList instance

value :

the value to search for

Returns :

TRUE if we found the data in the list

pk_enum_list_contains_priority ()

gint                pk_enum_list_contains_priority      (PkEnumList *elist,
                                                         gint value,
                                                         ...);

Finds elements in a list, but with priority going to the preceeding entry

elist :

a valid PkEnumList instance

value :

the values we are searching for

... :

Returns :

The return enumerated type, or -1 if none are found

pk_enum_list_append ()

gboolean            pk_enum_list_append                 (PkEnumList *elist,
                                                         guint value);

Set a single item into a list.

elist :

a valid PkEnumList instance

value :

the value to add

Returns :

TRUE if we set the data, FALSE if it already existed

pk_enum_list_remove ()

gboolean            pk_enum_list_remove                 (PkEnumList *elist,
                                                         guint value);

Removes a single item from a list.

elist :

a valid PkEnumList instance

value :

the value to add

Returns :

TRUE if we set the data, FALSE if it did not exist

pk_enum_list_print ()

gboolean            pk_enum_list_print                  (PkEnumList *elist);

Prints the enumerated list. This is most useful for debugging.

elist :

a valid PkEnumList instance

Returns :

TRUE for success.

pk_enum_list_append_multiple ()

gboolean            pk_enum_list_append_multiple        (PkEnumList *elist,
                                                         gint value,
                                                         ...);

Set a many items into a list in one method. Always terminate the enum list with the value -1

elist :

a valid PkEnumList instance

value :

the initial value

... :

Returns :

TRUE if we set the data