Next Previous Contents

2. ARRAY object

Linuxconf makes extensive use of the ARRAY object. This is an extensible table of ARRAY_OBJ pointers. It is possible to add, insert, remove items in the table.

2.1 Alphabetical function listing

Classe ARRAY, vue publique

2.2 Defining ARRAYs

Arrays are never directly defined. A new object is derived and generally, this object override various function of the class ( ARRAY::getitem() most of the time).

ARRAY::ARRAY()

Manage the content of a hosts file (generally /etc/hosts

        PUBLIC ARRAY::ARRAY(
                void)
        

2.3 Adding/removing records to the array

ARRAY::add()

Add one item to the in memory hosts table

        PUBLIC void ARRAY::add(
                ARRAY_OBJ *pt)
        

ARRAY::getitem()

This function should be duplicate in each sub-class to allow proper casting.

        PROTECTED ARRAY_OBJ *ARRAY::getitem(
                int no) const
        
        

ARRAY::getnb()

Return the number of entry in a table.

        PUBLIC int ARRAY::getnb(
                void) const
        
        

ARRAY::insert()

Insert one item to the table

        PUBLIC void ARRAY::insert(
                int pos,
                ARRAY_OBJ *pt)
        

ARRAY::remove()

Remove one entry from the list. The entry is not freed. The caller must do it. Return -1 if the entry was not found.

        PUBLIC int ARRAY::remove(
                ARRAY_OBJ *obj)
        

ARRAY::remove_all()

Remove all entry from the list and destroy the objects if owner

        PUBLIC void ARRAY::remove_all(
                void)
        

ARRAY::remove_del()

Remove one entry from the list and delete the object. If the object is not part of the list, it is not deleted. Return -1 if the entry was not found.

        PUBLIC int ARRAY::remove_del(
                ARRAY_OBJ *obj)
        

ARRAY::remove_del()

        PUBLIC int ARRAY::remove_del(
                int no)
        

2.4 Misc

ARRAY::neverdelete()

Instruct this array it is not allowed to delete objects. We use this function when we intend to share some object between several arrays. One array is the owner and the others represents various views of the original array (for example).

        PUBLIC void ARRAY::neverdelete(
                void)
        

ARRAY::moveto()

Displace an object in the list

        PUBLIC void ARRAY::moveto(
                ARRAY_OBJ *o,
                int newpos)
        

ARRAY::rstmodified()

Reset the modify flags of all elements of the array.

        PUBLIC void ARRAY::rstmodified(
                void)
        

ARRAY::sort()

Sort the ARRAY with a user function working like the one for qsort. Use qsort() internally.

        PUBLIC void ARRAY::sort(
                int(*cmp)(const ARRAY_OBJ *, const ARRAY_OBJ *))
        

ARRAY::was_modified()

Return != if the element was modified.

        PUBLIC VIRTUAL int ARRAY::was_modified(
                void)
        

ARRAY::write()

Save the content of the array Return -1 if any error. The default behavior is to do nothing

        PUBLIC VIRTUAL int ARRAY::write(
                void)
        

2.5 Editing records

ARRAY::editone()

Edit one object or create a new one and manage the deletion if told by the edit function of the object.

        PUBLIC int ARRAY::editone(
                int no)
        

ARRAY::editone()

Edit one object or create a new one and manage the deletion if told by the edit function of the object.

        PUBLIC int ARRAY::editone(
                ARRAY_OBJ *e)
        

ARRAY::manage_edit()

Behavior after the editing of one object

        PUBLIC int ARRAY::manage_edit(
                ARRAY_OBJ *e,
                int code,
                int insertpos)
        

ARRAY::manage_edit()

Behavior after the editing of one object

        PUBLIC int ARRAY::manage_edit(
                ARRAY_OBJ *e,
                int code)
        

2.6 ARRAY records are ARRAY_OBJ objets

ARRAY_OBJ::ARRAY_OBJ()

        PUBLIC ARRAY_OBJ::ARRAY_OBJ(
                void)
        

ARRAY_OBJ::edit()

Edit the object. Return 1 if the object must be deleted Return 0 if the modification are accepted Return -1 if the user has escape away.

        PUBLIC VIRTUAL int ARRAY_OBJ::edit(
                void)
        

ARRAY_OBJ::rstmodified()

Reset the modify flags of the element.

        PUBLIC void ARRAY_OBJ::rstmodified(
                void)
        

ARRAY_OBJ::setmodified()

Reset the modify flags of the element. This function is generally used with ARRAY::was_modified().

        PUBLIC void ARRAY_OBJ::setmodified(
                void)
        

ARRAY_OBJ::was_modified()

Return true if the element was modified.

        PUBLIC VIRTUAL int ARRAY_OBJ::was_modified(
                void)
        

ARRAY_OBJ:: ARRAY_OBJ()

        PUBLIC VIRTUAL ARRAY_OBJ::~ARRAY_OBJ(
                void)
        

Next Previous Contents