X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fspreadsheet-reader.h;h=37b249d4e9c4af6c4884ac7b7da8b2d4259e6b53;hb=17339b8ef2b6c9c403ceccb9f0ab534a943f92e1;hp=9f84fa1abeb9eab212e9f6c7af13585c8191095a;hpb=1d05dd7fce36ca16a644705b0b05fd144f52463e;p=pspp diff --git a/src/data/spreadsheet-reader.h b/src/data/spreadsheet-reader.h index 9f84fa1abe..37b249d4e9 100644 --- a/src/data/spreadsheet-reader.h +++ b/src/data/spreadsheet-reader.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2010 Free Software Foundation, Inc. + Copyright (C) 2007, 2010, 2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,9 @@ #define SPREADSHEET_READ_H 1 #include +#include + +struct casereeader; /* Default width of string variables. */ #define SPREADSHEET_DEFAULT_WIDTH 8 @@ -31,11 +34,6 @@ struct spreadsheet_read_options char *sheet_name ; /* The name of the sheet to open (in UTF-8) */ int sheet_index ; /* The index of the sheet to open (only used if sheet_name is NULL) */ char *cell_range ; /* The cell range (in UTF-8) */ -}; - - -struct spreadsheet_read_info -{ bool read_names ; /* True if the first row is to be used as the names of the variables */ int asw ; /* The width of string variables in the created dictionary */ }; @@ -48,9 +46,9 @@ bool convert_cell_ref (const char *ref, int *coli, int *rowi); -#define _xml(X) (CHAR_CAST (const xmlChar *, X)) +#define _xml(X) (CHAR_CAST (const xmlChar *, (X))) -#define _xmlchar_to_int(X) (atoi(CHAR_CAST (const char *, X))) +#define _xmlchar_to_int(X) ((X) ? atoi (CHAR_CAST (const char *, (X))) : -1) enum spreadsheet_type { @@ -59,6 +57,7 @@ enum spreadsheet_type SPREADSHEET_ODS }; + struct spreadsheet { char *file_name; @@ -66,27 +65,30 @@ struct spreadsheet enum spreadsheet_type type; /* The total number of sheets in the "workbook" */ - int sheets; + int n_sheets; - /* The dictionary */ - struct dictionary *dict; + /* The dictionary for client's reference. + Client must clone if it needs a permanent or modifiable copy. */ + const struct dictionary *dict; + + int ref_cnt; }; -char *create_cell_ref (int col0, int row0, int coli, int rowi); +struct casereader * spreadsheet_make_reader (struct spreadsheet *, const struct spreadsheet_read_options *); + +const char * spreadsheet_get_sheet_name (struct spreadsheet *s, int n) OPTIMIZE(2); +char * spreadsheet_get_sheet_range (struct spreadsheet *s, int n) OPTIMIZE(2); + + +char * create_cell_ref (int col0, int row0); +char *create_cell_range (int col0, int row0, int coli, int rowi); + +void spreadsheet_unref (struct spreadsheet *); +void spreadsheet_ref (struct spreadsheet *); + -/* - Attempt to open the file called FILENAME as a spreadsheet. - It is not known a priori, what type of spreadsheet FILENAME is, or - even if it is a spreadsheet at all. - If it fails to open, then it will return NULL without any error or - warning messages. - */ -struct spreadsheet * spreadsheet_open (const char *filename); -void spreadsheet_close (struct spreadsheet *); -struct casereeader; -struct casereader * spreadsheet_make_reader (struct spreadsheet *s); #define SPREADSHEET_CAST(X) ((struct spreadsheet *)(X))