Skip to content

Commit 7c6b721

Browse files
committed
remove std::basic_string<uint8_t> and basic_string_view
1 parent a1d767c commit 7c6b721

23 files changed

+273
-256
lines changed

beidou.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "beidou.hh"
22
#include "bits.hh"
33
#include <iostream>
4+
#include <vector>
5+
#include "navmon.hh"
46

57
using namespace std;
68

@@ -29,7 +31,7 @@ static int checkbds(int bits)
2931
return 1;
3032
}
3133

32-
std::basic_string<uint8_t> getCondensedBeidouMessage(std::basic_string_view<uint8_t> payload)
34+
std::vector<uint8_t> getCondensedBeidouMessage(const std::vector<uint8_t>& payload)
3335
{
3436

3537
// payload consists of 32 bit words where we have to ignore the first 2 bits of every word
@@ -56,7 +58,7 @@ std::basic_string<uint8_t> getCondensedBeidouMessage(std::basic_string_view<uint
5658
setbitu(buffer, 26+22*(w-1), 22, getbitu(&payload[0], 2 + w*32, 22));
5759
}
5860

59-
return std::basic_string<uint8_t>(buffer, 28);
61+
return makeVec(buffer, 28);
6062
}
6163

6264

beidou.hh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#include "bits.hh"
55
#include <math.h>
66
#include <stdexcept>
7+
#include <vector>
78
#include "ephemeris.hh"
89

9-
std::basic_string<uint8_t> getCondensedBeidouMessage(std::basic_string_view<uint8_t> payload);
10+
std::vector<uint8_t> getCondensedBeidouMessage(const std::vector<uint8_t>& payload);
1011
int beidouBitconv(int their);
1112

1213
/* Geostationary, so D2, so not to be parsed by this parser:
@@ -21,7 +22,7 @@ struct BeidouMessage : GPSLikeEphemeris
2122
{
2223
uint8_t strtype;
2324

24-
std::basic_string_view<uint8_t> g_cond;
25+
std::vector<uint8_t> g_cond;
2526
int bbitu(int bit, int len)
2627
{
2728
return getbitu(&g_cond[0], beidouBitconv(bit), len);
@@ -34,7 +35,7 @@ struct BeidouMessage : GPSLikeEphemeris
3435

3536
int fraid{-1}, sow{-1}; // part of every message (thanks!)
3637

37-
int parse(std::basic_string_view<uint8_t> cond, uint8_t* pageno)
38+
int parse(const std::vector<uint8_t>& cond, uint8_t* pageno)
3839
{
3940
g_cond = cond;
4041
if(pageno)
@@ -89,7 +90,7 @@ struct BeidouMessage : GPSLikeEphemeris
8990
return {factor * cur, factor * trend};
9091
}
9192

92-
void parse1(std::basic_string_view<uint8_t> cond)
93+
void parse1(const std::vector<uint8_t>& cond)
9394
{
9495
sath1 = bbitu(43,1);
9596
aodc = bbitu(31+13, 5);
@@ -124,7 +125,7 @@ struct BeidouMessage : GPSLikeEphemeris
124125
return -1;
125126
}
126127

127-
void parse2(std::basic_string_view<uint8_t> cond)
128+
void parse2(const std::vector<uint8_t>& cond)
128129
{
129130
deltan = bbits(43, 16);
130131
cuc = bbits(67, 18);
@@ -151,7 +152,7 @@ struct BeidouMessage : GPSLikeEphemeris
151152
double getOmega0() const { return ldexp(Omega0 * M_PI, -31); } // radians
152153
double getIdot() const { return ldexp(idot * M_PI, -43); } // radians/s
153154
double getOmega() const { return ldexp(omega * M_PI, -31); } // radians
154-
void parse3(std::basic_string_view<uint8_t> cond)
155+
void parse3(const std::vector<uint8_t>& cond)
155156
{
156157
t0eLSB = bbitu(43, 15);
157158
i0 = bbits(66, 32);
@@ -207,7 +208,7 @@ struct BeidouMessage : GPSLikeEphemeris
207208
} alma;
208209

209210
// 4 is all almanac
210-
int parse4(std::basic_string_view<uint8_t> cond)
211+
int parse4(const std::vector<uint8_t>& cond)
211212
{
212213
alma.sqrtA = bbitu(51, 24);
213214
alma.a1 = bbits(91, 11);
@@ -254,7 +255,7 @@ struct BeidouMessage : GPSLikeEphemeris
254255
}
255256

256257

257-
int parse5(std::basic_string_view<uint8_t> cond)
258+
int parse5(const std::vector<uint8_t>& cond)
258259
{
259260
alma.pageno = bbitu(44, 7);
260261
if(alma.pageno == 9) {

fixhunter.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "galileo.hh"
77
using namespace std;
88

9-
void FixHunter::reportInav(const basic_string<uint8_t>& inav, int32_t gst)
9+
void FixHunter::reportInav(const vector<uint8_t>& inav, int32_t gst)
1010
{
1111
int wtype = getbitu(&inav[0], 0, 6);
1212

@@ -181,7 +181,7 @@ void FixHunter::tryFix(int32_t gst)
181181
struct GalileoMessage FixHunter::fillGMFromRS(const std::string& out)
182182
{
183183
// we need to reconstruct words 1, 2, 3 and 4 and feed them to the parser
184-
basic_string<uint8_t> inav[5];
184+
vector<uint8_t> inav[5];
185185
string inavraw[5];
186186
inavraw[4] = out.substr(0, 14);
187187
inavraw[3] = out.substr(14, 14);
@@ -198,7 +198,7 @@ struct GalileoMessage FixHunter::fillGMFromRS(const std::string& out)
198198
for(int n=0; n < 14; ++n)
199199
setbitu(tmp, 16 + n*8, 8, getbitu((unsigned char*) inavraw[1].c_str(), 16 + n*8, 8));
200200

201-
inav[1].assign(tmp, 16);
201+
inav[1]= makeVec(tmp, 16);
202202

203203
struct GalileoMessage gm={};
204204
gm.parse(inav[1]);
@@ -210,7 +210,7 @@ struct GalileoMessage FixHunter::fillGMFromRS(const std::string& out)
210210
setbitu(tmp, 6, 10, getbitu((unsigned char*) inav[1].c_str(), 6, 10)); // fake in IOD from inav1
211211
for(int n=0; n < 14; ++n)
212212
setbitu(tmp, 16 + n*8, 8, getbitu((unsigned char*) inavraw[i].c_str(), n*8, 8));
213-
inav[i].assign(tmp, 16);
213+
inav[i]= makeVec(tmp, 16);
214214
gm.parse(inav[i]);
215215
cout<<"wtype: "<<(int)gm.wtype<<", iod "<<gm.iodnav<<endl;
216216
}

fixhunter.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
class FixHunter
66
{
77
public:
8-
void reportInav(const std::basic_string<uint8_t>& inav, int32_t gst);
8+
void reportInav(const std::vector<uint8_t>& inav, int32_t gst);
99
private:
1010
void tryFix(int32_t gst);
1111
struct GalileoMessage fillGMFromRS(const std::string& out);
12-
std::basic_string<uint8_t> inav1, inav2, inav3, inav4, inav16, inav17, inav18, inav19, inav20;
12+
std::vector<uint8_t> inav1, inav2, inav3, inav4, inav16, inav17, inav18, inav19, inav20;
1313
int d_latestiod;
1414
uint32_t d_inav16t0r;
1515
};

galileo.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "bits.hh"
22
#include "galileo.hh"
33

4-
bool getTOWFromInav(std::basic_string_view<uint8_t> inav, uint32_t *satTOW, uint16_t *wn)
4+
bool getTOWFromInav(const std::vector<uint8_t>& inav, uint32_t *satTOW, uint16_t *wn)
55
{
66
unsigned int wtype = getbitu(&inav[0], 0, 6);
77
if(wtype==0) {
@@ -25,7 +25,7 @@ bool getTOWFromInav(std::basic_string_view<uint8_t> inav, uint32_t *satTOW, uint
2525
return false;
2626
}
2727

28-
int GalileoMessage::parseFnav(std::basic_string_view<uint8_t> page)
28+
int GalileoMessage::parseFnav(const std::vector<uint8_t>& page)
2929
{
3030
const uint8_t* ptr = &page[0];
3131
int offset=0;

galileo.hh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
#include "ephemeris.hh"
88
#include "bits.hh"
99

10-
bool getTOWFromInav(std::basic_string_view<uint8_t> inav, uint32_t *satTOW, uint16_t *wn);
10+
bool getTOWFromInav(const std::vector<uint8_t>& inav, uint32_t *satTOW, uint16_t *wn);
1111

1212
struct GalileoMessage : GPSLikeEphemeris
1313
{
1414
uint8_t wtype;
1515

16-
typedef void (GalileoMessage::*func_t)(std::basic_string_view<uint8_t> page);
16+
typedef void (GalileoMessage::*func_t)(const std::vector<uint8_t>& page);
1717
std::map<int, func_t> parsers{
1818
{0, &GalileoMessage::parse0},
1919
{1, &GalileoMessage::parse1},
@@ -34,7 +34,7 @@ struct GalileoMessage : GPSLikeEphemeris
3434
};
3535

3636

37-
int parse(std::basic_string_view<uint8_t> page)
37+
int parse(const std::vector<uint8_t>& page)
3838
{
3939
wtype = getbitu(&page[0], 0, 6);
4040
if(!parsers.count(wtype)) {
@@ -46,7 +46,7 @@ struct GalileoMessage : GPSLikeEphemeris
4646
return wtype;
4747
}
4848

49-
int parseFnav(std::basic_string_view<uint8_t> page);
49+
int parseFnav(const std::vector<uint8_t>& page);
5050

5151
uint8_t sparetime{0};
5252
uint16_t wn{0};
@@ -58,7 +58,7 @@ struct GalileoMessage : GPSLikeEphemeris
5858

5959

6060
// spare word, only contains a WN and a TOW, but only if the 'time' field is set to 2
61-
void parse0(std::basic_string_view<uint8_t> page)
61+
void parse0(const std::vector<uint8_t>& page)
6262
{
6363
sparetime = getbitu(&page[0], 6, 2);
6464
if(sparetime == 2) {
@@ -164,7 +164,7 @@ struct GalileoMessage : GPSLikeEphemeris
164164

165165

166166
// an ephemeris word
167-
void parse1(std::basic_string_view<uint8_t> page)
167+
void parse1(const std::vector<uint8_t>& page)
168168
{
169169
iodnav = getbitu(&page[0], 6, 10);
170170
t0e = getbitu(&page[0], 16, 14);
@@ -174,7 +174,7 @@ struct GalileoMessage : GPSLikeEphemeris
174174
}
175175

176176
// another ephemeris word
177-
void parse2(std::basic_string_view<uint8_t> page)
177+
void parse2(const std::vector<uint8_t>& page)
178178
{
179179
iodnav = getbitu(&page[0], 6, 10);
180180
omega0 = getbits(&page[0], 16, 32);
@@ -184,7 +184,7 @@ struct GalileoMessage : GPSLikeEphemeris
184184
}
185185

186186
// yet another ephemeris word
187-
void parse3(std::basic_string_view<uint8_t> page)
187+
void parse3(const std::vector<uint8_t>& page)
188188
{
189189
iodnav = getbitu(&page[0], 6, 10);
190190
omegadot = getbits(&page[0], 16, 24);
@@ -264,7 +264,7 @@ struct GalileoMessage : GPSLikeEphemeris
264264

265265

266266
// can't get enough of that ephemeris
267-
void parse4(std::basic_string_view<uint8_t> page)
267+
void parse4(const std::vector<uint8_t>& page)
268268
{
269269
iodnav = getbitu(&page[0], 6, 10);
270270
cic = getbits(&page[0], 22, 16);
@@ -277,7 +277,7 @@ struct GalileoMessage : GPSLikeEphemeris
277277
}
278278

279279
// ionospheric disturbance, health, group delay, time
280-
void parse5(std::basic_string_view<uint8_t> page)
280+
void parse5(const std::vector<uint8_t>& page)
281281
{
282282
ai0 = getbitu(&page[0], 6, 11);
283283
ai1 = getbits(&page[0], 17, 11); // ai1 & 2 are signed, 0 not
@@ -300,7 +300,7 @@ struct GalileoMessage : GPSLikeEphemeris
300300
}
301301

302302
// time stuff
303-
void parse6(std::basic_string_view<uint8_t> page)
303+
void parse6(const std::vector<uint8_t>& page)
304304
{
305305
a0 = getbits(&page[0], 6, 32);
306306
a1 = getbits(&page[0], 38, 24);
@@ -315,7 +315,7 @@ struct GalileoMessage : GPSLikeEphemeris
315315
}
316316

317317
// almanac
318-
void parse7(std::basic_string_view<uint8_t> page)
318+
void parse7(const std::vector<uint8_t>& page)
319319
{
320320
iodalmanac = getbitu(&page[0], 6, 4);
321321
alma1.wnalmanac = wnalmanac = getbitu(&page[0], 10, 2);
@@ -331,7 +331,7 @@ struct GalileoMessage : GPSLikeEphemeris
331331

332332
}
333333
// almanac
334-
void parse8(std::basic_string_view<uint8_t> page)
334+
void parse8(const std::vector<uint8_t>& page)
335335
{
336336
iodalmanac = getbitu(&page[0], 6, 4);
337337
alma1.af0 = getbits(&page[0], 10, 16);
@@ -350,7 +350,7 @@ struct GalileoMessage : GPSLikeEphemeris
350350
}
351351

352352
// almanac
353-
void parse9(std::basic_string_view<uint8_t> page)
353+
void parse9(const std::vector<uint8_t>& page)
354354
{
355355
iodalmanac = getbitu(&page[0], 6, 4);
356356
alma2.wnalmanac = wnalmanac = getbitu(&page[0], 10, 2);
@@ -371,7 +371,7 @@ struct GalileoMessage : GPSLikeEphemeris
371371
}
372372

373373
// almanac + more time stuff (GPS)
374-
void parse10(std::basic_string_view<uint8_t> page)
374+
void parse10(const std::vector<uint8_t>& page)
375375
{
376376
iodalmanac = getbitu(&page[0], 6, 4);
377377
alma3.Omega0 = getbits(&page[0], 10, 16);
@@ -391,7 +391,7 @@ struct GalileoMessage : GPSLikeEphemeris
391391

392392

393393
// reduced clock and ephemeris data (redced)
394-
void parse16(std::basic_string_view<uint8_t> page)
394+
void parse16(const std::vector<uint8_t>& page)
395395
{
396396
deltaAred = getbits(&page[0], 6, 5);
397397
exred = getbits(&page[0], 11, 13);
@@ -404,7 +404,7 @@ struct GalileoMessage : GPSLikeEphemeris
404404
}
405405

406406
// reed-solomon data
407-
void parseRS(std::basic_string_view<uint8_t> page)
407+
void parseRS(const std::vector<uint8_t>& page)
408408
{
409409
// see 5.1.13.2 of the Galileo SIS ICD 2.0
410410
rs2bitiod = getbitu(&page[0], 6+8, 2);

glonass.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <string.h>
44
#include <chrono>
55
#include <iostream>
6+
#include "navmon.hh"
67
using std::cout;
78
using std::endl;
89

@@ -12,15 +13,15 @@ static const double J2 = 1082625.75E-9; // IERS: 1.0826359
1213
static const double oe = 7.2921151467E-5; // rad/s // IERS: 7.292115
1314

1415
// this strips out spare bits + parity, and leaves 10 clean 24 bit words
15-
std::basic_string<uint8_t> getGlonassMessage(std::basic_string_view<uint8_t> payload)
16+
std::vector<uint8_t> getGlonassMessage(const std::vector<uint8_t>& payload)
1617
{
1718
uint8_t buffer[4*4];
1819

1920
for(int w = 0 ; w < 4; ++w) {
2021
setbitu(buffer, 32*w, 32, getbitu(&payload[0], w*32, 32));
2122
}
2223

23-
return std::basic_string<uint8_t>(buffer, 16);
24+
return makeVec(buffer, 16);
2425

2526
}
2627

0 commit comments

Comments
 (0)