Re: Some new GString functions - constructors



Hi,

There's no need to Cc: me - I'm subscribed to the list.

On Tue, 2005-12-20 at 23:12 +0000, Paul LeoNerd Evans wrote:

> > >     gint g_string_indexof(GString *str, gchar c);
> > 
> > This would be useful with Unicode support, or with a gunichar variant.
> 

> I can have a go at a Unicode-aware _indexof(), sure... but currently I
> just wrap g_strchr() for that case, so I'd need to know how to handle it
> in UTF-8.

Then g_utf8_strchr() can be used, instead of g_strchr(), in this case.

> <snip>
> 
> > Also, a
> > 
> > 	gchar ** g_string_tokenize (GString     *str,
> >                                     const gchar *token,
> >                                     gsize        lenght);
> > 
> > Could be interesting, instead of creating a new StringList type, since,
> > if you want a list of GString, you can always iterate on the returned
> > strings vector.
> 
> Hmm.. That one seems a little messy to me. GString in, GString out. Or
> gchar* in, gchar* out. If it takes in a GString*, but returns a gchar**,
> that's sort of a mix of types. I don't know how anyone else feels about
> that, but it doesn't quite feel right to me.

EIther way, you would have another type out: GStringList would be a
G(S)List of GString; you would have to use:

  GSList *iter; /* or GList *iter; */
  for (iter = stringlist; iter != NULL; iter = iter->next)
    do_something ((GString *) iter->data);

to iterate though the list, which would break the least-surprise
principle, since you would have to use a G(S)List pointer to iterate
through a GStringList.

Ciao,
 Emmanuele.

-- 
Emmanuele Bassi - <ebassi gmail com>
Log: http://log.emmanuelebassi.net




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