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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 } | 73 } |
74 } | 74 } |
75 return 0; | 75 return 0; |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 Version::Version() { | 80 Version::Version() { |
81 } | 81 } |
82 | 82 |
83 Version::Version(const Version& other) = default; | 83 Version::Version(const Version& other) = default; |
danakj
2016/07/19 20:50:07
please order things in here to match the header wh
Alex Z.
2016/07/22 13:28:03
Done.
| |
84 | 84 |
85 Version::~Version() { | 85 Version::~Version() { |
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) {} | |
98 | |
99 Version& Version::operator=(Version&& other) { | |
danakj
2016/07/19 20:50:07
can you just use =
default?
Alex Z.
2016/07/22 13:28:03
Done.
| |
100 components_ = std::move(other.components_); | |
101 return *this; | |
102 } | |
103 | |
104 Version& Version::operator=(const Version& other) { | |
danakj
2016/07/19 20:50:07
ditto, =default?
Alex Z.
2016/07/22 13:28:03
Done.
| |
105 components_ = other.components_; | |
106 return *this; | |
107 } | |
108 | |
96 bool Version::IsValid() const { | 109 bool Version::IsValid() const { |
97 return (!components_.empty()); | 110 return (!components_.empty()); |
98 } | 111 } |
99 | 112 |
100 // static | 113 // static |
101 bool Version::IsValidWildcardString(const std::string& wildcard_string) { | 114 bool Version::IsValidWildcardString(const std::string& wildcard_string) { |
102 std::string version_string = wildcard_string; | 115 std::string version_string = wildcard_string; |
103 if (EndsWith(version_string, ".*", CompareCase::SENSITIVE)) | 116 if (EndsWith(version_string, ".*", CompareCase::SENSITIVE)) |
104 version_string.resize(version_string.size() - 2); | 117 version_string.resize(version_string.size() - 2); |
105 | 118 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 197 |
185 bool operator>=(const Version& v1, const Version& v2) { | 198 bool operator>=(const Version& v1, const Version& v2) { |
186 return v1.CompareTo(v2) >= 0; | 199 return v1.CompareTo(v2) >= 0; |
187 } | 200 } |
188 | 201 |
189 std::ostream& operator<<(std::ostream& stream, const Version& v) { | 202 std::ostream& operator<<(std::ostream& stream, const Version& v) { |
190 return stream << v.GetString(); | 203 return stream << v.GetString(); |
191 } | 204 } |
192 | 205 |
193 } // namespace base | 206 } // namespace base |
OLD | NEW |