/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/Map.h

  • Committer: Gustav Hartvigsson
  • Date: 2013-09-09 21:06:09 UTC
  • mfrom: (19 simpletypesystem)
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: gustav.hartvigsson@gmail.com-20130909210609-jqyy0z02vhe00kq0
* Merging from local branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 * @file
32
32
 */
33
33
 
34
 
#include "SimpleTypeSystem.h"
35
34
#include "baseobject.h"
 
35
#include "Func.h"
36
36
#include <stdbool.h>
37
37
 
38
38
/** @brief
61
61
 * Data structure representing an SMapItem
62
62
 */
63
63
struct _SMapItem {
64
 
  void * key; /** The Key */
65
 
  void * value; /** The Value */
 
64
  void * key; /**< The Key */
 
65
  void * value; /**< The Value */
66
66
};
67
67
 
68
68
/** @brief
69
69
 * Data structure representing an SMap
70
70
 */
71
71
struct _SMap {
72
 
  SBaseObjectInstance parent; /** The parent instance */
73
 
  SMapPrivate * priv; /** Private data pointer */
 
72
  SBaseObjectInstance parent; /**< The parent instance */
 
73
  SMapPrivate * priv; /**< Private data pointer */
74
74
};
75
75
 
76
76
struct _SMapClass {
77
77
  SBaseObjectClass parentclass;
78
 
  bool CompFunc is_equal; /** method to check if items are equal. */
 
78
  CompFunc is_equal; /** method to check if items are equal. */
 
79
  MethodFunc free_key;
 
80
  MethodFunc free_value;
79
81
};
80
82
 
81
83
/* -------------------------------
88
90
 *
89
91
 * @param key The key to be added to the item.
90
92
 * @param value The value to be added to the item.
 
93
 * @param free_key The function to be used to free the key.
 
94
 * @param free_value The function to be used to free the value.
91
95
 */
92
96
SMapItem * s_map_item_new (void * key, void * value);
93
97
 
95
99
 * Frees a SMapItem.
96
100
 * 
97
101
 * @param self the item to be freed.
 
102
 * @param free_key The function to be used to free the key.
 
103
 * @param free_value The function to be used to free the value.
98
104
 */
99
 
void s_map_item_free (SMapItem * self);
 
105
void s_map_item_free (SMapItem * self, MethodFunc free_key,
 
106
                                       MethodFunc free_value);
100
107
 
101
108
/* -------------------------------
102
109
 * The SMap functions.
109
116
 * @param comp_func tells the SMap object if the key already exists when
110
117
 * adding key/value pares or when searching after a key when retrieving a value.
111
118
 *
112
 
 * A the @c CompFunc returns true if the first and second parameters are equal,
 
119
 * The @c CompFunc returns true if the first and second parameters are equal,
113
120
 * otherwise false.
 
121
 *
 
122
 * @todo
 
123
 * Check if free_key and/or free_value is null and set them to something
 
124
 * appropriate.
114
125
 */
115
 
SMap * s_map_new ( CompFunc comp_func );
 
126
SMap * s_map_new ( CompFunc comp_func, MethodFunc free_key,
 
127
                                       MethodFunc free_value);
116
128
 
117
129
/** @breif
118
130
 * This function frees an instance of an SMap.
125
137
 * This function adds a key/value pair to an SMap.
126
138
 * 
127
139
 * @param self the SMap to add the key/value pair to.
128
 
 * @param key the key that is used to 
 
140
 * @param key the key that is used to
 
141
 *
 
142
 * @todo
 
143
 *  make it return false on failure, or some other nastiness.
129
144
 */
130
145
void s_map_add (SMap * self ,void * key, void * value);
131
146
 
138
153
 */
139
154
void * s_map_get (SMap * self, void * key);
140
155
 
 
156
/**
 
157
 * @todo
 
158
 */
 
159
void  s_map_remove (SMap * self, void * key);
 
160
 
141
161
#endif