1 /* 2 * gsf-output-csv.h: a GsfOutput to write .csv style files. 3 * 4 * Copyright (C) 2005-2006 Morten Welinder (terra@gnome.org) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of version 2.1 of the GNU Lesser General Public 8 * License as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 18 * USA 19 */ 20 21 #ifndef GSF_OUTPUT_CSV_H 22 #define GSF_OUTPUT_CSV_H 23 24 #include <gsf/gsf-fwd.h> 25 #include <gsf/gsf-output.h> 26 27 G_BEGIN_DECLS 28 29 /** 30 * GsfOutputCsvQuotingMode: 31 * @GSF_OUTPUT_CSV_QUOTING_MODE_NEVER: never add quotes around fields 32 * @GSF_OUTPUT_CSV_QUOTING_MODE_AUTO: add quotes around fields when needed 33 * @GSF_OUTPUT_CSV_QUOTING_MODE_ALWAYS: always add quotes around fields 34 * 35 * Controls when to add quotes around fields. 36 */ 37 typedef enum { 38 GSF_OUTPUT_CSV_QUOTING_MODE_NEVER, 39 GSF_OUTPUT_CSV_QUOTING_MODE_AUTO, 40 GSF_OUTPUT_CSV_QUOTING_MODE_ALWAYS 41 } GsfOutputCsvQuotingMode; 42 43 GType gsf_output_csv_quoting_mode_get_type (void); 44 /* void gsf_output_csv_quoting_mode_register_type (GTypeModule *module); glib dynamic types are not thread safe */ 45 46 #define GSF_OUTPUT_CSV_QUOTING_MODE_TYPE (gsf_output_csv_quoting_mode_get_type ()) 47 48 typedef struct { 49 GsfOutput output; 50 51 GsfOutput *sink; 52 53 char *quote; 54 size_t quote_len; 55 GsfOutputCsvQuotingMode quoting_mode; 56 char *quoting_triggers; 57 58 char *eol; 59 size_t eol_len; 60 char *separator; 61 size_t separator_len; 62 gboolean fields_on_line; 63 64 GString *buf; 65 } GsfOutputCsv; 66 67 #define GSF_OUTPUT_CSV_TYPE (gsf_output_csv_get_type ()) 68 #define GSF_OUTPUT_CSV(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSF_OUTPUT_CSV_TYPE, GsfOutputCsv)) 69 #define GSF_IS_OUTPUT_CSV(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSF_OUTPUT_CSV_TYPE)) 70 GType gsf_output_csv_get_type (void); 71 /* void gsf_output_csv_register_type (GTypeModule *module); glib dynamic types are not thread safe */ 72 73 gboolean gsf_output_csv_write_field (GsfOutputCsv *csv, 74 char const *field, 75 size_t len); 76 gboolean gsf_output_csv_write_eol (GsfOutputCsv *csv); 77 78 typedef struct { 79 GsfOutputClass output_class; 80 } GsfOutputCsvClass; 81 82 G_END_DECLS 83 84 #endif /* GSF_OUTPUT_CSV_H */ 85