Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2012 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 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*============================================================================
41  * Macro definitions
42  *============================================================================*/
43 
44 /*============================================================================
45  * Type definitions
46  *============================================================================*/
47 
49 
50 /*============================================================================
51  * Global variables
52  *============================================================================*/
53 
54 /*=============================================================================
55  * Public function prototypes for Fortran API
56  *============================================================================*/
57 
58 /*=============================================================================
59  * Public function prototypes
60  *============================================================================*/
61 
62 /*----------------------------------------------------------------------------
63  * Create empty name to id map.
64  *
65  * returns:
66  * pointer to newly initialized map structure.
67  *----------------------------------------------------------------------------*/
68 
71 
72 /*----------------------------------------------------------------------------
73  * Destroy name to id map structure.
74  *
75  * parameters:
76  * m <-> pointer to map structure.
77  *----------------------------------------------------------------------------*/
78 
79 void
81 
82 /*----------------------------------------------------------------------------
83  * Find id matching a key, inserting key if not already present.
84  *
85  * parameters:
86  * m <-> pointer to map structure
87  * key <-- character string (key)
88  *
89  * returns:
90  * id matching key (already present or newly inserted)
91  *----------------------------------------------------------------------------*/
92 
93 int
95  const char *key);
96 
97 /*----------------------------------------------------------------------------
98  * Return id matching a key, or -1 if not present.
99  *
100  *
101  * parameters:
102  * m <-- pointer to map structure
103  * key <-- character string (key)
104  *
105  * returns:
106  * id matching key, or -1.
107  *----------------------------------------------------------------------------*/
108 
109 int
111  const char *key);
112 
113 /*----------------------------------------------------------------------------
114  * Return a key name in a map matching a given id.
115  *
116  * parameters:
117  * m <-- pointer to map structure.
118  * id <-- key id
119  *
120  * returns:
121  * pointer to key.
122  *----------------------------------------------------------------------------*/
123 
124 const char *
126  size_t id);
127 
128 /*----------------------------------------------------------------------------
129  * Return the size of a map.
130  *
131  * parameters:
132  * m <-- pointer to map structure.
133  *
134  * returns:
135  * number of entries in map.
136  *----------------------------------------------------------------------------*/
137 
138 size_t
140 
141 /*----------------------------------------------------------------------------
142  * Return key in a map for a given index position.
143  *
144  * parameters:
145  * m <-- pointer to map structure.
146  * index <-- key index
147  *
148  * returns:
149  * pointer to key.
150  *----------------------------------------------------------------------------*/
151 
152 const char *
154  size_t index);
155 
156 /*----------------------------------------------------------------------------*/
157 
159 
160 #endif /* __CS_MAP_H__ */
cs_map_name_to_id_t * cs_map_name_to_id_create(void)
Definition: cs_map.c:195
Definition: cs_map.c:77
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
typedefBEGIN_C_DECLS struct _cs_map_name_to_id_t cs_map_name_to_id_t
Definition: cs_map.h:48
const char * cs_map_name_to_id_reverse(const cs_map_name_to_id_t *m, size_t id)
Definition: cs_map.c:344
void cs_map_name_to_id_destroy(cs_map_name_to_id_t **m)
Definition: cs_map.c:224
const char * cs_map_name_to_id_key(const cs_map_name_to_id_t *m, size_t index)
Definition: cs_map.c:390
char ** key
Definition: cs_map.c:86
#define END_C_DECLS
Definition: cs_defs.h:366
size_t cs_map_name_to_id_size(const cs_map_name_to_id_t *m)
Definition: cs_map.c:368
int cs_map_name_to_id_try(const cs_map_name_to_id_t *m, const char *key)
Definition: cs_map.c:300
int cs_map_name_to_id(cs_map_name_to_id_t *m, const char *key)
Definition: cs_map.c:256