mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 12:40:35 +00:00
Fix for GCC 4.9 using std::array instead of char array
This commit is contained in:
parent
0897811d16
commit
2f3f63309b
@ -34,6 +34,7 @@
|
|||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
#include <algorithm> // for min
|
#include <algorithm> // for min
|
||||||
|
#include <array>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cstddef> // for size_t
|
#include <cstddef> // for size_t
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -506,18 +507,18 @@ private:
|
|||||||
static const std::size_t max_body_length = 1029;
|
static const std::size_t max_body_length = 1029;
|
||||||
|
|
||||||
Rtcm_Message()
|
Rtcm_Message()
|
||||||
|
: body_length_(0)
|
||||||
{
|
{
|
||||||
body_length_ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* data() const
|
const char* data() const
|
||||||
{
|
{
|
||||||
return data_;
|
return data_.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
char* data()
|
char* data()
|
||||||
{
|
{
|
||||||
return data_;
|
return data_.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::size_t length() const
|
inline std::size_t length() const
|
||||||
@ -527,12 +528,12 @@ private:
|
|||||||
|
|
||||||
const char* body() const
|
const char* body() const
|
||||||
{
|
{
|
||||||
return data_ + header_length;
|
return data_.data() + header_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* body()
|
char* body()
|
||||||
{
|
{
|
||||||
return data_ + header_length;
|
return data_.data() + header_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t body_length() const
|
std::size_t body_length() const
|
||||||
@ -552,14 +553,14 @@ private:
|
|||||||
inline bool decode_header()
|
inline bool decode_header()
|
||||||
{
|
{
|
||||||
char header[header_length + 1] = "";
|
char header[header_length + 1] = "";
|
||||||
std::strncat(header, data_, header_length);
|
std::strncat(header, data_.data(), header_length);
|
||||||
if (header[0] != 'G' || header[1] != 'S')
|
if (header[0] != 'G' || header[1] != 'S')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char header2_[header_length - 1] = "";
|
char header2_[header_length - 1] = "";
|
||||||
std::strncat(header2_, data_ + 2, header_length - 2);
|
std::strncat(header2_, data_.data() + 2, header_length - 2);
|
||||||
body_length_ = std::atoi(header2_);
|
body_length_ = std::atoi(header2_);
|
||||||
if (body_length_ == 0)
|
if (body_length_ == 0)
|
||||||
{
|
{
|
||||||
@ -578,11 +579,11 @@ private:
|
|||||||
{
|
{
|
||||||
char header[header_length + 1] = "";
|
char header[header_length + 1] = "";
|
||||||
std::snprintf(header, header_length + 1, "GS%4d", std::max(std::min(static_cast<int>(body_length_), static_cast<int>(max_body_length)), 0));
|
std::snprintf(header, header_length + 1, "GS%4d", std::max(std::min(static_cast<int>(body_length_), static_cast<int>(max_body_length)), 0));
|
||||||
std::memcpy(data_, header, header_length);
|
std::memcpy(data_.data(), header, header_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char data_[header_length + max_body_length] = "";
|
std::array<char, header_length + max_body_length> data_{};
|
||||||
std::size_t body_length_;
|
std::size_t body_length_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user