Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Mamoru Sobue <[email protected]>
  • Loading branch information
soblin committed Jun 14, 2024
1 parent 6d2f8a9 commit b142e1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ class AutowareOsmParser : public OsmParser

std::optional<uint64_t> parseMajorVersion(const std::string & format_version);

std::optional<uint64_t> parseMinorVersion(const std::string & format_version);

std::optional<uint64_t> parsePatchVersion(const std::string & format_version);

} // namespace lanelet::io_handlers

// NOLINTEND(readability-identifier-naming)
Expand Down
50 changes: 9 additions & 41 deletions tmp/lanelet2_extension/lib/autoware_osm_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,57 +80,25 @@ std::optional<uint64_t> parseMajorVersion(const std::string & format_version)
{
std::regex re(R"(^(\d+\.)?(\d+\.)?(\d+)$)");
// NOTE(Mamoru Sobue): matches `1`, `1.10`, `1.10.100`
// `1` ==> [`1`, ``, ``]
// `1` ==> [``, ``, `1`]
// `1.10` ==> [`1.`, ``, `10`]
// `1.10.100` ==> [`1.`, `10.`, `100`]
std::smatch match;
if (!std::regex_match(format_version, match, re)) {
return std::nullopt;
}
std::string major = match[1].str();
major.erase(std::remove(major.begin(), major.end(), '.'), major.end());
return std::stoi(major);
}

std::optional<uint64_t> parseMinorVersion(const std::string & format_version)
{
std::regex re(R"(^(\d+\.)?(\d+\.)?(\d+)$)");
// NOTE(Mamoru Sobue): matches `1`, `1.10`, `1.10.100`
// `1` ==> [`1`, ``, ``]
// `1.10` ==> [`1.`, ``, `10`]
// `1.10.100` ==> [`1.`, `10.`, `100`]
std::smatch match;
if (!std::regex_match(format_version, match, re)) {
if (match[3].str() == "") {
return std::nullopt;
}
std::string minor = match[2].str();
if (minor == "") {
if (match[3].str() == "") {
return std::nullopt;
}
minor = match[3].str();
}
minor.erase(std::remove(minor.begin(), minor.end(), '.'), minor.end());
return std::stoi(minor);
}

std::optional<uint64_t> parsePatchVersion(const std::string & format_version)
{
std::regex re(R"(^(\d+\.)?(\d+\.)?(\d+)$)");
// NOTE(Mamoru Sobue): matches `1`, `1.10`, `1.10.100`
// `1` ==> [`1`, ``, ``]
// `1.10` ==> [`1.`, ``, `10`]
// `1.10.100` ==> [`1.`, `10.`, `100`]
std::smatch match;
if (!std::regex_match(format_version, match, re)) {
return std::nullopt;
}
std::string patch = match[3].str();
if (patch == "") {
return std::nullopt;
std::string major{};
if (match[1].str() == "") {
major = match[3].str();
} else {
major = match[1].str();
}
patch.erase(std::remove(patch.begin(), patch.end(), '.'), patch.end());
return std::stoi(patch);
major.erase(std::remove(major.begin(), major.end(), '.'), major.end());
return std::stoi(major);
}

} // namespace lanelet::io_handlers
Expand Down

0 comments on commit b142e1c

Please sign in to comment.