9.2
general documentation
cs_map.h
Go to the documentation of this file.
1#ifndef CS_MAP_H
2#define CS_MAP_H
3
4/*============================================================================
5 * Map helper structures
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------
29 * Local headers
30 *----------------------------------------------------------------------------*/
31
32#include "base/cs_base.h"
33
34/*============================================================================
35 * Macro definitions
36 *============================================================================*/
37
38/*============================================================================
39 * Type definitions
40 *============================================================================*/
41
42typedef struct _cs_map_name_to_id_t cs_map_name_to_id_t;
43
44/*============================================================================
45 * Global variables
46 *============================================================================*/
47
48/*=============================================================================
49 * Public function prototypes for Fortran API
50 *============================================================================*/
51
52/*=============================================================================
53 * Public function prototypes
54 *============================================================================*/
55
56/*----------------------------------------------------------------------------
57 * Create empty name to id map.
58 *
59 * returns:
60 * pointer to newly initialized map structure.
61 *----------------------------------------------------------------------------*/
62
65
66/*----------------------------------------------------------------------------
67 * Destroy name to id map structure.
68 *
69 * parameters:
70 * m <-> pointer to map structure.
71 *----------------------------------------------------------------------------*/
72
73void
75
76/*----------------------------------------------------------------------------
77 * Find id matching a key, inserting key if not already present.
78 *
79 * parameters:
80 * m <-> pointer to map structure
81 * key <-- character string (key)
82 *
83 * returns:
84 * id matching key (already present or newly inserted)
85 *----------------------------------------------------------------------------*/
86
87int
89 const char *key);
90
91/*----------------------------------------------------------------------------
92 * Return id matching a key, or -1 if not present.
93 *
94 * parameters:
95 * m <-- pointer to map structure
96 * key <-- character string (key)
97 *
98 * returns:
99 * id matching key, or -1.
100 *----------------------------------------------------------------------------*/
101
102int
104 const char *key);
105
106/*----------------------------------------------------------------------------
107 * Return a key name in a map matching a given id.
108 *
109 * parameters:
110 * m <-- pointer to map structure.
111 * id <-- key id
112 *
113 * returns:
114 * pointer to key.
115 *----------------------------------------------------------------------------*/
116
117const char *
119 size_t id);
120
121/*----------------------------------------------------------------------------
122 * Return the size of a map.
123 *
124 * parameters:
125 * m <-- pointer to map structure.
126 *
127 * returns:
128 * number of entries in map.
129 *----------------------------------------------------------------------------*/
130
131size_t
133
134/*----------------------------------------------------------------------------
135 * Return key in a map for a given index position.
136 *
137 * parameters:
138 * m <-- pointer to map structure.
139 * index <-- key index
140 *
141 * returns:
142 * pointer to key.
143 *----------------------------------------------------------------------------*/
144
145const char *
147 size_t index);
148
149/*----------------------------------------------------------------------------*/
150
151#endif /* CS_MAP_H */
const char * cs_map_name_to_id_reverse(const cs_map_name_to_id_t *m, size_t id)
Definition: cs_map.cpp:371
struct _cs_map_name_to_id_t cs_map_name_to_id_t
Definition: cs_map.h:42
void cs_map_name_to_id_destroy(cs_map_name_to_id_t **m)
Definition: cs_map.cpp:246
int cs_map_name_to_id(cs_map_name_to_id_t *m, const char *key)
Definition: cs_map.cpp:280
cs_map_name_to_id_t * cs_map_name_to_id_create(void)
Definition: cs_map.cpp:204
const char * cs_map_name_to_id_key(const cs_map_name_to_id_t *m, size_t index)
Definition: cs_map.cpp:418
size_t cs_map_name_to_id_size(const cs_map_name_to_id_t *m)
Definition: cs_map.cpp:396
int cs_map_name_to_id_try(const cs_map_name_to_id_t *m, const char *key)
Definition: cs_map.cpp:324