source: git/src/exportfilter.h

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

Need <io.h> for _commit()

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/* exportfilter.h
2 * Export to GIS formats, CAD formats, and other formats.
3 */
4
5/* Copyright (C) 2005-2026 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#ifdef _WIN32
29# include <io.h> // For _commit().
30#endif
31
32#include "img_for_survex.h"
33
34class ExportFilter {
35  protected:
36    FILE * fh = nullptr;
37
38  public:
39    ExportFilter() { }
40    // FIXME: deal with errors closing file... (safe_fclose?)
41    virtual ~ExportFilter() {
42        if (fh) {
43#ifdef _WIN32
44            // Untested attempt to address https://trac.survex.com/ticket/147
45            _commit(fileno(fh));
46#endif
47            fclose(fh);
48        }
49    }
50    virtual const int * passes() const;
51    virtual bool fopen(const wxString& fnm_out) {
52        fh = wxFopen(fnm_out.fn_str(), wxT("wb"));
53        return (fh != NULL);
54    }
55    virtual void header(const char* title,
56                        time_t datestamp,
57                        double min_x, double min_y, double min_z,
58                        double max_x, double max_y, double max_z);
59    virtual void start_pass(int);
60    virtual void line(const img_point *, const img_point *, unsigned, bool);
61    virtual void label(const img_point* p, const wxString& s,
62                       int sflags, int type) = 0;
63    virtual void cross(const img_point *, const wxString&, int sflags);
64    virtual void xsect(const img_point *, double, double, double);
65    virtual void wall(const img_point *, double, double);
66    virtual void passage(const img_point *, double, double, double);
67    virtual void tube_end();
68    virtual void footer();
69};
70
71inline void
72ExportFilter::header(const char*,
73                     time_t,
74                     double, double, double,
75                     double, double, double) { }
76
77inline void
78ExportFilter::start_pass(int) { }
79
80inline void
81ExportFilter::line(const img_point *, const img_point *, unsigned, bool) { }
82
83inline void
84ExportFilter::cross(const img_point *, const wxString&, int) { }
85
86inline void
87ExportFilter::xsect(const img_point *, double, double, double) { }
88
89inline void
90ExportFilter::wall(const img_point *, double, double) { }
91
92inline void
93ExportFilter::passage(const img_point *, double, double, double) { }
94
95inline void
96ExportFilter::tube_end() { }
97
98inline void
99ExportFilter::footer() { }
100
101#endif
Note: See TracBrowser for help on using the repository browser.