@@ -106,7 +106,7 @@ GdbFormat::disp_summary(const gbfile* f) const
106
106
gbWarning (" %s\n " , QByteArray (len + 21 , ' =' ).constData ());
107
107
108
108
gbWarning (" %s summary for \" %s\"\n " ,
109
- (f->mode == ' r' ) ? " Reader" : " Writer" , gbLogCStr (f->name ));
109
+ (f->mode == ' r' ) ? " Reader" : " Writer" , gbLogCStr (f->name ));
110
110
111
111
gbWarning (" %s\n " , QByteArray (len + 21 , ' -' ).constData ());
112
112
@@ -116,7 +116,7 @@ GdbFormat::disp_summary(const gbfile* f) const
116
116
gbWarning (" %d track(s) with total %d point(s)\n " , trk_ct, trkpt_ct);
117
117
118
118
gbWarning (" %s\n " , QByteArray (len + 21 , ' -' ).constData ());
119
- } else {
119
+ } else {
120
120
Q_UNUSED (f);
121
121
}
122
122
}
@@ -245,9 +245,9 @@ GdbFormat::gdb_add_route_waypt(route_head* rte, Waypoint* ref, const int wpt_cla
245
245
246
246
if (fabs (dist) > 100 ) {
247
247
gbFatal (" Route point mismatch!\n " \
248
- " \" %s\" from waypoints differs to \" %s\"\n " \
249
- " from route table by more than %0.1f meters!\n " , \
250
- gbLogCStr (tmp->shortname ), gbLogCStr (ref->shortname ), dist);
248
+ " \" %s\" from waypoints differs to \" %s\"\n " \
249
+ " from route table by more than %0.1f meters!\n " , \
250
+ gbLogCStr (tmp->shortname ), gbLogCStr (ref->shortname ), dist);
251
251
}
252
252
}
253
253
Waypoint* res = nullptr ;
@@ -451,37 +451,37 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
451
451
if constexpr (GDB_DEBUG) {
452
452
DBG (GDB_DBG_WPTe, true )
453
453
gbDebug (" wpt \" %s\" (%d): Altitude = %.1f\n " ,
454
- gbLogCStr (res->shortname ), wpt_class, alt);
454
+ gbLogCStr (res->shortname ), wpt_class, alt);
455
455
}
456
456
}
457
457
}
458
458
if constexpr (GDB_DEBUG) {
459
459
DBG (GDB_DBG_WPT, true )
460
460
gbDebug (" wpt \" %s\" : coordinates = %c%0.6f %c%0.6f\n " ,
461
- gbLogCStr (res->shortname ),
462
- res->latitude < 0 ? ' S' : ' N' , res->latitude ,
463
- res->longitude < 0 ? ' W' : ' E' , res->longitude );
461
+ gbLogCStr (res->shortname ),
462
+ res->latitude < 0 ? ' S' : ' N' , res->latitude ,
463
+ res->longitude < 0 ? ' W' : ' E' , res->longitude );
464
464
}
465
465
res->notes = fread_cstr ();
466
466
if constexpr (GDB_DEBUG) {
467
467
DBG (GDB_DBG_WPTe, !res->notes .isNull ())
468
468
gbDebug (" wpt \" %s\" (%d): notes = %s\n " ,
469
- gbLogCStr (res->shortname ), wpt_class,
470
- gbLogCStr (QString (res->notes ).replace (" \r\n " , " , " )));
469
+ gbLogCStr (res->shortname ), wpt_class,
470
+ gbLogCStr (QString (res->notes ).replace (" \r\n " , " , " )));
471
471
}
472
472
if (FREAD_C == 1 ) {
473
473
res->set_proximity (FREAD_DBL);
474
474
if constexpr (GDB_DEBUG) {
475
475
DBG (GDB_DBG_WPTe, res->proximity_has_value ())
476
476
gbDebug (" wpt \" %s\" (%d): Proximity = %.1f\n " ,
477
- gbLogCStr (res->shortname ), wpt_class, res->proximity_value () / 1000 );
477
+ gbLogCStr (res->shortname ), wpt_class, res->proximity_value () / 1000 );
478
478
}
479
479
}
480
480
int display = FREAD_i32;
481
481
if constexpr (GDB_DEBUG) {
482
482
DBG (GDB_DBG_WPTe, true )
483
483
gbDebug (" wpt \" %s\" (%d): display = %d\n " ,
484
- gbLogCStr (res->shortname ), wpt_class, display);
484
+ gbLogCStr (res->shortname ), wpt_class, display);
485
485
}
486
486
switch (display) { /* display value */
487
487
case gt_gdb_display_mode_symbol:
@@ -510,7 +510,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
510
510
if constexpr (GDB_DEBUG) {
511
511
DBG (GDB_DBG_WPTe, res->depth_has_value ())
512
512
gbDebug (" wpt \" %s\" (%d): Depth = %.1f\n " ,
513
- gbLogCStr (res->shortname ), wpt_class, res->depth_value ());
513
+ gbLogCStr (res->shortname ), wpt_class, res->depth_value ());
514
514
}
515
515
}
516
516
@@ -530,7 +530,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
530
530
QString temp = FREAD_CSTR_AS_QSTR; /* undocumented & unused string */
531
531
DBG (GDB_DBG_WPTe, !temp.isEmpty ())
532
532
gbDebug (" wpt \" %s\" (%d): Unknown string = %s\n " ,
533
- gbLogCStr (res->shortname ), wpt_class, gbLogCStr (temp));
533
+ gbLogCStr (res->shortname ), wpt_class, gbLogCStr (temp));
534
534
} else {
535
535
(void ) FREAD_CSTR_AS_QSTR; /* undocumented & unused string */
536
536
}
@@ -559,7 +559,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
559
559
if constexpr (GDB_DEBUG) {
560
560
DBG (GDB_DBG_WPTe, true )
561
561
gbDebug (" wpt \" %s\" (%d): duration = %u\n " ,
562
- gbLogCStr (res->shortname ), wpt_class, duration);
562
+ gbLogCStr (res->shortname ), wpt_class, duration);
563
563
}
564
564
}
565
565
int url_ct = FREAD_i32;
@@ -570,7 +570,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
570
570
if constexpr (GDB_DEBUG) {
571
571
DBG (GDB_DBG_WPTe, true )
572
572
gbDebug (" wpt \" %s\" (%d): url(%d) = %s\n " ,
573
- gbLogCStr (res->shortname ), wpt_class, url_ct - i, gbLogCStr (str));
573
+ gbLogCStr (res->shortname ), wpt_class, url_ct - i, gbLogCStr (str));
574
574
}
575
575
}
576
576
}
@@ -579,10 +579,10 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
579
579
if constexpr (GDB_DEBUG) {
580
580
DBG (GDB_DBG_WPTe, !res->description .isNull ())
581
581
gbDebug (" wpt \" %s\" (%d): description = %s\n " ,
582
- gbLogCStr (res->shortname ), wpt_class, gbLogCStr (res->description ));
582
+ gbLogCStr (res->shortname ), wpt_class, gbLogCStr (res->description ));
583
583
DBG (GDB_DBG_WPTe, res->urls .HasUrlLink ())
584
584
gbDebug (" wpt \" %s\" (%d): url = %s\n " ,
585
- gbLogCStr (res->shortname ), wpt_class, gbLogCStr (res->urls .GetUrlLink ().url_ ));
585
+ gbLogCStr (res->shortname ), wpt_class, gbLogCStr (res->urls .GetUrlLink ().url_ ));
586
586
}
587
587
int category = FREAD_i16;
588
588
if (category != 0 ) {
@@ -591,15 +591,15 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
591
591
if constexpr (GDB_DEBUG) {
592
592
DBG (GDB_DBG_WPTe, category)
593
593
gbDebug (" wpt \" %s\" (%d): category = %d\n " ,
594
- gbLogCStr (res->shortname ), wpt_class, category);
594
+ gbLogCStr (res->shortname ), wpt_class, category);
595
595
}
596
596
597
597
if (FREAD_C == 1 ) {
598
598
res->set_temperature (FREAD_DBL);
599
599
if constexpr (GDB_DEBUG) {
600
600
DBG (GDB_DBG_WPTe, res->temperature_has_value ())
601
601
gbDebug (" wpt \" %s\" (%d): temperature = %.1f\n " ,
602
- gbLogCStr (res->shortname ), wpt_class, res->temperature_value ());
602
+ gbLogCStr (res->shortname ), wpt_class, res->temperature_value ());
603
603
}
604
604
}
605
605
@@ -628,7 +628,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
628
628
if constexpr (GDB_DEBUG) {
629
629
DBG (GDB_DBG_WPTe, icon != kGDBDefIcon )
630
630
gbDebug (" wpt \" %s\" (%d): icon = \" %s\" (MapSource symbol %d)\n " ,
631
- gbLogCStr (res->shortname ), wpt_class, gbLogCStr (res->icon_descr ), icon);
631
+ gbLogCStr (res->shortname ), wpt_class, gbLogCStr (res->icon_descr ), icon);
632
632
}
633
633
QString str;
634
634
if (!(str = garmin_fs_t::get_cc (gmsd, nullptr )).isEmpty ()) {
@@ -681,7 +681,7 @@ GdbFormat::read_route()
681
681
if constexpr (GDB_DEBUG) {
682
682
DBG (GDB_DBG_RTE, true )
683
683
gbDebug (" rte \" %s\" : loading route with %d point(s)...\n " ,
684
- gbLogCStr (rte->rte_name ), points);
684
+ gbLogCStr (rte->rte_name ), points);
685
685
}
686
686
687
687
for (int i = 0 ; i < points; i++) {
@@ -723,7 +723,7 @@ GdbFormat::read_route()
723
723
if constexpr (GDB_DEBUG) {
724
724
DBG (GDB_DBG_RTE, links)
725
725
gbDebug (" rte_pt \" %s\" (%d): %d interlink step(s)\n " ,
726
- gbLogCStr (wpt->shortname ), wpt_class, links);
726
+ gbLogCStr (wpt->shortname ), wpt_class, links);
727
727
}
728
728
for (int j = 0 ; j < links; j++) {
729
729
garmin_ilink_t il_step;
@@ -747,9 +747,9 @@ GdbFormat::read_route()
747
747
if constexpr (GDB_DEBUG) {
748
748
DBG (GDB_DBG_RTEe, true ) {
749
749
gbDebug (" rte_il \" %s\" (%d of %d): %c%0.6f %c%0.6f\n " ,
750
- gbLogCStr (wpt->shortname ), j + 1 , links,
751
- il_step.lat < 0 ? ' S' : ' N' , il_step.lat ,
752
- il_step.lon < 0 ? ' W' : ' E' , il_step.lon );
750
+ gbLogCStr (wpt->shortname ), j + 1 , links,
751
+ il_step.lat < 0 ? ' S' : ' N' , il_step.lat ,
752
+ il_step.lon < 0 ? ' W' : ' E' , il_step.lon );
753
753
}
754
754
}
755
755
}
@@ -796,9 +796,9 @@ GdbFormat::read_route()
796
796
if constexpr (GDB_DEBUG) {
797
797
DBG (GDB_DBG_RTE, true )
798
798
gbDebug (" rte_pt \" %s\" : coordinates = %c%0.6f, %c%0.6f\n " ,
799
- gbLogCStr (wpt->shortname ),
800
- wpt->latitude < 0 ? ' S' : ' N' , wpt->latitude ,
801
- wpt->longitude < 0 ? ' W' : ' E' , wpt->longitude );
799
+ gbLogCStr (wpt->shortname ),
800
+ wpt->latitude < 0 ? ' S' : ' N' , wpt->latitude ,
801
+ wpt->longitude < 0 ? ' W' : ' E' , wpt->longitude );
802
802
}
803
803
wpt = gdb_add_route_waypt (rte, wpt, wpt_class);
804
804
if (wpt != nullptr ) {
@@ -838,9 +838,9 @@ GdbFormat::read_route()
838
838
if constexpr (GDB_DEBUG) {
839
839
DBG (GDB_DBG_RTE, true )
840
840
gbDebug (" rte_pt: autoroute info: route style %d, calculation type %d, vehicle type %d, road selection %d\n "
841
- " driving speeds (kph) %.0f, %.0f, %.0f, %.0f, %.0f\n " ,
842
- route_style, calc_type, vehicle_type, road_selection,
843
- driving_speed[0 ], driving_speed[1 ], driving_speed[2 ], driving_speed[3 ], driving_speed[4 ]);
841
+ " driving speeds (kph) %.0f, %.0f, %.0f, %.0f, %.0f\n " ,
842
+ route_style, calc_type, vehicle_type, road_selection,
843
+ driving_speed[0 ], driving_speed[1 ], driving_speed[2 ], driving_speed[3 ], driving_speed[4 ]);
844
844
} else {
845
845
Q_UNUSED (route_style);
846
846
Q_UNUSED (calc_type);
@@ -919,7 +919,7 @@ GdbFormat::read_track()
919
919
if constexpr (GDB_DEBUG) {
920
920
DBG (GDB_DBG_TRK, res->rte_urls .HasUrlLink ())
921
921
gbDebug (" trk \" %s\" : url = %s\n " ,
922
- gbLogCStr (res->rte_name ), gbLogCStr (res->rte_urls .GetUrlLink ().url_ ));
922
+ gbLogCStr (res->rte_name ), gbLogCStr (res->rte_urls .GetUrlLink ().url_ ));
923
923
}
924
924
return res;
925
925
}
@@ -1041,7 +1041,7 @@ GdbFormat::read()
1041
1041
}
1042
1042
if (typ == ' W' )
1043
1043
gbWarning (" (%d%c-%02d): delta = %d (flag=%3d/%02x)-" ,
1044
- gdb_ver, typ, wpt_class, delta, waypt_flag, waypt_flag);
1044
+ gdb_ver, typ, wpt_class, delta, waypt_flag, waypt_flag);
1045
1045
else {
1046
1046
gbWarning (" (%d%c): delta = %d -" , gdb_ver, typ, delta);
1047
1047
}
@@ -1215,7 +1215,7 @@ GdbFormat::write_waypoint(
1215
1215
QString str;
1216
1216
1217
1217
if (wpt_class < gt_waypt_class_map_point) { /* street address */
1218
- str = garmin_fs_t::get_addr (gmsd, " " );
1218
+ str = garmin_fs_t::get_addr (gmsd, " " );
1219
1219
} else {
1220
1220
str = " " ;
1221
1221
}
@@ -1314,23 +1314,22 @@ GdbFormat::write_route(const route_head* rte, const QString& rte_name)
1314
1314
int points = rte->rte_waypt_ct ();
1315
1315
FWRITE_i32 (points);
1316
1316
1317
- int index = 0 ;
1318
-
1319
- for (auto it =rte->waypoint_list .cbegin (); it != rte->waypoint_list .cend (); ++it) {
1317
+ for (auto begin = rte->waypoint_list .cbegin (), end = rte->waypoint_list .cend (), it = begin;
1318
+ it != end; ++it) {
1320
1319
1320
+ bool firstpass = it == begin;
1321
1321
Waypoint* wpt = *it;
1322
- Waypoint* next = nullptr ;
1323
- if (index < points) {
1324
- next = *std::next (it);
1325
- }
1326
1322
1327
- index++;
1323
+ auto next_it = std::next (it);
1324
+ bool lastpass = next_it == end;
1325
+ Waypoint* next = lastpass? nullptr : *next_it;
1326
+
1328
1327
rtept_ct++; /* increase informational number of written route points */
1329
1328
1330
- if (index == 1 ) {
1329
+ if (firstpass ) {
1331
1330
gdb_check_waypt (wpt);
1332
1331
}
1333
- if (index < points ) {
1332
+ if (!lastpass ) {
1334
1333
gdb_check_waypt (next);
1335
1334
}
1336
1335
@@ -1368,10 +1367,10 @@ GdbFormat::write_route(const route_head* rte, const QString& rte_name)
1368
1367
FWRITE (ffbuf, 4 );
1369
1368
FWRITE (zbuf, 10 );
1370
1369
1371
- if (index == points ) {
1370
+ if (lastpass ) {
1372
1371
FWRITE_i32 (0 ); /* no more steps */
1373
1372
FWRITE_C (1 ); /* skip bounds */
1374
- } else { /* if (index < points) */
1373
+ } else { /* !last_pass */
1375
1374
FWRITE_i32 (2 ); /* two interstep links */
1376
1375
1377
1376
FWRITE_LATLON (wpt->latitude );
0 commit comments