parent
a97e790238
commit
0caf66875c
@ -0,0 +1,28 @@ |
||||
#include "sectionarray.h" |
||||
#include <proto/exec.h> |
||||
#include <string.h> |
||||
|
||||
Array SectionArrayNew(VOID)
|
||||
{ |
||||
#define SIZE_STRPTR 2 |
||||
return NewArray(SIZE_STRPTR); |
||||
} |
||||
|
||||
VOID SectionArrayAppend(SectionArray array, SECTIONPTR value) |
||||
{ |
||||
AppendToArray(CONST_STRPTR, array, value);
|
||||
} |
||||
|
||||
VOID SectionArrayFree(SectionArray array) |
||||
{ |
||||
if( array != NULL ) |
||||
{ |
||||
SectionArrayForEach(array, SectionFree(aSection);); |
||||
DeleteArray(array); |
||||
} |
||||
} |
||||
|
||||
SECTIONPTR* SectionArrayValues(SectionArray array) |
||||
{ |
||||
return ArrayValues(SECTIONPTR, array); |
||||
} |
@ -0,0 +1,17 @@ |
||||
#ifndef __SECTIONARRAY_H |
||||
#define __SECTIONARRAY_H |
||||
|
||||
#include <exec/types.h> |
||||
#include <proto/containerkit.h> |
||||
#include "configmodel.h" |
||||
#define SectionArray Array |
||||
|
||||
SectionArray SectionArrayNew(VOID);
|
||||
VOID SectionArrayAppend(SectionArray array, CONST_STRPTR value); |
||||
VOID SectionArrayFree(SectionArray array); |
||||
SECTIONPTR* SectionArrayValues(SectionArray array); |
||||
|
||||
#define SectionArrayForEach(array, block) do {SECTIONPTR *afe_123_p = (*(SECTIONPTR **)array); SECTIONPTR aSection = *afe_123_p; int afe_123_c = (((ULONG *)array)[1]);\ |
||||
for (; afe_123_c--; aSection = *(++afe_123_p)) block} while (0); |
||||
|
||||
#endif |
@ -0,0 +1,45 @@ |
||||
#include "sectionmap.h" |
||||
#include "configmodel.h" |
||||
|
||||
SectionMap SectionMapNew() |
||||
{ |
||||
SectionMap result = NewMap(CNTKIT_KEY_STRING, |
||||
CNTKIT_CAPACITY, 8, |
||||
CNTKIT_VALUESIZE, 4, |
||||
TAG_DONE); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
VOID SectionMapSet(SectionMap map, CONST_STRPTR canonicalName, SECTIONPTR section) |
||||
{ |
||||
if( canonicalName != NULL ) |
||||
{ |
||||
if( section == NULL ) |
||||
{ |
||||
RemoveStrKey(map, (STRPTR)canonicalName); |
||||
} |
||||
else |
||||
{ |
||||
MapStrToValue(map, (STRPTR)canonicalName, (ULONG)section); |
||||
} |
||||
} |
||||
} |
||||
|
||||
SECTIONPTR SectionMapGet(SectionMap map, CONST_STRPTR canonicalName) |
||||
{ |
||||
if( canonicalName != NULL ) |
||||
{ |
||||
return (SECTIONPTR)ValueOfStrKey(map, (STRPTR)canonicalName); |
||||
} |
||||
else |
||||
{ |
||||
return NULL; |
||||
} |
||||
} |
||||
|
||||
VOID SectionMapFree(SectionMap map) |
||||
{ |
||||
// doesnt seem to delete contents
|
||||
DeleteMap(map);
|
||||
} |
@ -0,0 +1,14 @@ |
||||
#ifndef __SECTIONMAP_H |
||||
#define __SECTIONMAP_H |
||||
|
||||
#include <exec/types.h> |
||||
#include <proto/containerkit.h> |
||||
#include "configmodel.h" |
||||
|
||||
#define SectionMap Map // a map of string (canonical name) to Section
|
||||
|
||||
SectionMap SectionMapNew(VOID); |
||||
VOID SectionMapSet(SectionMap map, CONST_STRPTR canonicalName, SECTIONPTR section); |
||||
SECTIONPTR SectionMapGet(SectionMap map, CONST_STRPTR canonicalName); |
||||
VOID SectionMapFree(SectionMap map); |
||||
#endif |
@ -0,0 +1,48 @@ |
||||
#include "sectionstore.h" |
||||
#include "containers/sectionmap.h" |
||||
#include "containers/sectionarray.h" |
||||
|
||||
#include <proto/exec.h> |
||||
|
||||
struct SectionStore |
||||
{ |
||||
SectionMap map; |
||||
SectionArray array; |
||||
}; |
||||
|
||||
SECTIONSTOREPTR SectionStoreNew(VOID) |
||||
{ |
||||
struct SectionStore* result = AllocVec(sizeof(struct SectionStore), MEMF_CLEAR); |
||||
result->map = SectionMapNew(); |
||||
result->array = SectionArrayNew(); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
VOID SectionStoreFree(SECTIONSTOREPTR abstractSectionStore) |
||||
{ |
||||
if( abstractSectionStore != NULL ) |
||||
{ |
||||
struct SectionStore* store = (struct SectionStore*)abstractSectionStore; |
||||
if( store->map != NULL ) SectionMapFree( store->map ); |
||||
if( store->array != NULL ) SectionArrayFree( store->array ); |
||||
FreeVec(store); |
||||
} |
||||
} |
||||
|
||||
VOID SectionStoreAddSection(SECTIONPTR section) |
||||
{ |
||||
} |
||||
|
||||
VOID SectionStoreRemoveSection(SECTIONPTR section) |
||||
{ |
||||
} |
||||
|
||||
VOID SectionStoreRemoveSectionByName(CONST_STRPTR canonicalName) |
||||
{ |
||||
} |
||||
|
||||
SECTIONPTR SectionStoreGetSection(CONST_STRPTR canonicalName) |
||||
{ |
||||
return NULL; |
||||
} |
@ -0,0 +1,18 @@ |
||||
#ifndef __SECTIONSTORE_H |
||||
#define __SECTIONSTORE_H |
||||
|
||||
#include <exec/types.h> |
||||
|
||||
typedef APTR SECTIONSTOREPTR; |
||||
|
||||
#include "configmodel.h" |
||||
|
||||
SECTIONSTOREPTR SectionStoreNew(VOID); |
||||
VOID SectionStoreFree(SECTIONSTOREPTR sectionStore); |
||||
|
||||
VOID SectionStoreAddSection(SECTIONPTR section); |
||||
VOID SectionStoreRemoveSection(SECTIONPTR section); |
||||
VOID SectionStoreRemoveSectionByName(CONST_STRPTR canonicalName); |
||||
|
||||
SECTIONPTR SectionStoreGetSection(CONST_STRPTR canonicalName); |
||||
#endif |
Loading…
Reference in new issue