1 /*
2 Copyright (C) 2002 Alex Mottram (geo_alexm at cox-internet.com)
3 Copyright (C) 2002-2014 Robert Lipe
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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 General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 */
20
21 #ifndef CSV_UTIL_H_INCLUDED_
22 #define CSV_UTIL_H_INCLUDED_
23
24 #include <QtCore/QString> // for QString
25
26 #include "defs.h"
27
28 /* function prototypes */
29
30 QString
31 csv_stringclean(const QString& source, const QString& to_nuke);
32
33 char*
34 csv_stringtrim(const char* string, const char* enclosure, int strip_max);
35 QString
36 csv_stringtrim(const QString& source, const QString& enclosure);
37 QString
38 csv_stringtrim(const QString& string, const QString& enclosure, int strip_max);
39 QString
40 csv_enquote(const QString& str, const QString& enclosure);
41 QString
42 csv_dequote(const QString& string, const QString& enclosure);
43
44 enum class CsvQuoteMethod {historic, rfc4180};
45
46 char*
47 csv_lineparse(const char* stringstart, const char* delimited_by, const char* enclosed_in, int line_no);
48 QStringList
49 csv_linesplit(const QString& string, const QString& delimited_by,
50 const QString& enclosed_in, const int line_no, CsvQuoteMethod method = CsvQuoteMethod::historic);
51
52 int
53 dec_to_intdeg(const double d);
54
55 double
56 intdeg_to_dec(const int ideg);
57
58 double
59 decdir_to_dec(const char* decdir);
60
61 double
62 ddmmdir_to_degrees(const char* ddmmdir);
63
64 void
65 human_to_dec(const char* instr, double* outlat, double* outlon, int which);
66 inline void
human_to_dec(const QString & instr,double * outlat,double * outlon,int which)67 human_to_dec(const QString& instr, double* outlat, double* outlon, int which) {
68 human_to_dec(CSTR(instr), outlat, outlon, which);
69 }
70
71 QString
72 dec_to_human(const char* format, const char* dirs, double val);
73
74 #endif // CSV_UTIL_H_INCLUDED_
75