1#include "protocol/version.h"
8#include "absl/strings/numbers.h"
9#include "absl/strings/str_split.h"
16std::optional<std::array<int, 3>> Parse(std::string_view version) {
17 const std::vector<std::string_view> parts = absl::StrSplit(version,
'.');
18 if (parts.size() != 3) {
21 std::array<int, 3> numbers;
22 for (
int i = 0; i < 3; ++i) {
23 if (!absl::SimpleAtoi(parts[i], &numbers[i]) || numbers[i] < 0) {
32bool Compatible(std::string_view client, std::string_view server) {
33 const std::optional<std::array<int, 3>> a = Parse(client);
34 const std::optional<std::array<int, 3>> b = Parse(server);
35 return a && b && (*a)[0] == (*b)[0] && (*a)[1] == (*b)[1];
bool Compatible(std::string_view client, std::string_view server)