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);
53 /** Store a string and create an ident.
55 * Stores a string in the ident module and returns a handle for the string.
56 * Copies the string. This version takes non-zero-terminated strings.
58 * @param str - the string (or whatever) which shall be stored
59 * @param len - the length of the data in bytes
61 * @return id - a handle for the generated ident
63 * @see new_id_from_str(), get_id_strlen()
65 ident *new_id_from_chars (const char *str, int len);
68 * Returns a string represented by an ident.
70 * Returns the string represented by id. This string is
71 * NULL terminated. The string may not be changed.
73 * @param id - the ident
75 * @return cp - a string
77 * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
79 const char *get_id_str (ident *id);
82 * Returns the length of the string represented by an ident.
84 * @param id - the ident
86 * @return len - the length of the string
88 * @see new_id_from_str(), new_id_from_chars(), get_id_str()
90 int get_id_strlen(ident *id);
92 * Returns true if prefix is a prefix of an ident.
94 * @param prefix - the prefix
95 * @param id - the ident
97 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
99 int id_is_prefix (ident *prefix, ident *id);
102 * Returns true if suffix is a suffix of an ident.
104 * @param suffix - the suffix
105 * @param id - the ident
107 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
109 int id_is_suffix (ident *suffix, ident *id);
112 * Returns true if infix is a contained in id. (Can be suffix or prefix)
114 * @param infix - the infix
115 * @param id - the ident to search in
117 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
119 /* int id_contains(ident *infix, ident *id); */
122 * Return true if an ident contains a given character.
124 * @param id - the ident
125 * @param c - the character
127 * @see new_id_from_str(), new_id_from_chars(), get_id_str()
129 int id_contains_char (ident *id, char c);
132 * Prints the ident to stdout.
134 * @param id - The ident to be printed.
137 * number of bytes written
139 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix(), fprint_id()
141 int print_id (ident *id);
144 * Prints the ident to the file passed.
146 * @param F - file pointer to print the ident to.
147 * @param id - The ident to print and the file.
150 * number of btes written
152 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix(), print_id()
154 int fprint_id (FILE *F, ident *id);
156 # endif /* _IDENT_H_ */