/* vim: ts=4 sw=4 sts=4 ff=unix fenc=utf-8 : * ===================================================================== * sc_list.h * Copyright (c) 2003 - 2011 sys0tem * LICENSE : * LGPL (GNU Lesser General Public License - Version 3,29 June 2007) * http://www.gnu.org/copyleft/lesser.html * or * EPL (Eclipse Public License - v1.0) * http://www.eclipse.org/legal/epl-v10.html * ===================================================================== */ #ifndef __SC_LIST_H__ #define __SC_LIST_H__ #include <stddef.h> #include <sc_iterator.h> #ifdef __cplusplus extern "C" { #endif /** * リストエントリ. */ typedef struct SC_List_Entry_ { void* value; /*< 値 */ size_t size; /*< 値のサイズ */ struct SC_List_Entry_* next; /*< 次のエントリ */ struct SC_List_Entry_* prev; /*< 前のエントリ */ } SC_List_Entry; /** * リスト. * <pre> * [使用方法] * char* val; * SC_List* list = SC_List_new(); * list->addStr(list, -1, "val1"); * list->addStr(list, -1, "val2"); * . * . * val = map->getStr(list, 0); * . * . * SC_List_delete(list); * </pre> */ typedef struct SC_List_ { size_t size; void* (*add )(struct SC_List_*, int index, const void* obj, size_t size); char* (*addStr )(struct SC_List_*, int index, const char* obj); void* (*get )(struct SC_List_*, int index, size_t* size); char* (*getStr )(struct SC_List_*, int index); void (*remove )(struct SC_List_*, int index); void (*clear )(struct SC_List_*); SC_List_Entry* _head; SC_List_Entry* _tail; } SC_List; SC_List* SC_List_new(void); void SC_List_delete(SC_List* list); #ifdef __cplusplus } #endif #endif /* __SC_LIST_H__ */