mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:10:06 +00:00
Integrate UGC class into Text Product Message, support multi-line UGC
This commit is contained in:
parent
d3b3ac6be6
commit
8fe7d5da6e
2 changed files with 23 additions and 4 deletions
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
#include <scwx/awips/coded_location.hpp>
|
#include <scwx/awips/coded_location.hpp>
|
||||||
#include <scwx/awips/coded_time_motion_location.hpp>
|
#include <scwx/awips/coded_time_motion_location.hpp>
|
||||||
#include <scwx/awips/pvtec.hpp>
|
|
||||||
#include <scwx/awips/message.hpp>
|
#include <scwx/awips/message.hpp>
|
||||||
|
#include <scwx/awips/pvtec.hpp>
|
||||||
|
#include <scwx/awips/ugc.hpp>
|
||||||
#include <scwx/awips/wmo_header.hpp>
|
#include <scwx/awips/wmo_header.hpp>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
@ -31,13 +32,18 @@ struct Vtec
|
||||||
|
|
||||||
struct SegmentHeader
|
struct SegmentHeader
|
||||||
{
|
{
|
||||||
std::string ugcString_;
|
std::vector<std::string> ugcString_;
|
||||||
|
Ugc ugc_;
|
||||||
std::vector<Vtec> vtecString_;
|
std::vector<Vtec> vtecString_;
|
||||||
std::vector<std::string> ugcNames_;
|
std::vector<std::string> ugcNames_;
|
||||||
std::string issuanceDateTime_;
|
std::string issuanceDateTime_;
|
||||||
|
|
||||||
SegmentHeader() :
|
SegmentHeader() :
|
||||||
ugcString_ {}, vtecString_ {}, ugcNames_ {}, issuanceDateTime_ {}
|
ugcString_ {},
|
||||||
|
ugc_ {},
|
||||||
|
vtecString_ {},
|
||||||
|
ugcNames_ {},
|
||||||
|
issuanceDateTime_ {}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,9 @@ std::optional<SegmentHeader> TryParseSegmentHeader(std::istream& is)
|
||||||
{
|
{
|
||||||
// UGC takes the form SSFNNN-NNN>NNN-SSFNNN-DDHHMM- (NWSI 10-1702)
|
// UGC takes the form SSFNNN-NNN>NNN-SSFNNN-DDHHMM- (NWSI 10-1702)
|
||||||
// Look for SSF(NNN)?[->] to key the UGC string
|
// Look for SSF(NNN)?[->] to key the UGC string
|
||||||
|
// Look for DDHHMM- to end the UGC string
|
||||||
static const std::regex reUgcString {"^[A-Z]{2}[CZ]([0-9]{3})?[->]"};
|
static const std::regex reUgcString {"^[A-Z]{2}[CZ]([0-9]{3})?[->]"};
|
||||||
|
static const std::regex reUgcExpiration {"[0-9]{6}-$"};
|
||||||
|
|
||||||
std::optional<SegmentHeader> header = std::nullopt;
|
std::optional<SegmentHeader> header = std::nullopt;
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
@ -344,7 +346,18 @@ std::optional<SegmentHeader> TryParseSegmentHeader(std::istream& is)
|
||||||
if (std::regex_search(line, reUgcString))
|
if (std::regex_search(line, reUgcString))
|
||||||
{
|
{
|
||||||
header = SegmentHeader();
|
header = SegmentHeader();
|
||||||
header->ugcString_.swap(line);
|
header->ugcString_.push_back(line);
|
||||||
|
|
||||||
|
// If UGC is multi-line, continue parsing
|
||||||
|
while (!is.eof() && is.peek() != '\r' &&
|
||||||
|
!std::regex_search(line, reUgcExpiration))
|
||||||
|
{
|
||||||
|
util::getline(is, line);
|
||||||
|
header->ugcString_.push_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse UGC
|
||||||
|
header->ugc_.Parse(header->ugcString_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.has_value())
|
if (header.has_value())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue