blob: 9615cd64ee77a7cbecc9295e67bd7cdf6310c476 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001/* An abstract string datatype.
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Mark Mitchell (mark@markmitchell.com).
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21#ifndef __DYN_STRING_H
22#define __DYN_STRING_H
23
24
25typedef 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
74extern int dyn_string_init PARAMS ((struct dyn_string *, int));
75extern dyn_string_t dyn_string_new PARAMS ((int));
76extern void dyn_string_delete PARAMS ((dyn_string_t));
77extern char *dyn_string_release PARAMS ((dyn_string_t));
78extern dyn_string_t dyn_string_resize PARAMS ((dyn_string_t, int));
79extern void dyn_string_clear PARAMS ((dyn_string_t));
80extern int dyn_string_copy PARAMS ((dyn_string_t, dyn_string_t));
81extern int dyn_string_copy_cstr PARAMS ((dyn_string_t, const char *));
82extern int dyn_string_prepend PARAMS ((dyn_string_t, dyn_string_t));
83extern int dyn_string_prepend_cstr PARAMS ((dyn_string_t, const char *));
84extern int dyn_string_insert PARAMS ((dyn_string_t, int,
85 dyn_string_t));
86extern int dyn_string_insert_cstr PARAMS ((dyn_string_t, int,
87 const char *));
88extern int dyn_string_insert_char PARAMS ((dyn_string_t, int, int));
89extern int dyn_string_append PARAMS ((dyn_string_t, dyn_string_t));
90extern int dyn_string_append_cstr PARAMS ((dyn_string_t, const char *));
91extern int dyn_string_append_char PARAMS ((dyn_string_t, int));
92extern int dyn_string_substring PARAMS ((dyn_string_t,
93 dyn_string_t, int, int));
94extern int dyn_string_eq PARAMS ((dyn_string_t, dyn_string_t));
95
96#endif