*** empty log message ***
[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 /**
11  * @file ident.h
12  *
13  * Declarations for identifiers in the firm library
14  *
15  * Identifiers are used in the firm library. This is the interface to it.
16  */
17
18 /* $Id$ */
19
20 # ifndef _IDENT_H_
21 # define _IDENT_H_
22
23 # include <stdio.h>
24 # include <assert.h>
25 # include "firm_common.h"
26
27 /* Identifiers */
28
29 /**
30  * Initialises the ident handling.
31  *
32  * Must be called before any id_*() function can be called.
33  */
34 void id_init(void);
35
36 /**
37  *  The abstract data type ident.
38  *
39  *  An ident represents an unique string. The == operator
40  *  is sufficient to compare two idents.
41  */
42 typedef const struct set_entry ident;
43
44 /**
45  *  Store a string and create an ident.
46  *
47  *  Stores a string in the ident module and returns a handle for the string.
48  *
49  *  Copies the string. @p str must be zero terminated
50  *
51  * @param str - the string which shall be stored
52  *
53  * @return id - a handle for the generated ident
54  *
55  * @see id_to_str(), id_to_strlen()
56  */
57 ident *new_id_from_str (const char *str);
58
59 /**
60  *  Store a string and create an ident.
61  *
62  *  Stores a string in the ident module and returns a handle for the string.
63  *
64  *  Copies the string. This version can take non-zero-terminated strings
65  *
66  * @param str - the string (or whatever) which shall be stored
67  * @param len - the length of the data in bytes
68  *
69  * @return id - a handle for the generated ident
70  *
71  * @see new_id_to_str(), id_to_strlen()
72  */
73 INLINE ident      *id_from_str (const char *str, int len);
74
75 /**
76  * Returns a string represented by an ident.
77  *
78  * Returns the string represented by id. This string is
79  * NULL terminated. The string may not be changed.
80  *
81  * @param id - the ident
82  *
83  * @return cp - a string
84  *
85  * @see new_id_to_str(), id_from_str(), id_to_strlen()
86  */
87 INLINE const char *id_to_str   (ident *id);
88
89 /**
90  * Returns the length of the string represented by an ident.
91  *
92  * @param id - the ident
93  *
94  * @return len - the length of the string
95  *
96  * @see new_id_to_str(), id_from_str(), id_to_str()
97  */
98 INLINE int  id_to_strlen(ident *id);
99
100 /**
101  * Returns true if prefix is a prefix of an ident.
102  *
103  * @param prefix - the prefix
104  * @param id     - the ident
105  *
106  * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix()
107  */
108 int id_is_prefix (ident *prefix, ident *id);
109
110 /**
111  * Returns true if suffix is a suffix of an ident.
112  *
113  * @param suffix - the suffix
114  * @param id     - the ident
115  *
116  * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix()
117  */
118 int id_is_suffix (ident *suffix, ident *id);
119
120 /**
121  * Return true if an ident contains a given character.
122  *
123  * @param id     - the ident
124  * @param c      - the character
125  *
126  * @see new_id_to_str(), id_from_str(), id_to_str()
127  */
128 int id_contains_char (ident *id, char c);
129
130 /**
131  * Prints the ident to stdout.
132  *
133  * @param id - The ident to be printed.
134  *
135  * @return
136  *    number of btes written
137  *
138  * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix(), fprint_id()
139  */
140 int print_id (ident *id);
141
142 /**
143  * Prints the ident to the file passed.
144  *
145  * @param F  - file pointer to print the ident to.
146  * @param id - The ident to print and the file.
147  *
148  * @return
149  *    number of btes written
150  *
151  * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix(), print_id()
152  */
153 int fprint_id (FILE *F, ident *id);
154
155 # endif /* _IDENT_H_ */