Flutter Impeller
version.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include <sstream>
8 
9 namespace impeller {
10 
11 std::optional<Version> Version::FromVector(const std::vector<size_t>& version) {
12  if (version.size() == 0) {
13  return Version{0, 0, 0};
14  }
15  if (version.size() == 1) {
16  return Version{version[0], 0, 0};
17  }
18  if (version.size() == 2) {
19  return Version{version[0], version[1], 0};
20  }
21  if (version.size() == 3) {
22  return Version{version[0], version[1], version[2]};
23  }
24  return std::nullopt;
25 }
26 
27 std::string Version::ToString() const {
28  std::stringstream stream;
29  stream << major_version << "." << minor_version << "." << patch_version;
30  return stream.str();
31 }
32 
33 } // namespace impeller
size_t patch_version
Definition: version.h:20
size_t minor_version
Definition: version.h:19
std::string ToString() const
Definition: version.cc:27
static std::optional< Version > FromVector(const std::vector< size_t > &version)
Definition: version.cc:11
size_t major_version
Definition: version.h:18