Objectively
Ultra-lightweight object oriented framework for GNU C.
Loading...
Searching...
No Matches
Dictionary.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Array.h>
27#include <Objectively/Object.h>
28
34typedef struct Dictionary Dictionary;
35typedef struct DictionaryInterface DictionaryInterface;
36
45
54
60struct Dictionary {
61
66
71 DictionaryInterface *interface;
72
77 size_t capacity;
78
82 size_t count;
83
88 ident *elements;
89};
90
91
95struct DictionaryInterface {
96
100 ObjectInterface objectInterface;
101
109 void (*addEntriesFromDictionary)(Dictionary *self, const Dictionary *dictionary);
110
117 Array *(*allKeys)(const Dictionary *self);
118
125 Array *(*allObjects)(const Dictionary *self);
126
134 bool (*containsKey)(const Dictionary *self, const ident key);
135
143 bool (*containsKeyPath)(const Dictionary *self, const char *path);
144
152 Dictionary *(*dictionary)(void);
153
162 Dictionary *(*dictionaryWithCapacity)(size_t capacity);
163
172 Dictionary *(*dictionaryWithDictionary)(const Dictionary *dictionary);
173
182 Dictionary *(*dictionaryWithObjectsAndKeys)(ident obj, ...);
183
193 void (*enumerateObjectsAndKeys)(const Dictionary *self, DictionaryEnumerator enumerator, ident data);
194
204 Dictionary *(*filterObjectsAndKeys)(const Dictionary *self, DictionaryPredicate predicate, ident data);
205
213 Dictionary *(*init)(Dictionary *self);
214
223 Dictionary *(*initWithCapacity)(Dictionary *self, size_t capacity);
224
233 Dictionary *(*initWithDictionary)(Dictionary *self, const Dictionary *dictionary);
234
242 Dictionary *(*initWithObjectsAndKeys)(Dictionary *self, ...);
243
251 ident (*objectForKey)(const Dictionary *self, const ident key);
252
260 ident (*objectForKeyPath)(const Dictionary *self, const char *path);
261
272 ident (*objectForKeyPathWithClass)(const Dictionary *self, const char *path, const Class *clazz);
273
280 void (*removeAllObjects)(Dictionary *self);
281
290 void (*removeAllObjectsWithEnumerator)(Dictionary *self, DictionaryEnumerator enumerator, ident data);
291
299 void (*removeObjectForKey)(Dictionary *self, const ident key);
300
308 void (*removeObjectForKeyPath)(Dictionary *self, const char *path);
309
318 void (*setObjectForKey)(Dictionary *self, const ident obj, const ident key);
319
328 void (*setObjectForKeyPath)(Dictionary *self, const ident obj, const char *path);
329
336 void (*setObjectsForKeyPaths)(Dictionary *self, ...);
337
344 void (*setObjectsForKeys)(Dictionary *self, ...);
345
346};
347
Arrays.
#define obj
static Data * data(void)
Definition Data.c:286
static Dictionary * dictionary(void)
Definition Dictionary.c:242
void(* DictionaryEnumerator)(const Dictionary *dictionary, ident obj, ident key, ident data)
A function type for Dictionary enumeration (iteration).
Definition Dictionary.h:44
OBJECTIVELY_EXPORT Class * _Dictionary(void)
Definition Dictionary.c:762
bool(* DictionaryPredicate)(ident obj, ident key, ident data)
A function pointer for Dictionary filtering.
Definition Dictionary.h:53
Object is the root Class of The Objectively Class hierarchy.
void * ident
The identity type, similar to Objective-C id.
Definition Types.h:49
#define OBJECTIVELY_EXPORT
Definition Types.h:36
Arrays.
Definition Array.h:56
The runtime representation of a Class.
Definition Class.h:95
Key-value stores.
Definition Dictionary.h:60
Object object
The superclass.
Definition Dictionary.h:65
DictionaryInterface * interface
The interface.
Definition Dictionary.h:71
size_t count
The count of elements.
Definition Dictionary.h:82
Object is the root Class of The Objectively Class hierarchy.
Definition Object.h:46