Design Pattern Examples
Overview of object-oriented design patterns
helpers/mapofstrings.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __MAPOFSTRINGS_H__
8#define __MAPOFSTRINGS_H__
9
10#include <stdlib.h>
11#include "conststringlist.h"
12
17typedef struct
18{
19 const char* key;
22
23
30typedef struct
31{
35
36//-----------------------------------------------------------------------------
37
50
57
73bool MapOfStrings_AddStringList(MapOfStrings* map, const char* key, ConstStringList* value);
74
88bool MapOfStrings_AddArray(MapOfStrings* map, const char* key, const char** value);
89
98int MapOfStrings_Find(MapOfStrings* map, const char* key);
99
100#endif // __MAPOFSTRINGS_H__
101
Declaration of the ConstStringList structure and supporting functions to work with a list of constant...
void MapOfStrings_Initialize(MapOfStrings *map)
Initialize the given MapOfStrings structure so it is ready for use.
Definition: mapofstrings.c:16
void MapOfStrings_Clear(MapOfStrings *map)
Clear the given MapOfStrings object, releasing all memory associated with it. Leaves the object in an...
Definition: mapofstrings.c:28
int MapOfStrings_Find(MapOfStrings *map, const char *key)
Find the specified key in the given MapOfStrings object, returning an index into the object.
Definition: mapofstrings.c:105
bool MapOfStrings_AddStringList(MapOfStrings *map, const char *key, ConstStringList *value)
Add a key/value association to the given MapOfStrings object. The MapOfStrings object takes ownership...
Definition: mapofstrings.c:44
bool MapOfStrings_AddArray(MapOfStrings *map, const char *key, const char **value)
Add a key/value association to the given MapOfStrings object, where the value is provided as a NULL-t...
Definition: mapofstrings.c:77
Represents a list of pointers to zero-terminated strings that are to remain constant and never delete...
Represents an entry in the MapOfStrings structure, associating a string "key" with a StringList "valu...
ConstStringList * value
The "value" that is a ConstStringList object.
const char * key
A string that is associated with the value field.
Represents a list of structures that map strings to ConstStringList objects.
MapOfStringsEntry * entries
List of MapOfStringsEntry for each mapping.
size_t entries_count
Number of items in the entries list.