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 SPDX-License-Identifier: ISC
17*/
18
28#ifndef SYMAP_H
29#define SYMAP_H
30
31#include <stdint.h>
32
33#define ZSYMAP (ZRYTHM->symap)
34
35typedef struct Symap
36{
41 char ** symbols;
42
46 uint32_t * index;
47
51 uint32_t size;
52} Symap;
53
57Symap *
58symap_new (void);
59
63void
65
69uint32_t
70symap_try_map (Symap * map, const char * sym);
71
77uint32_t
78symap_map (Symap * map, const char * sym);
79
85const char *
86symap_unmap (Symap * map, uint32_t id);
87
88#endif /* SYMAP_H */
Definition symap.h:36
char ** symbols
Unsorted array of strings, such that the symbol for ID i is found at symbols[i - 1].
Definition symap.h:41
uint32_t * index
Array of IDs, sorted by corresponding string in symbols.
Definition symap.h:46
uint32_t size
Number of symbols (number of items in symbols and index).
Definition symap.h:51
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.