1 /* Declarations for ident.
2 Copyright (C) 1995, 1996 Markus Armbruster */
4 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
7 * Authors: Martin Trapp, Christian Schaefer
13 * Declarations for identifiers in the firm library
15 * Identifiers are used in the firm library. This is the interface to it.
25 # include "firm_common.h"
30 * Initialises the ident handling.
32 * Must be called before any id_*() function can be called.
37 * The abstract data type ident.
39 * An ident represents an unique string. The == operator
40 * is sufficient to compare two idents.
42 typedef const struct set_entry ident;
45 * Store a string and create an ident.
47 * Stores a string in the ident module and returns a handle for the string.
49 * Copies the string. @p str must be zero terminated
51 * @param str - the string which shall be stored
53 * @return id - a handle for the generated ident
55 * @see id_to_str(), id_to_strlen()
57 ident *new_id_from_str (const char *str);
60 * Store a string and create an ident.
62 * Stores a string in the ident module and returns a handle for the string.
64 * Copies the string. This version can take non-zero-terminated strings
66 * @param str - the string (or whatever) which shall be stored
67 * @param len - the length of the data in bytes
69 * @return id - a handle for the generated ident
71 * @see new_id_to_str(), id_to_strlen()
73 INLINE ident *id_from_str (const char *str, int len);
76 * Returns a string represented by an ident.
78 * Returns the string represented by id. This string is
79 * NULL terminated. The string may not be changed.
81 * @param id - the ident
83 * @return cp - a string
85 * @see new_id_to_str(), id_from_str(), id_to_strlen()
87 INLINE const char *id_to_str (ident *id);
90 * Returns the length of the string represented by an ident.
92 * @param id - the ident
94 * @return len - the length of the string
96 * @see new_id_to_str(), id_from_str(), id_to_str()
98 INLINE int id_to_strlen(ident *id);
101 * Returns true if prefix is a prefix of an ident.
103 * @param prefix - the prefix
104 * @param id - the ident
106 * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix()
108 int id_is_prefix (ident *prefix, ident *id);
111 * Returns true if suffix is a suffix of an ident.
113 * @param suffix - the suffix
114 * @param id - the ident
116 * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix()
118 int id_is_suffix (ident *suffix, ident *id);
121 * Return true if an ident contains a given character.
123 * @param id - the ident
124 * @param c - the character
126 * @see new_id_to_str(), id_from_str(), id_to_str()
128 int id_contains_char (ident *id, char c);
131 * Prints the ident to stdout.
133 * @param id - The ident to be printed.
136 * number of btes written
138 * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix(), fprint_id()
140 int print_id (ident *id);
143 * Prints the ident to the file passed.
145 * @param F - file pointer to print the ident to.
146 * @param id - The ident to print and the file.
149 * number of btes written
151 * @see new_id_to_str(), id_from_str(), id_to_str(), id_is_prefix(), print_id()
153 int fprint_id (FILE *F, ident *id);
155 # endif /* _IDENT_H_ */