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) : components_(components) {} |
| 97 |
96 bool Version::IsValid() const { | 98 bool Version::IsValid() const { |
97 return (!components_.empty()); | 99 return (!components_.empty()); |
98 } | 100 } |
99 | 101 |
100 // static | 102 // static |
101 bool Version::IsValidWildcardString(const std::string& wildcard_string) { | 103 bool Version::IsValidWildcardString(const std::string& wildcard_string) { |
102 std::string version_string = wildcard_string; | 104 std::string version_string = wildcard_string; |
103 if (EndsWith(version_string, ".*", CompareCase::SENSITIVE)) | 105 if (EndsWith(version_string, ".*", CompareCase::SENSITIVE)) |
104 version_string.resize(version_string.size() - 2); | 106 version_string.resize(version_string.size() - 2); |
105 | 107 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 186 |
185 bool operator>=(const Version& v1, const Version& v2) { | 187 bool operator>=(const Version& v1, const Version& v2) { |
186 return v1.CompareTo(v2) >= 0; | 188 return v1.CompareTo(v2) >= 0; |
187 } | 189 } |
188 | 190 |
189 std::ostream& operator<<(std::ostream& stream, const Version& v) { | 191 std::ostream& operator<<(std::ostream& stream, const Version& v) { |
190 return stream << v.GetString(); | 192 return stream << v.GetString(); |
191 } | 193 } |
192 | 194 |
193 } // namespace base | 195 } // namespace base |
OLD | NEW |