Skip to content

Commit

Permalink
QStringize vecs a bit more. (GPSBabel#913)
Browse files Browse the repository at this point in the history
This fixes an ancient FIXME regarding the use of the option name
to indicate a option was given without a value.

This enhances the validity checking of default, minimum and maximum
values.
  • Loading branch information
tsteven4 authored Aug 18, 2022
1 parent 1df589d commit c6b998a
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 90 deletions.
12 changes: 6 additions & 6 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -960,13 +960,13 @@ void setshort_defname(short_handle, const char* s);
#define ARG_NOMINMAX nullptr, nullptr

struct arglist_t {
const char* argstring{nullptr};
char** argval{nullptr};
const char* helpstring{nullptr};
const char* defaultvalue{nullptr};
const QString argstring;
char** const argval{nullptr};
const QString helpstring;
const QString defaultvalue;
const uint32_t argtype{ARGTYPE_UNKNOWN};
const char* minvalue{nullptr}; /* minimum value for numeric options */
const char* maxvalue{nullptr}; /* maximum value for numeric options */
const QString minvalue; /* minimum value for numeric options */
const QString maxvalue; /* maximum value for numeric options */
char* argvalptr{nullptr}; /* !!! internal helper. Not used in definitions !!! */
};

Expand Down
20 changes: 10 additions & 10 deletions filter_vecs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Filter* FilterVecs::find_filter_vec(const QString& vecname)
if (qtemp.isNull()) {
Vecs::assign_option(vec.name, &arg, arg.defaultvalue);
} else {
Vecs::assign_option(vec.name, &arg, CSTR(qtemp));
Vecs::assign_option(vec.name, &arg, qtemp);
}
}
}
Expand All @@ -233,7 +233,7 @@ Filter* FilterVecs::find_filter_vec(const QString& vecname)
for (auto& arg : *args) {
const QString opt = Vecs::get_option(options, arg.argstring);
if (!opt.isNull()) {
Vecs::assign_option(vec.name, &arg, CSTR(opt));
Vecs::assign_option(vec.name, &arg, opt);
}
}
}
Expand Down Expand Up @@ -308,7 +308,7 @@ void FilterVecs::disp_filter_vecs() const
for (const auto& arg : *args) {
if (!(arg.argtype & ARGTYPE_HIDDEN)) {
printf(" %-18.18s %-.50s %s\n",
arg.argstring, arg.helpstring,
qPrintable(arg.argstring), qPrintable(arg.helpstring),
(arg.argtype & ARGTYPE_REQUIRED) ? "(required)" : "");
}
}
Expand All @@ -329,7 +329,7 @@ void FilterVecs::disp_filter_vec(const QString& vecname) const
for (const auto& arg : *args) {
if (!(arg.argtype & ARGTYPE_HIDDEN)) {
printf(" %-18.18s %-.50s %s\n",
arg.argstring, arg.helpstring,
qPrintable(arg.argstring), qPrintable(arg.helpstring),
(arg.argtype & ARGTYPE_REQUIRED) ? "(required)" : "");
}
}
Expand All @@ -341,7 +341,7 @@ void FilterVecs::disp_help_url(const fl_vecs_t& vec, const arglist_t* arg)
{
printf("\t" WEB_DOC_DIR "/filter_%s.html", CSTR(vec.name));
if (arg) {
printf("#fmt_%s_o_%s", CSTR(vec.name), arg->argstring);
printf("#fmt_%s_o_%s", CSTR(vec.name), CSTR(arg->argstring));
}
}

Expand All @@ -355,12 +355,12 @@ void FilterVecs::disp_v1(const fl_vecs_t& vec)
if (!(arg.argtype & ARGTYPE_HIDDEN)) {
printf("option\t%s\t%s\t%s\t%s\t%s\t%s\t%s",
CSTR(vec.name),
arg.argstring,
arg.helpstring,
CSTR(arg.argstring),
CSTR(arg.helpstring),
Vecs::name_option(arg.argtype),
arg.defaultvalue ? arg.defaultvalue : "",
arg.minvalue ? arg.minvalue : "",
arg.maxvalue ? arg.maxvalue : "");
CSTR(arg.defaultvalue),
CSTR(arg.minvalue),
CSTR(arg.maxvalue));
disp_help_url(vec, &arg);
printf("\n");
}
Expand Down
4 changes: 2 additions & 2 deletions reference/filter1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ option track split Split by date or time interval (see README) string https:/
option track sdistance Split by distance string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_sdistance
option track merge Merge multiple tracks for the same way string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_merge
option track name Use only track(s) where title matches given name string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_name
option track start Use only track points after this timestamp integer https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_start
option track stop Use only track points before this timestamp integer https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_stop
option track start Use only track points after this timestamp string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_start
option track stop Use only track points before this timestamp string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_stop
option track title Basic title for new track(s) string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_title
option track fix Synthesize GPS fixes (PPS, DGPS, 3D, 2D, NONE) string https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_fix
option track course Synthesize course boolean https://www.gpsbabel.org/WEB_DOC_DIR/filter_track.html#fmt_track_o_course
Expand Down
4 changes: 2 additions & 2 deletions trackfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class TrackFilter:public Filter
},
{
TRACKFILTER_START_OPTION, &opt_start,
"Use only track points after this timestamp", nullptr, ARGTYPE_INT,
"Use only track points after this timestamp", nullptr, ARGTYPE_STRING,
ARG_NOMINMAX, nullptr
},
{
TRACKFILTER_STOP_OPTION, &opt_stop,
"Use only track points before this timestamp", nullptr, ARGTYPE_INT,
"Use only track points before this timestamp", nullptr, ARGTYPE_STRING,
ARG_NOMINMAX, nullptr
},
{
Expand Down
Loading

0 comments on commit c6b998a

Please sign in to comment.