defs/si_std/listt.h File Reference

A template file that generates strongly typed lists of user defined types. More...

#include <si_std/list.h>

Go to the source code of this file.

Defines

#define sm_nodePtr(it)   (it)->priv_.node
 This macro is an implementation detail and should be ignored by users of the list facilities here.
#define sm_listIteratorDecl(T)
 Declares a strongly typed list iterator for user defined type T.
#define sm_listDecl(T)
 A macro declaring a list containing items of the given type T. This macro declares strongly typed wrappers of all the list member functions given in list.h.
#define sm_listImpl(T)
 A macro implementing a list template for the given type T. This includes all the member functions declared with the macro sm_listDecl.


Detailed Description

A template file that generates strongly typed lists of user defined types.

This file contains the macros sm_listDecl and sm_listImpl for declaring and implementing list containers of user defined types. For example, sm_listDecl(ut_myRecord); would declare the types:

In the file implementing ut_myRecord, one would simply add the line: sm_listImpl(ut_myRecord); to implement the list for this type. This is a process nearly identical to that used with C++ templates, but is usable from C code, and thus portable to small systems. For more documentation on list members, see list.h


Define Documentation

#define sm_listDecl (  ) 

Value:

sm_listIteratorDecl(T);\
    typedef sc_list T##List;\
    typedef s_int32 (*T##ListNode_compare)(T* pLHS, T* pRHS);\
    sc_status T##List_construct(T##List* pl,\
                                s_int32 initialCapacity, s_int32 maxCapacity);\
    sc_status T##List_destruct(T##List* pl);\
    sc_status T##List_assign(T##List* pl, T##List* prhs);\
    \
    sc_status T##List_getBegin(T##List* pl, T##ListIterator* pit);\
    sc_status T##List_getEnd(T##List* pl, T##ListIterator* pit);\
    sc_status T##List_getIsEmpty(T##List* pl, s_bool* pb);\
    \
    sc_status T##List_clear(T##List* pl);\
    sc_status T##List_insert(T##List* pl, T##ListIterator* it, T* nt);\
    sc_status T##List_erase(T##List* pl, T##ListIterator* it);\
    sc_status T##List_remove(T##List* pl, T##ListIterator* it);\
    \
    sc_status T##List_pushBack(T##List* pl, T* pnt);\
    sc_status T##List_pushFront(T##List* pl, T* pnt);\
    sc_status T##List_popBack(T##List* pl, T* pnt);\
    sc_status T##List_popFront(T##List* pl, T* pnt);\
    \
    sc_status T##List_front(T##List* pl, T** pnt);\
    sc_status T##List_back(T##List* pl, T** pnt);\
    \
    sc_status T##List_getSize(T##List* pl, s_uint32* sz);\
A macro declaring a list containing items of the given type T. This macro declares strongly typed wrappers of all the list member functions given in list.h.

Note:
This declaration assumes the list type will be used in a statically linked fashion.

#define sm_listImpl (  ) 

A macro implementing a list template for the given type T. This includes all the member functions declared with the macro sm_listDecl.

Note:
This macro assumes that you have implemented the following functions for your type T:
  • sc_status T_constructCopy(T*, const T*);
  • sc_status T_assign(T*, const T*);
  • sc_status T_destruct(T*);

and that the list will be used in a statically linked fashion.

#define sm_listIteratorDecl (  ) 

Value:

typedef sc_listIterator T##ListIterator;\
    static void T##ListIterator_init(T##ListIterator* I)\
    { sm_nodePtr(I) = NULL; }\
    static T* T##ListIterator_get(T##ListIterator* I)\
    { return (T*)(sm_nodePtr(I)+1); }\
    static void T##ListIterator_next(T##ListIterator* I)\
    {  sm_nodePtr(I) = sm_nodePtr(I)->next; }\
    static void T##ListIterator_prev(T##ListIterator* I)\
    {  sm_nodePtr(I) = sm_nodePtr(I)->prev; }\
    static s_bool T##ListIterator_isEnd(T##ListIterator* I)\
    { return ( (sm_nodePtr(I) == NULL) || (sm_nodePtr(I)->next == NULL) ) \
               ? seTrue : seFalse; }
Declares a strongly typed list iterator for user defined type T.

These functions are declared inline as static functions to allow the optimizer to remove the function call. In particular, _get, _next, _prev and _isEnd will typically be used in loops containing potentially large numbers of elements, so this can be important. For the same reason, there is little error checking in release mode.


doxygen