46b31fb2370476d2fa733d48767326959a65575f
[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  *  Copies the string.
49  *
50  * @param str - the string (or whatever) which shall be stored
51  * @param len - the length of the data in bytes
52  *
53  * @return id - a handle for the generated ident
54  *
55  * @see id_to_str(), id_to_strlen()
56  */
57 INLINE ident      *id_from_str (const char *str, int len);
58
59 /**
60  * Returns a string represented by an ident.
61  *
62  * Returns the string represented by id. This string is
63  * NULL terminated. The string may not be changed.
64  *
65  * @param id - the ident
66  *
67  * @return cp - a string
68  *
69  * @see id_from_str(), id_to_strlen()
70  */
71 INLINE const char *id_to_str   (ident *id);
72
73 /**
74  * Returns the length of the string represented by an ident.
75  *
76  * @param id - the ident
77  *
78  * @return len - the length of the string
79  *
80  * @see id_from_str(), id_to_str()
81  */
82 INLINE int  id_to_strlen(ident *id);
83
84 /**
85  * Returns true if prefix is a prefix of an ident.
86  *
87  * @param prefix - the prefix
88  * @param id     - the ident
89  *
90  * @see id_from_str(), id_to_str(), id_is_prefix()
91  */
92 int id_is_prefix (ident *prefix, ident *id);
93
94 /**
95  * Returns true if suffix is a suffix of an ident.
96  *
97  * @param suffix - the suffix
98  * @param id     - the ident
99  *
100  * @see id_from_str(), id_to_str(), id_is_prefix()
101  */
102 int id_is_suffix (ident *suffix, ident *id);
103
104 /**
105  * Prints the ident to stdout.
106  *
107  * @param id - The ident to be printed.
108  *
109  * @return
110  *    number of btes written
111  *
112  * @see id_from_str(), id_to_str(), id_is_prefix(), fprint_id()
113  */
114 int print_id (ident *id);
115
116 /**
117  * Prints the ident to the file passed.
118  *
119  * @param F  - file pointer to print the ident to.
120  * @param id - The ident to print and the file.
121  *
122  * @return
123  *    number of btes written
124  *
125  * @see id_from_str(), id_to_str(), id_is_prefix(), print_id()
126  */
127 int fprint_id (FILE *F, ident *id);
128
129 # endif /* _IDENT_H_ */