sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | /* An abstract string datatype. |
| 2 | Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. |
| 3 | Contributed by Mark Mitchell (mark@markmitchell.com). |
| 4 | |
| 5 | This file is part of GCC. |
| 6 | |
| 7 | GCC 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. |
| 11 | |
| 12 | GCC 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. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GCC; see the file COPYING. If not, write to |
| 19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
| 20 | Boston, MA 02111-1307, USA. */ |
| 21 | #ifndef __DYN_STRING_H |
| 22 | #define __DYN_STRING_H |
| 23 | |
| 24 | |
| 25 | typedef struct dyn_string |
| 26 | { |
| 27 | int allocated; /* The amount of space allocated for the string. */ |
| 28 | int length; /* The actual length of the string. */ |
| 29 | char *s; /* The string itself, NUL-terminated. */ |
| 30 | }* dyn_string_t; |
| 31 | |
| 32 | /* The length STR, in bytes, not including the terminating NUL. */ |
| 33 | #define dyn_string_length(STR) \ |
| 34 | ((STR)->length) |
| 35 | |
| 36 | /* The NTBS in which the contents of STR are stored. */ |
| 37 | #define dyn_string_buf(STR) \ |
| 38 | ((STR)->s) |
| 39 | |
| 40 | /* Compare DS1 to DS2 with strcmp. */ |
| 41 | #define dyn_string_compare(DS1, DS2) \ |
| 42 | (VG_(strcmp) ((DS1)->s, (DS2)->s)) |
| 43 | |
| 44 | |
| 45 | /* dyn_string functions are used in the demangling implementation |
| 46 | included in the G++ runtime library. To prevent collisions with |
| 47 | names in user programs, the functions that are used in the |
| 48 | demangler are given implementation-reserved names. */ |
| 49 | |
| 50 | #if 1 /* def IN_LIBGCC2 */ |
| 51 | |
| 52 | #define dyn_string_init VG_(__cxa_dyn_string_init) |
| 53 | #define dyn_string_new VG_(__cxa_dyn_string_new) |
| 54 | #define dyn_string_delete VG_(__cxa_dyn_string_delete) |
| 55 | #define dyn_string_release VG_(__cxa_dyn_string_release) |
| 56 | #define dyn_string_resize VG_(__cxa_dyn_string_resize) |
| 57 | #define dyn_string_clear VG_(__cxa_dyn_string_clear) |
| 58 | #define dyn_string_copy VG_(__cxa_dyn_string_copy) |
| 59 | #define dyn_string_copy_cstr VG_(__cxa_dyn_string_copy_cstr) |
| 60 | #define dyn_string_prepend VG_(__cxa_dyn_string_prepend) |
| 61 | #define dyn_string_prepend_cstr VG_(__cxa_dyn_string_prepend_cstr) |
| 62 | #define dyn_string_insert VG_(__cxa_dyn_string_insert) |
| 63 | #define dyn_string_insert_cstr VG_(__cxa_dyn_string_insert_cstr) |
| 64 | #define dyn_string_insert_char VG_(__cxa_dyn_string_insert_char) |
| 65 | #define dyn_string_append VG_(__cxa_dyn_string_append) |
| 66 | #define dyn_string_append_cstr VG_(__cxa_dyn_string_append_cstr) |
| 67 | #define dyn_string_append_char VG_(__cxa_dyn_string_append_char) |
| 68 | #define dyn_string_substring VG_(__cxa_dyn_string_substring) |
| 69 | #define dyn_string_eq VG_(__cxa_dyn_string_eq) |
| 70 | |
| 71 | #endif /* IN_LIBGCC2 */ |
| 72 | |
| 73 | |
| 74 | extern int dyn_string_init PARAMS ((struct dyn_string *, int)); |
| 75 | extern dyn_string_t dyn_string_new PARAMS ((int)); |
| 76 | extern void dyn_string_delete PARAMS ((dyn_string_t)); |
| 77 | extern char *dyn_string_release PARAMS ((dyn_string_t)); |
| 78 | extern dyn_string_t dyn_string_resize PARAMS ((dyn_string_t, int)); |
| 79 | extern void dyn_string_clear PARAMS ((dyn_string_t)); |
| 80 | extern int dyn_string_copy PARAMS ((dyn_string_t, dyn_string_t)); |
| 81 | extern int dyn_string_copy_cstr PARAMS ((dyn_string_t, const char *)); |
| 82 | extern int dyn_string_prepend PARAMS ((dyn_string_t, dyn_string_t)); |
| 83 | extern int dyn_string_prepend_cstr PARAMS ((dyn_string_t, const char *)); |
| 84 | extern int dyn_string_insert PARAMS ((dyn_string_t, int, |
| 85 | dyn_string_t)); |
| 86 | extern int dyn_string_insert_cstr PARAMS ((dyn_string_t, int, |
| 87 | const char *)); |
| 88 | extern int dyn_string_insert_char PARAMS ((dyn_string_t, int, int)); |
| 89 | extern int dyn_string_append PARAMS ((dyn_string_t, dyn_string_t)); |
| 90 | extern int dyn_string_append_cstr PARAMS ((dyn_string_t, const char *)); |
| 91 | extern int dyn_string_append_char PARAMS ((dyn_string_t, int)); |
| 92 | extern int dyn_string_substring PARAMS ((dyn_string_t, |
| 93 | dyn_string_t, int, int)); |
| 94 | extern int dyn_string_eq PARAMS ((dyn_string_t, dyn_string_t)); |
| 95 | |
| 96 | #endif |