1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2018 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "output/group-item.h"
23 #include "libpspp/compiler.h"
24 #include "libpspp/str.h"
25 #include "output/driver.h"
26 #include "output/output-item-provider.h"
28 #include "gl/xalloc.h"
31 #define _(msgid) gettext (msgid)
33 struct group_open_item *
34 group_open_item_create (const char *command_name, const char *label)
36 return group_open_item_create_nocopy (
37 xstrdup_if_nonnull (command_name),
38 xstrdup_if_nonnull (label));
41 struct group_open_item *
42 group_open_item_create_nocopy (char *command_name, char *label)
44 struct group_open_item *item = xmalloc (sizeof *item);
45 *item = (struct group_open_item) {
46 .output_item = OUTPUT_ITEM_INITIALIZER (&group_open_item_class),
47 .output_item.label = label,
48 .output_item.command_name = command_name,
53 /* Submits ITEM to the configured output drivers, and transfers ownership to
54 the output subsystem. */
56 group_open_item_submit (struct group_open_item *item)
58 output_submit (&item->output_item);
62 group_open_item_get_label (const struct output_item *output_item)
64 struct group_open_item *item = to_group_open_item (output_item);
66 return (item->output_item.command_name
67 ? item->output_item.command_name
72 group_open_item_destroy (struct output_item *output_item)
74 struct group_open_item *item = to_group_open_item (output_item);
79 const struct output_item_class group_open_item_class =
81 group_open_item_get_label,
82 group_open_item_destroy,
85 struct group_close_item *
86 group_close_item_create (void)
88 struct group_close_item *item = xmalloc (sizeof *item);
89 *item = (struct group_close_item) {
90 .output_item = OUTPUT_ITEM_INITIALIZER (&group_close_item_class),
95 /* Submits ITEM to the configured output drivers, and transfers ownership to
96 the output subsystem. */
98 group_close_item_submit (struct group_close_item *item)
100 output_submit (&item->output_item);
104 group_close_item_get_label (const struct output_item *output_item UNUSED)
106 /* Not marked for translation: user should never see it. */
107 return "Group Close";
111 group_close_item_destroy (struct output_item *output_item)
113 struct group_close_item *item = to_group_close_item (output_item);
118 const struct output_item_class group_close_item_class =
120 group_close_item_get_label,
121 group_close_item_destroy,