5bebf9b7ed00900ef7ff07914bc922860897ff63
[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  *  The abstract data type ident.
31  *
32  *  An ident repraesents an unique string. The == operator
33  *  is sufficient to compare two idents.
34  */
35 typedef const struct set_entry ident;
36
37 /**
38  *  Store a string and create an ident.
39  *
40  *  Stores a string in the ident module and returns a handle for the string.
41  *  Copies the string.
42  *
43  * @param str - the string (or whatever) which shall be stored
44  * @param len - the length of the data in bytes
45  *
46  * @return id - a handle for the generated ident
47  *
48  * @see id_to_str(), id_to_strlen()
49  */
50 INLINE ident      *id_from_str (const char *str, int len);
51
52 /**
53  * Returns a string represented by an ident.
54  *
55  * Returns the string represented by id. This string is not
56  * NULL terminated! The string may not be changed.
57  *
58  * @param id - the ident
59  *
60  * @return cp - a string
61  *
62  * @see id_from_str(), id_to_strlen()
63  */
64 INLINE const char *id_to_str   (ident *id);
65
66 /**
67  * Returns the length of the string represented by an ident.
68  *
69  * @param id - the ident
70  *
71  * @return len - the length of the string
72  *
73  * @see id_from_str(), id_to_str()
74  */
75 INLINE int  id_to_strlen(ident *id);
76
77 /**
78  * Returns true if prefix is a prefix of an ident.
79  *
80  * @param prefix - the prefix
81  * @param id     - the ident
82  *
83  * @see id_from_str(), id_to_str(), id_is_prefix()
84  */
85 int id_is_prefix (ident *prefix, ident *id);
86
87 /**
88  * Returns true if suffix is a suffix of an ident.
89  *
90  * @param suffix - the suffix
91  * @param id     - the ident
92  *
93  * @see id_from_str(), id_to_str(), id_is_prefix()
94  */
95 int id_is_suffix (ident *suffix, ident *id);
96
97 /**
98  * Prints the ident to stdout.
99  *
100  * @param id - The ident to be printed.
101  *
102  * @return
103  *    number of btes written
104  *
105  * @see id_from_str(), id_to_str(), id_is_prefix(), fprint_id()
106  */
107 int print_id (ident *id);
108
109 /**
110  * Prints the ident to the file passed.
111  *
112  * @param F  - file pointer to print the ident to.
113  * @param id - The ident to print and the file.
114  *
115  * @return
116  *    number of btes written
117  *
118  * @see id_from_str(), id_to_str(), id_is_prefix(), print_id()
119  */
120 int fprint_id (FILE *F, ident *id);
121
122 # endif /* _IDENT_H_ */