#ifndef H_ED_FARR_20041215092824
#define H_ED_FARR_20041215092824

#ifdef __cplusplus
extern "C"
{
#endif

/* ---------------------------------------------------------------------
   (c) ED 2004
   Project      : CLIB
   Function     : Flexible array
   Module       : FARR
   File         : farr.h
   Created      : 15-12-2004
   Modified     : 21-04-2006
   --------------------------------------------------------------------- */

/* ---------------------------------------------------------------------
   Log

   1.3 21-04-2006 out of memory error fixed.
   1.2 03-05-2005 Added farr_qsort() and farr_traverse()
   1.1 16-12-2004 farr_nb() becomes farr_nb_max(). Added farr_nb_cur()
   1.0 15-12-2004 Initial version
   0.0 15-12-2004 Created

   Specifications
   --------------

   The size of the element is defined when the object is created

   create (size).

   The array is created with a size of 2.

   Then, an add() function allows the array to record the data at the end
   and to grown by one.
   The size is adapted according to the needs (realloc())

   The get() and put() functions allow a random access.

   --------------------------------------------------------------------- */
#include <stddef.h>

/* macros ============================================================== */

/* constants =========================================================== */

   typedef enum
   {
      FARR_OK,

#define ITEM(n_, s_)\
   FARR_ERR_##n_,

#include "ed/inc/farr_err.itm"

#undef ITEM

      FARR_ERR_NB
   }
   farr_err_e;

/* types =============================================================== */

   typedef int farr_cmp_f (void const *va, void const *vb);
   typedef int farr_lst_f (void const *v, void *p_user);

/* structures ========================================================== */

   typedef struct farr farr_s;

/* functions =========================================================== */

/* Identification */
   char const *farr_sid (void);
   char const *farr_sver (void);
   char const *farr_serr (farr_err_e err);

/* Dynamic constructor / destructor */
   farr_s *farr_create (size_t elem_size);
   void farr_delete (farr_s * this);

/* Initialisation */
   farr_err_e farr_init (farr_s * this);

   farr_err_e farr_add (farr_s * this, void const *p_data);
   farr_err_e farr_get (farr_s * this, size_t i, void *p_data);
   farr_err_e farr_put (farr_s * this, size_t i, void const *p_data);

   farr_err_e farr_qsort (farr_s * this, farr_cmp_f * pf);

/* status reading */
#if 1
   size_t farr_nb_cur (farr_s * this);
   size_t farr_nb_max (farr_s * this);
#endif

/* traversing */
   farr_err_e farr_traverse (farr_s * this, farr_lst_f * pf, void *p_user);

#ifdef __cplusplus
}
#endif

/* ---------------------------------------------------------------------
   Generated by NEW (c) ED 2.4
   Powered by C-code generator (c) ED 2003 1.0
   --------------------------------------------------------------------- */

#endif                          /* guard */
