source: git/src/exportfilter.h @ b0a4292

main
Last change on this file since b0a4292 was c1419df, checked in by Olly Betts <olly@…>, 3 weeks ago

Microsoft Windows: Call _commit(fileno(f))

Attempt to commit data for writable streams before closing.

Untested fix for #147, reported by Philip Schuchardt.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/* exportfilter.h
2 * Export to GIS formats, CAD formats, and other formats.
3 */
4
5/* Copyright (C) 2005-2024 Olly Betts
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see
19 * <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef SURVEX_EXPORTFILTER_H
23#define SURVEX_EXPORTFILTER_H
24
25#include <stdio.h>
26#include <wx/wx.h>
27
28#include "img_for_survex.h"
29
30class ExportFilter {
31  protected:
32    FILE * fh = nullptr;
33
34  public:
35    ExportFilter() { }
36    // FIXME: deal with errors closing file... (safe_fclose?)
37    virtual ~ExportFilter() {
38        if (fh) {
39#ifdef _WIN32
40            // Untested attempt to address https://trac.survex.com/ticket/147
41            _commit(fileno(fh));
42#endif
43            fclose(fh);
44        }
45    }
46    virtual const int * passes() const;
47    virtual bool fopen(const wxString& fnm_out) {
48        fh = wxFopen(fnm_out.fn_str(), wxT("wb"));
49        return (fh != NULL);
50    }
51    virtual void header(const char* title,
52                        time_t datestamp,
53                        double min_x, double min_y, double min_z,
54                        double max_x, double max_y, double max_z);
55    virtual void start_pass(int);
56    virtual void line(const img_point *, const img_point *, unsigned, bool);
57    virtual void label(const img_point* p, const wxString& s,
58                       int sflags, int type) = 0;
59    virtual void cross(const img_point *, const wxString&, int sflags);
60    virtual void xsect(const img_point *, double, double, double);
61    virtual void wall(const img_point *, double, double);
62    virtual void passage(const img_point *, double, double, double);
63    virtual void tube_end();
64    virtual void footer();
65};
66
67inline void
68ExportFilter::header(const char*,
69                     time_t,
70                     double, double, double,
71                     double, double, double) { }
72
73inline void
74ExportFilter::start_pass(int) { }
75
76inline void
77ExportFilter::line(const img_point *, const img_point *, unsigned, bool) { }
78
79inline void
80ExportFilter::cross(const img_point *, const wxString&, int) { }
81
82inline void
83ExportFilter::xsect(const img_point *, double, double, double) { }
84
85inline void
86ExportFilter::wall(const img_point *, double, double) { }
87
88inline void
89ExportFilter::passage(const img_point *, double, double, double) { }
90
91inline void
92ExportFilter::tube_end() { }
93
94inline void
95ExportFilter::footer() { }
96
97#endif
Note: See TracBrowser for help on using the repository browser.