Add constructor and destructor to demangle_parse_info
[deliverable/binutils-gdb.git] / gdb / ui-file.h
1 /* UI_FILE - a generic STDIO like output stream.
2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef UI_FILE_H
20 #define UI_FILE_H
21
22 struct obstack;
23 struct ui_file;
24
25 #include <string>
26
27 /* Create a generic ui_file object with null methods. */
28
29 extern struct ui_file *ui_file_new (void);
30
31 /* Override methods used by specific implementations of a UI_FILE
32 object. */
33
34 typedef void (ui_file_flush_ftype) (struct ui_file *stream);
35 extern void set_ui_file_flush (struct ui_file *stream,
36 ui_file_flush_ftype *flush);
37
38 /* NOTE: Both fputs and write methods are available. Default
39 implementations that mapping one onto the other are included. */
40 typedef void (ui_file_write_ftype) (struct ui_file *stream,
41 const char *buf, long length_buf);
42 extern void set_ui_file_write (struct ui_file *stream,
43 ui_file_write_ftype *fputs);
44
45 typedef void (ui_file_fputs_ftype) (const char *, struct ui_file *stream);
46 extern void set_ui_file_fputs (struct ui_file *stream,
47 ui_file_fputs_ftype *fputs);
48
49 /* This version of "write" is safe for use in signal handlers.
50 It's not guaranteed that all existing output will have been
51 flushed first.
52 Implementations are also free to ignore some or all of the request.
53 fputs_async is not provided as the async versions are rarely used,
54 no point in having both for a rarely used interface. */
55 typedef void (ui_file_write_async_safe_ftype)
56 (struct ui_file *stream, const char *buf, long length_buf);
57 extern void set_ui_file_write_async_safe
58 (struct ui_file *stream, ui_file_write_async_safe_ftype *write_async_safe);
59
60 typedef long (ui_file_read_ftype) (struct ui_file *stream,
61 char *buf, long length_buf);
62 extern void set_ui_file_read (struct ui_file *stream,
63 ui_file_read_ftype *fread);
64
65 typedef int (ui_file_isatty_ftype) (struct ui_file *stream);
66 extern void set_ui_file_isatty (struct ui_file *stream,
67 ui_file_isatty_ftype *isatty);
68
69 typedef void (ui_file_rewind_ftype) (struct ui_file *stream);
70 extern void set_ui_file_rewind (struct ui_file *stream,
71 ui_file_rewind_ftype *rewind);
72
73 typedef void (ui_file_put_method_ftype) (void *object, const char *buffer,
74 long length_buffer);
75 typedef void (ui_file_put_ftype) (struct ui_file *stream,
76 ui_file_put_method_ftype *method,
77 void *context);
78 extern void set_ui_file_put (struct ui_file *stream, ui_file_put_ftype *put);
79
80 typedef void (ui_file_delete_ftype) (struct ui_file * stream);
81 extern void set_ui_file_data (struct ui_file *stream, void *data,
82 ui_file_delete_ftype *to_delete);
83
84 typedef int (ui_file_fseek_ftype) (struct ui_file *stream, long offset,
85 int whence);
86 extern void set_ui_file_fseek (struct ui_file *stream,
87 ui_file_fseek_ftype *fseek_ptr);
88
89 extern void *ui_file_data (struct ui_file *file);
90
91
92 extern void gdb_flush (struct ui_file *);
93
94 extern void ui_file_delete (struct ui_file *stream);
95
96 extern void ui_file_rewind (struct ui_file *stream);
97
98 extern int ui_file_isatty (struct ui_file *);
99
100 extern void ui_file_write (struct ui_file *file, const char *buf,
101 long length_buf);
102
103 /* A wrapper for ui_file_write that is suitable for use by
104 ui_file_put. */
105
106 extern void ui_file_write_for_put (void *data, const char *buffer,
107 long length_buffer);
108
109 extern void ui_file_write_async_safe (struct ui_file *file, const char *buf,
110 long length_buf);
111
112 /* NOTE: copies left to right. */
113 extern void ui_file_put (struct ui_file *src,
114 ui_file_put_method_ftype *write, void *dest);
115
116 /* Returns a freshly allocated buffer containing the entire contents
117 of FILE (as determined by ui_file_put()) with a NUL character
118 appended. LENGTH, if not NULL, is set to the size of the buffer
119 minus that appended NUL. */
120 extern char *ui_file_xstrdup (struct ui_file *file, long *length);
121
122 /* Returns a std::string containing the entire contents of FILE (as
123 determined by ui_file_put()). */
124 extern std::string ui_file_as_string (struct ui_file *file);
125
126 /* Similar to ui_file_xstrdup, but return a new string allocated on
127 OBSTACK. */
128 extern char *ui_file_obsavestring (struct ui_file *file,
129 struct obstack *obstack, long *length);
130
131 extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
132
133 extern int ui_file_fseek (struct ui_file *file, long offset, int whence);
134
135 /* Create/open a memory based file. Can be used as a scratch buffer
136 for collecting output. */
137 extern struct ui_file *mem_fileopen (void);
138
139
140
141 /* Open/create a STDIO based UI_FILE using the already open FILE. */
142 extern struct ui_file *stdio_fileopen (FILE *file);
143
144 /* Likewise, for stderr-like streams. */
145 extern struct ui_file *stderr_fileopen (FILE *file);
146
147
148 /* Open NAME returning an STDIO based UI_FILE. */
149 extern struct ui_file *gdb_fopen (const char *name, const char *mode);
150
151 /* Create a file which writes to both ONE and TWO. CLOSE_ONE
152 and CLOSE_TWO indicate whether the original files should be
153 closed when the new file is closed. */
154 extern struct ui_file *tee_file_new (struct ui_file *one,
155 int close_one,
156 struct ui_file *two,
157 int close_two);
158 #endif
This page took 0.03309 seconds and 4 git commands to generate.