| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return vers; | 25 return vers; |
| 26 } | 26 } |
| 27 delete vers; | 27 delete vers; |
| 28 return NULL; | 28 return NULL; |
| 29 } | 29 } |
| 30 | 30 |
| 31 Version::Version() : is_valid_(false) {} | 31 Version::Version() : is_valid_(false) {} |
| 32 | 32 |
| 33 Version::~Version() {} | 33 Version::~Version() {} |
| 34 | 34 |
| 35 Version* Version::Clone() const { |
| 36 DCHECK(is_valid_); |
| 37 Version* copy = new Version(); |
| 38 copy->components_ = components_; |
| 39 copy->is_valid_ = true; |
| 40 return copy; |
| 41 } |
| 42 |
| 35 bool Version::Equals(const Version& that) const { | 43 bool Version::Equals(const Version& that) const { |
| 36 DCHECK(is_valid_); | 44 DCHECK(is_valid_); |
| 37 DCHECK(that.is_valid_); | 45 DCHECK(that.is_valid_); |
| 38 return CompareTo(that) == 0; | 46 return CompareTo(that) == 0; |
| 39 } | 47 } |
| 40 | 48 |
| 41 int Version::CompareTo(const Version& other) const { | 49 int Version::CompareTo(const Version& other) const { |
| 42 DCHECK(is_valid_); | 50 DCHECK(is_valid_); |
| 43 DCHECK(other.is_valid_); | 51 DCHECK(other.is_valid_); |
| 44 size_t count = std::min(components_.size(), other.components_.size()); | 52 size_t count = std::min(components_.size(), other.components_.size()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return false; | 98 return false; |
| 91 // This throws out things like +3, or 032. | 99 // This throws out things like +3, or 032. |
| 92 if (base::IntToString(num) != *i) | 100 if (base::IntToString(num) != *i) |
| 93 return false; | 101 return false; |
| 94 uint16 component = static_cast<uint16>(num); | 102 uint16 component = static_cast<uint16>(num); |
| 95 components_.push_back(component); | 103 components_.push_back(component); |
| 96 } | 104 } |
| 97 is_valid_ = true; | 105 is_valid_ = true; |
| 98 return true; | 106 return true; |
| 99 } | 107 } |
| OLD | NEW |