Added void casts to shut up warnings
[libfirm] / ir / ident / ident.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/common/ident_t.h
4  * Purpose:     Data type for unique names.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1999-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 /**
13  * @file ident.h
14  *
15  * Declarations for identifiers in the firm library
16  *
17  * Identifiers are used in the firm library. This is the interface to it.
18  */
19
20
21 # ifndef _IDENT_H_
22 # define _IDENT_H_
23
24 # include <stdio.h>
25 # include <assert.h>
26 # include "firm_common.h"
27
28 /* Identifiers */
29
30 /**
31  *  The abstract data type ident.
32  *
33  *  An ident represents an unique string. The == operator
34  *  is sufficient to compare two idents.
35  */
36 typedef const struct set_entry ident;
37
38 /**
39  *  Store a string and create an ident.
40  *
41  *  Stores a string in the ident module and returns a handle for the string.
42  *
43  *  Copies the string. @p str must be zero terminated
44  *
45  * @param str - the string which shall be stored
46  *
47  * @return id - a handle for the generated ident
48  *
49  * @see get_id_str(), get_id_strlen()
50  */
51 ident *new_id_from_str (const char *str);
52
53 /**
54  *  Store a string and create an ident.
55  *
56  *  Stores a string in the ident module and returns a handle for the string.
57  *
58  *  Copies the string. This version can take non-zero-terminated strings
59  *
60  * @param str - the string (or whatever) which shall be stored
61  * @param len - the length of the data in bytes
62  *
63  * @return id - a handle for the generated ident
64  *
65  * @see new_get_id_str(), get_id_strlen()
66  */
67 INLINE ident *id_from_str (const char *str, int len);
68
69 /**
70  * Returns a string represented by an ident.
71  *
72  * Returns the string represented by id. This string is
73  * NULL terminated. The string may not be changed.
74  *
75  * @param id - the ident
76  *
77  * @return cp - a string
78  *
79  * @see new_get_id_str(), id_from_str(), get_id_strlen()
80  */
81 INLINE const char *get_id_str  (ident *id);
82 //INLINE const char *get_id_str  (ident *id);    /* No more supported */
83 #define id_to_str  get_id_str
84
85 /**
86  * Returns the length of the string represented by an ident.
87  *
88  * @param id - the ident
89  *
90  * @return len - the length of the string
91  *
92  * @see new_get_id_str(), id_from_str(), get_id_str()
93  */
94 INLINE int  get_id_strlen(ident *id);
95 #define id_to_strlen get_id_strlen
96 /**
97  * Returns true if prefix is a prefix of an ident.
98  *
99  * @param prefix - the prefix
100  * @param id     - the ident
101  *
102  * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix()
103  */
104 int id_is_prefix (ident *prefix, ident *id);
105
106 /**
107  * Returns true if suffix is a suffix of an ident.
108  *
109  * @param suffix - the suffix
110  * @param id     - the ident
111  *
112  * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix()
113  */
114 int id_is_suffix (ident *suffix, ident *id);
115
116 /**
117  * Return true if an ident contains a given character.
118  *
119  * @param id     - the ident
120  * @param c      - the character
121  *
122  * @see new_get_id_str(), id_from_str(), get_id_str()
123  */
124 int id_contains_char (ident *id, char c);
125
126 /**
127  * Prints the ident to stdout.
128  *
129  * @param id - The ident to be printed.
130  *
131  * @return
132  *    number of btes written
133  *
134  * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix(), fprint_id()
135  */
136 int print_id (ident *id);
137
138 /**
139  * Prints the ident to the file passed.
140  *
141  * @param F  - file pointer to print the ident to.
142  * @param id - The ident to print and the file.
143  *
144  * @return
145  *    number of btes written
146  *
147  * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix(), print_id()
148  */
149 int fprint_id (FILE *F, ident *id);
150
151 # endif /* _IDENT_H_ */