Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
symap.h
Go to the documentation of this file.
1/*
2 Copyright 2011-2014 David Robillard <http://drobilla.net>
3
4 Permission to use, copy, modify, and/or distribute this software for any
5 purpose with or without fee is hereby granted, provided that the above
6 copyright notice and this permission notice appear in all copies.
7
8 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
26#ifndef SYMAP_H
27#define SYMAP_H
28
29#include <stdint.h>
30
31#define ZSYMAP (ZRYTHM->symap)
32
33typedef struct Symap
34{
39 char ** symbols;
40
44 uint32_t * index;
45
49 uint32_t size;
50} Symap;
51
55Symap *
56symap_new (void);
57
61void
63
67uint32_t
68symap_try_map (Symap * map, const char * sym);
69
75uint32_t
76symap_map (Symap * map, const char * sym);
77
83const char *
84symap_unmap (Symap * map, uint32_t id);
85
86#endif /* SYMAP_H */
Definition symap.h:34
char ** symbols
Unsorted array of strings, such that the symbol for ID i is found at symbols[i - 1].
Definition symap.h:39
uint32_t * index
Array of IDs, sorted by corresponding string in symbols.
Definition symap.h:44
uint32_t size
Number of symbols (number of items in symbols and index).
Definition symap.h:49
const char * symap_unmap(Symap *map, uint32_t id)
Unmap a symbol ID back to a symbol, or NULL if no such ID exists.
uint32_t symap_map(Symap *map, const char *sym)
Map a string to a symbol ID.
void symap_free(Symap *map)
Free a symbol map.
Symap * symap_new(void)
Create a new symbol map.
uint32_t symap_try_map(Symap *map, const char *sym)
Map a string to a symbol ID if it is already mapped, otherwise return 0.