OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/version.h" | 5 #include "base/version.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 } | 86 } |
87 | 87 |
88 Version::Version(const std::string& version_str) { | 88 Version::Version(const std::string& version_str) { |
89 std::vector<uint32_t> parsed; | 89 std::vector<uint32_t> parsed; |
90 if (!ParseVersionNumbers(version_str, &parsed)) | 90 if (!ParseVersionNumbers(version_str, &parsed)) |
91 return; | 91 return; |
92 | 92 |
93 components_.swap(parsed); | 93 components_.swap(parsed); |
94 } | 94 } |
95 | 95 |
96 Version::Version(std::vector<uint32_t>&& components) { | |
97 components_ = components; | |
Fady Samuel
2016/07/19 19:56:46
Add to initializer list.
Alex Z.
2016/07/19 20:46:13
Done.
| |
98 } | |
99 | |
96 bool Version::IsValid() const { | 100 bool Version::IsValid() const { |
97 return (!components_.empty()); | 101 return (!components_.empty()); |
98 } | 102 } |
99 | 103 |
100 // static | 104 // static |
101 bool Version::IsValidWildcardString(const std::string& wildcard_string) { | 105 bool Version::IsValidWildcardString(const std::string& wildcard_string) { |
102 std::string version_string = wildcard_string; | 106 std::string version_string = wildcard_string; |
103 if (EndsWith(version_string, ".*", CompareCase::SENSITIVE)) | 107 if (EndsWith(version_string, ".*", CompareCase::SENSITIVE)) |
104 version_string.resize(version_string.size() - 2); | 108 version_string.resize(version_string.size() - 2); |
105 | 109 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 188 |
185 bool operator>=(const Version& v1, const Version& v2) { | 189 bool operator>=(const Version& v1, const Version& v2) { |
186 return v1.CompareTo(v2) >= 0; | 190 return v1.CompareTo(v2) >= 0; |
187 } | 191 } |
188 | 192 |
189 std::ostream& operator<<(std::ostream& stream, const Version& v) { | 193 std::ostream& operator<<(std::ostream& stream, const Version& v) { |
190 return stream << v.GetString(); | 194 return stream << v.GetString(); |
191 } | 195 } |
192 | 196 |
193 } // namespace base | 197 } // namespace base |
OLD | NEW |