2000-09-05 Eric Christopher <echristo@cygnus.com>
[binutils.git] / include / dyn-string.h
blob103f9472538f24508c05fdce92c58c1a7e69b946
1 /* An abstract string datatype.
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Mark Mitchell (mark@markmitchell.com).
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 typedef struct dyn_string
25 int allocated; /* The amount of space allocated for the string. */
26 int length; /* The actual length of the string. */
27 char *s; /* The string itself, NUL-terminated. */
28 }* dyn_string_t;
30 /* The length STR, in bytes, not including the terminating NUL. */
31 #define dyn_string_length(STR) \
32 ((STR)->length)
34 /* The NTBS in which the contents of STR are stored. */
35 #define dyn_string_buf(STR) \
36 ((STR)->s)
38 /* Compare DS1 to DS2 with strcmp. */
39 #define dyn_string_compare(DS1, DS2) \
40 (strcmp ((DS1)->s, (DS2)->s))
43 /* dyn_string functions are used in the demangling implementation
44 included in the G++ runtime library. To prevent collisions with
45 names in user programs, the functions that are used in the
46 demangler are given implementation-reserved names. */
48 #ifdef IN_LIBGCC2
50 #define dyn_string_init __cxa_dyn_string_init
51 #define dyn_string_new __cxa_dyn_string_new
52 #define dyn_string_delete __cxa_dyn_string_delete
53 #define dyn_string_release __cxa_dyn_string_release
54 #define dyn_string_resize __cxa_dyn_string_resize
55 #define dyn_string_clear __cxa_dyn_string_clear
56 #define dyn_string_copy __cxa_dyn_string_copy
57 #define dyn_string_copy_cstr __cxa_dyn_string_copy_cstr
58 #define dyn_string_prepend __cxa_dyn_string_prepend
59 #define dyn_string_prepend_cstr __cxa_dyn_string_prepend_cstr
60 #define dyn_string_insert __cxa_dyn_string_insert
61 #define dyn_string_insert_cstr __cxa_dyn_string_insert_cstr
62 #define dyn_string_append __cxa_dyn_string_append
63 #define dyn_string_append_cstr __cxa_dyn_string_append_cstr
64 #define dyn_string_append_char __cxa_dyn_string_append_char
65 #define dyn_string_substring __cxa_dyn_string_substring
66 #define dyn_string_eq __cxa_dyn_string_eq
68 #endif /* IN_LIBGCC2 */
71 extern int dyn_string_init PARAMS ((struct dyn_string *, int));
72 extern dyn_string_t dyn_string_new PARAMS ((int));
73 extern void dyn_string_delete PARAMS ((dyn_string_t));
74 extern char *dyn_string_release PARAMS ((dyn_string_t));
75 extern dyn_string_t dyn_string_resize PARAMS ((dyn_string_t, int));
76 extern void dyn_string_clear PARAMS ((dyn_string_t));
77 extern int dyn_string_copy PARAMS ((dyn_string_t, dyn_string_t));
78 extern int dyn_string_copy_cstr PARAMS ((dyn_string_t, const char *));
79 extern int dyn_string_prepend PARAMS ((dyn_string_t, dyn_string_t));
80 extern int dyn_string_prepend_cstr PARAMS ((dyn_string_t, const char *));
81 extern int dyn_string_insert PARAMS ((dyn_string_t, int,
82 dyn_string_t));
83 extern int dyn_string_insert_cstr PARAMS ((dyn_string_t, int,
84 const char *));
85 extern int dyn_string_append PARAMS ((dyn_string_t, dyn_string_t));
86 extern int dyn_string_append_cstr
87 PARAMS ((dyn_string_t, const char *));
88 extern int dyn_string_append_char
89 PARAMS ((dyn_string_t, int));
90 extern int dyn_string_substring PARAMS ((dyn_string_t,
91 dyn_string_t, int, int));
92 extern int dyn_string_eq PARAMS ((dyn_string_t, dyn_string_t));