Skip to content

Commit 62eff91

Browse files
committed
ais.h: Fix google-global-names-in-headers for std::string
1 parent cf478e7 commit 62eff91

5 files changed

Lines changed: 74 additions & 76 deletions

File tree

src/libais/ais.h

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <string>
1717
#include <vector>
1818

19-
using std::string;
20-
2119
constexpr int LIBAIS_VERSION_MAJOR = 0;
2220
constexpr int LIBAIS_VERSION_MINOR = 17;
2321

@@ -29,15 +27,15 @@ namespace libais {
2927

3028
// Returns the text in the nth field starting with the first field being 0.
3129
// Empty delim_str is not allowed.
32-
string GetNthField(const string &str, size_t n, const string &delim_str);
30+
std::string GetNthField(const std::string &str, size_t n, const std::string &delim_str);
3331

3432
// Returns the number of pad bits in an AIS AIVDM NMEA string.
3533
// Returns -1 if there is an error.
36-
int GetPad(const string &nmea_str);
34+
int GetPad(const std::string &nmea_str);
3735

3836
// Returns the armored payload of an AIS AIVDM NMEA string.
3937
// Returns an empty string if there was an error.
40-
string GetBody(const string &nmea_str);
38+
std::string GetBody(const std::string &nmea_str);
4139

4240

4341
// Note: Needs to be kept in sync with AIS_STATUS_STRINGS list in ais.cpp.
@@ -396,7 +394,7 @@ class AisBitset : protected std::bitset<MAX_BITS> {
396394

397395
unsigned int ToUnsignedInt(size_t start, size_t len) const;
398396
int ToInt(size_t start, size_t len) const;
399-
string ToString(size_t start, size_t len) const;
397+
std::string ToString(size_t start, size_t len) const;
400398

401399
const AisPoint ToAisPoint(size_t start, size_t point_size) const;
402400

@@ -567,8 +565,8 @@ class Ais5 : public AisMsg {
567565
public:
568566
int ais_version;
569567
int imo_num;
570-
string callsign;
571-
string name;
568+
std::string callsign;
569+
std::string name;
572570
int type_and_cargo;
573571
int dim_a;
574572
int dim_b;
@@ -580,7 +578,7 @@ class Ais5 : public AisMsg {
580578
int eta_hour;
581579
int eta_minute;
582580
float draught; // present static draft. m
583-
string destination;
581+
std::string destination;
584582
int dte;
585583
int spare;
586584

@@ -628,7 +626,7 @@ class Ais6_1_0 : public Ais6 {
628626
public:
629627
bool ack_required;
630628
int msg_seq;
631-
string text;
629+
std::string text;
632630
int spare2;
633631

634632
Ais6_1_0(const char *nmea_payload, size_t pad);
@@ -705,18 +703,18 @@ class Ais6_1_5 : public Ais6 {
705703
// Not to be transmitted after 2012-Jan-01
706704
class Ais6_1_12 : public Ais6 {
707705
public:
708-
string last_port;
706+
std::string last_port;
709707
int utc_month_dep; // actual time of departure
710708
int utc_day_dep;
711709
int utc_hour_dep;
712710
int utc_min_dep;
713-
string next_port;
711+
std::string next_port;
714712
int utc_month_next; // estimated arrival
715713
int utc_day_next;
716714
int utc_hour_next;
717715
int utc_min_next;
718-
string main_danger;
719-
string imo_cat;
716+
std::string main_danger;
717+
std::string imo_cat;
720718
int un;
721719
int value; // TODO(schwehr): units?
722720
int value_unit;
@@ -760,8 +758,8 @@ class Ais6_1_18 : public Ais6 {
760758
int utc_day;
761759
int utc_hour;
762760
int utc_min;
763-
string port_berth;
764-
string dest;
761+
std::string port_berth;
762+
std::string dest;
765763
AisPoint position;
766764
std::array<int, 2> spare2; // 32 bits per spare
767765

@@ -784,7 +782,7 @@ class Ais6_1_20 : public Ais6 {
784782
bool services_known;
785783
// TODO(schwehr): enum of service types
786784
std::array<int, 26> services;
787-
string name;
785+
std::string name;
788786
AisPoint position;
789787

790788
Ais6_1_20(const char *nmea_payload, size_t pad);
@@ -902,7 +900,7 @@ class Ais8_1_0 : public Ais8 {
902900
public:
903901
bool ack_required;
904902
int msg_seq;
905-
string text;
903+
std::string text;
906904
int spare2;
907905

908906
Ais8_1_0(const char *nmea_payload, size_t pad);
@@ -964,9 +962,9 @@ std::ostream& operator<< (std::ostream &o, const Ais8_1_11 &msg);
964962
// IMO Circ 236 Fairway closed - Not to be transmitted after 2012-Jan-01
965963
class Ais8_1_13 : public Ais8 {
966964
public:
967-
string reason;
968-
string location_from;
969-
string location_to;
965+
std::string reason;
966+
std::string location_from;
967+
std::string location_to;
970968
int radius;
971969
int units;
972970
// TODO(schwehr): utc? warning: day/month out of order
@@ -1009,7 +1007,7 @@ std::ostream& operator<< (std::ostream &o, const Ais8_1_16 &msg);
10091007
class Ais8_1_17_Target {
10101008
public:
10111009
int type;
1012-
string id;
1010+
std::string id;
10131011
int spare;
10141012
AisPoint position;
10151013
int cog;
@@ -1034,7 +1032,7 @@ std::ostream& operator<< (std::ostream &o, const Ais8_1_17 &msg);
10341032
class Ais8_1_19 : public Ais8 {
10351033
public:
10361034
int link_id;
1037-
string name;
1035+
std::string name;
10381036
AisPoint position; // funny bit count
10391037
int status;
10401038
int signal;
@@ -1055,7 +1053,7 @@ class Ais8_1_21 : public Ais8 {
10551053
int type_wx_report;
10561054

10571055
// TYPE 0
1058-
string location;
1056+
std::string location;
10591057
AisPoint position; // 25, 24 bits
10601058
int utc_day;
10611059
int utc_hour;
@@ -1236,7 +1234,7 @@ class Ais8_1_22_Polygon : public Ais8_1_22_SubArea {
12361234

12371235
class Ais8_1_22_Text : public Ais8_1_22_SubArea {
12381236
public:
1239-
string text;
1237+
std::string text;
12401238
// TODO(schwehr): spare?
12411239

12421240
Ais8_1_22_Text(const AisBitset &bs, size_t offset);
@@ -1270,15 +1268,15 @@ class Ais8_1_24 : public Ais8 {
12701268
public:
12711269
int link_id;
12721270
float air_draught; // m
1273-
string last_port;
1271+
std::string last_port;
12741272
std::array<std::string, 2> next_ports;
12751273

12761274
// TODO(schwehr): enum list of param types
12771275
std::array<int, 26> solas_status; // 0 NA, 1 operational, 2 SNAFU, 3 no data
12781276
int ice_class;
12791277
int shaft_power; // horses
12801278
int vhf;
1281-
string lloyds_ship_type;
1279+
std::string lloyds_ship_type;
12821280
int gross_tonnage;
12831281
int laden_ballast;
12841282
int heavy_oil;
@@ -1347,7 +1345,7 @@ class Ais8_1_26_Location : public Ais8_1_26_SensorReport {
13471345

13481346
class Ais8_1_26_Station : public Ais8_1_26_SensorReport {
13491347
public:
1350-
string name;
1348+
std::string name;
13511349
int spare{};
13521350

13531351
Ais8_1_26_Station(const AisBitset &bs, size_t offset);
@@ -1559,7 +1557,7 @@ std::ostream& operator<< (std::ostream &o, const Ais8_1_27 &msg);
15591557
class Ais8_1_29 : public Ais8 {
15601558
public:
15611559
int link_id;
1562-
string text;
1560+
std::string text;
15631561
int spare2;
15641562

15651563
Ais8_1_29(const char *nmea_payload, size_t pad);
@@ -1625,7 +1623,7 @@ std::ostream& operator<< (std::ostream &o, const Ais8_1_31 &msg);
16251623
// Inland ship static and voyage related data
16261624
class Ais8_200_10 : public Ais8 {
16271625
public:
1628-
string eu_id; // European Vessel ID - 8 characters
1626+
std::string eu_id; // European Vessel ID - 8 characters
16291627
float length; // m
16301628
float beam; // m
16311629
int ship_type;
@@ -1645,11 +1643,11 @@ class Ais8_200_10 : public Ais8 {
16451643
// ETA at lock/bridge/terminal
16461644
class Ais8_200_21 : public Ais8 {
16471645
public:
1648-
string country; // UN country code 0 = not available = default
1649-
string location; // UN location code 0 = not available = default
1650-
string section; // Fairway section number 0 = not available = default
1651-
string terminal; // Terminal code 0 = not available = default
1652-
string hectometre; // Fairway hectometre 0 = not available = default
1646+
std::string country; // UN country code 0 = not available = default
1647+
std::string location; // UN location code 0 = not available = default
1648+
std::string section; // Fairway section number 0 = not available = default
1649+
std::string terminal; // Terminal code 0 = not available = default
1650+
std::string hectometre; // Fairway hectometre 0 = not available = default
16531651
// Examples for previous fields. See:
16541652
// http://www.ris.eu/docs/File/427/implementation_location_code_austria.pdf
16551653

@@ -1670,11 +1668,11 @@ class Ais8_200_21 : public Ais8 {
16701668
// RTA at lock/bridge/terminal
16711669
class Ais8_200_22 : public Ais8 {
16721670
public:
1673-
string country; // UN country code 0 = not available
1674-
string location; // UN location code 0 = not available
1675-
string section; // Fairway section number 0 = not available
1676-
string terminal; // Terminal code 0 = not available
1677-
string hectometre; // Fairway hectometre 0 = not available
1671+
std::string country; // UN country code 0 = not available
1672+
std::string location; // UN location code 0 = not available
1673+
std::string section; // Fairway section number 0 = not available
1674+
std::string terminal; // Terminal code 0 = not available
1675+
std::string hectometre; // Fairway hectometre 0 = not available
16781676
// Examples for previous fields. See:
16791677
// http://www.ris.eu/docs/File/427/implementation_location_code_austria.pdf
16801678

@@ -1725,7 +1723,7 @@ class Ais8_200_24 : public Ais8 {
17251723
public:
17261724
// UN 2 letter code. See Comtrade Country Code and Name.
17271725
// https://unstats.un.org/unsd/tradekb/Knowledgebase/50377/Comtrade-Country-Code-and-Name
1728-
string country;
1726+
std::string country;
17291727
std::array<int, 4> gauge_ids;
17301728
std::array<float, 4> levels; // m
17311729

@@ -1858,7 +1856,7 @@ class Ais8_366_22_Polygon final : public Ais8_366_22_SubArea {
18581856

18591857
class Ais8_366_22_Text final : public Ais8_366_22_SubArea {
18601858
public:
1861-
string text;
1859+
std::string text;
18621860
unsigned int spare; // 3 bits
18631861

18641862
Ais8_366_22_Text(const AisBitset &bs, size_t offset);
@@ -1968,7 +1966,7 @@ class Ais8_367_22_Poly : public Ais8_367_22_SubArea {
19681966

19691967
class Ais8_367_22_Text : public Ais8_367_22_SubArea {
19701968
public:
1971-
string text;
1969+
std::string text;
19721970
unsigned int spare; // 3 bits
19731971

19741972
Ais8_367_22_Text(const AisBitset &bs, size_t offset);
@@ -2436,7 +2434,7 @@ class Ais12 : public AisMsg {
24362434
int dest_mmsi;
24372435
bool retransmitted;
24382436
int spare;
2439-
string text;
2437+
std::string text;
24402438
int spare2;
24412439

24422440
Ais12(const char *nmea_payload, size_t pad);
@@ -2449,7 +2447,7 @@ std::ostream& operator<< (std::ostream &o, const Ais12 &msg);
24492447
class Ais14 : public AisMsg {
24502448
public:
24512449
int spare;
2452-
string text;
2450+
std::string text;
24532451
int spare2;
24542452

24552453
Ais14(const char *nmea_payload, size_t pad);
@@ -2585,7 +2583,7 @@ class Ais19 : public AisMsg {
25852583
int true_heading;
25862584
int timestamp;
25872585
int spare2;
2588-
string name;
2586+
std::string name;
25892587
int type_and_cargo;
25902588
int dim_a;
25912589
int dim_b;
@@ -2639,7 +2637,7 @@ std::ostream& operator<< (std::ostream &o, const Ais20 &msg);
26392637
class Ais21 : public AisMsg {
26402638
public:
26412639
int aton_type;
2642-
string name;
2640+
std::string name;
26432641
int position_accuracy;
26442642
AisPoint position;
26452643
int dim_a;
@@ -2716,12 +2714,12 @@ class Ais24 : public AisMsg {
27162714
int part_num;
27172715

27182716
// Part A
2719-
string name;
2717+
std::string name;
27202718

27212719
// Part B
27222720
int type_and_cargo;
2723-
string vendor_id;
2724-
string callsign;
2721+
std::string vendor_id;
2722+
std::string callsign;
27252723
int dim_a;
27262724
int dim_b;
27272725
int dim_c;

src/libais/decode_body.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace libais {
3131
// The fill_bits are the number of pad bits in the last character of the
3232
// body. AIS messages are 8-bit aligned and the characters in the armored
3333
// body are 6-bit aligned.
34-
std::unique_ptr<libais::AisMsg> CreateAisMsg(const string &body,
34+
std::unique_ptr<libais::AisMsg> CreateAisMsg(const std::string &body,
3535
const int fill_bits);
3636

3737
} // namespace libais

src/libais/vdm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ unique_ptr<NmeaSentence> NmeaSentence::Create(const std::string &line,
192192
return nullptr;
193193
}
194194

195-
const string body(fields[5]);
195+
const std::string body(fields[5]);
196196
if (body.size() < 1 || body.size() > 199) {
197197
// TODO(schwehr): Test this code path.
198198
return nullptr;

0 commit comments

Comments
 (0)