Class-ify ui_out_level
[deliverable/binutils-gdb.git] / gdb / ui-out.c
1 /* Output generating routines for GDB.
2
3 Copyright (C) 1999-2016 Free Software Foundation, Inc.
4
5 Contributed by Cygnus Solutions.
6 Written by Fernando Nasser for Cygnus.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22
23 #include "defs.h"
24 #include "expression.h" /* For language.h */
25 #include "language.h"
26 #include "ui-out.h"
27
28 #include <vector>
29 #include <memory>
30 #include <string>
31
32 /* A header of a ui_out_table. */
33
34 class ui_out_hdr
35 {
36 public:
37
38 explicit ui_out_hdr (int number, int min_width, ui_align alignment,
39 const std::string &name, const std::string &header)
40 : m_number (number),
41 m_min_width (min_width),
42 m_alignment (alignment),
43 m_name (name),
44 m_header (header)
45 {
46 }
47
48 int number () const
49 {
50 return m_number;
51 }
52
53 int min_width () const
54 {
55 return m_min_width;
56 }
57
58 ui_align alignment () const
59 {
60 return m_alignment;
61 }
62
63 const std::string &header () const
64 {
65 return m_header;
66 }
67
68 const std::string &name () const
69 {
70 return m_name;
71 }
72
73 private:
74
75 /* The number of the table column this header represents, 1-based. */
76 int m_number;
77
78 /* Minimal column width in characters. May or may not be applicable,
79 depending on the actual implementation of ui_out. */
80 int m_min_width;
81
82 /* Alignment of the content in the column. May or may not be applicable,
83 depending on the actual implementation of ui_out. */
84 ui_align m_alignment;
85
86 /* Internal column name, used to internally refer to the column. */
87 std::string m_name;
88
89 /* Printed header text of the column. */
90 std::string m_header;
91 };
92
93 /* A level of nesting (either a list or a tuple) in a ui_out output. */
94
95 class ui_out_level
96 {
97 public:
98
99 explicit ui_out_level (ui_out_type type)
100 : m_type (type),
101 m_field_count (0)
102 {
103 }
104
105 ui_out_type type () const
106 {
107 return m_type;
108 }
109
110 int field_count () const
111 {
112 return m_field_count;
113 }
114
115 void inc_field_count ()
116 {
117 m_field_count++;
118 }
119
120 private:
121
122 /* The type of this level. */
123 ui_out_type m_type;
124
125 /* Count each field; the first element is for non-list fields. */
126 int m_field_count;
127 };
128
129
130 /* Tables are special. Maintain a separate structure that tracks
131 their state. At present an output can only contain a single table
132 but that restriction might eventually be lifted. */
133
134 struct ui_out_table
135 {
136 /* If on, a table is being generated. */
137 int flag;
138
139 /* If on, the body of a table is being generated. If off, the table
140 header is being generated. */
141 int body_flag;
142
143 /* The level at which each entry of the table is to be found. A row
144 (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one
145 above that of the table. */
146 int entry_level;
147
148 /* Number of table columns (as specified in the table_begin call). */
149 int columns;
150
151 /* String identifying the table (as specified in the table_begin
152 call). */
153 std::string id;
154
155 /* Pointers to the column headers. */
156 std::vector<std::unique_ptr<ui_out_hdr>> headers;
157
158 /* Iterator over the headers vector, used when printing successive fields. */
159 std::vector<std::unique_ptr<ui_out_hdr>>::const_iterator headers_iterator;
160
161 };
162
163
164 /* The ui_out structure */
165
166 struct ui_out
167 {
168 int flags;
169 /* Specific implementation of ui-out. */
170 const struct ui_out_impl *impl;
171 void *data;
172
173 /* Current level. */
174 int level;
175
176 /* Vector to store and track the ui-out levels. */
177 std::vector<std::unique_ptr<ui_out_level>> levels;
178
179 /* A table, if any. At present only a single table is supported. */
180 struct ui_out_table table;
181 };
182
183 /* The current (inner most) level. */
184 static ui_out_level *
185 current_level (struct ui_out *uiout)
186 {
187 return uiout->levels[uiout->level].get ();
188 }
189
190 /* Create a new level, of TYPE. Return the new level's index. */
191 static int
192 push_level (struct ui_out *uiout,
193 enum ui_out_type type)
194 {
195 std::unique_ptr<ui_out_level> level (new ui_out_level (type));
196
197 uiout->levels.push_back (std::move (level));
198 uiout->level++;
199
200 return uiout->level;
201 }
202
203 /* Discard the current level, return the discarded level's index.
204 TYPE is the type of the level being discarded. */
205 static int
206 pop_level (struct ui_out *uiout,
207 enum ui_out_type type)
208 {
209 /* We had better not underflow the buffer. */
210 gdb_assert (uiout->level > 0);
211 gdb_assert (current_level (uiout)->type () == type);
212
213 uiout->levels.pop_back ();
214 uiout->level--;
215
216 return uiout->level + 1;
217 }
218
219 /* These are the interfaces to implementation functions. */
220
221 static void uo_table_begin (struct ui_out *uiout, int nbrofcols,
222 int nr_rows, const char *tblid);
223 static void uo_table_body (struct ui_out *uiout);
224 static void uo_table_end (struct ui_out *uiout);
225 static void uo_table_header (struct ui_out *uiout, int width,
226 enum ui_align align,
227 const std::string &col_name,
228 const std::string &col_hdr);
229 static void uo_begin (struct ui_out *uiout,
230 enum ui_out_type type,
231 int level, const char *id);
232 static void uo_end (struct ui_out *uiout,
233 enum ui_out_type type,
234 int level);
235 static void uo_field_int (struct ui_out *uiout, int fldno, int width,
236 enum ui_align align, const char *fldname, int value);
237 static void uo_field_skip (struct ui_out *uiout, int fldno, int width,
238 enum ui_align align, const char *fldname);
239 static void uo_field_fmt (struct ui_out *uiout, int fldno, int width,
240 enum ui_align align, const char *fldname,
241 const char *format, va_list args)
242 ATTRIBUTE_PRINTF (6, 0);
243 static void uo_spaces (struct ui_out *uiout, int numspaces);
244 static void uo_text (struct ui_out *uiout, const char *string);
245 static void uo_message (struct ui_out *uiout,
246 const char *format, va_list args)
247 ATTRIBUTE_PRINTF (2, 0);
248 static void uo_wrap_hint (struct ui_out *uiout, const char *identstring);
249 static void uo_flush (struct ui_out *uiout);
250 static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream);
251
252 /* Prototypes for local functions */
253
254 static void append_header_to_list (struct ui_out *uiout, int width,
255 enum ui_align alignment,
256 const std::string &col_name,
257 const std::string &col_hdr);
258 static int get_next_header (struct ui_out *uiout, int *colno, int *width,
259 enum ui_align *alignment, const char **col_hdr);
260 static void clear_header_list (struct ui_out *uiout);
261 static void clear_table (struct ui_out *uiout);
262 static void verify_field (struct ui_out *uiout, int *fldno, int *width,
263 enum ui_align *align);
264
265 /* exported functions (ui_out API) */
266
267 /* Mark beginning of a table. */
268
269 static void
270 ui_out_table_begin (struct ui_out *uiout, int nbrofcols,
271 int nr_rows, const std::string &tblid)
272 {
273 if (uiout->table.flag)
274 internal_error (__FILE__, __LINE__,
275 _("tables cannot be nested; table_begin found before \
276 previous table_end."));
277
278 uiout->table.flag = 1;
279 uiout->table.body_flag = 0;
280 uiout->table.entry_level = uiout->level + 1;
281 uiout->table.columns = nbrofcols;
282 uiout->table.id = tblid;
283
284 clear_header_list (uiout);
285
286 uo_table_begin (uiout, nbrofcols, nr_rows, uiout->table.id.c_str ());
287 }
288
289 void
290 ui_out_table_body (struct ui_out *uiout)
291 {
292 if (!uiout->table.flag)
293 internal_error (__FILE__, __LINE__,
294 _("table_body outside a table is not valid; it must be \
295 after a table_begin and before a table_end."));
296 if (uiout->table.body_flag)
297 internal_error (__FILE__, __LINE__,
298 _("extra table_body call not allowed; there must be \
299 only one table_body after a table_begin and before a table_end."));
300 if (uiout->table.headers.size () != uiout->table.columns)
301 internal_error (__FILE__, __LINE__,
302 _("number of headers differ from number of table \
303 columns."));
304
305 uiout->table.body_flag = 1;
306
307 uo_table_body (uiout);
308 }
309
310 static void
311 ui_out_table_end (struct ui_out *uiout)
312 {
313 if (!uiout->table.flag)
314 internal_error (__FILE__, __LINE__,
315 _("misplaced table_end or missing table_begin."));
316
317 uiout->table.entry_level = 0;
318 uiout->table.body_flag = 0;
319 uiout->table.flag = 0;
320
321 uo_table_end (uiout);
322 clear_table (uiout);
323 }
324
325 void
326 ui_out_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
327 const std::string &col_name, const std::string &col_hdr)
328 {
329 if (!uiout->table.flag || uiout->table.body_flag)
330 internal_error (__FILE__, __LINE__,
331 _("table header must be specified after table_begin \
332 and before table_body."));
333
334 append_header_to_list (uiout, width, alignment, col_name, col_hdr);
335
336 uo_table_header (uiout, width, alignment, col_name, col_hdr);
337 }
338
339 static void
340 do_cleanup_table_end (void *data)
341 {
342 struct ui_out *ui_out = (struct ui_out *) data;
343
344 ui_out_table_end (ui_out);
345 }
346
347 struct cleanup *
348 make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, int nr_cols,
349 int nr_rows, const char *tblid)
350 {
351 ui_out_table_begin (ui_out, nr_cols, nr_rows, tblid);
352 return make_cleanup (do_cleanup_table_end, ui_out);
353 }
354
355 void
356 ui_out_begin (struct ui_out *uiout,
357 enum ui_out_type type,
358 const char *id)
359 {
360 int new_level;
361
362 if (uiout->table.flag && !uiout->table.body_flag)
363 internal_error (__FILE__, __LINE__,
364 _("table header or table_body expected; lists must be \
365 specified after table_body."));
366
367 /* Be careful to verify the ``field'' before the new tuple/list is
368 pushed onto the stack. That way the containing list/table/row is
369 verified and not the newly created tuple/list. This verification
370 is needed (at least) for the case where a table row entry
371 contains either a tuple/list. For that case bookkeeping such as
372 updating the column count or advancing to the next heading still
373 needs to be performed. */
374 {
375 int fldno;
376 int width;
377 enum ui_align align;
378
379 verify_field (uiout, &fldno, &width, &align);
380 }
381
382 new_level = push_level (uiout, type);
383
384 /* If the push puts us at the same level as a table row entry, we've
385 got a new table row. Put the header pointer back to the start. */
386 if (uiout->table.body_flag
387 && uiout->table.entry_level == new_level)
388 uiout->table.headers_iterator = uiout->table.headers.begin ();
389
390 uo_begin (uiout, type, new_level, id);
391 }
392
393 void
394 ui_out_end (struct ui_out *uiout,
395 enum ui_out_type type)
396 {
397 int old_level = pop_level (uiout, type);
398
399 uo_end (uiout, type, old_level);
400 }
401
402 struct ui_out_end_cleanup_data
403 {
404 struct ui_out *uiout;
405 enum ui_out_type type;
406 };
407
408 static void
409 do_cleanup_end (void *data)
410 {
411 struct ui_out_end_cleanup_data *end_cleanup_data
412 = (struct ui_out_end_cleanup_data *) data;
413
414 ui_out_end (end_cleanup_data->uiout, end_cleanup_data->type);
415 xfree (end_cleanup_data);
416 }
417
418 static struct cleanup *
419 make_cleanup_ui_out_end (struct ui_out *uiout,
420 enum ui_out_type type)
421 {
422 struct ui_out_end_cleanup_data *end_cleanup_data;
423
424 end_cleanup_data = XNEW (struct ui_out_end_cleanup_data);
425 end_cleanup_data->uiout = uiout;
426 end_cleanup_data->type = type;
427 return make_cleanup (do_cleanup_end, end_cleanup_data);
428 }
429
430 struct cleanup *
431 make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout,
432 const char *id)
433 {
434 ui_out_begin (uiout, ui_out_type_tuple, id);
435 return make_cleanup_ui_out_end (uiout, ui_out_type_tuple);
436 }
437
438 struct cleanup *
439 make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
440 const char *id)
441 {
442 ui_out_begin (uiout, ui_out_type_list, id);
443 return make_cleanup_ui_out_end (uiout, ui_out_type_list);
444 }
445
446 void
447 ui_out_field_int (struct ui_out *uiout,
448 const char *fldname,
449 int value)
450 {
451 int fldno;
452 int width;
453 enum ui_align align;
454
455 verify_field (uiout, &fldno, &width, &align);
456
457 uo_field_int (uiout, fldno, width, align, fldname, value);
458 }
459
460 void
461 ui_out_field_fmt_int (struct ui_out *uiout,
462 int input_width,
463 enum ui_align input_align,
464 const char *fldname,
465 int value)
466 {
467 int fldno;
468 int width;
469 enum ui_align align;
470
471 verify_field (uiout, &fldno, &width, &align);
472
473 uo_field_int (uiout, fldno, input_width, input_align, fldname, value);
474 }
475
476 /* Documented in ui-out.h. */
477
478 void
479 ui_out_field_core_addr (struct ui_out *uiout,
480 const char *fldname,
481 struct gdbarch *gdbarch,
482 CORE_ADDR address)
483 {
484 ui_out_field_string (uiout, fldname,
485 print_core_address (gdbarch, address));
486 }
487
488 void
489 ui_out_field_stream (struct ui_out *uiout,
490 const char *fldname,
491 struct ui_file *stream)
492 {
493 std::string buffer = ui_file_as_string (stream);
494
495 if (!buffer.empty ())
496 ui_out_field_string (uiout, fldname, buffer.c_str ());
497 else
498 ui_out_field_skip (uiout, fldname);
499 ui_file_rewind (stream);
500 }
501
502 /* Used to omit a field. */
503
504 void
505 ui_out_field_skip (struct ui_out *uiout,
506 const char *fldname)
507 {
508 int fldno;
509 int width;
510 enum ui_align align;
511
512 verify_field (uiout, &fldno, &width, &align);
513
514 uo_field_skip (uiout, fldno, width, align, fldname);
515 }
516
517 void
518 ui_out_field_string (struct ui_out *uiout,
519 const char *fldname,
520 const char *string)
521 {
522 int fldno;
523 int width;
524 enum ui_align align;
525
526 verify_field (uiout, &fldno, &width, &align);
527
528 uo_field_string (uiout, fldno, width, align, fldname, string);
529 }
530
531 /* VARARGS */
532 void
533 ui_out_field_fmt (struct ui_out *uiout,
534 const char *fldname,
535 const char *format, ...)
536 {
537 va_list args;
538 int fldno;
539 int width;
540 enum ui_align align;
541
542 /* Will not align, but has to call anyway. */
543 verify_field (uiout, &fldno, &width, &align);
544
545 va_start (args, format);
546
547 uo_field_fmt (uiout, fldno, width, align, fldname, format, args);
548
549 va_end (args);
550 }
551
552 void
553 ui_out_spaces (struct ui_out *uiout, int numspaces)
554 {
555 uo_spaces (uiout, numspaces);
556 }
557
558 void
559 ui_out_text (struct ui_out *uiout,
560 const char *string)
561 {
562 uo_text (uiout, string);
563 }
564
565 void
566 ui_out_message (struct ui_out *uiout, const char *format, ...)
567 {
568 va_list args;
569
570 va_start (args, format);
571 uo_message (uiout, format, args);
572 va_end (args);
573 }
574
575 void
576 ui_out_wrap_hint (struct ui_out *uiout, const char *identstring)
577 {
578 uo_wrap_hint (uiout, identstring);
579 }
580
581 void
582 ui_out_flush (struct ui_out *uiout)
583 {
584 uo_flush (uiout);
585 }
586
587 int
588 ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream)
589 {
590 return uo_redirect (uiout, outstream);
591 }
592
593 /* Test the flags against the mask given. */
594 int
595 ui_out_test_flags (struct ui_out *uiout, int mask)
596 {
597 return (uiout->flags & mask);
598 }
599
600 int
601 ui_out_is_mi_like_p (struct ui_out *uiout)
602 {
603 return uiout->impl->is_mi_like_p;
604 }
605
606 /* Interface to the implementation functions. */
607
608 void
609 uo_table_begin (struct ui_out *uiout, int nbrofcols,
610 int nr_rows,
611 const char *tblid)
612 {
613 if (!uiout->impl->table_begin)
614 return;
615 uiout->impl->table_begin (uiout, nbrofcols, nr_rows, tblid);
616 }
617
618 void
619 uo_table_body (struct ui_out *uiout)
620 {
621 if (!uiout->impl->table_body)
622 return;
623 uiout->impl->table_body (uiout);
624 }
625
626 void
627 uo_table_end (struct ui_out *uiout)
628 {
629 if (!uiout->impl->table_end)
630 return;
631 uiout->impl->table_end (uiout);
632 }
633
634 void
635 uo_table_header (struct ui_out *uiout, int width, enum ui_align align,
636 const std::string &col_name, const std::string &col_hdr)
637 {
638 if (!uiout->impl->table_header)
639 return;
640 uiout->impl->table_header (uiout, width, align, col_name, col_hdr);
641 }
642
643 /* Clear the table associated with UIOUT. */
644
645 static void
646 clear_table (struct ui_out *uiout)
647 {
648 uiout->table.id.clear ();
649 clear_header_list (uiout);
650 }
651
652 void
653 uo_begin (struct ui_out *uiout,
654 enum ui_out_type type,
655 int level,
656 const char *id)
657 {
658 if (uiout->impl->begin == NULL)
659 return;
660 uiout->impl->begin (uiout, type, level, id);
661 }
662
663 void
664 uo_end (struct ui_out *uiout,
665 enum ui_out_type type,
666 int level)
667 {
668 if (uiout->impl->end == NULL)
669 return;
670 uiout->impl->end (uiout, type, level);
671 }
672
673 void
674 uo_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align align,
675 const char *fldname,
676 int value)
677 {
678 if (!uiout->impl->field_int)
679 return;
680 uiout->impl->field_int (uiout, fldno, width, align, fldname, value);
681 }
682
683 void
684 uo_field_skip (struct ui_out *uiout, int fldno, int width, enum ui_align align,
685 const char *fldname)
686 {
687 if (!uiout->impl->field_skip)
688 return;
689 uiout->impl->field_skip (uiout, fldno, width, align, fldname);
690 }
691
692 void
693 uo_field_string (struct ui_out *uiout, int fldno, int width,
694 enum ui_align align,
695 const char *fldname,
696 const char *string)
697 {
698 if (!uiout->impl->field_string)
699 return;
700 uiout->impl->field_string (uiout, fldno, width, align, fldname, string);
701 }
702
703 void
704 uo_field_fmt (struct ui_out *uiout, int fldno, int width, enum ui_align align,
705 const char *fldname,
706 const char *format,
707 va_list args)
708 {
709 if (!uiout->impl->field_fmt)
710 return;
711 uiout->impl->field_fmt (uiout, fldno, width, align, fldname, format, args);
712 }
713
714 void
715 uo_spaces (struct ui_out *uiout, int numspaces)
716 {
717 if (!uiout->impl->spaces)
718 return;
719 uiout->impl->spaces (uiout, numspaces);
720 }
721
722 void
723 uo_text (struct ui_out *uiout,
724 const char *string)
725 {
726 if (!uiout->impl->text)
727 return;
728 uiout->impl->text (uiout, string);
729 }
730
731 void
732 uo_message (struct ui_out *uiout,
733 const char *format,
734 va_list args)
735 {
736 if (!uiout->impl->message)
737 return;
738 uiout->impl->message (uiout, format, args);
739 }
740
741 void
742 uo_wrap_hint (struct ui_out *uiout, const char *identstring)
743 {
744 if (!uiout->impl->wrap_hint)
745 return;
746 uiout->impl->wrap_hint (uiout, identstring);
747 }
748
749 void
750 uo_flush (struct ui_out *uiout)
751 {
752 if (!uiout->impl->flush)
753 return;
754 uiout->impl->flush (uiout);
755 }
756
757 int
758 uo_redirect (struct ui_out *uiout, struct ui_file *outstream)
759 {
760 if (!uiout->impl->redirect)
761 return -1;
762 return uiout->impl->redirect (uiout, outstream);
763 }
764
765 /* local functions */
766
767 /* List of column headers manipulation routines. */
768
769 static void
770 clear_header_list (struct ui_out *uiout)
771 {
772 uiout->table.headers.clear ();
773 uiout->table.headers_iterator = uiout->table.headers.end ();
774 }
775
776 static void
777 append_header_to_list (struct ui_out *uiout,
778 int width,
779 enum ui_align alignment,
780 const std::string &col_name,
781 const std::string &col_hdr)
782 {
783 std::unique_ptr<ui_out_hdr> temphdr(
784 new ui_out_hdr (uiout->table.headers.size () + 1, width,
785 alignment, col_name, col_hdr));
786
787 uiout->table.headers.push_back (std::move (temphdr));
788 }
789
790 /* Extract the format information for the NEXT header and advance
791 the header pointer. Return 0 if there was no next header. */
792
793 static int
794 get_next_header (struct ui_out *uiout,
795 int *colno,
796 int *width,
797 enum ui_align *alignment,
798 const char **col_hdr)
799 {
800 /* There may be no headers at all or we may have used all columns. */
801 if (uiout->table.headers_iterator == uiout->table.headers.end ())
802 return 0;
803
804 ui_out_hdr *hdr = uiout->table.headers_iterator->get ();
805
806 *colno = hdr->number ();
807 *width = hdr->min_width ();
808 *alignment = hdr->alignment ();
809 *col_hdr = hdr->header ().c_str ();
810
811 /* Advance the header pointer to the next entry. */
812 uiout->table.headers_iterator++;
813
814 return 1;
815 }
816
817
818 /* Verify that the field/tuple/list is correctly positioned. Return
819 the field number and corresponding alignment (if
820 available/applicable). */
821
822 static void
823 verify_field (struct ui_out *uiout, int *fldno, int *width,
824 enum ui_align *align)
825 {
826 ui_out_level *current = current_level (uiout);
827 const char *text;
828
829 if (uiout->table.flag)
830 {
831 if (!uiout->table.body_flag)
832 internal_error (__FILE__, __LINE__,
833 _("table_body missing; table fields must be \
834 specified after table_body and inside a list."));
835 /* NOTE: cagney/2001-12-08: There was a check here to ensure
836 that this code was only executed when uiout->level was
837 greater than zero. That no longer applies - this code is run
838 before each table row tuple is started and at that point the
839 level is zero. */
840 }
841
842 current->inc_field_count ();
843
844 if (uiout->table.body_flag
845 && uiout->table.entry_level == uiout->level
846 && get_next_header (uiout, fldno, width, align, &text))
847 {
848 if (*fldno != current->field_count ())
849 internal_error (__FILE__, __LINE__,
850 _("ui-out internal error in handling headers."));
851 }
852 else
853 {
854 *width = 0;
855 *align = ui_noalign;
856 *fldno = current->field_count ();
857 }
858 }
859
860
861 /* Access to ui-out members data. */
862
863 void *
864 ui_out_data (struct ui_out *uiout)
865 {
866 return uiout->data;
867 }
868
869 /* Access table field parameters. */
870 int
871 ui_out_query_field (struct ui_out *uiout, int colno,
872 int *width, int *alignment, const char **col_name)
873 {
874 if (!uiout->table.flag)
875 return 0;
876
877 /* Column numbers are 1-based, so convert to 0-based index. */
878 int index = colno - 1;
879
880 if (index >= 0 && index < uiout->table.headers.size ())
881 {
882 ui_out_hdr *hdr = uiout->table.headers[index].get ();
883
884 gdb_assert (colno == hdr->number ());
885
886 *width = hdr->min_width ();
887 *alignment = hdr->alignment ();
888 *col_name = hdr->name ().c_str ();
889
890 return 1;
891 }
892 else
893 return 0;
894 }
895
896 /* Initialize private members at startup. */
897
898 struct ui_out *
899 ui_out_new (const struct ui_out_impl *impl, void *data,
900 int flags)
901 {
902 struct ui_out *uiout = new ui_out ();
903
904 uiout->data = data;
905 uiout->impl = impl;
906 uiout->flags = flags;
907 uiout->table.flag = 0;
908 uiout->table.body_flag = 0;
909 uiout->level = 0;
910
911 /* Create uiout->level 0, the default level. */
912 std::unique_ptr<ui_out_level> level (new ui_out_level (ui_out_type_tuple));
913 uiout->levels.push_back (std::move (level));
914
915 uiout->table.headers_iterator = uiout->table.headers.end ();
916
917 return uiout;
918 }
This page took 0.054624 seconds and 5 git commands to generate.