GPatternSpec



hi all,

i've renamed the GtkPatternSpec API/implementation for GLib now,
and wondered whetehr there are any objections to incorporare this
into the 1.2 tree. the code is obviously fairly well tested already,
it works nice for gtk's key bindings and rc-file lookups.
to stay backwards compatible, we only need to alias the
GtkMatchType enum values ala GTK_MATCH_ALL = G_MATCH_ALL and
keep GtkPatternSpec in sync with GPatternSpec (GtkPatternSpec
contains the additional fields user_data and seq_id).
since the code will go into 1.3 anyways, and i don't expect it
to change even after that, i don't see a good reason for not
putting it into 1.2.3.

i've appended the renamed API below.


---
ciaoTJ

/* --- GLib pattern matching --- */

/* GPatternSpec match types */
typedef enum
{
  G_MATCH_ALL,       /* "*A?A*" */
  G_MATCH_ALL_TAIL,  /* "*A?AA" */
  G_MATCH_HEAD,      /* "AAAA*" */
  G_MATCH_TAIL,      /* "*AAAA" */
  G_MATCH_EXACT,     /* "AAAAA" */
  G_MATCH_LAST
} GMatchType;

/* Pattern matching
 */
typedef struct  _GPatternSpec GPatternSpec;

struct _GPatternSpec
{
  GMatchType match_type;
  guint      pattern_length;
  gchar     *pattern;
  gchar     *pattern_reversed;
};

void     g_pattern_spec_init      (GPatternSpec       *pspec,
                                   const gchar        *pattern);
void     g_pattern_spec_free_segs (GPatternSpec       *pspec);
gboolean g_pattern_match          (GPatternSpec       *pspec,
                                   guint               string_length,
                                   const gchar        *string,
                                   const gchar        *string_reversed);
gboolean g_pattern_match_string   (GPatternSpec       *pspec,
                                   const gchar        *string);
gboolean g_pattern_match_simple   (const gchar        *pattern,
                                   const gchar        *string);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]