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