SGMetar: avoid raw char pointers in the public API

Ideally would refactor to remove the raw pointers internally, but this
is a good first step.
This commit is contained in:
James Turner 2021-10-15 15:31:06 +01:00
parent 6fe7c307b2
commit bf1db210d7
2 changed files with 12 additions and 3 deletions

View File

@ -491,9 +491,17 @@ void SGMetar::useCurrentDate()
_month = now.tm_mon + 1;
}
const char* SGMetar::getRawDataPtr()
std::string SGMetar::getDataString() const
{
return _data.data();
return std::string{_data.data()};
}
std::string SGMetar::getUnparsedData() const
{
if (!_m || (strlen(_m) < 1))
return {};
return std::string{_m};
}
/**
* Replace any number of subsequent spaces by just one space, and add

View File

@ -186,7 +186,8 @@ public:
std::vector<std::string> phenomena;
};
const char* getRawDataPtr();
std::string getDataString() const;
std::string getUnparsedData() const;
inline bool getProxy() const { return _x_proxy; }
inline const char *getId() const { return _icao; }