3 * File name: ir/common/ident_t.h
4 * Purpose: Data type for unique names.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 1999-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * Declarations for identifiers in the firm library
17 * Identifiers are used in the firm library. This is the interface to it.
26 # include "firm_common.h"
31 * The abstract data type ident.
33 * An ident represents an unique string. The == operator
34 * is sufficient to compare two idents.
36 typedef const struct set_entry ident;
39 * Store a string and create an ident.
41 * Stores a string in the ident module and returns a handle for the string.
43 * Copies the string. @p str must be zero terminated
45 * @param str - the string which shall be stored
47 * @return id - a handle for the generated ident
49 * @see get_id_str(), get_id_strlen()
51 ident *new_id_from_str (const char *str);
54 * Store a string and create an ident.
56 * Stores a string in the ident module and returns a handle for the string.
58 * Copies the string. This version can take non-zero-terminated strings
60 * @param str - the string (or whatever) which shall be stored
61 * @param len - the length of the data in bytes
63 * @return id - a handle for the generated ident
65 * @see new_get_id_str(), get_id_strlen()
67 INLINE ident *id_from_str (const char *str, int len);
70 * Returns a string represented by an ident.
72 * Returns the string represented by id. This string is
73 * NULL terminated. The string may not be changed.
75 * @param id - the ident
77 * @return cp - a string
79 * @see new_get_id_str(), id_from_str(), get_id_strlen()
81 INLINE const char *get_id_str (ident *id);
82 #define id_to_str get_id_str
85 * Returns the length of the string represented by an ident.
87 * @param id - the ident
89 * @return len - the length of the string
91 * @see new_get_id_str(), id_from_str(), get_id_str()
93 INLINE int get_id_strlen(ident *id);
94 #define id_to_strlen get_id_strlen
96 * Returns true if prefix is a prefix of an ident.
98 * @param prefix - the prefix
99 * @param id - the ident
101 * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix()
103 int id_is_prefix (ident *prefix, ident *id);
106 * Returns true if suffix is a suffix of an ident.
108 * @param suffix - the suffix
109 * @param id - the ident
111 * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix()
113 int id_is_suffix (ident *suffix, ident *id);
116 * Returns true if infix is a contained in id. (Can be suffix or prefix)
118 * @param infix - the infix
119 * @param id - the ident to search in
121 * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix()
123 //int id_contains(ident *infix, ident *id);
126 * Return true if an ident contains a given character.
128 * @param id - the ident
129 * @param c - the character
131 * @see new_get_id_str(), id_from_str(), get_id_str()
133 int id_contains_char (ident *id, char c);
136 * Prints the ident to stdout.
138 * @param id - The ident to be printed.
141 * number of btes written
143 * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix(), fprint_id()
145 int print_id (ident *id);
148 * Prints the ident to the file passed.
150 * @param F - file pointer to print the ident to.
151 * @param id - The ident to print and the file.
154 * number of btes written
156 * @see new_get_id_str(), id_from_str(), get_id_str(), id_is_prefix(), print_id()
158 int fprint_id (FILE *F, ident *id);
160 # endif /* _IDENT_H_ */