e03d2e6fb95990986fea7ead18c653b9da3b1ac2
[libfirm] / ir / ident / ident.h
1 /* Declarations for ident.
2    Copyright (C) 1995, 1996 Markus Armbruster */
3
4 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
5 ** All rights reserved.
6 **
7 ** Authors: Martin Trapp, Christian Schaefer
8 */
9
10 /* $Id$ */
11
12 # ifndef _IDENT_H_
13 # define _IDENT_H_
14
15 # include <stdio.h>
16 # include <assert.h>
17 # include "firm_common.h"
18
19 /****h* libfirm/ident
20  *
21  * NAME
22  *   ident -- identifiers in the firm library
23  * NOTES
24  *  Identifiers are used in the firm library. This is the interface to it.
25  ******
26  */
27
28 /* Identifiers */
29 /****s* ident/ident
30  *
31  * NAME
32  *  ident - the abstract data type ident
33  * SOURCE
34  */
35 typedef const struct set_entry ident;
36 /*****/
37
38 /****f* ident/id_from_str
39  *
40  * NAME
41  *  id_from_str - store a string and create an ident
42  * SYNOPSIS
43  *  ident *id = id_from_str (const char *str, int len);
44  * FUNCTION
45  *  Stores a string in the ident module and returns a handle for the string.
46  *  Copies the string.
47  * INPUTS
48  *  str - the string (or whatever) which shall be stored
49  *  len - the length of the data in bytes
50  * RESULT
51  *  id - a handle for the generated ident
52  * SEE ALSO
53  *  id_to_str, id_to_strlen
54  ***
55  */
56 INLINE ident      *id_from_str (const char *str, int len);
57
58 /****f* ident/id_to_str
59  *
60  * NAME
61  *  id_to_str - return a string represented by an ident
62  * SYNOPSIS
63  *  char *cp = id_to_str (ident *id);
64  * FUNCTION
65  *  Returns the string cp represented by id. This string cp is not
66  *  Null terminated!  The string may not be changed.
67  * INPUTS
68  *  id - the ident
69  * RESULT
70  *  cp - a string
71  * SEE ALSO
72  *  id_from_str, id_to_strlen
73  ***
74  */
75 INLINE const char *id_to_str   (ident *id);
76
77 /****f* ident/id_to_strlen
78  *
79  * NAME
80  *  id_to_strlen - return the length of a string represented by an ident
81  * SYNOPSIS
82  *  int len = id_to_strlen (ident *id);
83  * FUNCTION
84  *  Returns the length of string represented by id.
85  * INPUTS
86  *  id - the ident
87  * RESULT
88  *  len - the length of the string
89  * SEE ALSO
90  *  id_from_str, id_to_str
91  ***
92  */
93 INLINE int  id_to_strlen(ident *id);
94
95 /****f* ident/id_is_suffix
96  *
97  * NAME
98  *
99  * SYNOPSIS
100  *  int id_is_prefix (ident *prefix, ident *id);
101  * FUNCTION
102  *  Returns true if prefix is prefix of id.
103  * INPUTS
104  *  prefix - the prefix
105  *  id - the ident
106  * SEE ALSO
107  *  id_from_str, id_to_str, id_is_prefix
108  ***
109  */
110 /*  */
111 int id_is_prefix (ident *prefix, ident *id);
112
113 /****f* ident/id_is_suffix
114  *
115  * NAME
116  *
117  * SYNOPSIS
118  *  int id_is_suffix (ident *suffix, ident *id);
119  * FUNCTION
120  *  Returns true if suffix is suffix of id.
121  * INPUTS
122  *  suffix - the suffix
123  *  id - the ident
124  * SEE ALSO
125  *  id_from_str, id_to_str, id_is_prefix
126  ***
127  */
128 /*  */
129 int id_is_suffix (ident *suffix, ident *id);
130
131 /****f* ident/print_id
132  *
133  * NAME
134  *
135  * SYNOPSIS
136  *  int print_id (ident *id);
137  * FUNCTION
138  *  Prints the ident to stdout.
139  * INPUTS
140  *  The ident to print.
141  * SEE ALSO
142  *  id_from_str, id_to_str, id_is_prefix, fprint_id
143  ***
144  */
145 /*  */
146 int print_id (ident *id);
147
148 /****f* ident/fprint_id
149  *
150  * NAME
151  *
152  * SYNOPSIS
153  *  int fprint_id (FILE *f, ident *id);
154  * FUNCTION
155  *  Prints the ident to the file passed.
156  * INPUTS
157  *  The ident to print and the file.
158  * SEE ALSO
159  *  id_from_str, id_to_str, id_is_prefix, print_id
160  ***
161  */
162 /*  */
163 int fprint_id (FILE *F, ident *id);
164
165
166 # endif /* _IDENT_H_ */