| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 | 14 |
| 15 Version::Version() : is_valid_(false) {} |
| 16 |
| 17 Version::~Version() {} |
| 18 |
| 15 // static | 19 // static |
| 16 Version* Version::GetVersionFromString(const std::string& version_str) { | 20 Version* Version::GetVersionFromString(const std::string& version_str) { |
| 17 Version* vers = new Version(); | 21 Version* vers = new Version(); |
| 18 if (vers->InitFromString(version_str)) { | 22 if (vers->InitFromString(version_str)) { |
| 19 DCHECK(vers->is_valid_); | 23 DCHECK(vers->is_valid_); |
| 20 return vers; | 24 return vers; |
| 21 } | 25 } |
| 22 delete vers; | 26 delete vers; |
| 23 return NULL; | 27 return NULL; |
| 24 } | 28 } |
| 25 | 29 |
| 26 Version::Version() : is_valid_(false) {} | |
| 27 | |
| 28 Version::~Version() {} | |
| 29 | |
| 30 Version* Version::Clone() const { | 30 Version* Version::Clone() const { |
| 31 DCHECK(is_valid_); | 31 DCHECK(is_valid_); |
| 32 Version* copy = new Version(); | 32 Version* copy = new Version(); |
| 33 copy->components_ = components_; | 33 copy->components_ = components_; |
| 34 copy->is_valid_ = true; | 34 copy->is_valid_ = true; |
| 35 return copy; | 35 return copy; |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool Version::Equals(const Version& that) const { | 38 bool Version::Equals(const Version& that) const { |
| 39 DCHECK(is_valid_); | 39 DCHECK(is_valid_); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return false; | 93 return false; |
| 94 // This throws out things like +3, or 032. | 94 // This throws out things like +3, or 032. |
| 95 if (base::IntToString(num) != *i) | 95 if (base::IntToString(num) != *i) |
| 96 return false; | 96 return false; |
| 97 uint16 component = static_cast<uint16>(num); | 97 uint16 component = static_cast<uint16>(num); |
| 98 components_.push_back(component); | 98 components_.push_back(component); |
| 99 } | 99 } |
| 100 is_valid_ = true; | 100 is_valid_ = true; |
| 101 return true; | 101 return true; |
| 102 } | 102 } |
| OLD | NEW |