Re: [AD] Export AL_VECTOR

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2008-06-18, Thomas Fjellstrom <tfjellstrom@xxxxxxxxxx> wrote:
> On June 18, 2008, Peter Wang wrote:
> > On 2008-06-18, Thomas Fjellstrom <tfjellstrom@xxxxxxxxxx> wrote:
> >
> > Yes.  On the plus side you can present a subset or specialised interface
> > of the operations that make sense, and retain type safety (which is the
> > main problem with a generic interface in C).
> >
> > Not that I'm in favour of code duplication.  Can you explain how you
> > plan to use the vectors in your fs API?
> 
> To start with, people want to play with path names. splitting them up into 
> component parts, adding entries, changing some, and re joining them up into a 
> final path name.

It seems to me that a specific API really would be easier to work with.
Something like this?

    AL_PATH *al_path_init(void);
    AL_PATH *al_path_init_from_string(const char *s, char delim);
    int al_path_num_components(AL_PATH *path);
    const char *al_path_index(AL_PATH *path, int i);
    void al_path_replace(AL_PATH *path, int i, const char *s);
    void al_path_delete(AL_PATH *path, int i);
    void al_path_insert(AL_PATH *path, int i, const char *s);
    const char *al_path_tail(AL_PATH *path);
    void al_path_drop_tail(AL_PATH *path);
    void al_path_append(AL_PATH *path, const char *s);
    void al_path_concat(AL_PATH *path, const AL_PATH *tail);
    char *al_path_to_string(AL_PATH *path, char delim); 
    void al_path_free(AL_PATH *path);

Another good thing is that with a specific interface you can hide the
memory management of the individual path components, which you can't do
for the generic vector.

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/