Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Side by Side Diff: base/version.cc

Issue 7541015: Add a convenience function to Version (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/version.h ('k') | base/version_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 27 matching lines...) Expand all
38 return; 38 return;
39 parsed.push_back(static_cast<uint16>(num)); 39 parsed.push_back(static_cast<uint16>(num));
40 } 40 }
41 components_.swap(parsed); 41 components_.swap(parsed);
42 } 42 }
43 43
44 bool Version::IsValid() const { 44 bool Version::IsValid() const {
45 return (!components_.empty()); 45 return (!components_.empty());
46 } 46 }
47 47
48 bool Version::IsOlderThan(const std::string& version_str) const {
49 Version proposed_ver(version_str);
50 if (!proposed_ver.IsValid())
51 return false;
52 return (CompareTo(proposed_ver) < 0);
53 }
54
48 // TODO(cpu): remove this method. 55 // TODO(cpu): remove this method.
49 Version* Version::GetVersionFromString(const std::string& version_str) { 56 Version* Version::GetVersionFromString(const std::string& version_str) {
50 Version* vers = new Version(version_str); 57 Version* vers = new Version(version_str);
51 if (vers->IsValid()) { 58 if (vers->IsValid()) {
52 return vers; 59 return vers;
53 } 60 }
54 delete vers; 61 delete vers;
55 return NULL; 62 return NULL;
56 } 63 }
57 64
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 DCHECK(IsValid()); 100 DCHECK(IsValid());
94 std::string version_str; 101 std::string version_str;
95 size_t count = components_.size(); 102 size_t count = components_.size();
96 for (size_t i = 0; i < count - 1; ++i) { 103 for (size_t i = 0; i < count - 1; ++i) {
97 version_str.append(base::IntToString(components_[i])); 104 version_str.append(base::IntToString(components_[i]));
98 version_str.append("."); 105 version_str.append(".");
99 } 106 }
100 version_str.append(base::IntToString(components_[count - 1])); 107 version_str.append(base::IntToString(components_[count - 1]));
101 return version_str; 108 return version_str;
102 } 109 }
OLDNEW
« no previous file with comments | « base/version.h ('k') | base/version_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698